super-three 0.141.0 → 0.144.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/README.md +8 -8
  2. package/build/three.cjs +1558 -1034
  3. package/build/three.js +1558 -1034
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +2012 -1243
  6. package/examples/js/animation/MMDPhysics.js +1 -16
  7. package/examples/js/controls/ArcballControls.js +16 -3
  8. package/examples/js/controls/FirstPersonControls.js +0 -7
  9. package/examples/js/controls/FlyControls.js +0 -8
  10. package/examples/js/controls/OrbitControls.js +0 -4
  11. package/examples/js/controls/PointerLockControls.js +0 -8
  12. package/examples/js/controls/TrackballControls.js +0 -2
  13. package/examples/js/controls/TransformControls.js +20 -16
  14. package/examples/js/effects/AnaglyphEffect.js +2 -2
  15. package/examples/js/effects/OutlineEffect.js +4 -24
  16. package/examples/js/effects/ParallaxBarrierEffect.js +2 -2
  17. package/examples/js/effects/PeppersGhostEffect.js +2 -2
  18. package/examples/js/effects/StereoEffect.js +2 -2
  19. package/examples/js/environments/RoomEnvironment.js +22 -0
  20. package/examples/js/exporters/ColladaExporter.js +4 -13
  21. package/examples/js/exporters/DRACOExporter.js +0 -12
  22. package/examples/js/exporters/GLTFExporter.js +28 -29
  23. package/examples/js/exporters/OBJExporter.js +2 -23
  24. package/examples/js/exporters/PLYExporter.js +12 -24
  25. package/examples/js/exporters/STLExporter.js +0 -7
  26. package/examples/js/exporters/USDZExporter.js +6 -0
  27. package/examples/js/geometries/ConvexGeometry.js +1 -1
  28. package/examples/js/geometries/ParametricGeometry.js +1 -8
  29. package/examples/js/interactive/SelectionHelper.js +2 -0
  30. package/examples/js/libs/ktx-parse.umd.js +1 -0
  31. package/examples/js/libs/meshopt_decoder.js +98 -32
  32. package/examples/js/loaders/ColladaLoader.js +1 -0
  33. package/examples/js/loaders/DRACOLoader.js +2 -25
  34. package/examples/js/loaders/EXRLoader.js +2 -13
  35. package/examples/js/loaders/FBXLoader.js +10 -3
  36. package/examples/js/loaders/FontLoader.js +3 -16
  37. package/examples/js/loaders/GLTFLoader.js +52 -36
  38. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -11
  39. package/examples/js/loaders/LDrawLoader.js +139 -74
  40. package/examples/js/loaders/OBJLoader.js +7 -13
  41. package/examples/js/loaders/PCDLoader.js +59 -14
  42. package/examples/js/loaders/PLYLoader.js +3 -3
  43. package/examples/js/loaders/SVGLoader.js +4 -3
  44. package/examples/js/loaders/TIFFLoader.js +31 -0
  45. package/examples/js/loaders/VRMLLoader.js +33 -24
  46. package/examples/js/loaders/VTKLoader.js +1 -1
  47. package/examples/js/loaders/lwo/LWO2Parser.js +8 -7
  48. package/examples/js/loaders/lwo/LWO3Parser.js +8 -7
  49. package/examples/js/materials/MeshGouraudMaterial.js +385 -0
  50. package/examples/js/math/ColorConverter.js +0 -50
  51. package/examples/js/misc/GPUComputationRenderer.js +23 -0
  52. package/examples/js/misc/Volume.js +198 -190
  53. package/examples/js/misc/VolumeSlice.js +90 -88
  54. package/examples/js/modifiers/SimplifyModifier.js +1 -1
  55. package/examples/js/objects/GroundProjectedEnv.js +193 -0
  56. package/examples/js/objects/Reflector.js +9 -2
  57. package/examples/js/objects/ReflectorForSSRPass.js +3 -4
  58. package/examples/js/objects/Refractor.js +10 -4
  59. package/examples/js/objects/ShadowMesh.js +5 -1
  60. package/examples/js/postprocessing/OutlinePass.js +5 -3
  61. package/examples/js/renderers/CSS2DRenderer.js +2 -2
  62. package/examples/js/renderers/CSS3DRenderer.js +2 -2
  63. package/examples/js/renderers/Projector.js +2 -23
  64. package/examples/js/shaders/LuminosityShader.js +1 -1
  65. package/examples/js/shaders/MMDToonShader.js +6 -2
  66. package/examples/js/shaders/ToneMapShader.js +1 -1
  67. package/examples/js/utils/BufferGeometryUtils.js +1 -1
  68. package/examples/js/utils/GeometryUtils.js +2 -18
  69. package/examples/js/utils/PackedPhongMaterial.js +1 -1
  70. package/examples/js/utils/SceneUtils.js +0 -16
  71. package/examples/jsm/animation/MMDPhysics.js +3 -22
  72. package/examples/jsm/controls/ArcballControls.js +17 -2
  73. package/examples/jsm/controls/FirstPersonControls.js +0 -7
  74. package/examples/jsm/controls/FlyControls.js +0 -7
  75. package/examples/jsm/controls/OrbitControls.js +0 -5
  76. package/examples/jsm/controls/PointerLockControls.js +0 -7
  77. package/examples/jsm/controls/TrackballControls.js +0 -3
  78. package/examples/jsm/controls/TransformControls.js +18 -16
  79. package/examples/jsm/effects/AnaglyphEffect.js +2 -2
  80. package/examples/jsm/effects/OutlineEffect.js +4 -25
  81. package/examples/jsm/effects/ParallaxBarrierEffect.js +2 -2
  82. package/examples/jsm/effects/PeppersGhostEffect.js +2 -2
  83. package/examples/jsm/effects/StereoEffect.js +2 -2
  84. package/examples/jsm/environments/RoomEnvironment.js +23 -0
  85. package/examples/jsm/exporters/ColladaExporter.js +4 -13
  86. package/examples/jsm/exporters/DRACOExporter.js +0 -13
  87. package/examples/jsm/exporters/GLTFExporter.js +29 -31
  88. package/examples/jsm/exporters/KTX2Exporter.js +29 -29
  89. package/examples/jsm/exporters/OBJExporter.js +0 -18
  90. package/examples/jsm/exporters/PLYExporter.js +14 -22
  91. package/examples/jsm/exporters/STLExporter.js +1 -9
  92. package/examples/jsm/exporters/USDZExporter.js +14 -3
  93. package/examples/jsm/geometries/ConvexGeometry.js +1 -1
  94. package/examples/jsm/geometries/ParametricGeometry.js +0 -6
  95. package/examples/jsm/interactive/HTMLMesh.js +9 -9
  96. package/examples/jsm/interactive/SelectionHelper.js +5 -3
  97. package/examples/jsm/libs/meshopt_decoder.module.js +97 -32
  98. package/examples/jsm/libs/utif.module.js +1579 -0
  99. package/examples/jsm/libs/zstddec.module.js +1 -0
  100. package/examples/jsm/loaders/ColladaLoader.js +1 -0
  101. package/examples/jsm/loaders/DRACOLoader.js +2 -28
  102. package/examples/jsm/loaders/EXRLoader.js +3 -13
  103. package/examples/jsm/loaders/FBXLoader.js +10 -3
  104. package/examples/jsm/loaders/FontLoader.js +3 -16
  105. package/examples/jsm/loaders/GLTFLoader.js +52 -36
  106. package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -13
  107. package/examples/jsm/loaders/KTX2Loader.js +192 -30
  108. package/examples/jsm/loaders/LDrawLoader.js +135 -74
  109. package/examples/jsm/loaders/OBJLoader.js +6 -14
  110. package/examples/jsm/loaders/PCDLoader.js +59 -13
  111. package/examples/jsm/loaders/PLYLoader.js +3 -3
  112. package/examples/jsm/loaders/RGBELoader.js +1 -1
  113. package/examples/jsm/loaders/SVGLoader.js +4 -3
  114. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  115. package/examples/jsm/loaders/USDZLoader.js +393 -0
  116. package/examples/jsm/loaders/VRMLLoader.js +23 -25
  117. package/examples/jsm/loaders/VTKLoader.js +1 -1
  118. package/examples/jsm/loaders/lwo/LWO2Parser.js +6 -8
  119. package/examples/jsm/loaders/lwo/LWO3Parser.js +6 -8
  120. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  121. package/examples/jsm/math/ColorConverter.js +1 -49
  122. package/examples/jsm/misc/GPUComputationRenderer.js +43 -0
  123. package/examples/jsm/misc/Volume.js +169 -171
  124. package/examples/jsm/misc/VolumeSlice.js +78 -80
  125. package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
  126. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +1 -1
  127. package/examples/jsm/node-editor/accessors/NormalEditor.js +1 -1
  128. package/examples/jsm/node-editor/accessors/PositionEditor.js +1 -1
  129. package/examples/jsm/node-editor/accessors/UVEditor.js +1 -1
  130. package/examples/jsm/node-editor/display/BlendEditor.js +1 -1
  131. package/examples/jsm/node-editor/display/NormalMapEditor.js +1 -1
  132. package/examples/jsm/node-editor/inputs/ColorEditor.js +1 -1
  133. package/examples/jsm/node-editor/inputs/FloatEditor.js +1 -1
  134. package/examples/jsm/node-editor/inputs/SliderEditor.js +1 -1
  135. package/examples/jsm/node-editor/inputs/TextureEditor.js +1 -1
  136. package/examples/jsm/node-editor/inputs/Vector2Editor.js +1 -1
  137. package/examples/jsm/node-editor/inputs/Vector3Editor.js +1 -1
  138. package/examples/jsm/node-editor/inputs/Vector4Editor.js +1 -1
  139. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +1 -1
  140. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +1 -1
  141. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +1 -1
  142. package/examples/jsm/node-editor/math/AngleEditor.js +1 -1
  143. package/examples/jsm/node-editor/math/DotEditor.js +1 -1
  144. package/examples/jsm/node-editor/math/InvertEditor.js +1 -1
  145. package/examples/jsm/node-editor/math/LimiterEditor.js +1 -1
  146. package/examples/jsm/node-editor/math/NormalizeEditor.js +1 -1
  147. package/examples/jsm/node-editor/math/OperatorEditor.js +1 -1
  148. package/examples/jsm/node-editor/math/PowerEditor.js +1 -1
  149. package/examples/jsm/node-editor/math/TrigonometryEditor.js +1 -1
  150. package/examples/jsm/node-editor/procedural/CheckerEditor.js +1 -1
  151. package/examples/jsm/node-editor/utils/JoinEditor.js +1 -1
  152. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  153. package/examples/jsm/node-editor/utils/PreviewEditor.js +3 -3
  154. package/examples/jsm/node-editor/utils/SplitEditor.js +1 -1
  155. package/examples/jsm/node-editor/utils/TimerEditor.js +1 -1
  156. package/examples/jsm/nodes/Nodes.js +43 -13
  157. package/examples/jsm/nodes/accessors/CubeTextureNode.js +9 -5
  158. package/examples/jsm/nodes/accessors/NormalNode.js +4 -4
  159. package/examples/jsm/nodes/accessors/PositionNode.js +5 -5
  160. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  161. package/examples/jsm/nodes/core/AttributeNode.js +3 -3
  162. package/examples/jsm/nodes/core/CodeNode.js +3 -3
  163. package/examples/jsm/nodes/core/FunctionCallNode.js +20 -5
  164. package/examples/jsm/nodes/core/FunctionNode.js +2 -2
  165. package/examples/jsm/nodes/core/Node.js +14 -12
  166. package/examples/jsm/nodes/core/NodeBuilder.js +12 -12
  167. package/examples/jsm/nodes/core/NodeUtils.js +23 -1
  168. package/examples/jsm/nodes/core/{NodeVary.js → NodeVarying.js} +3 -3
  169. package/examples/jsm/nodes/core/{VaryNode.js → VaryingNode.js} +7 -7
  170. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +94 -0
  171. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  172. package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -0
  173. package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -7
  174. package/examples/jsm/nodes/lighting/LightingContextNode.js +4 -4
  175. package/examples/jsm/nodes/loaders/NodeLoader.js +2 -2
  176. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +31 -0
  177. package/examples/jsm/nodes/materials/Materials.js +13 -25
  178. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  179. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +4 -7
  180. package/examples/jsm/nodes/materials/NodeMaterial.js +2 -2
  181. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +28 -17
  182. package/examples/jsm/nodes/materialx/Disclaimer.md +199 -0
  183. package/examples/jsm/nodes/materialx/functions/lib/mx_hsv.js +56 -0
  184. package/examples/jsm/nodes/materialx/functions/lib/mx_noise.js +607 -0
  185. package/examples/jsm/nodes/math/MathNode.js +2 -12
  186. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +21 -6
  187. package/examples/jsm/nodes/procedural/CheckerNode.js +2 -2
  188. package/examples/jsm/nodes/shadernode/ShaderNode.js +5 -5
  189. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +8 -5
  190. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +20 -6
  191. package/examples/jsm/nodes/utils/ConvertNode.js +8 -3
  192. package/examples/jsm/nodes/utils/JoinNode.js +7 -7
  193. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +2 -1
  194. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  195. package/examples/jsm/nodes/utils/SplitNode.js +21 -5
  196. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  197. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  198. package/examples/jsm/objects/Reflector.js +12 -5
  199. package/examples/jsm/objects/ReflectorForSSRPass.js +3 -5
  200. package/examples/jsm/objects/Refractor.js +12 -6
  201. package/examples/jsm/objects/ShadowMesh.js +8 -2
  202. package/examples/jsm/postprocessing/OutlinePass.js +5 -3
  203. package/examples/jsm/renderers/CSS2DRenderer.js +2 -2
  204. package/examples/jsm/renderers/CSS3DRenderer.js +2 -2
  205. package/examples/jsm/renderers/Projector.js +2 -24
  206. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +9 -5
  207. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +329 -218
  208. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +7 -3
  209. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +39 -3
  210. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +6 -0
  211. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +6 -0
  212. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
  213. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +17 -19
  214. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +16 -14
  215. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +2 -2
  216. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +66 -81
  217. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +5 -3
  218. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +2 -2
  219. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  220. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +25 -30
  221. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
  222. package/examples/jsm/shaders/LuminosityShader.js +1 -1
  223. package/examples/jsm/shaders/MMDToonShader.js +2 -2
  224. package/examples/jsm/shaders/ToneMapShader.js +1 -1
  225. package/examples/jsm/utils/BufferGeometryUtils.js +2 -1
  226. package/examples/jsm/utils/GeometryUtils.js +17 -25
  227. package/examples/jsm/utils/PackedPhongMaterial.js +0 -1
  228. package/examples/jsm/utils/SceneUtils.js +1 -21
  229. package/examples/jsm/webxr/OculusHandPointerModel.js +6 -1
  230. package/examples/jsm/webxr/VRButton.js +1 -7
  231. package/package.json +18 -14
  232. package/src/Three.Legacy.js +262 -36
  233. package/src/Three.js +3 -2
  234. package/src/animation/AnimationAction.js +6 -5
  235. package/src/animation/AnimationClip.js +1 -1
  236. package/src/animation/AnimationMixer.js +1 -1
  237. package/src/animation/AnimationUtils.js +204 -199
  238. package/src/animation/KeyframeTrack.js +1 -1
  239. package/src/animation/PropertyBinding.js +24 -5
  240. package/src/cameras/CubeCamera.js +0 -7
  241. package/src/constants.js +2 -4
  242. package/src/core/BufferAttribute.js +81 -111
  243. package/src/core/BufferGeometry.js +3 -41
  244. package/src/core/InstancedBufferAttribute.js +0 -10
  245. package/src/core/InterleavedBuffer.js +1 -1
  246. package/src/core/InterleavedBufferAttribute.js +56 -7
  247. package/src/core/Object3D.js +22 -5
  248. package/src/core/Uniform.js +0 -7
  249. package/src/core/UniformsGroup.js +92 -0
  250. package/src/extras/DataUtils.js +104 -88
  251. package/src/extras/core/Path.js +1 -0
  252. package/src/extras/core/ShapePath.js +1 -4
  253. package/src/extras/curves/CatmullRomCurve3.js +4 -2
  254. package/src/geometries/BoxGeometry.js +1 -1
  255. package/src/geometries/CapsuleGeometry.js +1 -1
  256. package/src/geometries/CircleGeometry.js +1 -1
  257. package/src/geometries/ConeGeometry.js +1 -1
  258. package/src/geometries/CylinderGeometry.js +2 -1
  259. package/src/geometries/DodecahedronGeometry.js +1 -1
  260. package/src/geometries/EdgesGeometry.js +5 -4
  261. package/src/geometries/ExtrudeGeometry.js +2 -11
  262. package/src/geometries/IcosahedronGeometry.js +1 -1
  263. package/src/geometries/LatheGeometry.js +2 -2
  264. package/src/geometries/OctahedronGeometry.js +1 -1
  265. package/src/geometries/PlaneGeometry.js +2 -1
  266. package/src/geometries/PolyhedronGeometry.js +1 -1
  267. package/src/geometries/RingGeometry.js +1 -1
  268. package/src/geometries/ShapeGeometry.js +2 -1
  269. package/src/geometries/SphereGeometry.js +2 -1
  270. package/src/geometries/TetrahedronGeometry.js +1 -1
  271. package/src/geometries/TorusGeometry.js +2 -1
  272. package/src/geometries/TorusKnotGeometry.js +2 -1
  273. package/src/geometries/TubeGeometry.js +2 -1
  274. package/src/geometries/WireframeGeometry.js +1 -0
  275. package/src/helpers/CameraHelper.js +97 -38
  276. package/src/helpers/DirectionalLightHelper.js +1 -0
  277. package/src/helpers/HemisphereLightHelper.js +1 -0
  278. package/src/helpers/PlaneHelper.js +6 -9
  279. package/src/helpers/PolarGridHelper.js +18 -14
  280. package/src/helpers/SpotLightHelper.js +1 -0
  281. package/src/lights/SpotLight.js +2 -0
  282. package/src/loaders/FileLoader.js +12 -1
  283. package/src/loaders/LoadingManager.js +1 -1
  284. package/src/loaders/MaterialLoader.js +49 -7
  285. package/src/loaders/ObjectLoader.js +4 -41
  286. package/src/materials/Material.js +1 -33
  287. package/src/materials/Materials.js +0 -27
  288. package/src/materials/MeshLambertMaterial.js +28 -1
  289. package/src/materials/ShaderMaterial.js +3 -7
  290. package/src/math/Color.js +3 -13
  291. package/src/math/MathUtils.js +1 -7
  292. package/src/math/Matrix3.js +1 -7
  293. package/src/math/Matrix4.js +3 -27
  294. package/src/math/Quaternion.js +1 -21
  295. package/src/math/Vector2.js +4 -24
  296. package/src/math/Vector3.js +7 -46
  297. package/src/math/Vector4.js +4 -24
  298. package/src/renderers/WebGLRenderer.js +84 -8
  299. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +12 -12
  300. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -5
  301. package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -5
  302. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +24 -24
  303. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +1 -1
  304. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +1 -1
  305. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +2 -1
  306. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +113 -99
  307. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +34 -12
  308. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  309. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
  310. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +3 -1
  311. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +13 -1
  312. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +2 -4
  313. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -1
  314. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +18 -7
  315. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +8 -3
  316. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +9 -6
  317. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
  318. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +14 -10
  319. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +1 -1
  320. package/src/renderers/shaders/ShaderChunk.js +4 -2
  321. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +0 -1
  322. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +22 -50
  323. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
  324. package/src/renderers/shaders/ShaderLib.js +31 -31
  325. package/src/renderers/shaders/UniformsLib.js +12 -11
  326. package/src/renderers/shaders/UniformsUtils.js +14 -0
  327. package/src/renderers/webgl/WebGLBackground.js +2 -2
  328. package/src/renderers/webgl/WebGLLights.js +37 -13
  329. package/src/renderers/webgl/WebGLMorphtargets.js +0 -20
  330. package/src/renderers/webgl/WebGLProgram.js +6 -11
  331. package/src/renderers/webgl/WebGLPrograms.js +30 -26
  332. package/src/renderers/webgl/WebGLRenderLists.js +5 -4
  333. package/src/renderers/webgl/WebGLRenderStates.js +5 -4
  334. package/src/renderers/webgl/WebGLShaderCache.js +9 -6
  335. package/src/renderers/webgl/WebGLShadowMap.js +10 -15
  336. package/src/renderers/webgl/WebGLState.js +47 -0
  337. package/src/renderers/webgl/WebGLUniforms.js +4 -4
  338. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  339. package/src/renderers/webgl/WebGLUtils.js +2 -0
  340. package/src/renderers/webvr/WebVRManager.js +42 -9
  341. package/src/renderers/webvr/WebVRUtils.js +1 -1
  342. package/src/renderers/webxr/WebXRController.js +45 -37
  343. package/src/renderers/webxr/WebXRManager.js +58 -33
  344. package/src/scenes/Scene.js +16 -3
  345. package/src/textures/Source.js +1 -1
  346. package/src/utils.js +1 -1
  347. package/examples/js/controls/experimental/CameraControls.js +0 -1048
  348. package/examples/js/loaders/KTX2Loader.js +0 -558
  349. package/examples/jsm/controls/experimental/CameraControls.js +0 -1248
  350. package/examples/jsm/nodes/accessors/ReflectNode.js +0 -70
  351. package/examples/jsm/package.json +0 -3
  352. package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +0 -45
  353. package/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +0 -122
