super-three 0.167.0 → 0.168.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 (311) hide show
  1. package/build/three.cjs +165 -44
  2. package/build/three.module.js +165 -45
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +23600 -21931
  5. package/build/three.webgpu.min.js +1 -1
  6. package/examples/jsm/Addons.js +3 -1
  7. package/examples/jsm/animation/AnimationClipCreator.js +1 -1
  8. package/examples/jsm/capabilities/WebGL.js +27 -21
  9. package/examples/jsm/controls/ArcballControls.js +174 -158
  10. package/examples/jsm/controls/DragControls.js +260 -132
  11. package/examples/jsm/controls/FirstPersonControls.js +175 -163
  12. package/examples/jsm/controls/FlyControls.js +194 -188
  13. package/examples/jsm/controls/OrbitControls.js +777 -786
  14. package/examples/jsm/controls/PointerLockControls.js +24 -15
  15. package/examples/jsm/controls/TrackballControls.js +453 -452
  16. package/examples/jsm/effects/AnaglyphEffect.js +6 -13
  17. package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
  18. package/examples/jsm/effects/StereoEffect.js +6 -1
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -1
  20. package/examples/jsm/exporters/GLTFExporter.js +6 -1
  21. package/examples/jsm/exporters/USDZExporter.js +29 -8
  22. package/examples/jsm/helpers/LightProbeHelper.js +42 -43
  23. package/examples/jsm/loaders/KTX2Loader.js +19 -7
  24. package/examples/jsm/loaders/MaterialXLoader.js +11 -4
  25. package/examples/jsm/loaders/PCDLoader.js +9 -9
  26. package/examples/jsm/objects/SkyMesh.js +188 -0
  27. package/examples/jsm/objects/Water2Mesh.js +159 -0
  28. package/examples/jsm/objects/WaterMesh.js +102 -0
  29. package/examples/jsm/physics/RapierPhysics.js +20 -0
  30. package/examples/jsm/postprocessing/OutlinePass.js +31 -46
  31. package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
  32. package/examples/jsm/shaders/BleachBypassShader.js +1 -2
  33. package/examples/jsm/shaders/OutputShader.js +1 -1
  34. package/examples/jsm/transpiler/TSLEncoder.js +8 -8
  35. package/examples/jsm/utils/TextureUtils.js +1 -1
  36. package/package.json +2 -1
  37. package/src/Three.WebGPU.js +6 -0
  38. package/src/Three.js +1 -0
  39. package/src/constants.js +1 -1
  40. package/src/extras/Controls.js +32 -0
  41. package/src/loaders/ObjectLoader.js +3 -3
  42. package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
  43. package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
  44. package/src/materials/Material.js +4 -7
  45. package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
  46. package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
  47. package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
  48. package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
  49. package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
  50. package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
  51. package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
  52. package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
  53. package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
  54. package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
  55. package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
  56. package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
  57. package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
  58. package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
  59. package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
  60. package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
  61. package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
  62. package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
  63. package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
  64. package/src/nodes/Nodes.js +103 -159
  65. package/src/nodes/TSL.js +176 -0
  66. package/src/nodes/accessors/AccessorsUtils.js +8 -8
  67. package/src/nodes/accessors/BatchNode.js +48 -20
  68. package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
  69. package/src/nodes/accessors/BufferAttributeNode.js +5 -5
  70. package/src/nodes/accessors/BufferNode.js +4 -4
  71. package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
  72. package/src/nodes/accessors/ClippingNode.js +16 -14
  73. package/src/nodes/accessors/CubeTextureNode.js +5 -7
  74. package/src/nodes/accessors/InstanceNode.js +17 -13
  75. package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
  76. package/src/nodes/accessors/MaterialNode.js +52 -55
  77. package/src/nodes/accessors/MaterialProperties.js +3 -0
  78. package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
  79. package/src/nodes/accessors/ModelNode.js +11 -11
  80. package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
  81. package/src/nodes/accessors/MorphNode.js +12 -12
  82. package/src/nodes/accessors/Normal.js +62 -0
  83. package/src/nodes/accessors/Object3DNode.js +10 -10
  84. package/src/nodes/accessors/PointUVNode.js +4 -4
  85. package/src/nodes/accessors/Position.js +10 -0
  86. package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
  87. package/src/nodes/accessors/ReferenceNode.js +13 -7
  88. package/src/nodes/accessors/ReflectVector.js +10 -0
  89. package/src/nodes/accessors/RendererReferenceNode.js +6 -6
  90. package/src/nodes/accessors/SceneNode.js +5 -6
  91. package/src/nodes/accessors/SkinningNode.js +84 -21
  92. package/src/nodes/accessors/StorageBufferNode.js +4 -5
  93. package/src/nodes/accessors/StorageTextureNode.js +5 -5
  94. package/src/nodes/accessors/Tangent.js +22 -0
  95. package/src/nodes/accessors/Texture3DNode.js +11 -11
  96. package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
  97. package/src/nodes/accessors/TextureNode.js +16 -21
  98. package/src/nodes/accessors/TextureSizeNode.js +4 -6
  99. package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
  100. package/src/nodes/accessors/UserDataNode.js +4 -4
  101. package/src/nodes/accessors/VelocityNode.js +83 -0
  102. package/src/nodes/accessors/VertexColorNode.js +4 -4
  103. package/src/nodes/code/CodeNode.js +5 -5
  104. package/src/nodes/code/ExpressionNode.js +4 -4
  105. package/src/nodes/code/FunctionCallNode.js +5 -5
  106. package/src/nodes/code/FunctionNode.js +5 -23
  107. package/src/nodes/code/ScriptableNode.js +4 -6
  108. package/src/nodes/code/ScriptableValueNode.js +4 -6
  109. package/src/nodes/core/AssignNode.js +5 -5
  110. package/src/nodes/core/AttributeNode.js +7 -20
  111. package/src/nodes/core/BypassNode.js +5 -5
  112. package/src/nodes/core/CacheNode.js +5 -5
  113. package/src/nodes/core/ConstNode.js +2 -2
  114. package/src/nodes/core/ContextNode.js +17 -11
  115. package/src/nodes/core/IndexNode.js +12 -7
  116. package/src/nodes/core/InputNode.js +2 -2
  117. package/src/nodes/core/MRTNode.js +12 -6
  118. package/src/nodes/core/Node.js +39 -19
  119. package/src/nodes/core/NodeBuilder.js +46 -33
  120. package/src/nodes/core/NodeUtils.js +1 -0
  121. package/src/nodes/core/OutputStructNode.js +4 -4
  122. package/src/nodes/core/ParameterNode.js +4 -4
  123. package/src/nodes/core/PropertyNode.js +32 -32
  124. package/src/nodes/core/StackNode.js +26 -10
  125. package/src/nodes/core/StructTypeNode.js +2 -2
  126. package/src/nodes/core/TempNode.js +2 -2
  127. package/src/nodes/core/UniformGroupNode.js +8 -9
  128. package/src/nodes/core/UniformNode.js +4 -4
  129. package/src/nodes/core/VarNode.js +6 -6
  130. package/src/nodes/core/VaryingNode.js +5 -5
  131. package/src/nodes/display/AfterImageNode.js +9 -9
  132. package/src/nodes/display/AnaglyphPassNode.js +61 -0
  133. package/src/nodes/display/AnamorphicNode.js +11 -11
  134. package/src/nodes/display/BleachBypass.js +26 -0
  135. package/src/nodes/display/BlendMode.js +54 -0
  136. package/src/nodes/display/BloomNode.js +21 -19
  137. package/src/nodes/display/BumpMapNode.js +7 -12
  138. package/src/nodes/display/ColorAdjustment.js +46 -0
  139. package/src/nodes/display/ColorSpaceFunctions.js +38 -0
  140. package/src/nodes/display/ColorSpaceNode.js +40 -63
  141. package/src/nodes/display/DenoiseNode.js +20 -17
  142. package/src/nodes/display/DepthOfFieldNode.js +8 -6
  143. package/src/nodes/display/DotScreenNode.js +10 -22
  144. package/src/nodes/display/FXAANode.js +17 -15
  145. package/src/nodes/display/FilmNode.js +7 -6
  146. package/src/nodes/display/FrontFacingNode.js +5 -5
  147. package/src/nodes/display/GTAONode.js +19 -15
  148. package/src/nodes/display/GaussianBlurNode.js +11 -8
  149. package/src/nodes/display/Lut3DNode.js +6 -5
  150. package/src/nodes/display/MotionBlur.js +25 -0
  151. package/src/nodes/display/NormalMapNode.js +8 -10
  152. package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
  153. package/src/nodes/display/PassNode.js +84 -8
  154. package/src/nodes/display/PixelationPassNode.js +12 -7
  155. package/src/nodes/display/PosterizeNode.js +4 -6
  156. package/src/nodes/display/RGBShiftNode.js +8 -7
  157. package/src/nodes/display/RenderOutputNode.js +9 -9
  158. package/src/nodes/display/SSAAPassNode.js +284 -0
  159. package/src/nodes/display/Sepia.js +17 -0
  160. package/src/nodes/display/SobelOperatorNode.js +9 -7
  161. package/src/nodes/display/StereoCompositePassNode.js +107 -0
  162. package/src/nodes/display/StereoPassNode.js +80 -0
  163. package/src/nodes/display/ToneMappingFunctions.js +190 -0
  164. package/src/nodes/display/ToneMappingNode.js +12 -173
  165. package/src/nodes/display/TransitionNode.js +9 -8
  166. package/src/nodes/display/ViewportDepthNode.js +30 -29
  167. package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
  168. package/src/nodes/display/ViewportNode.js +26 -25
  169. package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
  170. package/src/nodes/display/ViewportTextureNode.js +7 -10
  171. package/src/nodes/fog/FogExp2Node.js +4 -6
  172. package/src/nodes/fog/FogNode.js +5 -7
  173. package/src/nodes/fog/FogRangeNode.js +4 -6
  174. package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
  175. package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  176. package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
  177. package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
  178. package/src/nodes/functions/BSDF/D_GGX.js +2 -2
  179. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
  180. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
  181. package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
  182. package/src/nodes/functions/BSDF/LTC.js +6 -6
  183. package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
  184. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
  185. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
  186. package/src/nodes/functions/BasicLightingModel.js +1 -1
  187. package/src/nodes/functions/PhongLightingModel.js +5 -5
  188. package/src/nodes/functions/PhysicalLightingModel.js +32 -31
  189. package/src/nodes/functions/ShadowMaskModel.js +1 -1
  190. package/src/nodes/functions/ToonLightingModel.js +3 -3
  191. package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
  192. package/src/nodes/functions/material/getRoughness.js +2 -2
  193. package/src/nodes/geometry/RangeNode.js +4 -4
  194. package/src/nodes/gpgpu/ComputeNode.js +5 -5
  195. package/src/nodes/lighting/AONode.js +2 -2
  196. package/src/nodes/lighting/AmbientLightNode.js +2 -7
  197. package/src/nodes/lighting/AnalyticLightNode.js +34 -13
  198. package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
  199. package/src/nodes/lighting/BasicLightMapNode.js +3 -3
  200. package/src/nodes/lighting/DirectionalLightNode.js +2 -7
  201. package/src/nodes/lighting/EnvironmentNode.js +20 -19
  202. package/src/nodes/lighting/HemisphereLightNode.js +3 -7
  203. package/src/nodes/lighting/IESSpotLightNode.js +3 -8
  204. package/src/nodes/lighting/IrradianceNode.js +2 -2
  205. package/src/nodes/lighting/LightNode.js +5 -5
  206. package/src/nodes/lighting/LightProbeNode.js +76 -0
  207. package/src/nodes/lighting/LightUtils.js +3 -3
  208. package/src/nodes/lighting/LightingContextNode.js +15 -17
  209. package/src/nodes/lighting/LightingNode.js +2 -2
  210. package/src/nodes/lighting/LightsNode.js +94 -76
  211. package/src/nodes/lighting/PointLightNode.js +3 -8
  212. package/src/nodes/lighting/RectAreaLightNode.js +2 -6
  213. package/src/nodes/lighting/SpotLightNode.js +3 -8
  214. package/src/nodes/materialx/MaterialXNodes.js +2 -2
  215. package/src/nodes/materialx/lib/mx_hsv.js +36 -31
  216. package/src/nodes/materialx/lib/mx_noise.js +96 -96
  217. package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
  218. package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
  219. package/src/nodes/math/Hash.js +13 -0
  220. package/src/nodes/math/MathNode.js +124 -124
  221. package/src/nodes/math/MathUtils.js +0 -7
  222. package/src/nodes/math/OperatorNode.js +94 -52
  223. package/src/nodes/math/TriNoise3D.js +19 -29
  224. package/src/nodes/pmrem/PMREMNode.js +58 -15
  225. package/src/nodes/pmrem/PMREMUtils.js +46 -46
  226. package/src/nodes/procedural/Checker.js +14 -0
  227. package/src/nodes/tsl/TSLBase.js +30 -0
  228. package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
  229. package/src/nodes/utils/ArrayElementNode.js +2 -2
  230. package/src/nodes/utils/ConvertNode.js +2 -2
  231. package/src/nodes/utils/CubeMapNode.js +157 -0
  232. package/src/nodes/utils/Discard.js +8 -0
  233. package/src/nodes/utils/EquirectUVNode.js +5 -5
  234. package/src/nodes/utils/FlipNode.js +65 -0
  235. package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
  236. package/src/nodes/utils/JoinNode.js +2 -2
  237. package/src/nodes/utils/LoopNode.js +12 -6
  238. package/src/nodes/utils/MatcapUVNode.js +6 -6
  239. package/src/nodes/utils/MaxMipLevelNode.js +4 -4
  240. package/src/nodes/utils/OscNode.js +7 -7
  241. package/src/nodes/utils/Packing.js +4 -0
  242. package/src/nodes/utils/RTTNode.js +8 -8
  243. package/src/nodes/utils/ReflectorNode.js +8 -3
  244. package/src/nodes/utils/RemapNode.js +7 -7
  245. package/src/nodes/utils/RotateNode.js +4 -12
  246. package/src/nodes/utils/SetNode.js +2 -2
  247. package/src/nodes/utils/SplitNode.js +2 -2
  248. package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
  249. package/src/nodes/utils/SpriteUtils.js +47 -0
  250. package/src/nodes/utils/StorageArrayElementNode.js +4 -6
  251. package/src/nodes/utils/TimerNode.js +5 -5
  252. package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
  253. package/src/nodes/utils/UVUtils.js +19 -0
  254. package/src/nodes/utils/ViewportUtils.js +14 -0
  255. package/src/objects/BatchedMesh.js +2 -3
  256. package/src/renderers/WebGLRenderer.js +24 -0
  257. package/src/renderers/common/Backend.js +2 -2
  258. package/src/renderers/common/Background.js +3 -1
  259. package/src/renderers/common/BindGroup.js +3 -1
  260. package/src/renderers/common/Bindings.js +13 -15
  261. package/src/renderers/common/ClippingContext.js +14 -5
  262. package/src/renderers/common/CubeRenderTarget.js +9 -3
  263. package/src/renderers/common/PostProcessing.js +4 -1
  264. package/src/renderers/common/QuadMesh.js +2 -0
  265. package/src/renderers/common/RenderContext.js +24 -0
  266. package/src/renderers/common/RenderList.js +1 -1
  267. package/src/renderers/common/RenderObject.js +2 -2
  268. package/src/renderers/common/Renderer.js +75 -49
  269. package/src/renderers/common/SampledTexture.js +12 -3
  270. package/src/renderers/common/StandardRenderer.js +18 -0
  271. package/src/renderers/common/Textures.js +8 -12
  272. package/src/renderers/common/extras/PMREMGenerator.js +12 -13
  273. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  274. package/src/renderers/common/nodes/NodeLibrary.js +118 -0
  275. package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
  276. package/src/renderers/common/nodes/Nodes.js +36 -9
  277. package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
  278. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
  279. package/src/renderers/webgl/WebGLProgram.js +1 -1
  280. package/src/renderers/webgl/WebGLProperties.js +7 -0
  281. package/src/renderers/webgl/WebGLTextures.js +61 -4
  282. package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
  283. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
  284. package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
  285. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
  286. package/src/renderers/webgpu/WebGPUBackend.js +86 -68
  287. package/src/renderers/webgpu/WebGPURenderer.js +8 -8
  288. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
  289. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
  290. package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
  291. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
  292. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
  293. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
  294. package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
  295. package/src/renderers/webxr/WebXRManager.js +32 -25
  296. package/examples/jsm/loaders/LogLuvLoader.js +0 -606
  297. package/src/nodes/accessors/NormalNode.js +0 -14
  298. package/src/nodes/accessors/PositionNode.js +0 -10
  299. package/src/nodes/accessors/ReflectVectorNode.js +0 -10
  300. package/src/nodes/accessors/TangentNode.js +0 -23
  301. package/src/nodes/core/NodeKeywords.js +0 -80
  302. package/src/nodes/display/BlendModeNode.js +0 -128
  303. package/src/nodes/display/ColorAdjustmentNode.js +0 -104
  304. package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
  305. package/src/nodes/math/HashNode.js +0 -34
  306. package/src/nodes/procedural/CheckerNode.js +0 -42
  307. package/src/nodes/utils/DiscardNode.js +0 -28
  308. package/src/nodes/utils/PackingNode.js +0 -55
  309. package/src/nodes/utils/RotateUVNode.js +0 -35
  310. /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
  311. /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
