three-stdlib 2.24.2 → 2.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (540) hide show
  1. package/controls/OrbitControls.d.ts +2 -0
  2. package/index.cjs +116401 -611
  3. package/index.js +116037 -263
  4. package/package.json +17 -4
  5. package/_polyfill/CapsuleGeometry.cjs +0 -22
  6. package/_polyfill/CapsuleGeometry.js +0 -22
  7. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  8. package/_polyfill/CompressedArrayTexture.js +0 -12
  9. package/_polyfill/Data3DTexture.cjs +0 -17
  10. package/_polyfill/Data3DTexture.js +0 -17
  11. package/animation/AnimationClipCreator.cjs +0 -56
  12. package/animation/AnimationClipCreator.js +0 -56
  13. package/animation/CCDIKSolver.cjs +0 -269
  14. package/animation/CCDIKSolver.js +0 -269
  15. package/animation/MMDAnimationHelper.cjs +0 -688
  16. package/animation/MMDAnimationHelper.js +0 -688
  17. package/animation/MMDPhysics.cjs +0 -830
  18. package/animation/MMDPhysics.js +0 -830
  19. package/cameras/CinematicCamera.cjs +0 -131
  20. package/cameras/CinematicCamera.js +0 -131
  21. package/controls/ArcballControls.cjs +0 -2033
  22. package/controls/ArcballControls.js +0 -2033
  23. package/controls/DeviceOrientationControls.cjs +0 -85
  24. package/controls/DeviceOrientationControls.js +0 -85
  25. package/controls/DragControls.cjs +0 -182
  26. package/controls/DragControls.js +0 -182
  27. package/controls/FirstPersonControls.cjs +0 -229
  28. package/controls/FirstPersonControls.js +0 -229
  29. package/controls/FlyControls.cjs +0 -248
  30. package/controls/FlyControls.js +0 -248
  31. package/controls/OrbitControls.cjs +0 -787
  32. package/controls/OrbitControls.js +0 -787
  33. package/controls/PointerLockControls.cjs +0 -103
  34. package/controls/PointerLockControls.js +0 -103
  35. package/controls/TrackballControls.cjs +0 -502
  36. package/controls/TrackballControls.js +0 -502
  37. package/controls/TransformControls.cjs +0 -1089
  38. package/controls/TransformControls.js +0 -1089
  39. package/controls/experimental/CameraControls.cjs +0 -736
  40. package/controls/experimental/CameraControls.js +0 -736
  41. package/csm/CSM.cjs +0 -244
  42. package/csm/CSM.js +0 -244
  43. package/csm/CSMFrustum.cjs +0 -75
  44. package/csm/CSMFrustum.js +0 -75
  45. package/csm/CSMHelper.cjs +0 -114
  46. package/csm/CSMHelper.js +0 -114
  47. package/csm/CSMShader.cjs +0 -261
  48. package/csm/CSMShader.js +0 -261
  49. package/curves/CurveExtras.cjs +0 -214
  50. package/curves/CurveExtras.js +0 -214
  51. package/curves/NURBSCurve.cjs +0 -35
  52. package/curves/NURBSCurve.js +0 -35
  53. package/curves/NURBSSurface.cjs +0 -28
  54. package/curves/NURBSSurface.js +0 -28
  55. package/curves/NURBSUtils.cjs +0 -226
  56. package/curves/NURBSUtils.js +0 -226
  57. package/deprecated/Geometry.cjs +0 -971
  58. package/deprecated/Geometry.js +0 -971
  59. package/effects/AnaglyphEffect.cjs +0 -102
  60. package/effects/AnaglyphEffect.js +0 -102
  61. package/effects/AsciiEffect.cjs +0 -155
  62. package/effects/AsciiEffect.js +0 -155
  63. package/effects/OutlineEffect.cjs +0 -275
  64. package/effects/OutlineEffect.js +0 -275
  65. package/effects/ParallaxBarrierEffect.cjs +0 -65
  66. package/effects/ParallaxBarrierEffect.js +0 -65
  67. package/effects/PeppersGhostEffect.cjs +0 -88
  68. package/effects/PeppersGhostEffect.js +0 -88
  69. package/effects/StereoEffect.cjs +0 -35
  70. package/effects/StereoEffect.js +0 -35
  71. package/environments/RoomEnvironment.cjs +0 -95
  72. package/environments/RoomEnvironment.js +0 -78
  73. package/exporters/ColladaExporter.cjs +0 -331
  74. package/exporters/ColladaExporter.js +0 -331
  75. package/exporters/DRACOExporter.cjs +0 -141
  76. package/exporters/DRACOExporter.js +0 -141
  77. package/exporters/GLTFExporter.cjs +0 -1909
  78. package/exporters/GLTFExporter.js +0 -1909
  79. package/exporters/MMDExporter.cjs +0 -131
  80. package/exporters/MMDExporter.js +0 -131
  81. package/exporters/OBJExporter.cjs +0 -181
  82. package/exporters/OBJExporter.js +0 -181
  83. package/exporters/PLYExporter.cjs +0 -280
  84. package/exporters/PLYExporter.js +0 -280
  85. package/exporters/STLExporter.cjs +0 -146
  86. package/exporters/STLExporter.js +0 -146
  87. package/exporters/USDZExporter.cjs +0 -340
  88. package/exporters/USDZExporter.js +0 -340
  89. package/geometries/BoxLineGeometry.cjs +0 -45
  90. package/geometries/BoxLineGeometry.js +0 -45
  91. package/geometries/ConvexGeometry.cjs +0 -26
  92. package/geometries/ConvexGeometry.js +0 -26
  93. package/geometries/DecalGeometry.cjs +0 -184
  94. package/geometries/DecalGeometry.js +0 -184
  95. package/geometries/LightningStrike.cjs +0 -553
  96. package/geometries/LightningStrike.js +0 -553
  97. package/geometries/ParametricGeometries.cjs +0 -130
  98. package/geometries/ParametricGeometries.js +0 -130
  99. package/geometries/ParametricGeometry.cjs +0 -63
  100. package/geometries/ParametricGeometry.js +0 -63
  101. package/geometries/RoundedBoxGeometry.cjs +0 -91
  102. package/geometries/RoundedBoxGeometry.js +0 -91
  103. package/geometries/TeapotGeometry.cjs +0 -1563
  104. package/geometries/TeapotGeometry.js +0 -1563
  105. package/geometries/TextGeometry.cjs +0 -27
  106. package/geometries/TextGeometry.js +0 -27
  107. package/helpers/LightProbeHelper.cjs +0 -73
  108. package/helpers/LightProbeHelper.js +0 -73
  109. package/helpers/PositionalAudioHelper.cjs +0 -68
  110. package/helpers/PositionalAudioHelper.js +0 -68
  111. package/helpers/RectAreaLightHelper.cjs +0 -44
  112. package/helpers/RectAreaLightHelper.js +0 -44
  113. package/helpers/VertexNormalsHelper.cjs +0 -47
  114. package/helpers/VertexNormalsHelper.js +0 -47
  115. package/helpers/VertexTangentsHelper.cjs +0 -43
  116. package/helpers/VertexTangentsHelper.js +0 -43
  117. package/interactive/HTMLMesh.cjs +0 -325
  118. package/interactive/HTMLMesh.js +0 -325
  119. package/interactive/InteractiveGroup.cjs +0 -68
  120. package/interactive/InteractiveGroup.js +0 -68
  121. package/interactive/SelectionBox.cjs +0 -134
  122. package/interactive/SelectionBox.js +0 -134
  123. package/interactive/SelectionHelper.cjs +0 -51
  124. package/interactive/SelectionHelper.js +0 -51
  125. package/libs/MeshoptDecoder.cjs +0 -221
  126. package/libs/MeshoptDecoder.js +0 -221
  127. package/libs/MotionControllers.cjs +0 -325
  128. package/libs/MotionControllers.js +0 -325
  129. package/lights/LightProbeGenerator.cjs +0 -145
  130. package/lights/LightProbeGenerator.js +0 -145
  131. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  132. package/lights/RectAreaLightUniformsLib.js +0 -32846
  133. package/lines/Line2.cjs +0 -13
  134. package/lines/Line2.js +0 -13
  135. package/lines/LineGeometry.cjs +0 -44
  136. package/lines/LineGeometry.js +0 -44
  137. package/lines/LineMaterial.cjs +0 -547
  138. package/lines/LineMaterial.js +0 -547
  139. package/lines/LineSegments2.cjs +0 -203
  140. package/lines/LineSegments2.js +0 -203
  141. package/lines/LineSegmentsGeometry.cjs +0 -124
  142. package/lines/LineSegmentsGeometry.js +0 -124
  143. package/lines/Wireframe.cjs +0 -32
  144. package/lines/Wireframe.js +0 -32
  145. package/lines/WireframeGeometry2.cjs +0 -13
  146. package/lines/WireframeGeometry2.js +0 -13
  147. package/loaders/3DMLoader.cjs +0 -803
  148. package/loaders/3DMLoader.js +0 -803
  149. package/loaders/3MFLoader.cjs +0 -854
  150. package/loaders/3MFLoader.js +0 -854
  151. package/loaders/AMFLoader.cjs +0 -284
  152. package/loaders/AMFLoader.js +0 -284
  153. package/loaders/AssimpLoader.cjs +0 -1434
  154. package/loaders/AssimpLoader.js +0 -1434
  155. package/loaders/BVHLoader.cjs +0 -207
  156. package/loaders/BVHLoader.js +0 -207
  157. package/loaders/BasisTextureLoader.cjs +0 -489
  158. package/loaders/BasisTextureLoader.js +0 -489
  159. package/loaders/ColladaLoader.cjs +0 -2405
  160. package/loaders/ColladaLoader.js +0 -2405
  161. package/loaders/DDSLoader.cjs +0 -148
  162. package/loaders/DDSLoader.js +0 -148
  163. package/loaders/DRACOLoader.cjs +0 -341
  164. package/loaders/DRACOLoader.js +0 -341
  165. package/loaders/EXRLoader.cjs +0 -1356
  166. package/loaders/EXRLoader.js +0 -1356
  167. package/loaders/FBXLoader.cjs +0 -2457
  168. package/loaders/FBXLoader.js +0 -2457
  169. package/loaders/FontLoader.cjs +0 -123
  170. package/loaders/FontLoader.js +0 -123
  171. package/loaders/GCodeLoader.cjs +0 -141
  172. package/loaders/GCodeLoader.js +0 -141
  173. package/loaders/GLTFLoader.cjs +0 -2504
  174. package/loaders/GLTFLoader.js +0 -2504
  175. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  176. package/loaders/HDRCubeTextureLoader.js +0 -75
  177. package/loaders/KMZLoader.cjs +0 -75
  178. package/loaders/KMZLoader.js +0 -75
  179. package/loaders/KTX2Loader.cjs +0 -480
  180. package/loaders/KTX2Loader.js +0 -480
  181. package/loaders/KTXLoader.cjs +0 -93
  182. package/loaders/KTXLoader.js +0 -93
  183. package/loaders/LDrawLoader.cjs +0 -1424
  184. package/loaders/LDrawLoader.js +0 -1424
  185. package/loaders/LUT3dlLoader.cjs +0 -103
  186. package/loaders/LUT3dlLoader.js +0 -103
  187. package/loaders/LUTCubeLoader.cjs +0 -107
  188. package/loaders/LUTCubeLoader.js +0 -107
  189. package/loaders/LWOLoader.cjs +0 -645
  190. package/loaders/LWOLoader.js +0 -645
  191. package/loaders/LottieLoader.cjs +0 -47
  192. package/loaders/LottieLoader.js +0 -47
  193. package/loaders/MD2Loader.cjs +0 -359
  194. package/loaders/MD2Loader.js +0 -359
  195. package/loaders/MDDLoader.cjs +0 -58
  196. package/loaders/MDDLoader.js +0 -58
  197. package/loaders/MMDLoader.cjs +0 -1121
  198. package/loaders/MMDLoader.js +0 -1121
  199. package/loaders/MTLLoader.cjs +0 -304
  200. package/loaders/MTLLoader.js +0 -304
  201. package/loaders/NRRDLoader.cjs +0 -401
  202. package/loaders/NRRDLoader.js +0 -401
  203. package/loaders/OBJLoader.cjs +0 -487
  204. package/loaders/OBJLoader.js +0 -487
  205. package/loaders/PCDLoader.cjs +0 -248
  206. package/loaders/PCDLoader.js +0 -248
  207. package/loaders/PDBLoader.cjs +0 -247
  208. package/loaders/PDBLoader.js +0 -247
  209. package/loaders/PLYLoader.cjs +0 -317
  210. package/loaders/PLYLoader.js +0 -317
  211. package/loaders/PRWMLoader.cjs +0 -160
  212. package/loaders/PRWMLoader.js +0 -160
  213. package/loaders/PVRLoader.cjs +0 -131
  214. package/loaders/PVRLoader.js +0 -131
  215. package/loaders/RGBELoader.cjs +0 -252
  216. package/loaders/RGBELoader.js +0 -252
  217. package/loaders/RGBMLoader.cjs +0 -1004
  218. package/loaders/RGBMLoader.js +0 -1004
  219. package/loaders/STLLoader.cjs +0 -190
  220. package/loaders/STLLoader.js +0 -190
  221. package/loaders/SVGLoader.cjs +0 -1712
  222. package/loaders/SVGLoader.js +0 -1712
  223. package/loaders/TDSLoader.cjs +0 -650
  224. package/loaders/TDSLoader.js +0 -650
  225. package/loaders/TGALoader.cjs +0 -285
  226. package/loaders/TGALoader.js +0 -285
  227. package/loaders/TTFLoader.cjs +0 -131
  228. package/loaders/TTFLoader.js +0 -131
  229. package/loaders/TiltLoader.cjs +0 -375
  230. package/loaders/TiltLoader.js +0 -375
  231. package/loaders/VOXLoader.cjs +0 -432
  232. package/loaders/VOXLoader.js +0 -432
  233. package/loaders/VRMLLoader.cjs +0 -2105
  234. package/loaders/VRMLLoader.js +0 -2105
  235. package/loaders/VRMLoader.cjs +0 -38
  236. package/loaders/VRMLoader.js +0 -38
  237. package/loaders/VTKLoader.cjs +0 -648
  238. package/loaders/VTKLoader.js +0 -648
  239. package/loaders/XLoader.cjs +0 -1258
  240. package/loaders/XLoader.js +0 -1258
  241. package/loaders/XYZLoader.cjs +0 -60
  242. package/loaders/XYZLoader.js +0 -60
  243. package/loaders/lwo/IFFParser.cjs +0 -743
  244. package/loaders/lwo/IFFParser.js +0 -743
  245. package/loaders/lwo/LWO2Parser.cjs +0 -312
  246. package/loaders/lwo/LWO2Parser.js +0 -312
  247. package/loaders/lwo/LWO3Parser.cjs +0 -282
  248. package/loaders/lwo/LWO3Parser.js +0 -282
  249. package/math/Capsule.cjs +0 -98
  250. package/math/Capsule.js +0 -98
  251. package/math/ColorConverter.cjs +0 -42
  252. package/math/ColorConverter.js +0 -42
  253. package/math/ConvexHull.cjs +0 -596
  254. package/math/ConvexHull.js +0 -596
  255. package/math/ImprovedNoise.cjs +0 -304
  256. package/math/ImprovedNoise.js +0 -304
  257. package/math/Lut.cjs +0 -137
  258. package/math/Lut.js +0 -137
  259. package/math/MeshSurfaceSampler.cjs +0 -103
  260. package/math/MeshSurfaceSampler.js +0 -103
  261. package/math/OBB.cjs +0 -242
  262. package/math/OBB.js +0 -242
  263. package/math/Octree.cjs +0 -273
  264. package/math/Octree.js +0 -273
  265. package/math/SimplexNoise.cjs +0 -440
  266. package/math/SimplexNoise.js +0 -440
  267. package/misc/ConvexObjectBreaker.cjs +0 -292
  268. package/misc/ConvexObjectBreaker.js +0 -292
  269. package/misc/GPUComputationRenderer.cjs +0 -205
  270. package/misc/GPUComputationRenderer.js +0 -205
  271. package/misc/Gyroscope.cjs +0 -33
  272. package/misc/Gyroscope.js +0 -33
  273. package/misc/MD2Character.cjs +0 -167
  274. package/misc/MD2Character.js +0 -167
  275. package/misc/MD2CharacterComplex.cjs +0 -332
  276. package/misc/MD2CharacterComplex.js +0 -332
  277. package/misc/MorphAnimMesh.cjs +0 -40
  278. package/misc/MorphAnimMesh.js +0 -40
  279. package/misc/MorphBlendMesh.cjs +0 -179
  280. package/misc/MorphBlendMesh.js +0 -179
  281. package/misc/ProgressiveLightmap.cjs +0 -186
  282. package/misc/ProgressiveLightmap.js +0 -186
  283. package/misc/RollerCoaster.cjs +0 -353
  284. package/misc/RollerCoaster.js +0 -353
  285. package/misc/Timer.cjs +0 -101
  286. package/misc/Timer.js +0 -101
  287. package/misc/TubePainter.cjs +0 -123
  288. package/misc/TubePainter.js +0 -123
  289. package/misc/Volume.cjs +0 -305
  290. package/misc/Volume.js +0 -305
  291. package/misc/VolumeSlice.cjs +0 -114
  292. package/misc/VolumeSlice.js +0 -114
  293. package/misc/WebGL.cjs +0 -74
  294. package/misc/WebGL.js +0 -74
  295. package/modifiers/CurveModifier.cjs +0 -232
  296. package/modifiers/CurveModifier.js +0 -232
  297. package/modifiers/EdgeSplitModifier.cjs +0 -167
  298. package/modifiers/EdgeSplitModifier.js +0 -168
  299. package/modifiers/SimplifyModifier.cjs +0 -301
  300. package/modifiers/SimplifyModifier.js +0 -301
  301. package/modifiers/TessellateModifier.cjs +0 -214
  302. package/modifiers/TessellateModifier.js +0 -214
  303. package/objects/GroundProjectedEnv.cjs +0 -134
  304. package/objects/GroundProjectedEnv.js +0 -134
  305. package/objects/Lensflare.cjs +0 -291
  306. package/objects/Lensflare.js +0 -291
  307. package/objects/LightningStorm.cjs +0 -110
  308. package/objects/LightningStorm.js +0 -110
  309. package/objects/MarchingCubes.cjs +0 -4809
  310. package/objects/MarchingCubes.js +0 -4809
  311. package/objects/Reflector.cjs +0 -202
  312. package/objects/Reflector.js +0 -202
  313. package/objects/ReflectorForSSRPass.cjs +0 -260
  314. package/objects/ReflectorForSSRPass.js +0 -260
  315. package/objects/ReflectorRTT.cjs +0 -10
  316. package/objects/ReflectorRTT.js +0 -10
  317. package/objects/Refractor.cjs +0 -215
  318. package/objects/Refractor.js +0 -215
  319. package/objects/ShadowMesh.cjs +0 -45
  320. package/objects/ShadowMesh.js +0 -45
  321. package/objects/Sky.cjs +0 -200
  322. package/objects/Sky.js +0 -200
  323. package/objects/Water.cjs +0 -242
  324. package/objects/Water.js +0 -242
  325. package/objects/Water2.cjs +0 -256
  326. package/objects/Water2.js +0 -256
  327. package/physics/AmmoPhysics.cjs +0 -166
  328. package/physics/AmmoPhysics.js +0 -166
  329. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  330. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  331. package/postprocessing/AfterimagePass.cjs +0 -68
  332. package/postprocessing/AfterimagePass.js +0 -68
  333. package/postprocessing/BloomPass.cjs +0 -109
  334. package/postprocessing/BloomPass.js +0 -109
  335. package/postprocessing/BokehPass.cjs +0 -90
  336. package/postprocessing/BokehPass.js +0 -90
  337. package/postprocessing/ClearPass.cjs +0 -36
  338. package/postprocessing/ClearPass.js +0 -36
  339. package/postprocessing/CubeTexturePass.cjs +0 -53
  340. package/postprocessing/CubeTexturePass.js +0 -53
  341. package/postprocessing/DotScreenPass.cjs +0 -49
  342. package/postprocessing/DotScreenPass.js +0 -49
  343. package/postprocessing/EffectComposer.cjs +0 -157
  344. package/postprocessing/EffectComposer.js +0 -157
  345. package/postprocessing/FilmPass.cjs +0 -51
  346. package/postprocessing/FilmPass.js +0 -51
  347. package/postprocessing/GlitchPass.cjs +0 -84
  348. package/postprocessing/GlitchPass.js +0 -84
  349. package/postprocessing/HalftonePass.cjs +0 -53
  350. package/postprocessing/HalftonePass.js +0 -53
  351. package/postprocessing/LUTPass.cjs +0 -142
  352. package/postprocessing/LUTPass.js +0 -142
  353. package/postprocessing/MaskPass.cjs +0 -69
  354. package/postprocessing/MaskPass.js +0 -69
  355. package/postprocessing/OutlinePass.cjs +0 -479
  356. package/postprocessing/OutlinePass.js +0 -479
  357. package/postprocessing/Pass.cjs +0 -48
  358. package/postprocessing/Pass.js +0 -48
  359. package/postprocessing/RenderPass.cjs +0 -59
  360. package/postprocessing/RenderPass.js +0 -59
  361. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  362. package/postprocessing/RenderPixelatedPass.js +0 -199
  363. package/postprocessing/SAOPass.cjs +0 -288
  364. package/postprocessing/SAOPass.js +0 -288
  365. package/postprocessing/SMAAPass.cjs +0 -112
  366. package/postprocessing/SMAAPass.js +0 -112
  367. package/postprocessing/SSAARenderPass.cjs +0 -189
  368. package/postprocessing/SSAARenderPass.js +0 -189
  369. package/postprocessing/SSAOPass.cjs +0 -272
  370. package/postprocessing/SSAOPass.js +0 -272
  371. package/postprocessing/SSRPass.cjs +0 -411
  372. package/postprocessing/SSRPass.js +0 -411
  373. package/postprocessing/SavePass.cjs +0 -38
  374. package/postprocessing/SavePass.js +0 -38
  375. package/postprocessing/ShaderPass.cjs +0 -49
  376. package/postprocessing/ShaderPass.js +0 -49
  377. package/postprocessing/TAARenderPass.cjs +0 -174
  378. package/postprocessing/TAARenderPass.js +0 -174
  379. package/postprocessing/TexturePass.cjs +0 -42
  380. package/postprocessing/TexturePass.js +0 -42
  381. package/postprocessing/UnrealBloomPass.cjs +0 -277
  382. package/postprocessing/UnrealBloomPass.js +0 -277
  383. package/postprocessing/WaterPass.cjs +0 -72
  384. package/postprocessing/WaterPass.js +0 -72
  385. package/renderers/CSS2DRenderer.cjs +0 -122
  386. package/renderers/CSS2DRenderer.js +0 -122
  387. package/renderers/CSS3DRenderer.cjs +0 -167
  388. package/renderers/CSS3DRenderer.js +0 -167
  389. package/renderers/Projector.cjs +0 -499
  390. package/renderers/Projector.js +0 -499
  391. package/renderers/SVGRenderer.cjs +0 -311
  392. package/renderers/SVGRenderer.js +0 -311
  393. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  394. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  395. package/shaders/AfterimageShader.cjs +0 -32
  396. package/shaders/AfterimageShader.js +0 -32
  397. package/shaders/BasicShader.cjs +0 -12
  398. package/shaders/BasicShader.js +0 -12
  399. package/shaders/BleachBypassShader.cjs +0 -35
  400. package/shaders/BleachBypassShader.js +0 -35
  401. package/shaders/BlendShader.cjs +0 -30
  402. package/shaders/BlendShader.js +0 -30
  403. package/shaders/BokehShader.cjs +0 -109
  404. package/shaders/BokehShader.js +0 -109
  405. package/shaders/BokehShader2.cjs +0 -269
  406. package/shaders/BokehShader2.js +0 -269
  407. package/shaders/BrightnessContrastShader.cjs +0 -32
  408. package/shaders/BrightnessContrastShader.js +0 -32
  409. package/shaders/ColorCorrectionShader.cjs +0 -30
  410. package/shaders/ColorCorrectionShader.js +0 -30
  411. package/shaders/ColorifyShader.cjs +0 -28
  412. package/shaders/ColorifyShader.js +0 -28
  413. package/shaders/ConvolutionShader.cjs +0 -55
  414. package/shaders/ConvolutionShader.js +0 -55
  415. package/shaders/CopyShader.cjs +0 -25
  416. package/shaders/CopyShader.js +0 -25
  417. package/shaders/DOFMipMapShader.cjs +0 -32
  418. package/shaders/DOFMipMapShader.js +0 -32
  419. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  420. package/shaders/DepthLimitedBlurShader.js +0 -114
  421. package/shaders/DigitalGlitch.cjs +0 -85
  422. package/shaders/DigitalGlitch.js +0 -85
  423. package/shaders/DotScreenShader.cjs +0 -39
  424. package/shaders/DotScreenShader.js +0 -39
  425. package/shaders/FXAAShader.cjs +0 -1098
  426. package/shaders/FXAAShader.js +0 -1098
  427. package/shaders/FilmShader.cjs +0 -53
  428. package/shaders/FilmShader.js +0 -53
  429. package/shaders/FocusShader.cjs +0 -55
  430. package/shaders/FocusShader.js +0 -55
  431. package/shaders/FreiChenShader.cjs +0 -64
  432. package/shaders/FreiChenShader.js +0 -64
  433. package/shaders/FresnelShader.cjs +0 -47
  434. package/shaders/FresnelShader.js +0 -47
  435. package/shaders/GammaCorrectionShader.cjs +0 -23
  436. package/shaders/GammaCorrectionShader.js +0 -23
  437. package/shaders/GodRaysShader.cjs +0 -183
  438. package/shaders/GodRaysShader.js +0 -183
  439. package/shaders/HalftoneShader.cjs +0 -228
  440. package/shaders/HalftoneShader.js +0 -228
  441. package/shaders/HorizontalBlurShader.cjs +0 -49
  442. package/shaders/HorizontalBlurShader.js +0 -49
  443. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  444. package/shaders/HorizontalTiltShiftShader.js +0 -37
  445. package/shaders/HueSaturationShader.cjs +0 -43
  446. package/shaders/HueSaturationShader.js +0 -43
  447. package/shaders/KaleidoShader.cjs +0 -34
  448. package/shaders/KaleidoShader.js +0 -34
  449. package/shaders/LuminosityHighPassShader.cjs +0 -37
  450. package/shaders/LuminosityHighPassShader.js +0 -37
  451. package/shaders/LuminosityShader.cjs +0 -25
  452. package/shaders/LuminosityShader.js +0 -25
  453. package/shaders/MirrorShader.cjs +0 -35
  454. package/shaders/MirrorShader.js +0 -35
  455. package/shaders/NormalMapShader.cjs +0 -31
  456. package/shaders/NormalMapShader.js +0 -31
  457. package/shaders/ParallaxShader.cjs +0 -133
  458. package/shaders/ParallaxShader.js +0 -133
  459. package/shaders/PixelShader.cjs +0 -28
  460. package/shaders/PixelShader.js +0 -28
  461. package/shaders/RGBShiftShader.cjs +0 -30
  462. package/shaders/RGBShiftShader.js +0 -30
  463. package/shaders/SAOShader.cjs +0 -144
  464. package/shaders/SAOShader.js +0 -144
  465. package/shaders/SMAAShader.cjs +0 -358
  466. package/shaders/SMAAShader.js +0 -358
  467. package/shaders/SSAOShader.cjs +0 -182
  468. package/shaders/SSAOShader.js +0 -182
  469. package/shaders/SSRShader.cjs +0 -342
  470. package/shaders/SSRShader.js +0 -342
  471. package/shaders/SepiaShader.cjs +0 -29
  472. package/shaders/SepiaShader.js +0 -29
  473. package/shaders/SobelOperatorShader.cjs +0 -54
  474. package/shaders/SobelOperatorShader.js +0 -54
  475. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  476. package/shaders/SubsurfaceScatteringShader.js +0 -98
  477. package/shaders/TechnicolorShader.cjs +0 -24
  478. package/shaders/TechnicolorShader.js +0 -24
  479. package/shaders/ToneMapShader.cjs +0 -51
  480. package/shaders/ToneMapShader.js +0 -51
  481. package/shaders/ToonShader.cjs +0 -188
  482. package/shaders/ToonShader.js +0 -188
  483. package/shaders/TriangleBlurShader.cjs +0 -37
  484. package/shaders/TriangleBlurShader.js +0 -37
  485. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  486. package/shaders/UnpackDepthRGBAShader.js +0 -26
  487. package/shaders/VerticalBlurShader.cjs +0 -50
  488. package/shaders/VerticalBlurShader.js +0 -50
  489. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  490. package/shaders/VerticalTiltShiftShader.js +0 -37
  491. package/shaders/VignetteShader.cjs +0 -38
  492. package/shaders/VignetteShader.js +0 -38
  493. package/shaders/VolumeShader.cjs +0 -225
  494. package/shaders/VolumeShader.js +0 -225
  495. package/shaders/WaterRefractionShader.cjs +0 -59
  496. package/shaders/WaterRefractionShader.js +0 -59
  497. package/shaders/types.cjs +0 -1
  498. package/shaders/types.js +0 -1
  499. package/textures/FlakesTexture.cjs +0 -30
  500. package/textures/FlakesTexture.js +0 -30
  501. package/types/helpers.cjs +0 -4
  502. package/types/helpers.js +0 -4
  503. package/utils/BufferGeometryUtils.cjs +0 -636
  504. package/utils/BufferGeometryUtils.js +0 -636
  505. package/utils/GeometryCompressionUtils.cjs +0 -573
  506. package/utils/GeometryCompressionUtils.js +0 -573
  507. package/utils/GeometryUtils.cjs +0 -109
  508. package/utils/GeometryUtils.js +0 -109
  509. package/utils/RoughnessMipmapper.cjs +0 -223
  510. package/utils/RoughnessMipmapper.js +0 -223
  511. package/utils/SceneUtils.cjs +0 -36
  512. package/utils/SceneUtils.js +0 -36
  513. package/utils/ShadowMapViewer.cjs +0 -111
  514. package/utils/ShadowMapViewer.js +0 -111
  515. package/utils/SkeletonUtils.cjs +0 -211
  516. package/utils/SkeletonUtils.js +0 -211
  517. package/utils/UVsDebug.cjs +0 -80
  518. package/utils/UVsDebug.js +0 -80
  519. package/utils/WorkerPool.cjs +0 -62
  520. package/utils/WorkerPool.js +0 -62
  521. package/webxr/ARButton.cjs +0 -119
  522. package/webxr/ARButton.js +0 -119
  523. package/webxr/OculusHandModel.cjs +0 -82
  524. package/webxr/OculusHandModel.js +0 -82
  525. package/webxr/OculusHandPointerModel.cjs +0 -241
  526. package/webxr/OculusHandPointerModel.js +0 -224
  527. package/webxr/Text2D.cjs +0 -48
  528. package/webxr/Text2D.js +0 -31
  529. package/webxr/VRButton.cjs +0 -111
  530. package/webxr/VRButton.js +0 -111
  531. package/webxr/XRControllerModelFactory.cjs +0 -174
  532. package/webxr/XRControllerModelFactory.js +0 -174
  533. package/webxr/XREstimatedLight.cjs +0 -126
  534. package/webxr/XREstimatedLight.js +0 -126
  535. package/webxr/XRHandMeshModel.cjs +0 -82
  536. package/webxr/XRHandMeshModel.js +0 -82
  537. package/webxr/XRHandModelFactory.cjs +0 -61
  538. package/webxr/XRHandModelFactory.js +0 -61
  539. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  540. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,1424 +0,0 @@