@@ -1210,16 +1210,34 @@
1210
1210
 
1211
1211
  }
1212
1212
 
1213
- return Promise.all( [ buffer, decoder.ready ] ).then( function ( res ) {
1213
+ return buffer.then( function ( res ) {
1214
1214
 
1215
1215
  const byteOffset = extensionDef.byteOffset || 0;
1216
1216
  const byteLength = extensionDef.byteLength || 0;
1217
1217
  const count = extensionDef.count;
1218
1218
  const stride = extensionDef.byteStride;
1219
- const result = new ArrayBuffer( count * stride );
1220
- const source = new Uint8Array( res[ 0 ], byteOffset, byteLength );
1221
- decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
1222
- return result;
1219
+ const source = new Uint8Array( res, byteOffset, byteLength );
1220
+
1221
+ if ( decoder.decodeGltfBufferAsync ) {
1222
+
1223
+ return decoder.decodeGltfBufferAsync( count, stride, source, extensionDef.mode, extensionDef.filter ).then( function ( res ) {
1224
+
1225
+ return res.buffer;
1226
+
1227
+ } );
1228
+
1229
+ } else {
1230
+
1231
+ // Support for MeshoptDecoder 0.18 or earlier, without decodeGltfBufferAsync
1232
+ return decoder.ready.then( function () {
1233
+
1234
+ const result = new ArrayBuffer( count * stride );
1235
+ decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
1236
+ return result;
1237
+
1238
+ } );
1239
+
1240
+ }
1223
1241
 
1224
1242
  } );
1225
1243
 
@@ -1352,7 +1370,7 @@
1352
1370
 
1353
1371
  const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
1354
1372
  const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
1355
- attributeTypeMap[ threeAttributeName ] = componentType;
1373
+ attributeTypeMap[ threeAttributeName ] = componentType.name;
1356
1374
  attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
1357
1375
 
1358
1376
  }
@@ -1733,44 +1751,44 @@
1733
1751
 
1734
1752
  }