@@ -1,606 +0,0 @@
1
- import {
2
- DataUtils,
3
- DataTextureLoader,
4
- FloatType,
5
- HalfFloatType,
6
- RGBAFormat
7
- } from 'three';
8
-
9
- class LogLuvLoader extends DataTextureLoader {
10
-
11
- constructor( manager ) {
12
-
13
- super( manager );
14
-
15
- this.type = HalfFloatType;
16
-
17
- }
18
-
19
- parse( buffer ) {
20
-
21
- const ifds = UTIF.decode( buffer );
22
- UTIF.decodeImage( buffer, ifds[ 0 ] );
23
- const rgba = UTIF.toRGBA( ifds[ 0 ], this.type );
24
-
25
- return {
26
- width: ifds[ 0 ].width,
27
- height: ifds[ 0 ].height,
28
- data: rgba,
29
- format: RGBAFormat,
30
- type: this.type,
31
- flipY: true
32
- };
33
-
34
- }
35
-
36
- setDataType( value ) {
37
-
38
- this.type = value;
39
- return this;
40
-
41
- }
42
-
43
- }
44
-
45
- // from https://github.com/photopea/UTIF.js (MIT License)
46
-
47
- const UTIF = {};
48
-
49
- UTIF.decode = function ( buff, prm ) {
50
-
51
- if ( prm == null ) prm = { parseMN: true, debug: false }; // read MakerNote, debug
52
- var data = new Uint8Array( buff ), offset = 0;
53
-
54
- var id = UTIF._binBE.readASCII( data, offset, 2 ); offset += 2;
55
- var bin = id == 'II' ? UTIF._binLE : UTIF._binBE;
56
- bin.readUshort( data, offset ); offset += 2;
57
-
58
- var ifdo = bin.readUint( data, offset );
59
- var ifds = [];
60
- while ( true ) {
61
-
62
- var cnt = bin.readUshort( data, ifdo ), typ = bin.readUshort( data, ifdo + 4 ); if ( cnt != 0 ) if ( typ < 1 || 13 < typ ) {
63
-
64
- console.log( 'error in TIFF' ); break;
65
-
66
- }
67
-
68
-
69
- UTIF._readIFD( bin, data, ifdo, ifds, 0, prm );
70
-
71
- ifdo = bin.readUint( data, ifdo + 2 + cnt * 12 );
72
- if ( ifdo == 0 ) break;
73
-
74
- }
75
-
76
- return ifds;
77
-
78
- };
79
-
80
- UTIF.decodeImage = function ( buff, img, ifds ) {
81
-
82
- if ( img.data ) return;
83
- var data = new Uint8Array( buff );
84
- var id = UTIF._binBE.readASCII( data, 0, 2 );
85
-
86
- if ( img[ 't256' ] == null ) return; // No width => probably not an image
87
- img.isLE = id == 'II';
88
- img.width = img[ 't256' ][ 0 ]; //delete img["t256"];
89
- img.height = img[ 't257' ][ 0 ]; //delete img["t257"];
90
-
91
- var cmpr = img[ 't259' ] ? img[ 't259' ][ 0 ] : 1; //delete img["t259"];
92
- var fo = img[ 't266' ] ? img[ 't266' ][ 0 ] : 1; //delete img["t266"];
93
- if ( img[ 't284' ] && img[ 't284' ][ 0 ] == 2 ) console.log( 'PlanarConfiguration 2 should not be used!' );
94
- if ( cmpr == 7 && img[ 't258' ] && img[ 't258' ].length > 3 ) img[ 't258' ] = img[ 't258' ].slice( 0, 3 );
95
-
96
- var bipp; // bits per pixel
97
- if ( img[ 't258' ] ) bipp = Math.min( 32, img[ 't258' ][ 0 ] ) * img[ 't258' ].length;
98
- else bipp = ( img[ 't277' ] ? img[ 't277' ][ 0 ] : 1 );
99
- // Some .NEF files have t258==14, even though they use 16 bits per pixel
100
- if ( cmpr == 1 && img[ 't279' ] != null && img[ 't278' ] && img[ 't262' ][ 0 ] == 32803 ) {
101
-
102
- bipp = Math.round( ( img[ 't279' ][ 0 ] * 8 ) / ( img.width * img[ 't278' ][ 0 ] ) );
103
-
104
- }
105
-
106
- var bipl = Math.ceil( img.width * bipp / 8 ) * 8;
107
- var soff = img[ 't273' ]; if ( soff == null ) soff = img[ 't324' ];
108
- var bcnt = img[ 't279' ]; if ( cmpr == 1 && soff.length == 1 ) bcnt = [ img.height * ( bipl >>> 3 ) ]; if ( bcnt == null ) bcnt = img[ 't325' ];
109
- //bcnt[0] = Math.min(bcnt[0], data.length); // Hasselblad, "RAW_HASSELBLAD_H3D39II.3FR"
110
- var bytes = new Uint8Array( img.height * ( bipl >>> 3 ) ), bilen = 0;
111
-
112
- if ( img[ 't322' ] != null ) {
113
-
114
- var tw = img[ 't322' ][ 0 ], th = img[ 't323' ][ 0 ];
115
- var tx = Math.floor( ( img.width + tw - 1 ) / tw );
116
- var ty = Math.floor( ( img.height + th - 1 ) / th );
117
- var tbuff = new Uint8Array( Math.ceil( tw * th * bipp / 8 ) | 0 );
118
- for ( var y = 0; y < ty; y ++ )
119
- for ( var x = 0; x < tx; x ++ ) {
120
-
121
- var i = y * tx + x; for ( var j = 0; j < tbuff.length; j ++ ) tbuff[ j ] = 0;
122
- UTIF.decode._decompress( img, ifds, data, soff[ i ], bcnt[ i ], cmpr, tbuff, 0, fo );
123
- // Might be required for 7 too. Need to check
124
- if ( cmpr == 6 ) bytes = tbuff;
125
- else UTIF._copyTile( tbuff, Math.ceil( tw * bipp / 8 ) | 0, th, bytes, Math.ceil( img.width * bipp / 8 ) | 0, img.height, Math.ceil( x * tw * bipp / 8 ) | 0, y * th );
126
-
127
- }
128
-
129
- bilen = bytes.length * 8;
130
-
131
- } else {
132
-
133
- var rps = img[ 't278' ] ? img[ 't278' ][ 0 ] : img.height; rps = Math.min( rps, img.height );
134
- for ( var i = 0; i < soff.length; i ++ ) {
135
-
136
- UTIF.decode._decompress( img, ifds, data, soff[ i ], bcnt[ i ], cmpr, bytes, Math.ceil( bilen / 8 ) | 0, fo );
137
- bilen += bipl * rps;
138
-
139
- }
140
-
141
- bilen = Math.min( bilen, bytes.length * 8 );
142
-
143
- }
144
-
145
- img.data = new Uint8Array( bytes.buffer, 0, Math.ceil( bilen / 8 ) | 0 );
146
-
147
- };
148
-
149
- UTIF.decode._decompress = function ( img, ifds, data, off, len, cmpr, tgt, toff ) {
150
-
151
- //console.log("compression", cmpr);
152
- //var time = Date.now();
153
- if ( cmpr == 34676 ) UTIF.decode._decodeLogLuv32( img, data, off, len, tgt, toff );
154
- else console.log( 'Unsupported compression', cmpr );
155
-
156
- //console.log(Date.now()-time);
157
-
158
- var bps = ( img[ 't258' ] ? Math.min( 32, img[ 't258' ][ 0 ] ) : 1 );
159
- var noc = ( img[ 't277' ] ? img[ 't277' ][ 0 ] : 1 ), bpp = ( bps * noc ) >>> 3, h = ( img[ 't278' ] ? img[ 't278' ][ 0 ] : img.height ), bpl = Math.ceil( bps * noc * img.width / 8 );
160
-
161
- // convert to Little Endian /*
162
- if ( bps == 16 && ! img.isLE && img[ 't33422' ] == null ) // not DNG
163
- for ( var y = 0; y < h; y ++ ) {
164
-
165
- //console.log("fixing endianity");
166
- var roff = toff + y * bpl;
167
- for ( var x = 1; x < bpl; x += 2 ) {
168
-
169
- var t = tgt[ roff + x ]; tgt[ roff + x ] = tgt[ roff + x - 1 ]; tgt[ roff + x - 1 ] = t;
170
-
171
- }
172
-
173
- } //*/
174
-
175
- if ( img[ 't317' ] && img[ 't317' ][ 0 ] == 2 ) {
176
-
177
- for ( var y = 0; y < h; y ++ ) {
178
-
179
- var ntoff = toff + y * bpl;
180
- if ( bps == 16 ) for ( var j = bpp; j < bpl; j += 2 ) {
181
-
182
- var nv = ( ( tgt[ ntoff + j + 1 ] << 8 ) | tgt[ ntoff + j ] ) + ( ( tgt[ ntoff + j - bpp + 1 ] << 8 ) | tgt[ ntoff + j - bpp ] );
183
- tgt[ ntoff + j ] = nv & 255; tgt[ ntoff + j + 1 ] = ( nv >>> 8 ) & 255;
184
-
185
- }
186
- else if ( noc == 3 ) for ( var j = 3; j < bpl; j += 3 ) {
187
-
188
- tgt[ ntoff + j ] = ( tgt[ ntoff + j ] + tgt[ ntoff + j - 3 ] ) & 255;
189
- tgt[ ntoff + j + 1 ] = ( tgt[ ntoff + j + 1 ] + tgt[ ntoff + j - 2 ] ) & 255;
190
- tgt[ ntoff + j + 2 ] = ( tgt[ ntoff + j + 2 ] + tgt[ ntoff + j - 1 ] ) & 255;
191
-
192
- }
193
- else for ( var j = bpp; j < bpl; j ++ ) tgt[ ntoff + j ] = ( tgt[ ntoff + j ] + tgt[ ntoff + j - bpp ] ) & 255;
194
-
195
- }
196
-
197
- }
198
-
199
- };
200
-
201
- UTIF.decode._decodeLogLuv32 = function ( img, data, off, len, tgt, toff ) {
202
-
203
- var w = img.width, qw = w * 4;
204
- var io = 0, out = new Uint8Array( qw );
205
-
206
- while ( io < len ) {
207
-
208
- var oo = 0;
209
- while ( oo < qw ) {
210
-
211
- var c = data[ off + io ]; io ++;
212
- if ( c < 128 ) {
213
-
214
- for ( var j = 0; j < c; j ++ ) out[ oo + j ] = data[ off + io + j ]; oo += c; io += c;
215
-
216
- } else {
217
-
218
- c = c - 126; for ( var j = 0; j < c; j ++ ) out[ oo + j ] = data[ off + io ]; oo += c; io ++;
219
-
220
- }
221
-
222
- }
223
-
224
- for ( var x = 0; x < w; x ++ ) {
225
-
226
- tgt[ toff + 0 ] = out[ x ];
227
- tgt[ toff + 1 ] = out[ x + w ];
228
- tgt[ toff + 2 ] = out[ x + w * 2 ];
229
- tgt[ toff + 4 ] = out[ x + w * 3 ];
230
- toff += 6;
231
-
232
- }
233
-
234
- }
235
-
236
- };
237
-
238
- UTIF.tags = {};
239
- //UTIF.ttypes = { 256:3,257:3,258:3, 259:3, 262:3, 273:4, 274:3, 277:3,278:4,279:4, 282:5, 283:5, 284:3, 286:5,287:5, 296:3, 305:2, 306:2, 338:3, 513:4, 514:4, 34665:4 };
240
- // start at tag 250
241
- UTIF._types = function () {
242
-
243
- var main = new Array( 250 ); main.fill( 0 );
244
- main = main.concat( [ 0, 0, 0, 0, 4, 3, 3, 3, 3, 3, 0, 0, 3, 0, 0, 0, 3, 0, 0, 2, 2, 2, 2, 4, 3, 0, 0, 3, 4, 4, 3, 3, 5, 5, 3, 2, 5, 5, 0, 0, 0, 0, 4, 4, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 3, 5, 5, 3, 0, 3, 3, 4, 4, 4, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] );
245
- var rest = { 33432: 2, 33434: 5, 33437: 5, 34665: 4, 34850: 3, 34853: 4, 34855: 3, 34864: 3, 34866: 4, 36864: 7, 36867: 2, 36868: 2, 37121: 7, 37377: 10, 37378: 5, 37380: 10, 37381: 5, 37383: 3, 37384: 3, 37385: 3, 37386: 5, 37510: 7, 37520: 2, 37521: 2, 37522: 2, 40960: 7, 40961: 3, 40962: 4, 40963: 4, 40965: 4, 41486: 5, 41487: 5, 41488: 3, 41985: 3, 41986: 3, 41987: 3, 41988: 5, 41989: 3, 41990: 3, 41993: 3, 41994: 3, 41995: 7, 41996: 3, 42032: 2, 42033: 2, 42034: 5, 42036: 2, 42037: 2, 59932: 7 };
246
- return {
247
- basic: {
248
- main: main,
249
- rest: rest
250
- },
251
- gps: {
252
- main: [ 1, 2, 5, 2, 5, 1, 5, 5, 0, 9 ],
253
- rest: { 18: 2, 29: 2 }
254
- }
255
- };
256
-
257
- }();
258
-
259
- UTIF._readIFD = function ( bin, data, offset, ifds, depth, prm ) {
260
-
261
- var cnt = bin.readUshort( data, offset ); offset += 2;
262
- var ifd = {};
263
-
264
- if ( prm.debug ) console.log( ' '.repeat( depth ), ifds.length - 1, '>>>----------------' );
265
- for ( var i = 0; i < cnt; i ++ ) {
266
-
267
- var tag = bin.readUshort( data, offset ); offset += 2;
268
- var type = bin.readUshort( data, offset ); offset += 2;
269
- var num = bin.readUint( data, offset ); offset += 4;
270
- var voff = bin.readUint( data, offset ); offset += 4;
271
-
272
- var arr = [];
273
- //ifd["t"+tag+"-"+UTIF.tags[tag]] = arr;
274
- if ( type == 1 || type == 7 ) {
275
-
276
- arr = new Uint8Array( data.buffer, ( num < 5 ? offset - 4 : voff ), num );
277
-
278
- }
279
-
280
- if ( type == 2 ) {
281
-
282
- var o0 = ( num < 5 ? offset - 4 : voff ), c = data[ o0 ], len = Math.max( 0, Math.min( num - 1, data.length - o0 ) );
283
- if ( c < 128 || len == 0 ) arr.push( bin.readASCII( data, o0, len ) );
284
- else arr = new Uint8Array( data.buffer, o0, len );
285
-
286
- }
287
-
288
- if ( type == 3 ) {
289
-
290
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readUshort( data, ( num < 3 ? offset - 4 : voff ) + 2 * j ) );
291
-
292
- }
293
-
294
- if ( type == 4
295
- || type == 13 ) {
296
-
297
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readUint( data, ( num < 2 ? offset - 4 : voff ) + 4 * j ) );
298
-
299
- }
300
-
301
- if ( type == 5 || type == 10 ) {
302
-
303
- var ri = type == 5 ? bin.readUint : bin.readInt;
304
- for ( var j = 0; j < num; j ++ ) arr.push( [ ri( data, voff + j * 8 ), ri( data, voff + j * 8 + 4 ) ] );
305
-
306
- }
307
-
308
- if ( type == 8 ) {
309
-
310
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readShort( data, ( num < 3 ? offset - 4 : voff ) + 2 * j ) );
311
-
312
- }
313
-
314
- if ( type == 9 ) {
315
-
316
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readInt( data, ( num < 2 ? offset - 4 : voff ) + 4 * j ) );
317
-
318
- }
319
-
320
- if ( type == 11 ) {
321
-
322
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readFloat( data, voff + j * 4 ) );
323
-
324
- }
325
-
326
- if ( type == 12 ) {
327
-
328
- for ( var j = 0; j < num; j ++ ) arr.push( bin.readDouble( data, voff + j * 8 ) );
329
-
330
- }
331
-
332
- if ( num != 0 && arr.length == 0 ) {
333
-
334
- console.log( tag, 'unknown TIFF tag type: ', type, 'num:', num ); if ( i == 0 ) return; continue;
335
-
336
- }
337
-
338
- if ( prm.debug ) console.log( ' '.repeat( depth ), tag, type, UTIF.tags[ tag ], arr );
339
-
340
- ifd[ 't' + tag ] = arr;
341
-
342
- if ( tag == 330 || tag == 34665 || tag == 34853 || ( tag == 50740 && bin.readUshort( data, bin.readUint( arr, 0 ) ) < 300 ) || tag == 61440 ) {
343
-
344
- var oarr = tag == 50740 ? [ bin.readUint( arr, 0 ) ] : arr;
345
- var subfd = [];
346
- for ( var j = 0; j < oarr.length; j ++ ) UTIF._readIFD( bin, data, oarr[ j ], subfd, depth + 1, prm );
347
- if ( tag == 330 ) ifd.subIFD = subfd;
348
- if ( tag == 34665 ) ifd.exifIFD = subfd[ 0 ];
349
- if ( tag == 34853 ) ifd.gpsiIFD = subfd[ 0 ]; //console.log("gps", subfd[0]); }
350
- if ( tag == 50740 ) ifd.dngPrvt = subfd[ 0 ];
351
- if ( tag == 61440 ) ifd.fujiIFD = subfd[ 0 ];
352
-
353
- }
354
-
355
- if ( tag == 37500 && prm.parseMN ) {
356
-
357
- var mn = arr;
358
- //console.log(bin.readASCII(mn,0,mn.length), mn);
359
- if ( bin.readASCII( mn, 0, 5 ) == 'Nikon' ) ifd.makerNote = UTIF[ 'decode' ]( mn.slice( 10 ).buffer )[ 0 ];
360
- else if ( bin.readUshort( data, voff ) < 300 && bin.readUshort( data, voff + 4 ) <= 12 ) {
361
-
362
- var subsub = []; UTIF._readIFD( bin, data, voff, subsub, depth + 1, prm );
363
- ifd.makerNote = subsub[ 0 ];
364
-
365
- }
366
-
367
- }
368
-
369
- }
370
-
371
- ifds.push( ifd );
372
- if ( prm.debug ) console.log( ' '.repeat( depth ), '<<<---------------' );
373
- return offset;
374
-
375
- };
376
-
377
- UTIF.toRGBA = function ( out, type ) {
378
-
379
- const w = out.width, h = out.height, area = w * h, data = out.data;
380
-
381
- let img;
382
-
383
- switch ( type ) {
384
-
385
- case HalfFloatType:
386
-
387
- img = new Uint16Array( area * 4 );
388
- break;
389
-
390
- case FloatType:
391
-
392
- img = new Float32Array( area * 4 );
393
- break;
394
-
395
- default:
396
- throw new Error( 'THREE.LogLuvLoader: Unsupported texture data type: ' + type );
397
-
398
- }
399
-
400
- let intp = out[ 't262' ] ? out[ 't262' ][ 0 ] : 2;
401
- const bps = out[ 't258' ] ? Math.min( 32, out[ 't258' ][ 0 ] ) : 1;
402
-
403
- if ( out[ 't262' ] == null && bps == 1 ) intp = 0;
404
-
405
- if ( intp == 32845 ) {
406
-
407
- for ( let y = 0; y < h; y ++ ) {
408
-
409
- for ( let x = 0; x < w; x ++ ) {
410
-
411
- const si = ( y * w + x ) * 6, qi = ( y * w + x ) * 4;
412
- let L = ( data[ si + 1 ] << 8 ) | data[ si ];
413
-
414
- L = Math.pow( 2, ( L + 0.5 ) / 256 - 64 );
415
- const u = ( data[ si + 3 ] + 0.5 ) / 410;
416
- const v = ( data[ si + 5 ] + 0.5 ) / 410;
417
-
418
- // Luv to xyY
419
- const sX = ( 9 * u ) / ( 6 * u - 16 * v + 12 );
420
- const sY = ( 4 * v ) / ( 6 * u - 16 * v + 12 );
421
- const bY = L;
422
-
423
- // xyY to XYZ
424
- const X = ( sX * bY ) / sY, Y = bY, Z = ( 1 - sX - sY ) * bY / sY;
425
-
426
- // XYZ to linear RGB
427
- const r = 2.690 * X - 1.276 * Y - 0.414 * Z;
428
- const g = - 1.022 * X + 1.978 * Y + 0.044 * Z;
429
- const b = 0.061 * X - 0.224 * Y + 1.163 * Z;
430
-
431
- if ( type === HalfFloatType ) {
432
-
433
- img[ qi ] = DataUtils.toHalfFloat( Math.min( r, 65504 ) );
434
- img[ qi + 1 ] = DataUtils.toHalfFloat( Math.min( g, 65504 ) );
435
- img[ qi + 2 ] = DataUtils.toHalfFloat( Math.min( b, 65504 ) );
436
- img[ qi + 3 ] = DataUtils.toHalfFloat( 1 );
437
-
438
-
439
- } else {
440
-
441
- img[ qi ] = r;
442
- img[ qi + 1 ] = g;
443
- img[ qi + 2 ] = b;
444
- img[ qi + 3 ] = 1;
445
-
446
- }
447
-
448
- }
449
-
450
- }
451
-
452
- } else {
453
-
454
- throw new Error( 'THREE.LogLuvLoader: Unsupported Photometric interpretation: ' + intp );
455
-
456
- }
457
-
458
- return img;
459
-
460
- };
461
-
462
- UTIF._binBE =
463
- {
464
- nextZero: function ( data, o ) {
465
-
466
- while ( data[ o ] != 0 ) o ++; return o;
467
-
468
- },
469
- readUshort: function ( buff, p ) {
470
-
471
- return ( buff[ p ] << 8 ) | buff[ p + 1 ];
472
-
473
- },
474
- readShort: function ( buff, p ) {
475
-
476
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 1 ]; a[ 1 ] = buff[ p + 0 ]; return UTIF._binBE.i16[ 0 ];
477
-
478
- },
479
- readInt: function ( buff, p ) {
480
-
481
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 3 ]; a[ 1 ] = buff[ p + 2 ]; a[ 2 ] = buff[ p + 1 ]; a[ 3 ] = buff[ p + 0 ]; return UTIF._binBE.i32[ 0 ];
482
-
483
- },
484
- readUint: function ( buff, p ) {
485
-
486
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 3 ]; a[ 1 ] = buff[ p + 2 ]; a[ 2 ] = buff[ p + 1 ]; a[ 3 ] = buff[ p + 0 ]; return UTIF._binBE.ui32[ 0 ];
487
-
488
- },
489
- readASCII: function ( buff, p, l ) {
490
-
491
- var s = ''; for ( var i = 0; i < l; i ++ ) s += String.fromCharCode( buff[ p + i ] ); return s;
492
-
493
- },
494
- readFloat: function ( buff, p ) {
495
-
496
- var a = UTIF._binBE.ui8; for ( var i = 0; i < 4; i ++ ) a[ i ] = buff[ p + 3 - i ]; return UTIF._binBE.fl32[ 0 ];
497
-
498
- },
499
- readDouble: function ( buff, p ) {
500
-
501
- var a = UTIF._binBE.ui8; for ( var i = 0; i < 8; i ++ ) a[ i ] = buff[ p + 7 - i ]; return UTIF._binBE.fl64[ 0 ];
502
-
503
- },
504
-
505
- writeUshort: function ( buff, p, n ) {
506
-
507
- buff[ p ] = ( n >> 8 ) & 255; buff[ p + 1 ] = n & 255;
508
-
509
- },
510
- writeInt: function ( buff, p, n ) {
511
-
512
- var a = UTIF._binBE.ui8; UTIF._binBE.i32[ 0 ] = n; buff[ p + 3 ] = a[ 0 ]; buff[ p + 2 ] = a[ 1 ]; buff[ p + 1 ] = a[ 2 ]; buff[ p + 0 ] = a[ 3 ];
513
-
514
- },
515
- writeUint: function ( buff, p, n ) {
516
-
517
- buff[ p ] = ( n >> 24 ) & 255; buff[ p + 1 ] = ( n >> 16 ) & 255; buff[ p + 2 ] = ( n >> 8 ) & 255; buff[ p + 3 ] = ( n >> 0 ) & 255;
518
-
519
- },
520
- writeASCII: function ( buff, p, s ) {
521
-
522
- for ( var i = 0; i < s.length; i ++ ) buff[ p + i ] = s.charCodeAt( i );
523
-
524
- },
525
- writeDouble: function ( buff, p, n ) {
526
-
527
- UTIF._binBE.fl64[ 0 ] = n;
528
- for ( var i = 0; i < 8; i ++ ) buff[ p + i ] = UTIF._binBE.ui8[ 7 - i ];
529
-
530
- }
531
- };
532
- UTIF._binBE.ui8 = new Uint8Array( 8 );
533
- UTIF._binBE.i16 = new Int16Array( UTIF._binBE.ui8.buffer );
534
- UTIF._binBE.i32 = new Int32Array( UTIF._binBE.ui8.buffer );
535
- UTIF._binBE.ui32 = new Uint32Array( UTIF._binBE.ui8.buffer );
536
- UTIF._binBE.fl32 = new Float32Array( UTIF._binBE.ui8.buffer );
537
- UTIF._binBE.fl64 = new Float64Array( UTIF._binBE.ui8.buffer );
538
-
539
- UTIF._binLE =
540
- {
541
- nextZero: UTIF._binBE.nextZero,
542
- readUshort: function ( buff, p ) {
543
-
544
- return ( buff[ p + 1 ] << 8 ) | buff[ p ];
545
-
546
- },
547
- readShort: function ( buff, p ) {
548
-
549
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 0 ]; a[ 1 ] = buff[ p + 1 ]; return UTIF._binBE.i16[ 0 ];
550
-
551
- },
552
- readInt: function ( buff, p ) {
553
-
554
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 0 ]; a[ 1 ] = buff[ p + 1 ]; a[ 2 ] = buff[ p + 2 ]; a[ 3 ] = buff[ p + 3 ]; return UTIF._binBE.i32[ 0 ];
555
-
556
- },
557
- readUint: function ( buff, p ) {
558
-
559
- var a = UTIF._binBE.ui8; a[ 0 ] = buff[ p + 0 ]; a[ 1 ] = buff[ p + 1 ]; a[ 2 ] = buff[ p + 2 ]; a[ 3 ] = buff[ p + 3 ]; return UTIF._binBE.ui32[ 0 ];
560
-
561
- },
562
- readASCII: UTIF._binBE.readASCII,
563
- readFloat: function ( buff, p ) {
564
-
565
- var a = UTIF._binBE.ui8; for ( var i = 0; i < 4; i ++ ) a[ i ] = buff[ p + i ]; return UTIF._binBE.fl32[ 0 ];
566
-
567
- },
568
- readDouble: function ( buff, p ) {
569
-
570
- var a = UTIF._binBE.ui8; for ( var i = 0; i < 8; i ++ ) a[ i ] = buff[ p + i ]; return UTIF._binBE.fl64[ 0 ];
571
-
572
- },
573
-
574
- writeUshort: function ( buff, p, n ) {
575
-
576
- buff[ p ] = ( n ) & 255; buff[ p + 1 ] = ( n >> 8 ) & 255;
577
-
578
- },
579
- writeInt: function ( buff, p, n ) {
580
-
581
- var a = UTIF._binBE.ui8; UTIF._binBE.i32[ 0 ] = n; buff[ p + 0 ] = a[ 0 ]; buff[ p + 1 ] = a[ 1 ]; buff[ p + 2 ] = a[ 2 ]; buff[ p + 3 ] = a[ 3 ];
582
-
583
- },
584
- writeUint: function ( buff, p, n ) {
585
-
586
- buff[ p ] = ( n >>> 0 ) & 255; buff[ p + 1 ] = ( n >>> 8 ) & 255; buff[ p + 2 ] = ( n >>> 16 ) & 255; buff[ p + 3 ] = ( n >>> 24 ) & 255;
587
-
588
- },
589
- writeASCII: UTIF._binBE.writeASCII
590
- };
591
- UTIF._copyTile = function ( tb, tw, th, b, w, h, xoff, yoff ) {
592
-
593
- //log("copyTile", tw, th, w, h, xoff, yoff);
594
- var xlim = Math.min( tw, w - xoff );
595
- var ylim = Math.min( th, h - yoff );
596
- for ( var y = 0; y < ylim; y ++ ) {
597
-
598
- var tof = ( yoff + y ) * w + xoff;
599
- var sof = y * tw;
600
- for ( var x = 0; x < xlim; x ++ ) b[ tof + x ] = tb[ sof + x ];
601
-
602
- }
603
-
604
- };
605
-
606
- export { LogLuvLoader };
@@ -1,14 +0,0 @@
1
- import { attribute } from '../core/AttributeNode.js';
2
- import { varying } from '../core/VaryingNode.js';
3
- import { property } from '../core/PropertyNode.js';
4
- import { cameraViewMatrix } from './CameraNode.js';
5
- import { modelNormalMatrix } from './ModelNode.js';
6
- import { vec3 } from '../shadernode/ShaderNode.js';
7
-
8
- export const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3', vec3( 0, 1, 0 ) );
9
- export const normalLocal = /*#__PURE__*/ normalGeometry.toVar( 'normalLocal' );
10
- export const normalView = /*#__PURE__*/ varying( modelNormalMatrix.mul( normalLocal ), 'v_normalView' ).normalize().toVar( 'normalView' );
11
- export const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'normalWorld' );
12
- export const transformedNormalView = /*#__PURE__*/ property( 'vec3', 'transformedNormalView' );
13
- export const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' );
14
- export const transformedClearcoatNormalView = /*#__PURE__*/ property( 'vec3', 'transformedClearcoatNormalView' );
@@ -1,10 +0,0 @@
1
- import { attribute } from '../core/AttributeNode.js';
2
- import { varying } from '../core/VaryingNode.js';
3
- import { modelWorldMatrix, modelViewMatrix } from './ModelNode.js';
4
-
5
- export const positionGeometry = /*#__PURE__*/ attribute( 'position', 'vec3' );
6
- export const positionLocal = /*#__PURE__*/ positionGeometry.toVar( 'positionLocal' );
7
- export const positionWorld = /*#__PURE__*/ varying( modelWorldMatrix.mul( positionLocal ).xyz, 'v_positionWorld' );
8
- export const positionWorldDirection = /*#__PURE__*/ varying( positionLocal.transformDirection( modelWorldMatrix ), 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' );
9
- export const positionView = /*#__PURE__*/ varying( modelViewMatrix.mul( positionLocal ).xyz, 'v_positionView' );
10
- export const positionViewDirection = /*#__PURE__*/ varying( positionView.negate(), 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );
@@ -1,10 +0,0 @@
1
- import { cameraViewMatrix } from './CameraNode.js';
2
- import { transformedNormalView } from './NormalNode.js';
3
- import { positionViewDirection } from './PositionNode.js';
4
- import { materialRefractionRatio } from './MaterialNode.js';
5
-
6
- export const reflectView = /*#__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
7
- export const refractView = /*#__PURE__*/ positionViewDirection.negate().refract( transformedNormalView, materialRefractionRatio );
8
-
9
- export const reflectVector = /*#__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
10
- export const refractVector = /*#__PURE__*/ refractView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
@@ -1,23 +0,0 @@
1
- import { attribute } from '../core/AttributeNode.js';
2
- import { varying } from '../core/VaryingNode.js';
3
- import { cameraViewMatrix } from './CameraNode.js';
4
- import { modelViewMatrix } from './ModelNode.js';
5
- import { tslFn, vec4 } from '../shadernode/ShaderNode.js';
6
-
7
- export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {
8
-
9
- if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
10
-
11
- builder.geometry.computeTangents();
12
-
13
- }
14
-
15
- return attribute( 'tangent', 'vec4' );
16
-
17
- } )();
18
-
19
- export const tangentLocal = /*#__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' );
20
- export const tangentView = /*#__PURE__*/ varying( modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz, 'v_tangentView' ).normalize().toVar( 'tangentView' );
21
- export const tangentWorld = /*#__PURE__*/ varying( tangentView.transformDirection( cameraViewMatrix ), 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
22
- export const transformedTangentView = /*#__PURE__*/ tangentView.toVar( 'transformedTangentView' );
23
- export const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );