@anov/3d 0.0.3 → 0.0.4-alpha12

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