1735
1753
 
1736
- }
1754
+ interpolate_( i1, t0, t, t1 ) {
1737
1755
 
1738
- GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) {
1756
+ const result = this.resultBuffer;
1757
+ const values = this.sampleValues;
1758
+ const stride = this.valueSize;
1759
+ const stride2 = stride * 2;
1760
+ const stride3 = stride * 3;
1761
+ const td = t1 - t0;
1762
+ const p = ( t - t0 ) / td;
1763
+ const pp = p * p;
1764
+ const ppp = pp * p;
1765
+ const offset1 = i1 * stride3;
1766
+ const offset0 = offset1 - stride3;
1767
+ const s2 = - 2 * ppp + 3 * pp;
1768
+ const s3 = ppp - pp;
1769
+ const s0 = 1 - s2;
1770
+ const s1 = s3 - pp + p; // Layout of keyframe output values for CUBICSPLINE animations:
1771
+ // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
1739
1772
 
1740
- const result = this.resultBuffer;
1741
- const values = this.sampleValues;
1742
- const stride = this.valueSize;
1743
- const stride2 = stride * 2;
1744
- const stride3 = stride * 3;
1745
- const td = t1 - t0;
1746
- const p = ( t - t0 ) / td;
1747
- const pp = p * p;
1748
- const ppp = pp * p;
1749
- const offset1 = i1 * stride3;
1750
- const offset0 = offset1 - stride3;
1751
- const s2 = - 2 * ppp + 3 * pp;
1752
- const s3 = ppp - pp;
1753
- const s0 = 1 - s2;
1754
- const s1 = s3 - pp + p; // Layout of keyframe output values for CUBICSPLINE animations:
1755
- // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
1773
+ for ( let i = 0; i !== stride; i ++ ) {
1756
1774
 
1757
- for ( let i = 0; i !== stride; i ++ ) {
1775
+ const p0 = values[ offset0 + i + stride ]; // splineVertex_k
1758
1776
 
1759
- const p0 = values[ offset0 + i + stride ]; // splineVertex_k
1777
+ const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
1760
1778
 
1761
- const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
1779
+ const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
1762
1780
 
1763
- const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
1781
+ const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
1764
1782
 
1765
- const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
1783
+ result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
1766
1784
 
1767
- result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
1785
+ }
1768
1786
 
1769
- }
1787
+ return result;
1770
1788
 
1771
- return result;
1789
+ }
1772
1790
 