1
- import { Vector3, ShaderMaterial, UniformsUtils, UniformsLib, Color, REVISION, LineSegments, Ray, FileLoader, Matrix4, Group, BufferGeometry, BufferAttribute, Mesh, Loader, MeshStandardMaterial, LineBasicMaterial } from "three";
2
- const FINISH_TYPE_DEFAULT = 0;
3
- const FINISH_TYPE_CHROME = 1;
4
- const FINISH_TYPE_PEARLESCENT = 2;
5
- const FINISH_TYPE_RUBBER = 3;
6
- const FINISH_TYPE_MATTE_METALLIC = 4;
7
- const FINISH_TYPE_METAL = 5;
8
- const FILE_LOCATION_AS_IS = 0;
9
- const FILE_LOCATION_TRY_PARTS = 1;
10
- const FILE_LOCATION_TRY_P = 2;
11
- const FILE_LOCATION_TRY_MODELS = 3;
12
- const FILE_LOCATION_TRY_RELATIVE = 4;
13
- const FILE_LOCATION_TRY_ABSOLUTE = 5;
14
- const FILE_LOCATION_NOT_FOUND = 6;
15
- const MAIN_COLOUR_CODE = "16";
16
- const MAIN_EDGE_COLOUR_CODE = "24";
17
- const _tempVec0 = /* @__PURE__ */ new Vector3();
18
- const _tempVec1 = /* @__PURE__ */ new Vector3();
19
- class LDrawConditionalLineMaterial extends ShaderMaterial {
20
- constructor(parameters) {
21
- super({
22
- uniforms: UniformsUtils.merge([
23
- UniformsLib.fog,
24
- {
25
- diffuse: {
26
- value: new Color()
27
- },
28
- opacity: {
29
- value: 1
30
- }
31
- }
32
- ]),
33
- vertexShader: (
34
- /* glsl */
35
- `
36
- attribute vec3 control0;
37
- attribute vec3 control1;
38
- attribute vec3 direction;
39
- varying float discardFlag;
40
-
41
- #include <common>
42
- #include <color_pars_vertex>
43
- #include <fog_pars_vertex>
44
- #include <logdepthbuf_pars_vertex>
45
- #include <clipping_planes_pars_vertex>
46
-
47
- void main() {
48
- #include <color_vertex>
49
-
50
- vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
51
- gl_Position = projectionMatrix * mvPosition;
52
-
53
- // Transform the line segment ends and control points into camera clip space
54
- vec4 c0 = projectionMatrix * modelViewMatrix * vec4(control0, 1.0);
55
- vec4 c1 = projectionMatrix * modelViewMatrix * vec4(control1, 1.0);
56
- vec4 p0 = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
57
- vec4 p1 = projectionMatrix * modelViewMatrix * vec4(position + direction, 1.0);
58
-
59
- c0.xy /= c0.w;
60
- c1.xy /= c1.w;
61
- p0.xy /= p0.w;
62
- p1.xy /= p1.w;
63
-
64
- // Get the direction of the segment and an orthogonal vector
65
- vec2 dir = p1.xy - p0.xy;
66
- vec2 norm = vec2(-dir.y, dir.x);
67
-
68
- // Get control point directions from the line
69
- vec2 c0dir = c0.xy - p1.xy;
70
- vec2 c1dir = c1.xy - p1.xy;
71
-
72
- // If the vectors to the controls points are pointed in different directions away
73
- // from the line segment then the line should not be drawn.
74
- float d0 = dot(normalize(norm), normalize(c0dir));
75
- float d1 = dot(normalize(norm), normalize(c1dir));
76
- discardFlag = float(sign(d0) != sign(d1));
77
-
78
- #include <logdepthbuf_vertex>
79
- #include <clipping_planes_vertex>
80
- #include <fog_vertex>
81
- }
82
- `
83
- ),
84
- fragmentShader: (
85
- /* glsl */
86
- `
87
- uniform vec3 diffuse;
88
- uniform float opacity;
89
- varying float discardFlag;
90
-
91
- #include <common>
92
- #include <color_pars_fragment>
93
- #include <fog_pars_fragment>
94
- #include <logdepthbuf_pars_fragment>
95
- #include <clipping_planes_pars_fragment>
96
-
97
- void main() {
98
- if (discardFlag > 0.5) discard;
99
-
100
- #include <clipping_planes_fragment>
101
- vec3 outgoingLight = vec3(0.0);
102
- vec4 diffuseColor = vec4(diffuse, opacity);
103
- #include <logdepthbuf_fragment>
104
- #include <color_fragment>
105
- outgoingLight = diffuseColor.rgb; // simple shader
106
- gl_FragColor = vec4(outgoingLight, diffuseColor.a);
107
- #include <tonemapping_fragment>
108
- #include <${parseInt(REVISION.replace(/\D+/g, "")) >= 154 ? "colorspace_fragment" : "encodings_fragment"}>
109
- #include <fog_fragment>
110
- #include <premultiplied_alpha_fragment>
111
- }
112
- `
113
- )
114
- });
115
- Object.defineProperties(this, {
116
- opacity: {
117
- get: function() {
118
- return this.uniforms.opacity.value;
119
- },
120
- set: function(value) {
121
- this.uniforms.opacity.value = value;
122
- }
123
- },
124
- color: {
125
- get: function() {
126
- return this.uniforms.diffuse.value;
127
- }
128
- }
129
- });
130
- this.setValues(parameters);
131
- this.isLDrawConditionalLineMaterial = true;
132
- }
133
- }
134
- class ConditionalLineSegments extends LineSegments {
135
- constructor(geometry, material) {
136
- super(geometry, material);
137
- this.isConditionalLine = true;
138
- }
139
- }
140
- function generateFaceNormals(faces) {
141
- for (let i = 0, l = faces.length; i < l; i++) {
142
- const face = faces[i];
143
- const vertices = face.vertices;
144
- const v0 = vertices[0];
145
- const v1 = vertices[1];
146
- const v2 = vertices[2];
147
- _tempVec0.subVectors(v1, v0);
148
- _tempVec1.subVectors(v2, v1);
149
- face.faceNormal = new Vector3().crossVectors(_tempVec0, _tempVec1).normalize();
150
- }
151
- }
152
- const _ray = /* @__PURE__ */ new Ray();
153
- function smoothNormals(faces, lineSegments, checkSubSegments = false) {
154
- const hashMultiplier = (1 + 1e-10) * 100;
155
- function hashVertex(v) {
156
- const x = ~~(v.x * hashMultiplier);
157
- const y = ~~(v.y * hashMultiplier);
158
- const z = ~~(v.z * hashMultiplier);
159
- return `${x},${y},${z}`;
160
- }
161
- function hashEdge(v0, v1) {
162
- return `${hashVertex(v0)}_${hashVertex(v1)}`;
163
- }
164
- function toNormalizedRay(v0, v1, targetRay) {
165
- targetRay.direction.subVectors(v1, v0).normalize();
166
- const scalar = v0.dot(targetRay.direction);
167
- targetRay.origin.copy(v0).addScaledVector(targetRay.direction, -scalar);
168
- return targetRay;
169
- }
170
- function hashRay(ray) {
171
- return hashEdge(ray.origin, ray.direction);
172
- }
173
- const hardEdges = /* @__PURE__ */ new Set();
174
- const hardEdgeRays = /* @__PURE__ */ new Map();
175
- const halfEdgeList = {};
176
- const normals = [];
177
- for (let i = 0, l = lineSegments.length; i < l; i++) {
178
- const ls = lineSegments[i];
179
- const vertices = ls.vertices;
180
- const v0 = vertices[0];
181
- const v1 = vertices[1];
182
- hardEdges.add(hashEdge(v0, v1));
183
- hardEdges.add(hashEdge(v1, v0));
184
- if (checkSubSegments) {
185
- const ray = toNormalizedRay(v0, v1, new Ray());
186
- const rh1 = hashRay(ray);
187
- if (!hardEdgeRays.has(rh1)) {
188
- toNormalizedRay(v1, v0, ray);
189
- const rh2 = hashRay(ray);
190
- const info2 = {
191
- ray,
192
- distances: []
193
- };
194
- hardEdgeRays.set(rh1, info2);
195
- hardEdgeRays.set(rh2, info2);
196
- }
197
- const info = hardEdgeRays.get(rh1);
198
- let d0 = info.ray.direction.dot(v0);
199
- let d1 = info.ray.direction.dot(v1);
200
- if (d0 > d1) {
201
- ;
202
- [d0, d1] = [d1, d0];
203
- }
204
- info.distances.push(d0, d1);
205
- }
206
- }
207
- for (let i = 0, l = faces.length; i < l; i++) {
208
- const tri = faces[i];
209
- const vertices = tri.vertices;
210
- const vertCount = vertices.length;
211
- for (let i2 = 0; i2 < vertCount; i2++) {
212
- const index = i2;
213
- const next = (i2 + 1) % vertCount;
214
- const v0 = vertices[index];
215
- const v1 = vertices[next];
216
- const hash = hashEdge(v0, v1);
217
- if (hardEdges.has(hash)) {
218
- continue;
219
- }
220
- if (checkSubSegments) {
221
- toNormalizedRay(v0, v1, _ray);
222
- const rayHash = hashRay(_ray);
223
- if (hardEdgeRays.has(rayHash)) {
224
- const info2 = hardEdgeRays.get(rayHash);
225
- const { ray, distances } = info2;
226
- let d0 = ray.direction.dot(v0);
227
- let d1 = ray.direction.dot(v1);
228
- if (d0 > d1) {
229
- ;
230
- [d0, d1] = [d1, d0];
231
- }
232
- let found = false;
233
- for (let i3 = 0, l2 = distances.length; i3 < l2; i3 += 2) {
234
- if (d0 >= distances[i3] && d1 <= distances[i3 + 1]) {
235
- found = true;
236
- break;
237
- }
238
- }
239
- if (found) {
240
- continue;
241
- }
242
- }
243
- }
244
- const info = {
245
- index,
246
- tri
247
- };
248
- halfEdgeList[hash] = info;
249
- }
250
- }
251
- while (true) {
252
- let halfEdge = null;
253
- for (const key in halfEdgeList) {
254
- halfEdge = halfEdgeList[key];
255
- break;
256
- }
257
- if (halfEdge === null) {
258
- break;
259
- }
260
- const queue = [halfEdge];
261
- while (queue.length > 0) {
262
- const tri = queue.pop().tri;
263
- const vertices = tri.vertices;
264
- const vertNormals = tri.normals;
265
- const faceNormal = tri.faceNormal;
266
- const vertCount = vertices.length;
267
- for (let i2 = 0; i2 < vertCount; i2++) {
268
- const index = i2;
269
- const next = (i2 + 1) % vertCount;
270
- const v0 = vertices[index];
271
- const v1 = vertices[next];
272
- const hash = hashEdge(v0, v1);
273
- delete halfEdgeList[hash];
274
- const reverseHash = hashEdge(v1, v0);
275
- const otherInfo = halfEdgeList[reverseHash];
276
- if (otherInfo) {
277
- const otherTri = otherInfo.tri;
278
- const otherIndex = otherInfo.index;
279
- const otherNormals = otherTri.normals;
280
- const otherVertCount = otherNormals.length;
281
- const otherFaceNormal = otherTri.faceNormal;
282
- if (Math.abs(otherTri.faceNormal.dot(tri.faceNormal)) < 0.25) {
283
- continue;
284
- }
285
- if (reverseHash in halfEdgeList) {
286
- queue.push(otherInfo);
287
- delete halfEdgeList[reverseHash];
288
- }
289
- const otherNext = (otherIndex + 1) % otherVertCount;
290
- if (vertNormals[index] && otherNormals[otherNext] && vertNormals[index] !== otherNormals[otherNext]) {
291
- otherNormals[otherNext].norm.add(vertNormals[index].norm);
292
- vertNormals[index].norm = otherNormals[otherNext].norm;
293
- }
294
- let sharedNormal1 = vertNormals[index] || otherNormals[otherNext];
295
- if (sharedNormal1 === null) {
296
- sharedNormal1 = { norm: new Vector3() };
297
- normals.push(sharedNormal1.norm);
298
- }
299
- if (vertNormals[index] === null) {
300
- vertNormals[index] = sharedNormal1;
301
- sharedNormal1.norm.add(faceNormal);
302
- }
303
- if (otherNormals[otherNext] === null) {
304
- otherNormals[otherNext] = sharedNormal1;
305
- sharedNormal1.norm.add(otherFaceNormal);
306
- }
307
- if (vertNormals[next] && otherNormals[otherIndex] && vertNormals[next] !== otherNormals[otherIndex]) {
308
- otherNormals[otherIndex].norm.add(vertNormals[next].norm);
309
- vertNormals[next].norm = otherNormals[otherIndex].norm;
310
- }
311
- let sharedNormal2 = vertNormals[next] || otherNormals[otherIndex];
312
- if (sharedNormal2 === null) {
313
- sharedNormal2 = { norm: new Vector3() };
314
- normals.push(sharedNormal2.norm);
315
- }
316
- if (vertNormals[next] === null) {
317
- vertNormals[next] = sharedNormal2;
318
- sharedNormal2.norm.add(faceNormal);
319
- }
320
- if (otherNormals[otherIndex] === null) {
321
- otherNormals[otherIndex] = sharedNormal2;
322
- sharedNormal2.norm.add(otherFaceNormal);
323
- }
324
- }
325
- }
326
- }
327
- }
328
- for (let i = 0, l = normals.length; i < l; i++) {
329
- normals[i].normalize();
330
- }
331
- }
332
- function isPartType(type) {
333
- return type === "Part" || type === "Unofficial_Part";
334
- }
335
- function isPrimitiveType(type) {
336
- return /primitive/i.test(type) || type === "Subpart";
337
- }
338
- class LineParser {
339
- constructor(line, lineNumber) {
340
- this.line = line;
341
- this.lineLength = line.length;
342
- this.currentCharIndex = 0;
343
- this.currentChar = " ";
344
- this.lineNumber = lineNumber;
345
- }
346
- seekNonSpace() {
347
- while (this.currentCharIndex < this.lineLength) {
348
- this.currentChar = this.line.charAt(this.currentCharIndex);
349
- if (this.currentChar !== " " && this.currentChar !== " ") {
350
- return;
351
- }
352
- this.currentCharIndex++;
353
- }
354
- }
355
- getToken() {
356
- const pos0 = this.currentCharIndex++;
357
- while (this.currentCharIndex < this.lineLength) {
358
- this.currentChar = this.line.charAt(this.currentCharIndex);
359
- if (this.currentChar === " " || this.currentChar === " ") {
360
- break;
361
- }
362
- this.currentCharIndex++;
363
- }
364
- const pos1 = this.currentCharIndex;
365
- this.seekNonSpace();
366
- return this.line.substring(pos0, pos1);
367
- }
368
- getVector() {
369
- return new Vector3(parseFloat(this.getToken()), parseFloat(this.getToken()), parseFloat(this.getToken()));
370
- }
371
- getRemainingString() {
372
- return this.line.substring(this.currentCharIndex, this.lineLength);
373
- }
374
- isAtTheEnd() {
375
- return this.currentCharIndex >= this.lineLength;
376
- }
377
- setToEnd() {
378
- this.currentCharIndex = this.lineLength;
379
- }
380
- getLineNumberString() {
381
- return this.lineNumber >= 0 ? " at line " + this.lineNumber : "";
382
- }
383
- }
384
- class LDrawParsedCache {
385
- constructor(loader) {
386
- this.loader = loader;
387
- this._cache = {};
388
- }
389
- cloneResult(original) {
390
- const result = {};
391
- result.faces = original.faces.map((face) => {
392
- return {
393
- colorCode: face.colorCode,
394
- material: face.material,
395
- vertices: face.vertices.map((v) => v.clone()),
396
- normals: face.normals.map(() => null),
397
- faceNormal: null
398
- };
399
- });
400
- result.conditionalSegments = original.conditionalSegments.map((face) => {
401
- return {
402
- colorCode: face.colorCode,
403
- material: face.material,
404
- vertices: face.vertices.map((v) => v.clone()),
405
- controlPoints: face.controlPoints.map((v) => v.clone())
406
- };
407
- });
408
- result.lineSegments = original.lineSegments.map((face) => {
409
- return {
410
- colorCode: face.colorCode,
411
- material: face.material,
412
- vertices: face.vertices.map((v) => v.clone())
413
- };
414
- });
415
- result.type = original.type;
416
- result.category = original.category;
417
- result.keywords = original.keywords;
418
- result.subobjects = original.subobjects;
419
- result.totalFaces = original.totalFaces;
420
- result.startingConstructionStep = original.startingConstructionStep;
421
- result.materials = original.materials;
422
- result.group = null;
423
- return result;
424
- }
425
- async fetchData(fileName) {
426
- let triedLowerCase = false;
427
- let locationState = FILE_LOCATION_AS_IS;
428
- while (locationState !== FILE_LOCATION_NOT_FOUND) {
429
- let subobjectURL = fileName;
430
- switch (locationState) {
431
- case FILE_LOCATION_AS_IS:
432
- locationState = locationState + 1;
433
- break;
434
- case FILE_LOCATION_TRY_PARTS:
435
- subobjectURL = "parts/" + subobjectURL;
436
- locationState = locationState + 1;
437
- break;
438
- case FILE_LOCATION_TRY_P:
439
- subobjectURL = "p/" + subobjectURL;
440
- locationState = locationState + 1;
441
- break;
442
- case FILE_LOCATION_TRY_MODELS:
443
- subobjectURL = "models/" + subobjectURL;
444
- locationState = locationState + 1;
445
- break;
446
- case FILE_LOCATION_TRY_RELATIVE:
447
- subobjectURL = fileName.substring(0, fileName.lastIndexOf("/") + 1) + subobjectURL;
448
- locationState = locationState + 1;
449
- break;
450
- case FILE_LOCATION_TRY_ABSOLUTE:
451
- if (triedLowerCase) {
452
- locationState = FILE_LOCATION_NOT_FOUND;
453
- } else {
454
- fileName = fileName.toLowerCase();
455
- subobjectURL = fileName;
456
- triedLowerCase = true;
457
- locationState = FILE_LOCATION_AS_IS;
458
- }
459
- break;
460
- }
461
- const loader = this.loader;
462
- const fileLoader = new FileLoader(loader.manager);
463
- fileLoader.setPath(loader.partsLibraryPath);
464
- fileLoader.setRequestHeader(loader.requestHeader);
465
- fileLoader.setWithCredentials(loader.withCredentials);
466
- try {
467
- const text = await fileLoader.loadAsync(subobjectURL);
468
- return text;
469
- } catch (e) {
470
- continue;
471
- }
472
- }
473
- throw new Error('LDrawLoader: Subobject "' + fileName + '" could not be loaded.');
474
- }
475
- parse(text, fileName = null) {
476
- const loader = this.loader;
477
- const faces = [];
478
- const lineSegments = [];
479
- const conditionalSegments = [];
480
- const subobjects = [];
481
- const materials = {};
482
- const getLocalMaterial = (colorCode) => {
483
- return materials[colorCode] || null;
484
- };
485
- let type = "Model";
486
- let category = null;
487
- let keywords = null;
488
- let totalFaces = 0;
489
- if (text.indexOf("\r\n") !== -1) {
490
- text = text.replace(/\r\n/g, "\n");
491
- }
492
- const lines = text.split("\n");
493
- const numLines = lines.length;
494
- let parsingEmbeddedFiles = false;
495
- let currentEmbeddedFileName = null;
496
- let currentEmbeddedText = null;
497
- let bfcCertified = false;
498
- let bfcCCW = true;
499
- let bfcInverted = false;
500
- let bfcCull = true;
501
- let startingConstructionStep = false;
502
- for (let lineIndex = 0; lineIndex < numLines; lineIndex++) {
503
- const line = lines[lineIndex];
504
- if (line.length === 0)
505
- continue;
506
- if (parsingEmbeddedFiles) {
507
- if (line.startsWith("0 FILE ")) {
508
- this.setData(currentEmbeddedFileName, currentEmbeddedText);
509
- currentEmbeddedFileName = line.substring(7);
510
- currentEmbeddedText = "";
511
- } else {
512
- currentEmbeddedText += line + "\n";
513
- }
514
- continue;
515
- }
516
- const lp = new LineParser(line, lineIndex + 1);
517
- lp.seekNonSpace();
518
- if (lp.isAtTheEnd()) {
519
- continue;
520
- }
521
- const lineType = lp.getToken();
522
- let material;
523
- let colorCode;
524
- let segment;
525
- let ccw;
526
- let doubleSided;
527
- let v0, v1, v2, v3, c0, c1;
528
- switch (lineType) {
529
- case "0":
530
- const meta = lp.getToken();
531
- if (meta) {
532
- switch (meta) {
533
- case "!LDRAW_ORG":
534
- type = lp.getToken();
535
- break;
536
- case "!COLOUR":
537
- material = loader.parseColorMetaDirective(lp);
538
- if (material) {
539
- materials[material.userData.code] = material;
540
- } else {
541
- console.warn("LDrawLoader: Error parsing material" + lp.getLineNumberString());
542
- }
543
- break;
544
- case "!CATEGORY":
545
- category = lp.getToken();
546
- break;
547
- case "!KEYWORDS":
548
- const newKeywords = lp.getRemainingString().split(",");
549
- if (newKeywords.length > 0) {
550
- if (!keywords) {
551
- keywords = [];
552
- }
553
- newKeywords.forEach(function(keyword) {
554
- keywords.push(keyword.trim());
555
- });
556
- }
557
- break;
558
- case "FILE":
559
- if (lineIndex > 0) {
560
- parsingEmbeddedFiles = true;
561
- currentEmbeddedFileName = lp.getRemainingString();
562
- currentEmbeddedText = "";
563
- bfcCertified = false;
564
- bfcCCW = true;
565
- }
566
- break;
567
- case "BFC":
568
- while (!lp.isAtTheEnd()) {
569
- const token = lp.getToken();
570
- switch (token) {
571
- case "CERTIFY":
572
- case "NOCERTIFY":
573
- bfcCertified = token === "CERTIFY";
574
- bfcCCW = true;
575
- break;
576
- case "CW":
577
- case "CCW":
578
- bfcCCW = token === "CCW";
579
- break;
580
- case "INVERTNEXT":
581
- bfcInverted = true;
582
- break;
583
- case "CLIP":
584
- case "NOCLIP":
585
- bfcCull = token === "CLIP";
586
- break;
587
- default:
588
- console.warn('THREE.LDrawLoader: BFC directive "' + token + '" is unknown.');
589
- break;
590
- }
591
- }
592
- break;
593
- case "STEP":
594
- startingConstructionStep = true;
595
- break;
596
- default:
597
- break;
598
- }
599
- }
600
- break;
601
- case "1":
602
- colorCode = lp.getToken();
603
- material = getLocalMaterial(colorCode);
604
- const posX = parseFloat(lp.getToken());
605
- const posY = parseFloat(lp.getToken());
606
- const posZ = parseFloat(lp.getToken());
607
- const m0 = parseFloat(lp.getToken());
608
- const m1 = parseFloat(lp.getToken());
609
- const m2 = parseFloat(lp.getToken());
610
- const m3 = parseFloat(lp.getToken());
611
- const m4 = parseFloat(lp.getToken());
612
- const m5 = parseFloat(lp.getToken());
613
- const m6 = parseFloat(lp.getToken());
614
- const m7 = parseFloat(lp.getToken());
615
- const m8 = parseFloat(lp.getToken());
616
- const matrix = new Matrix4().set(m0, m1, m2, posX, m3, m4, m5, posY, m6, m7, m8, posZ, 0, 0, 0, 1);
617
- let fileName2 = lp.getRemainingString().trim().replace(/\\/g, "/");
618
- if (loader.fileMap[fileName2]) {
619
- fileName2 = loader.fileMap[fileName2];
620
- } else {
621
- if (fileName2.startsWith("s/")) {
622
- fileName2 = "parts/" + fileName2;
623
- } else if (fileName2.startsWith("48/")) {
624
- fileName2 = "p/" + fileName2;
625
- }
626
- }
627
- subobjects.push({
628
- material,
629
- colorCode,
630
- matrix,
631
- fileName: fileName2,
632
- inverted: bfcInverted,
633
- startingConstructionStep
634
- });
635
- bfcInverted = false;
636
- break;
637
- case "2":
638
- colorCode = lp.getToken();
639
- material = getLocalMaterial(colorCode);
640
- v0 = lp.getVector();
641
- v1 = lp.getVector();
642
- segment = {
643
- material,
644
- colorCode,
645
- vertices: [v0, v1]
646
- };
647
- lineSegments.push(segment);
648
- break;
649
- case "5":
650
- colorCode = lp.getToken();
651
- material = getLocalMaterial(colorCode);
652
- v0 = lp.getVector();
653
- v1 = lp.getVector();
654
- c0 = lp.getVector();
655
- c1 = lp.getVector();
656
- segment = {
657
- material,
658
- colorCode,
659
- vertices: [v0, v1],
660
- controlPoints: [c0, c1]
661
- };
662
- conditionalSegments.push(segment);
663
- break;
664
- case "3":
665
- colorCode = lp.getToken();
666
- material = getLocalMaterial(colorCode);
667
- ccw = bfcCCW;
668
- doubleSided = !bfcCertified || !bfcCull;
669
- if (ccw === true) {
670
- v0 = lp.getVector();
671
- v1 = lp.getVector();
672
- v2 = lp.getVector();
673
- } else {
674
- v2 = lp.getVector();
675
- v1 = lp.getVector();
676
- v0 = lp.getVector();
677
- }
678
- faces.push({
679
- material,
680
- colorCode,
681
- faceNormal: null,
682
- vertices: [v0, v1, v2],
683
- normals: [null, null, null]
684
- });
685
- totalFaces++;
686
- if (doubleSided === true) {
687
- faces.push({
688
- material,
689
- colorCode,
690
- faceNormal: null,
691
- vertices: [v2, v1, v0],
692
- normals: [null, null, null]
693
- });
694
- totalFaces++;
695
- }
696
- break;
697
- case "4":
698
- colorCode = lp.getToken();
699
- material = getLocalMaterial(colorCode);
700
- ccw = bfcCCW;
701
- doubleSided = !bfcCertified || !bfcCull;
702
- if (ccw === true) {
703
- v0 = lp.getVector();
704
- v1 = lp.getVector();
705
- v2 = lp.getVector();
706
- v3 = lp.getVector();
707
- } else {
708
- v3 = lp.getVector();
709
- v2 = lp.getVector();
710
- v1 = lp.getVector();
711
- v0 = lp.getVector();
712
- }
713
- faces.push({
714
- material,
715
- colorCode,
716
- faceNormal: null,
717
- vertices: [v0, v1, v2, v3],
718
- normals: [null, null, null, null]
719
- });
720
- totalFaces += 2;
721
- if (doubleSided === true) {
722
- faces.push({
723
- material,
724
- colorCode,
725
- faceNormal: null,
726
- vertices: [v3, v2, v1, v0],
727
- normals: [null, null, null, null]
728
- });
729
- totalFaces += 2;
730
- }
731
- break;
732
- default:
733
- throw new Error('LDrawLoader: Unknown line type "' + lineType + '"' + lp.getLineNumberString() + ".");
734
- }
735
- }
736
- if (parsingEmbeddedFiles) {
737
- this.setData(currentEmbeddedFileName, currentEmbeddedText);
738
- }
739
- return {
740
- faces,
741
- conditionalSegments,
742
- lineSegments,
743
- type,
744
- category,
745
- keywords,
746
- subobjects,
747
- totalFaces,
748
- startingConstructionStep,
749
- materials,
750
- fileName,
751
- group: null
752
- };
753
- }
754
- // returns an (optionally cloned) instance of the data
755
- getData(fileName, clone = true) {
756
- const key = fileName.toLowerCase();
757
- const result = this._cache[key];
758
- if (result === null || result instanceof Promise) {
759
- return null;
760
- }
761
- if (clone) {
762
- return this.cloneResult(result);
763
- } else {
764
- return result;
765
- }
766
- }
767
- // kicks off a fetch and parse of the requested data if it hasn't already been loaded. Returns when
768
- // the data is ready to use and can be retrieved synchronously with "getData".
769
- async ensureDataLoaded(fileName) {
770
- const key = fileName.toLowerCase();
771
- if (!(key in this._cache)) {
772
- this._cache[key] = this.fetchData(fileName).then((text) => {
773
- const info = this.parse(text, fileName);
774
- this._cache[key] = info;
775
- return info;
776
- });
777
- }
778
- await this._cache[key];
779
- }
780
- // sets the data in the cache from parsed data
781
- setData(fileName, text) {
782
- const key = fileName.toLowerCase();
783
- this._cache[key] = this.parse(text, fileName);
784
- }
785
- }
786
- function getMaterialFromCode(colorCode, parentColorCode, materialHierarchy, forEdge) {
787
- const isPassthrough = !forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
788
- if (isPassthrough) {
789
- colorCode = parentColorCode;
790
- }
791
- return materialHierarchy[colorCode] || null;
792
- }
793
- class LDrawPartsGeometryCache {
794
- constructor(loader) {
795
- this.loader = loader;
796
- this.parseCache = new LDrawParsedCache(loader);
797
- this._cache = {};
798
- }
799
- // Convert the given file information into a mesh by processing subobjects.
800
- async processIntoMesh(info) {
801
- const loader = this.loader;
802
- const parseCache = this.parseCache;
803
- const faceMaterials = /* @__PURE__ */ new Set();
804
- const processInfoSubobjects = async (info2, subobject = null) => {
805
- const subobjects = info2.subobjects;
806
- const promises = [];
807
- for (let i = 0, l = subobjects.length; i < l; i++) {
808
- const subobject2 = subobjects[i];
809
- const promise = parseCache.ensureDataLoaded(subobject2.fileName).then(() => {
810
- const subobjectInfo = parseCache.getData(subobject2.fileName, false);
811
- if (!isPrimitiveType(subobjectInfo.type)) {
812
- return this.loadModel(subobject2.fileName).catch((error) => {
813
- console.warn(error);
814
- return null;
815
- });
816
- }
817
- return processInfoSubobjects(parseCache.getData(subobject2.fileName), subobject2);
818
- });
819
- promises.push(promise);
820
- }
821
- const group2 = new Group();
822
- group2.userData.category = info2.category;
823
- group2.userData.keywords = info2.keywords;
824
- info2.group = group2;
825
- const subobjectInfos = await Promise.all(promises);
826
- for (let i = 0, l = subobjectInfos.length; i < l; i++) {
827
- const subobject2 = info2.subobjects[i];
828
- const subobjectInfo = subobjectInfos[i];
829
- if (subobjectInfo === null) {
830
- continue;
831
- }
832
- if (subobjectInfo.isGroup) {
833
- const subobjectGroup = subobjectInfo;
834
- subobject2.matrix.decompose(subobjectGroup.position, subobjectGroup.quaternion, subobjectGroup.scale);
835
- subobjectGroup.userData.startingConstructionStep = subobject2.startingConstructionStep;
836
- subobjectGroup.name = subobject2.fileName;
837
- loader.applyMaterialsToMesh(subobjectGroup, subobject2.colorCode, info2.materials);
838
- group2.add(subobjectGroup);
839
- continue;
840
- }
841
- if (subobjectInfo.group.children.length) {
842
- group2.add(subobjectInfo.group);
843
- }
844
- const parentLineSegments = info2.lineSegments;
845
- const parentConditionalSegments = info2.conditionalSegments;
846
- const parentFaces = info2.faces;
847
- const lineSegments = subobjectInfo.lineSegments;
848
- const conditionalSegments = subobjectInfo.conditionalSegments;
849
- const faces = subobjectInfo.faces;
850
- const matrix = subobject2.matrix;
851
- const inverted = subobject2.inverted;
852
- const matrixScaleInverted = matrix.determinant() < 0;
853
- const colorCode = subobject2.colorCode;
854
- const lineColorCode = colorCode === MAIN_COLOUR_CODE ? MAIN_EDGE_COLOUR_CODE : colorCode;
855
- for (let i2 = 0, l2 = lineSegments.length; i2 < l2; i2++) {
856
- const ls = lineSegments[i2];
857
- const vertices = ls.vertices;
858
- vertices[0].applyMatrix4(matrix);
859
- vertices[1].applyMatrix4(matrix);
860
- ls.colorCode = ls.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : ls.colorCode;
861
- ls.material = ls.material || getMaterialFromCode(ls.colorCode, ls.colorCode, info2.materials, true);
862
- parentLineSegments.push(ls);
863
- }
864
- for (let i2 = 0, l2 = conditionalSegments.length; i2 < l2; i2++) {
865
- const os = conditionalSegments[i2];
866
- const vertices = os.vertices;
867
- const controlPoints = os.controlPoints;
868
- vertices[0].applyMatrix4(matrix);
869
- vertices[1].applyMatrix4(matrix);
870
- controlPoints[0].applyMatrix4(matrix);
871
- controlPoints[1].applyMatrix4(matrix);
872
- os.colorCode = os.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : os.colorCode;
873
- os.material = os.material || getMaterialFromCode(os.colorCode, os.colorCode, info2.materials, true);
874
- parentConditionalSegments.push(os);
875
- }
876
- for (let i2 = 0, l2 = faces.length; i2 < l2; i2++) {
877
- const tri = faces[i2];
878
- const vertices = tri.vertices;
879
- for (let i3 = 0, l3 = vertices.length; i3 < l3; i3++) {
880
- vertices[i3].applyMatrix4(matrix);
881
- }
882
- tri.colorCode = tri.colorCode === MAIN_COLOUR_CODE ? colorCode : tri.colorCode;
883
- tri.material = tri.material || getMaterialFromCode(tri.colorCode, colorCode, info2.materials, false);
884
- faceMaterials.add(tri.colorCode);
885
- if (matrixScaleInverted !== inverted) {
886
- vertices.reverse();
887
- }
888
- parentFaces.push(tri);
889
- }
890
- info2.totalFaces += subobjectInfo.totalFaces;
891
- }
892
- if (subobject) {
893
- loader.applyMaterialsToMesh(group2, subobject.colorCode, info2.materials);
894
- }
895
- return info2;
896
- };
897
- for (let i = 0, l = info.faces; i < l; i++) {
898
- faceMaterials.add(info.faces[i].colorCode);
899
- }
900
- await processInfoSubobjects(info);
901
- if (loader.smoothNormals) {
902
- const checkSubSegments = faceMaterials.size > 1;
903
- generateFaceNormals(info.faces);
904
- smoothNormals(info.faces, info.lineSegments, checkSubSegments);
905
- }
906
- const group = info.group;
907
- if (info.faces.length > 0) {
908
- group.add(createObject(info.faces, 3, false, info.totalFaces));
909
- }
910
- if (info.lineSegments.length > 0) {
911
- group.add(createObject(info.lineSegments, 2));
912
- }
913
- if (info.conditionalSegments.length > 0) {
914
- group.add(createObject(info.conditionalSegments, 2, true));
915
- }
916
- return group;
917
- }
918
- hasCachedModel(fileName) {
919
- return fileName !== null && fileName.toLowerCase() in this._cache;
920
- }
921
- async getCachedModel(fileName) {
922
- if (fileName !== null && this.hasCachedModel(fileName)) {
923
- const key = fileName.toLowerCase();
924
- const group = await this._cache[key];
925
- return group.clone();
926
- } else {
927
- return null;
928
- }
929
- }
930
- // Loads and parses the model with the given file name. Returns a cached copy if available.
931
- async loadModel(fileName) {
932
- const parseCache = this.parseCache;
933
- const key = fileName.toLowerCase();
934
- if (this.hasCachedModel(fileName)) {
935
- return this.getCachedModel(fileName);
936
- } else {
937
- await parseCache.ensureDataLoaded(fileName);
938
- const info = parseCache.getData(fileName);
939
- const promise = this.processIntoMesh(info);
940
- if (this.hasCachedModel(fileName)) {
941
- return this.getCachedModel(fileName);
942
- }
943
- if (isPartType(info.type)) {
944
- this._cache[key] = promise;
945
- }
946
- const group = await promise;
947
- return group.clone();
948
- }
949
- }
950
- // parses the given model text into a renderable object. Returns cached copy if available.
951
- async parseModel(text) {
952
- const parseCache = this.parseCache;
953
- const info = parseCache.parse(text);
954
- if (isPartType(info.type) && this.hasCachedModel(info.fileName)) {
955
- return this.getCachedModel(info.fileName);
956
- }
957
- return this.processIntoMesh(info);
958
- }
959
- }
960
- function sortByMaterial(a, b) {
961
- if (a.colorCode === b.colorCode) {
962
- return 0;
963
- }
964
- if (a.colorCode < b.colorCode) {
965
- return -1;
966
- }
967
- return 1;
968
- }
969
- function createObject(elements, elementSize, isConditionalSegments = false, totalElements = null) {
970
- elements.sort(sortByMaterial);
971
- if (totalElements === null) {
972
- totalElements = elements.length;
973
- }
974
- const positions = new Float32Array(elementSize * totalElements * 3);
975
- const normals = elementSize === 3 ? new Float32Array(elementSize * totalElements * 3) : null;
976
- const materials = [];
977
- const quadArray = new Array(6);
978
- const bufferGeometry = new BufferGeometry();
979
- let prevMaterial = null;
980
- let index0 = 0;
981
- let numGroupVerts = 0;
982
- let offset = 0;
983
- for (let iElem = 0, nElem = elements.length; iElem < nElem; iElem++) {
984
- const elem = elements[iElem];
985
- let vertices = elem.vertices;
986
- if (vertices.length === 4) {
987
- quadArray[0] = vertices[0];
988
- quadArray[1] = vertices[1];
989
- quadArray[2] = vertices[2];
990
- quadArray[3] = vertices[0];
991
- quadArray[4] = vertices[2];
992
- quadArray[5] = vertices[3];
993
- vertices = quadArray;
994
- }
995
- for (let j = 0, l = vertices.length; j < l; j++) {
996
- const v = vertices[j];
997
- const index = offset + j * 3;
998
- positions[index + 0] = v.x;
999
- positions[index + 1] = v.y;
1000
- positions[index + 2] = v.z;
1001
- }
1002
- if (elementSize === 3) {
1003
- if (!elem.faceNormal) {
1004
- const v0 = vertices[0];
1005
- const v1 = vertices[1];
1006
- const v2 = vertices[2];
1007
- _tempVec0.subVectors(v1, v0);
1008
- _tempVec1.subVectors(v2, v1);
1009
- elem.faceNormal = new Vector3().crossVectors(_tempVec0, _tempVec1).normalize();
1010
- }
1011
- let elemNormals = elem.normals;
1012
- if (elemNormals.length === 4) {
1013
- quadArray[0] = elemNormals[0];
1014
- quadArray[1] = elemNormals[1];
1015
- quadArray[2] = elemNormals[2];
1016
- quadArray[3] = elemNormals[0];
1017
- quadArray[4] = elemNormals[2];
1018
- quadArray[5] = elemNormals[3];
1019
- elemNormals = quadArray;
1020
- }
1021
- for (let j = 0, l = elemNormals.length; j < l; j++) {
1022
- let n = elem.faceNormal;
1023
- if (elemNormals[j]) {
1024
- n = elemNormals[j].norm;
1025
- }
1026
- const index = offset + j * 3;
1027
- normals[index + 0] = n.x;
1028
- normals[index + 1] = n.y;
1029
- normals[index + 2] = n.z;
1030
- }
1031
- }
1032
- if (prevMaterial !== elem.colorCode) {
1033
- if (prevMaterial !== null) {
1034
- bufferGeometry.addGroup(index0, numGroupVerts, materials.length - 1);
1035
- }
1036
- const material = elem.material;
1037
- if (material !== null) {
1038
- if (elementSize === 3) {
1039
- materials.push(material);
1040
- } else if (elementSize === 2) {
1041
- if (material !== null) {
1042
- if (isConditionalSegments) {
1043
- materials.push(material.userData.edgeMaterial.userData.conditionalEdgeMaterial);
1044
- } else {
1045
- materials.push(material.userData.edgeMaterial);
1046
- }
1047
- } else {
1048
- materials.push(null);
1049
- }
1050
- }
1051
- } else {
1052
- materials.push(elem.colorCode);
1053
- }
1054
- prevMaterial = elem.colorCode;
1055
- index0 = offset / 3;
1056
- numGroupVerts = vertices.length;
1057
- } else {
1058
- numGroupVerts += vertices.length;
1059
- }
1060
- offset += 3 * vertices.length;
1061
- }
1062
- if (numGroupVerts > 0) {
1063
- bufferGeometry.addGroup(index0, Infinity, materials.length - 1);
1064
- }
1065
- bufferGeometry.setAttribute("position", new BufferAttribute(positions, 3));
1066
- if (normals !== null) {
1067
- bufferGeometry.setAttribute("normal", new BufferAttribute(normals, 3));
1068
- }
1069
- let object3d = null;
1070
- if (elementSize === 2) {
1071
- if (isConditionalSegments) {
1072
- object3d = new ConditionalLineSegments(bufferGeometry, materials.length === 1 ? materials[0] : materials);
1073
- } else {
1074
- object3d = new LineSegments(bufferGeometry, materials.length === 1 ? materials[0] : materials);
1075
- }
1076
- } else if (elementSize === 3) {
1077
- object3d = new Mesh(bufferGeometry, materials.length === 1 ? materials[0] : materials);
1078
- }
1079
- if (isConditionalSegments) {
1080
- object3d.isConditionalLine = true;
1081
- const controlArray0 = new Float32Array(elements.length * 3 * 2);
1082
- const controlArray1 = new Float32Array(elements.length * 3 * 2);
1083
- const directionArray = new Float32Array(elements.length * 3 * 2);
1084
- for (let i = 0, l = elements.length; i < l; i++) {
1085
- const os = elements[i];
1086
- const vertices = os.vertices;
1087
- const controlPoints = os.controlPoints;
1088
- const c0 = controlPoints[0];
1089
- const c1 = controlPoints[1];
1090
- const v0 = vertices[0];
1091
- const v1 = vertices[1];
1092
- const index = i * 3 * 2;
1093
- controlArray0[index + 0] = c0.x;
1094
- controlArray0[index + 1] = c0.y;
1095
- controlArray0[index + 2] = c0.z;
1096
- controlArray0[index + 3] = c0.x;
1097
- controlArray0[index + 4] = c0.y;
1098
- controlArray0[index + 5] = c0.z;
1099
- controlArray1[index + 0] = c1.x;
1100
- controlArray1[index + 1] = c1.y;
1101
- controlArray1[index + 2] = c1.z;
1102
- controlArray1[index + 3] = c1.x;
1103
- controlArray1[index + 4] = c1.y;
1104
- controlArray1[index + 5] = c1.z;
1105
- directionArray[index + 0] = v1.x - v0.x;
1106
- directionArray[index + 1] = v1.y - v0.y;
1107
- directionArray[index + 2] = v1.z - v0.z;
1108
- directionArray[index + 3] = v1.x - v0.x;
1109
- directionArray[index + 4] = v1.y - v0.y;
1110
- directionArray[index + 5] = v1.z - v0.z;
1111
- }
1112
- bufferGeometry.setAttribute("control0", new BufferAttribute(controlArray0, 3, false));
1113
- bufferGeometry.setAttribute("control1", new BufferAttribute(controlArray1, 3, false));
1114
- bufferGeometry.setAttribute("direction", new BufferAttribute(directionArray, 3, false));
1115
- }
1116
- return object3d;
1117
- }
1118
- class LDrawLoader extends Loader {
1119
- constructor(manager) {
1120
- super(manager);
1121
- this.materials = [];
1122
- this.materialLibrary = {};
1123
- this.partsCache = new LDrawPartsGeometryCache(this);
1124
- this.fileMap = {};
1125
- this.setMaterials([]);
1126
- this.smoothNormals = true;
1127
- this.partsLibraryPath = "";
1128
- }
1129
- setPartsLibraryPath(path) {
1130
- this.partsLibraryPath = path;
1131
- return this;
1132
- }
1133
- async preloadMaterials(url) {
1134
- const fileLoader = new FileLoader(this.manager);
1135
- fileLoader.setPath(this.path);
1136
- fileLoader.setRequestHeader(this.requestHeader);
1137
- fileLoader.setWithCredentials(this.withCredentials);
1138
- const text = await fileLoader.loadAsync(url);
1139
- const colorLineRegex = /^0 !COLOUR/;
1140
- const lines = text.split(/[\n\r]/g);
1141
- const materials = [];
1142
- for (let i = 0, l = lines.length; i < l; i++) {
1143
- const line = lines[i];
1144
- if (colorLineRegex.test(line)) {
1145
- const directive = line.replace(colorLineRegex, "");
1146
- const material = this.parseColorMetaDirective(new LineParser(directive));
1147
- materials.push(material);
1148
- }
1149
- }
1150
- this.setMaterials(materials);
1151
- }
1152
- load(url, onLoad, onProgress, onError) {
1153
- const fileLoader = new FileLoader(this.manager);
1154
- fileLoader.setPath(this.path);
1155
- fileLoader.setRequestHeader(this.requestHeader);
1156
- fileLoader.setWithCredentials(this.withCredentials);
1157
- fileLoader.load(
1158
- url,
1159
- (text) => {
1160
- this.partsCache.parseModel(text, this.materialLibrary).then((group) => {
1161
- this.applyMaterialsToMesh(group, MAIN_COLOUR_CODE, this.materialLibrary, true);
1162
- this.computeConstructionSteps(group);
1163
- onLoad(group);
1164
- }).catch(onError);
1165
- },
1166
- onProgress,
1167
- onError
1168
- );
1169
- }
1170
- parse(text, onLoad) {
1171
- this.partsCache.parseModel(text, this.materialLibrary).then((group) => {
1172
- this.computeConstructionSteps(group);
1173
- onLoad(group);
1174
- });
1175
- }
1176
- setMaterials(materials) {
1177
- this.materialLibrary = {};
1178
- this.materials = [];
1179
- for (let i = 0, l = materials.length; i < l; i++) {
1180
- this.addMaterial(materials[i]);
1181
- }
1182
- this.addMaterial(this.parseColorMetaDirective(new LineParser("Main_Colour CODE 16 VALUE #FF8080 EDGE #333333")));
1183
- this.addMaterial(this.parseColorMetaDirective(new LineParser("Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333")));
1184
- return this;
1185
- }
1186
- setFileMap(fileMap) {
1187
- this.fileMap = fileMap;
1188
- return this;
1189
- }
1190
- addMaterial(material) {
1191
- const matLib = this.materialLibrary;
1192
- if (!matLib[material.userData.code]) {
1193
- this.materials.push(material);
1194
- matLib[material.userData.code] = material;
1195
- }
1196
- return this;
1197
- }
1198
- getMaterial(colorCode) {
1199
- if (colorCode.startsWith("0x2")) {
1200
- const color = colorCode.substring(3);
1201
- return this.parseColorMetaDirective(
1202
- new LineParser("Direct_Color_" + color + " CODE -1 VALUE #" + color + " EDGE #" + color)
1203
- );
1204
- }
1205
- return this.materialLibrary[colorCode] || null;
1206
- }
1207
- // Applies the appropriate materials to a prebuilt hierarchy of geometry. Assumes that color codes are present
1208
- // in the material array if they need to be filled in.
1209
- applyMaterialsToMesh(group, parentColorCode, materialHierarchy, finalMaterialPass = false) {
1210
- const loader = this;
1211
- const parentIsPassthrough = parentColorCode === MAIN_COLOUR_CODE;
1212
- group.traverse((c) => {
1213
- if (c.isMesh || c.isLineSegments) {
1214
- if (Array.isArray(c.material)) {
1215
- for (let i = 0, l = c.material.length; i < l; i++) {
1216
- if (!c.material[i].isMaterial) {
1217
- c.material[i] = getMaterial(c, c.material[i]);
1218
- }
1219
- }
1220
- } else if (!c.material.isMaterial) {
1221
- c.material = getMaterial(c, c.material);
1222
- }
1223
- }
1224
- });
1225
- function getMaterial(c, colorCode) {
1226
- if (parentIsPassthrough && !(colorCode in materialHierarchy) && !finalMaterialPass) {
1227
- return colorCode;
1228
- }
1229
- const forEdge = c.isLineSegments || c.isConditionalLine;
1230
- const isPassthrough = !forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
1231
- if (isPassthrough) {
1232
- colorCode = parentColorCode;
1233
- }
1234
- let material = null;
1235
- if (colorCode in materialHierarchy) {
1236
- material = materialHierarchy[colorCode];
1237
- } else if (finalMaterialPass) {
1238
- material = loader.getMaterial(colorCode);
1239
- if (material === null) {
1240
- throw new Error(`LDrawLoader: Material properties for code ${colorCode} not available.`);
1241
- }
1242
- } else {
1243
- return colorCode;
1244
- }
1245
- if (c.isLineSegments) {
1246
- material = material.userData.edgeMaterial;
1247
- if (c.isConditionalLine) {
1248
- material = material.userData.conditionalEdgeMaterial;
1249
- }
1250
- }
1251
- return material;
1252
- }
1253
- }
1254
- getMainMaterial() {
1255
- return this.getMaterial(MAIN_COLOUR_CODE);
1256
- }
1257
- getMainEdgeMaterial() {
1258
- return this.getMaterial(MAIN_EDGE_COLOUR_CODE);
1259
- }
1260
- parseColorMetaDirective(lineParser) {
1261
- let code = null;
1262
- let color = 16711935;
1263
- let edgeColor = 16711935;
1264
- let alpha = 1;
1265
- let isTransparent = false;
1266
- let luminance = 0;
1267
- let finishType = FINISH_TYPE_DEFAULT;
1268
- let edgeMaterial = null;
1269
- const name = lineParser.getToken();
1270
- if (!name) {
1271
- throw new Error(
1272
- 'LDrawLoader: Material name was expected after "!COLOUR tag' + lineParser.getLineNumberString() + "."
1273
- );
1274
- }
1275
- let token = null;
1276
- while (true) {
1277
- token = lineParser.getToken();
1278
- if (!token) {
1279
- break;
1280
- }
1281
- switch (token.toUpperCase()) {
1282
- case "CODE":
1283
- code = lineParser.getToken();
1284
- break;
1285
- case "VALUE":
1286
- color = lineParser.getToken();
1287
- if (color.startsWith("0x")) {
1288
- color = "#" + color.substring(2);
1289
- } else if (!color.startsWith("#")) {
1290
- throw new Error(
1291
- "LDrawLoader: Invalid color while parsing material" + lineParser.getLineNumberString() + "."
1292
- );
1293
- }
1294
- break;
1295
- case "EDGE":
1296
- edgeColor = lineParser.getToken();
1297
- if (edgeColor.startsWith("0x")) {
1298
- edgeColor = "#" + edgeColor.substring(2);
1299
- } else if (!edgeColor.startsWith("#")) {
1300
- edgeMaterial = this.getMaterial(edgeColor);
1301
- if (!edgeMaterial) {
1302
- throw new Error(
1303
- "LDrawLoader: Invalid edge color while parsing material" + lineParser.getLineNumberString() + "."
1304
- );
1305
- }
1306
- edgeMaterial = edgeMaterial.userData.edgeMaterial;
1307
- }
1308
- break;
1309
- case "ALPHA":
1310
- alpha = parseInt(lineParser.getToken());
1311
- if (isNaN(alpha)) {
1312
- throw new Error(
1313
- "LDrawLoader: Invalid alpha value in material definition" + lineParser.getLineNumberString() + "."
1314
- );
1315
- }
1316
- alpha = Math.max(0, Math.min(1, alpha / 255));
1317
- if (alpha < 1) {
1318
- isTransparent = true;
1319
- }
1320
- break;
1321
- case "LUMINANCE":
1322
- luminance = parseInt(lineParser.getToken());
1323
- if (isNaN(luminance)) {
1324
- throw new Error(
1325
- "LDrawLoader: Invalid luminance value in material definition" + LineParser.getLineNumberString() + "."
1326
- );
1327
- }
1328
- luminance = Math.max(0, Math.min(1, luminance / 255));
1329
- break;
1330
- case "CHROME":
1331
- finishType = FINISH_TYPE_CHROME;
1332
- break;
1333
- case "PEARLESCENT":
1334
- finishType = FINISH_TYPE_PEARLESCENT;
1335
- break;
1336
- case "RUBBER":
1337
- finishType = FINISH_TYPE_RUBBER;
1338
- break;
1339
- case "MATTE_METALLIC":
1340
- finishType = FINISH_TYPE_MATTE_METALLIC;
1341
- break;
1342
- case "METAL":
1343
- finishType = FINISH_TYPE_METAL;
1344
- break;
1345
- case "MATERIAL":
1346
- lineParser.setToEnd();
1347
- break;
1348
- default:
1349
- throw new Error(
1350
- 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + "."
1351
- );
1352
- }
1353
- }
1354
- let material = null;
1355
- switch (finishType) {
1356
- case FINISH_TYPE_DEFAULT:
1357
- material = new MeshStandardMaterial({ color, roughness: 0.3, metalness: 0 });
1358
- break;
1359
- case FINISH_TYPE_PEARLESCENT:
1360
- material = new MeshStandardMaterial({ color, roughness: 0.3, metalness: 0.25 });
1361
- break;
1362
- case FINISH_TYPE_CHROME:
1363
- material = new MeshStandardMaterial({ color, roughness: 0, metalness: 1 });
1364
- break;
1365
- case FINISH_TYPE_RUBBER:
1366
- material = new MeshStandardMaterial({ color, roughness: 0.9, metalness: 0 });
1367
- break;
1368
- case FINISH_TYPE_MATTE_METALLIC:
1369
- material = new MeshStandardMaterial({ color, roughness: 0.8, metalness: 0.4 });
1370
- break;
1371
- case FINISH_TYPE_METAL:
1372
- material = new MeshStandardMaterial({ color, roughness: 0.2, metalness: 0.85 });
1373
- break;
1374
- default:
1375
- break;
1376
- }
1377
- material.transparent = isTransparent;
1378
- material.premultipliedAlpha = true;
1379
- material.opacity = alpha;
1380
- material.depthWrite = !isTransparent;
1381
- material.polygonOffset = true;
1382
- material.polygonOffsetFactor = 1;
1383
- if (luminance !== 0) {
1384
- material.emissive.set(material.color).multiplyScalar(luminance);
1385
- }
1386
- if (!edgeMaterial) {
1387
- edgeMaterial = new LineBasicMaterial({
1388
- color: edgeColor,
1389
- transparent: isTransparent,
1390
- opacity: alpha,
1391
- depthWrite: !isTransparent
1392
- });
1393
- edgeMaterial.userData.code = code;
1394
- edgeMaterial.name = name + " - Edge";
1395
- edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial({
1396
- fog: true,
1397
- transparent: isTransparent,
1398
- depthWrite: !isTransparent,
1399
- color: edgeColor,
1400
- opacity: alpha
1401
- });
1402
- }
1403
- material.userData.code = code;
1404
- material.name = name;
1405
- material.userData.edgeMaterial = edgeMaterial;
1406
- this.addMaterial(material);
1407
- return material;
1408
- }
1409
- computeConstructionSteps(model) {
1410
- let stepNumber = 0;
1411
- model.traverse((c) => {
1412
- if (c.isGroup) {
1413
- if (c.userData.startingConstructionStep) {
1414
- stepNumber++;
1415
- }
1416
- c.userData.constructionStep = stepNumber;
1417
- }
1418
- });
1419
- model.userData.numConstructionSteps = stepNumber + 1;
1420
- }
1421
- }
1422
- export {
1423
- LDrawLoader
1424
- };