1773
- };
1791
+ }
1774
1792
 
1775
1793
  const _q = new THREE.Quaternion();
1776
1794
 
@@ -3451,8 +3469,7 @@
3451
3469
  const channel = animationDef.channels[ i ];
3452
3470
  const sampler = animationDef.samplers[ channel.sampler ];
3453
3471
  const target = channel.target;
3454
- const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
3455
-
3472
+ const name = target.node;
3456
3473
  const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
3457
3474
  const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
3458
3475
  pendingNodes.push( this.getDependency( 'node', name ) );
@@ -3481,7 +3498,6 @@
3481
3498
  const target = targets[ i ];
3482
3499
  if ( node === undefined ) continue;
3483
3500
  node.updateMatrix();
3484
- node.matrixAutoUpdate = true;
3485
3501
  let TypedKeyframeTrack;
3486
3502
 
3487
3503
  switch ( PATH_PROPERTIES[ target.path ] ) {
@@ -12,17 +12,6 @@
12
12
 
13
13
  load( urls, onLoad, onProgress, onError ) {
14
14
 
15
- if ( ! Array.isArray( urls ) ) {
16
-
17
- console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
18
- this.setDataType( urls );
19
- urls = onLoad;
20
- onLoad = onProgress;
21
- onProgress = onError;
22
- onError = arguments[ 4 ];
23
-
24
- }
25
-
26
15
  const texture = new THREE.CubeTexture();
27
16
  texture.type = this.type;
28
17
 
@@ -10,10 +10,10 @@
10
10
  const FINISH_TYPE_METAL = 5; // State machine to search a subobject path.
11
11
  // The LDraw standard establishes these various possible subfolders.
12
12
 
13
- const FILE_LOCATION_AS_IS = 0;
14
- const FILE_LOCATION_TRY_PARTS = 1;
15
- const FILE_LOCATION_TRY_P = 2;
16
- const FILE_LOCATION_TRY_MODELS = 3;
13
+ const FILE_LOCATION_TRY_PARTS = 0;
14
+ const FILE_LOCATION_TRY_P = 1;
15
+ const FILE_LOCATION_TRY_MODELS = 2;
16
+ const FILE_LOCATION_AS_IS = 3;
17
17
  const FILE_LOCATION_TRY_RELATIVE = 4;
18
18
  const FILE_LOCATION_TRY_ABSOLUTE = 5;
19
19
  const FILE_LOCATION_NOT_FOUND = 6;
@@ -655,7 +655,9 @@
655
655
  result.type = original.type;
656
656
  result.category = original.category;
657
657
  result.keywords = original.keywords;
658
+ result.author = original.author;
658
659
  result.subobjects = original.subobjects;
660
+ result.fileName = original.fileName;
659
661
  result.totalFaces = original.totalFaces;
660
662
  result.startingConstructionStep = original.startingConstructionStep;
661
663
  result.materials = original.materials;
@@ -667,7 +669,7 @@
667
669
  async fetchData( fileName ) {
668
670
 
669
671
  let triedLowerCase = false;
670
- let locationState = FILE_LOCATION_AS_IS;
672
+ let locationState = FILE_LOCATION_TRY_PARTS;
671
673
 
672
674
  while ( locationState !== FILE_LOCATION_NOT_FOUND ) {
673
675
 
@@ -711,7 +713,7 @@
711
713
  fileName = fileName.toLowerCase();
712
714
  subobjectURL = fileName;
713
715
  triedLowerCase = true;
714
- locationState = FILE_LOCATION_AS_IS;
716
+ locationState = FILE_LOCATION_TRY_PARTS;
715
717
 
716
718
  }
717
719
 
@@ -761,6 +763,7 @@
761
763
  let type = 'Model';
762
764
  let category = null;
763
765
  let keywords = null;
766
+ let author = null;
764
767
  let totalFaces = 0; // split into lines
765
768
 
766
769
  if ( text.indexOf( '\r\n' ) !== - 1 ) {
@@ -936,6 +939,10 @@
936
939
  startingConstructionStep = true;
937
940
  break;
938
941
 
942
+ case 'Author:':
943
+ author = lp.getToken();
944
+ break;
945
+
939
946
  default:
940
947
  // Other meta directives are not implemented
941
948
  break;
@@ -1141,6 +1148,7 @@
1141
1148
  type,
1142
1149
  category,
1143
1150
  keywords,
1151
+ author,
1144
1152
  subobjects,
1145
1153
  totalFaces,
1146
1154
  startingConstructionStep,
@@ -1277,6 +1285,9 @@
1277
1285
  const group = new THREE.Group();
1278
1286
  group.userData.category = info.category;
1279
1287
  group.userData.keywords = info.keywords;
1288
+ group.userData.author = info.author;
1289
+ group.userData.type = info.type;
1290
+ group.userData.fileName = info.fileName;
1280
1291
  info.group = group;
1281
1292
  const subobjectInfos = await Promise.all( promises );
1282
1293
 
@@ -1300,6 +1311,7 @@
1300
1311
  subobjectGroup.userData.startingConstructionStep = subobject.startingConstructionStep;
1301
1312
  subobjectGroup.name = subobject.fileName;
1302
1313
  loader.applyMaterialsToMesh( subobjectGroup, subobject.colorCode, info.materials );
1314
+ subobjectGroup.userData.colorCode = subobject.colorCode;
1303
1315
  group.add( subobjectGroup );
1304
1316
  continue;
1305
1317
 
@@ -1388,6 +1400,7 @@
1388
1400
  if ( subobject ) {
1389
1401
 
1390
1402
  loader.applyMaterialsToMesh( group, subobject.colorCode, info.materials );
1403
+ group.userData.colorCode = subobject.colorCode;
1391
1404
 
1392
1405
  }
1393
1406
 
@@ -1790,7 +1803,25 @@
1790
1803
 
1791
1804
  this.smoothNormals = true; // The path to load parts from the LDraw parts library from.
1792
1805
 
1793
- this.partsLibraryPath = '';
1806
+ this.partsLibraryPath = ''; // Material assigned to not available colors for meshes and edges
1807
+
1808
+ this.missingColorMaterial = new THREE.MeshStandardMaterial( {
1809
+ color: 0xFF00FF,
1810
+ roughness: 0.3,
1811
+ metalness: 0
1812
+ } );
1813
+ this.missingColorMaterial.name = 'Missing material';
1814
+ this.missingEdgeColorMaterial = new THREE.LineBasicMaterial( {
1815
+ color: 0xFF00FF
1816
+ } );
1817
+ this.missingEdgeColorMaterial.name = 'Missing material - Edge';
1818
+ this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( {
1819
+ fog: true,
1820
+ color: 0xFF00FF
1821
+ } );
1822
+ this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
1823
+ this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
1824
+ this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
1794
1825
 
1795
1826
  }
1796
1827
 
@@ -1842,6 +1873,7 @@
1842
1873
 
1843
1874
  this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1844
1875
  this.computeConstructionSteps( group );
1876
+ group.userData.fileName = url;
1845
1877
  onLoad( group );
1846
1878
 
1847
1879
  } ).catch( onError );
@@ -1854,7 +1886,9 @@
1854
1886
 
1855
1887
  this.partsCache.parseModel( text, this.materialLibrary ).then( group => {
1856
1888
 
1889
+ this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1857
1890
  this.computeConstructionSteps( group );
1891
+ group.userData.fileName = '';
1858
1892
  onLoad( group );
1859
1893
 
1860
1894
  } );
@@ -1984,8 +2018,10 @@
1984
2018
 
1985
2019
  if ( material === null ) {
1986
2020
 
1987
- // otherwise throw an error if this is final opportunity to set the material
1988
- throw new Error( `LDrawLoader: Material properties for code ${colorCode} not available.` );
2021
+ // otherwise throw a warning if this is final opportunity to set the material
2022
+ console.warn( `LDrawLoader: Material properties for code ${colorCode} not available.` ); // And return the 'missing color' material
2023
+
2024
+ material = loader.missingColorMaterial;
1989
2025
 
1990
2026
  }
1991
2027
 
@@ -2021,8 +2057,8 @@
2021
2057
 
2022
2058
  getMainEdgeMaterial() {
2023
2059
 
2024
- const mainMat = this.getMainMaterial();
2025
- return mainMat && mainMat.userData ? mainMat.userData.edgeMaterial : null;
2060
+ const mat = this.getMaterial( MAIN_EDGE_COLOUR_CODE );
2061
+ return mat ? mat.userData.edgeMaterial : null;
2026
2062
 
2027
2063
  }
2028
2064
 
@@ -2061,110 +2097,111 @@
2061
2097
 
2062
2098
  }
2063
2099
 
2064
- switch ( token.toUpperCase() ) {
2100
+ if ( ! parseLuminance( token ) ) {
2065
2101
 
2066
- case 'CODE':
2067
- code = lineParser.getToken();
2068
- break;
2102
+ switch ( token.toUpperCase() ) {
2069
2103
 
2070
- case 'VALUE':
2071
- color = lineParser.getToken();
2104
+ case 'CODE':
2105
+ code = lineParser.getToken();
2106
+ break;
2072
2107
 
2073
- if ( color.startsWith( '0x' ) ) {
2108
+ case 'VALUE':
2109
+ color = lineParser.getToken();
2074
2110
 
2075
- color = '#' + color.substring( 2 );
2111
+ if ( color.startsWith( '0x' ) ) {
2076
2112
 
2077
- } else if ( ! color.startsWith( '#' ) ) {
2113
+ color = '#' + color.substring( 2 );
2078
2114
 
2079
- throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
2115
+ } else if ( ! color.startsWith( '#' ) ) {
2080
2116
 
2081
- }
2117
+ throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
2082
2118
 
2083
- break;
2119
+ }
2084
2120
 
2085
- case 'EDGE':
2086
- edgeColor = lineParser.getToken();
2121
+ break;
2087
2122
 
2088
- if ( edgeColor.startsWith( '0x' ) ) {
2123
+ case 'EDGE':
2124
+ edgeColor = lineParser.getToken();
2089
2125
 
2090
- edgeColor = '#' + edgeColor.substring( 2 );
2126
+ if ( edgeColor.startsWith( '0x' ) ) {
2091
2127
 
2092
- } else if ( ! edgeColor.startsWith( '#' ) ) {
2128
+ edgeColor = '#' + edgeColor.substring( 2 );
2093
2129
 
2094
- // Try to see if edge color is a color code
2095
- edgeMaterial = this.getMaterial( edgeColor );
2130
+ } else if ( ! edgeColor.startsWith( '#' ) ) {
2096
2131
 
2097
- if ( ! edgeMaterial ) {
2132
+ // Try to see if edge color is a color code
2133
+ edgeMaterial = this.getMaterial( edgeColor );
2098
2134
 
2099
- throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
2135
+ if ( ! edgeMaterial ) {
2100
2136
 
2101
- } // Get the edge material for this triangle material
2137
+ throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
2102
2138
 
2139
+ } // Get the edge material for this triangle material
2103
2140
 
2104
- edgeMaterial = edgeMaterial.userData.edgeMaterial;
2105
2141
 
2106
- }
2142
+ edgeMaterial = edgeMaterial.userData.edgeMaterial;
2107
2143
 
2108
- break;
2144
+ }
2109
2145
 
2110
- case 'ALPHA':
2111
- alpha = parseInt( lineParser.getToken() );
2146
+ break;
2112
2147
 
2113
- if ( isNaN( alpha ) ) {
2148
+ case 'ALPHA':
2149
+ alpha = parseInt( lineParser.getToken() );
2114
2150
 
2115
- throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
2151
+ if ( isNaN( alpha ) ) {
2116
2152
 
2117
- }
2153
+ throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
2118
2154
 
2119
- alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
2155
+ }
2120
2156
 
2121
- if ( alpha < 1 ) {
2157
+ alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
2122
2158
 
2123
- isTransparent = true;
2159
+ if ( alpha < 1 ) {
2124
2160
 
2125
- }
2161
+ isTransparent = true;
2126
2162
 
2127
- break;
2163
+ }
2128
2164
 
2129
- case 'LUMINANCE':
2130
- luminance = parseInt( lineParser.getToken() );
2165
+ break;
2131
2166
 
2132
- if ( isNaN( luminance ) ) {
2167
+ case 'LUMINANCE':
2168
+ if ( ! parseLuminance( lineParser.getToken() ) ) {
2133
2169
 
2134
- throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
2170
+ throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
2135
2171
 
2136
- }
2172
+ }
2137
2173
 
2138
- luminance = Math.max( 0, Math.min( 1, luminance / 255 ) );
2139
- break;
2174
+ break;
2140
2175
 
2141
- case 'CHROME':
2142
- finishType = FINISH_TYPE_CHROME;
2143
- break;
2176
+ case 'CHROME':
2177
+ finishType = FINISH_TYPE_CHROME;
2178
+ break;
2144
2179
 
2145
- case 'PEARLESCENT':
2146
- finishType = FINISH_TYPE_PEARLESCENT;
2147
- break;
2180
+ case 'PEARLESCENT':
2181
+ finishType = FINISH_TYPE_PEARLESCENT;
2182
+ break;
2148
2183
 
2149
- case 'RUBBER':
2150
- finishType = FINISH_TYPE_RUBBER;
2151
- break;
2184
+ case 'RUBBER':
2185
+ finishType = FINISH_TYPE_RUBBER;
2186
+ break;
2152
2187
 
2153
- case 'MATTE_METALLIC':
2154
- finishType = FINISH_TYPE_MATTE_METALLIC;
2155
- break;
2188
+ case 'MATTE_METALLIC':
2189
+ finishType = FINISH_TYPE_MATTE_METALLIC;
2190
+ break;
2156
2191
 
2157
- case 'METAL':
2158
- finishType = FINISH_TYPE_METAL;
2159
- break;
2192
+ case 'METAL':
2193
+ finishType = FINISH_TYPE_METAL;
2194
+ break;
2160
2195
 
2161
- case 'MATERIAL':
2162
- // Not implemented
2163
- lineParser.setToEnd();
2164
- break;
2196
+ case 'MATERIAL':
2197
+ // Not implemented
2198
+ lineParser.setToEnd();
2199
+ break;
2165
2200
 
2166
- default:
2167
- throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
2201
+ default:
2202
+ throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
2203
+
2204
+ }
2168
2205
 
2169
2206
  }
2170
2207
 
@@ -2268,6 +2305,8 @@
2268
2305
  opacity: alpha
2269
2306
  } );
2270
2307
  edgeMaterial.userData.conditionalEdgeMaterial.color.convertSRGBToLinear();
2308
+ edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
2309
+ edgeMaterial.userData.conditionalEdgeMaterial.name = name + ' - Conditional Edge';
2271
2310
 
2272
2311
  }
2273
2312
 
@@ -2277,6 +2316,32 @@
2277
2316
  this.addMaterial( material );
2278
2317
  return material;
2279
2318
 
2319
+ function parseLuminance( token ) {
2320
+
2321
+ // Returns success
2322
+ let lum;
2323
+
2324
+ if ( token.startsWith( 'LUMINANCE' ) ) {
2325
+
2326
+ lum = parseInt( token.substring( 9 ) );
2327
+
2328
+ } else {
2329
+
2330
+ lum = parseInt( token );
2331
+
2332
+ }
2333
+
2334
+ if ( isNaN( lum ) ) {
2335
+
2336
+ return false;
2337
+
2338
+ }
2339
+
2340
+ luminance = Math.max( 0, Math.min( 1, lum / 255 ) );
2341
+ return true;
2342
+
2343
+ }
2344
+
2280
2345
  }
2281
2346
 
2282
2347
  computeConstructionSteps( model ) {
@@ -7,6 +7,7 @@
7
7
  const _material_use_pattern = /^usemtl /; // usemap map_name
8
8
 
9
9
  const _map_use_pattern = /^usemap /;
10
+ const _face_vertex_data_separator_pattern = /\s+/;
10
11
 
11
12
  const _vA = new THREE.Vector3();
12
13
 
@@ -438,26 +439,19 @@
438
439
  }
439
440
 
440
441
  const lines = text.split( '\n' );
441
- let line = '',
442
- lineFirstChar = '';
443
- let lineLength = 0;
444
- let result = []; // Faster to just trim left side of the line. Use if available.
445
-
446
- const trimLeft = typeof ''.trimLeft === 'function';
442
+ let result = [];
447
443
 
448
444
  for ( let i = 0, l = lines.length; i < l; i ++ ) {
449
445
 
450
- line = lines[ i ];
451
- line = trimLeft ? line.trimLeft() : line.trim();
452
- lineLength = line.length;
453
- if ( lineLength === 0 ) continue;
454
- lineFirstChar = line.charAt( 0 ); // @todo invoke passed in handler if any
446
+ const line = lines[ i ].trimStart();
447
+ if ( line.length === 0 ) continue;
448
+ const lineFirstChar = line.charAt( 0 ); // @todo invoke passed in handler if any
455
449
 
456
450
  if ( lineFirstChar === '#' ) continue;
457
451
 
458
452
  if ( lineFirstChar === 'v' ) {
459
453
 
460
- const data = line.split( /\s+/ );
454
+ const data = line.split( _face_vertex_data_separator_pattern );
461
455
 
462
456
  switch ( data[ 0 ] ) {
463
457
 
@@ -492,7 +486,7 @@
492
486
  } else if ( lineFirstChar === 'f' ) {
493
487
 
494
488
  const lineData = line.slice( 1 ).trim();
495
- const vertexData = lineData.split( /\s+/ );
489
+ const vertexData = lineData.split( _face_vertex_data_separator_pattern );
496
490
  const faceVertices = []; // Parse the face vertex data into an easy to work with format
497
491
 
498
492
  for ( let j = 0, jl = vertexData.length; j < jl; j ++ ) {