super-three 0.169.1 → 0.170.1

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 (255) hide show
  1. package/build/three.cjs +24628 -24228
  2. package/build/three.core.js +37002 -0
  3. package/build/three.core.min.js +6 -0
  4. package/build/three.module.js +10519 -47108
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +533 -0
  7. package/build/three.tsl.min.js +6 -0
  8. package/build/three.webgpu.js +17071 -53583
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +17134 -53623
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/Addons.js +3 -3
  13. package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
  14. package/examples/jsm/animation/MMDPhysics.js +2 -0
  15. package/examples/jsm/capabilities/WebGPU.js +1 -10
  16. package/examples/jsm/controls/ArcballControls.js +25 -21
  17. package/examples/jsm/controls/OrbitControls.js +41 -9
  18. package/examples/jsm/controls/PointerLockControls.js +2 -5
  19. package/examples/jsm/controls/TransformControls.js +22 -6
  20. package/examples/jsm/csm/CSM.js +2 -2
  21. package/examples/jsm/csm/CSMFrustum.js +7 -4
  22. package/examples/jsm/csm/CSMHelper.js +2 -0
  23. package/examples/jsm/csm/CSMShadowNode.js +437 -0
  24. package/examples/jsm/curves/NURBSCurve.js +34 -3
  25. package/examples/jsm/exporters/GLTFExporter.js +138 -71
  26. package/examples/jsm/exporters/KTX2Exporter.js +35 -12
  27. package/examples/jsm/exporters/MMDExporter.js +6 -0
  28. package/examples/jsm/exporters/USDZExporter.js +21 -3
  29. package/examples/jsm/geometries/DecalGeometry.js +70 -21
  30. package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
  31. package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
  32. package/examples/jsm/interactive/HTMLMesh.js +1 -0
  33. package/examples/jsm/lighting/TiledLighting.js +18 -0
  34. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  35. package/examples/jsm/lines/LineGeometry.js +25 -0
  36. package/examples/jsm/lines/LineMaterial.js +0 -1
  37. package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
  38. package/examples/jsm/lines/webgpu/Line2.js +2 -1
  39. package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
  40. package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
  41. package/examples/jsm/loaders/3DMLoader.js +1 -0
  42. package/examples/jsm/loaders/3MFLoader.js +91 -0
  43. package/examples/jsm/loaders/FBXLoader.js +12 -2
  44. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  45. package/examples/jsm/loaders/KTX2Loader.js +143 -49
  46. package/examples/jsm/loaders/LDrawLoader.js +22 -136
  47. package/examples/jsm/loaders/LottieLoader.js +1 -0
  48. package/examples/jsm/loaders/MMDLoader.js +3 -0
  49. package/examples/jsm/loaders/MaterialXLoader.js +2 -2
  50. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
  51. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
  52. package/examples/jsm/math/ColorSpaces.js +76 -0
  53. package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
  54. package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
  55. package/examples/jsm/misc/VolumeSlice.js +1 -0
  56. package/examples/jsm/objects/InstancedPoints.js +2 -4
  57. package/examples/jsm/objects/LensflareMesh.js +4 -2
  58. package/examples/jsm/objects/SkyMesh.js +5 -3
  59. package/examples/jsm/objects/Water2Mesh.js +7 -3
  60. package/examples/jsm/objects/WaterMesh.js +12 -10
  61. package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
  62. package/examples/jsm/postprocessing/SSRPass.js +6 -0
  63. package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
  64. package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
  65. package/examples/jsm/shaders/FXAAShader.js +225 -224
  66. package/examples/jsm/transpiler/AST.js +2 -2
  67. package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
  68. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  69. package/examples/jsm/transpiler/TSLEncoder.js +11 -6
  70. package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
  71. package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
  72. package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
  73. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
  74. package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
  75. package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
  76. package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
  77. package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
  78. package/examples/jsm/tsl/display/FXAANode.js +316 -0
  79. package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
  80. package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
  81. package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
  82. package/examples/jsm/tsl/display/LensflareNode.js +161 -0
  83. package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
  84. package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
  85. package/examples/jsm/tsl/display/OutlineNode.js +434 -0
  86. package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
  87. package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
  88. package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
  89. package/examples/jsm/tsl/display/SMAANode.js +620 -0
  90. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
  91. package/examples/jsm/tsl/display/SSRNode.js +366 -0
  92. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
  93. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
  94. package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
  95. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
  96. package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
  97. package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
  98. package/examples/jsm/tsl/display/hashBlur.js +24 -0
  99. package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
  100. package/examples/jsm/utils/SceneOptimizer.js +410 -0
  101. package/examples/jsm/utils/UVsDebug.js +1 -1
  102. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
  103. package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
  104. package/examples/jsm/webxr/Text2D.js +6 -6
  105. package/package.json +4 -4
  106. package/src/Three.Core.js +178 -0
  107. package/src/Three.TSL.js +526 -0
  108. package/src/Three.WebGPU.Nodes.js +9 -186
  109. package/src/Three.WebGPU.js +8 -186
  110. package/src/Three.js +1 -177
  111. package/src/animation/AnimationClip.js +2 -2
  112. package/src/animation/AnimationObjectGroup.js +2 -2
  113. package/src/audio/Audio.js +38 -0
  114. package/src/cameras/PerspectiveCamera.js +6 -6
  115. package/src/cameras/StereoCamera.js +2 -2
  116. package/src/constants.js +1 -6
  117. package/src/core/BufferGeometry.js +48 -8
  118. package/src/core/InterleavedBuffer.js +4 -4
  119. package/src/core/Object3D.js +2 -2
  120. package/src/extras/core/Curve.js +3 -3
  121. package/src/extras/core/Shape.js +2 -2
  122. package/src/geometries/CylinderGeometry.js +2 -2
  123. package/src/geometries/EdgesGeometry.js +2 -2
  124. package/src/geometries/LatheGeometry.js +2 -2
  125. package/src/lights/SpotLightShadow.js +2 -2
  126. package/src/materials/LineDashedMaterial.js +0 -1
  127. package/src/materials/Material.js +2 -2
  128. package/src/materials/MeshPhongMaterial.js +1 -1
  129. package/src/materials/MeshPhysicalMaterial.js +2 -2
  130. package/src/materials/MeshStandardMaterial.js +2 -2
  131. package/src/materials/nodes/Line2NodeMaterial.js +32 -13
  132. package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
  133. package/src/materials/nodes/NodeMaterial.js +93 -23
  134. package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
  135. package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
  136. package/src/math/ColorManagement.js +143 -102
  137. package/src/math/Line3.js +2 -2
  138. package/src/math/Quaternion.js +2 -2
  139. package/src/math/Spherical.js +3 -3
  140. package/src/math/Vector2.js +7 -7
  141. package/src/math/Vector3.js +9 -9
  142. package/src/math/Vector4.js +22 -9
  143. package/src/nodes/Nodes.js +2 -21
  144. package/src/nodes/TSL.js +9 -25
  145. package/src/nodes/accessors/Arrays.js +27 -0
  146. package/src/nodes/accessors/BuiltinNode.js +26 -0
  147. package/src/nodes/accessors/Camera.js +0 -1
  148. package/src/nodes/accessors/ClippingNode.js +76 -42
  149. package/src/nodes/accessors/InstanceNode.js +17 -20
  150. package/src/nodes/accessors/InstancedMeshNode.js +26 -0
  151. package/src/nodes/accessors/Lights.js +32 -0
  152. package/src/nodes/accessors/SceneNode.js +35 -1
  153. package/src/nodes/accessors/StorageBufferNode.js +61 -19
  154. package/src/nodes/accessors/StorageTextureNode.js +10 -4
  155. package/src/nodes/accessors/TextureNode.js +1 -1
  156. package/src/nodes/accessors/VelocityNode.js +13 -3
  157. package/src/nodes/code/FunctionCallNode.js +16 -5
  158. package/src/nodes/code/ScriptableNode.js +4 -4
  159. package/src/nodes/core/Node.js +1 -0
  160. package/src/nodes/core/NodeBuilder.js +31 -14
  161. package/src/nodes/core/NodeUtils.js +28 -0
  162. package/src/nodes/core/VarNode.js +15 -3
  163. package/src/nodes/core/constants.js +6 -0
  164. package/src/nodes/display/BlendModes.js +99 -0
  165. package/src/nodes/display/ColorAdjustment.js +53 -4
  166. package/src/nodes/display/ColorSpaceFunctions.js +5 -5
  167. package/src/nodes/display/ColorSpaceNode.js +27 -39
  168. package/src/nodes/display/PassNode.js +6 -4
  169. package/src/nodes/display/ToneMappingNode.js +1 -1
  170. package/src/nodes/display/ToonOutlinePassNode.js +3 -3
  171. package/src/nodes/display/ViewportDepthNode.js +48 -1
  172. package/src/nodes/functions/PhysicalLightingModel.js +21 -15
  173. package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
  174. package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
  175. package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
  176. package/src/nodes/gpgpu/ComputeNode.js +9 -1
  177. package/src/nodes/lighting/AnalyticLightNode.js +23 -419
  178. package/src/nodes/lighting/LightsNode.js +24 -12
  179. package/src/nodes/lighting/PointLightNode.js +41 -22
  180. package/src/nodes/lighting/PointShadowNode.js +254 -0
  181. package/src/nodes/lighting/RectAreaLightNode.js +3 -0
  182. package/src/nodes/lighting/ShadowNode.js +593 -0
  183. package/src/nodes/lighting/SpotLightNode.js +14 -2
  184. package/src/nodes/utils/LoopNode.js +2 -2
  185. package/src/nodes/utils/Oscillators.js +6 -0
  186. package/src/nodes/utils/PostProcessingUtils.js +89 -0
  187. package/src/nodes/utils/RTTNode.js +9 -1
  188. package/src/nodes/utils/ReflectorNode.js +101 -15
  189. package/src/nodes/utils/StorageArrayElementNode.js +2 -2
  190. package/src/nodes/utils/Timer.js +29 -0
  191. package/src/objects/BatchedMesh.js +472 -296
  192. package/src/objects/ClippingGroup.js +19 -0
  193. package/src/objects/Skeleton.js +2 -2
  194. package/src/renderers/WebGLRenderer.js +183 -109
  195. package/src/renderers/common/Animation.js +23 -11
  196. package/src/renderers/common/Attributes.js +4 -0
  197. package/src/renderers/common/Backend.js +2 -0
  198. package/src/renderers/common/Background.js +15 -5
  199. package/src/renderers/common/Bindings.js +23 -6
  200. package/src/renderers/common/ClippingContext.js +77 -85
  201. package/src/renderers/common/Constants.js +2 -1
  202. package/src/renderers/common/Geometries.js +20 -0
  203. package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
  204. package/src/renderers/common/Lighting.js +45 -0
  205. package/src/renderers/common/PostProcessingUtils.js +86 -0
  206. package/src/renderers/common/RenderList.js +48 -17
  207. package/src/renderers/common/RenderLists.js +4 -2
  208. package/src/renderers/common/RenderObject.js +45 -28
  209. package/src/renderers/common/RenderObjects.js +12 -6
  210. package/src/renderers/common/Renderer.js +222 -77
  211. package/src/renderers/common/Textures.js +41 -17
  212. package/src/renderers/common/UniformsGroup.js +16 -4
  213. package/src/renderers/common/extras/PMREMGenerator.js +89 -13
  214. package/src/renderers/common/nodes/NodeLibrary.js +2 -15
  215. package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
  216. package/src/renderers/common/nodes/NodeUniform.js +42 -0
  217. package/src/renderers/common/nodes/Nodes.js +2 -2
  218. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  219. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  220. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  221. package/src/renderers/webgl/WebGLBackground.js +20 -1
  222. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  223. package/src/renderers/webgl/WebGLCapabilities.js +0 -7
  224. package/src/renderers/webgl/WebGLGeometries.js +0 -28
  225. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  226. package/src/renderers/webgl/WebGLProgram.js +24 -28
  227. package/src/renderers/webgl/WebGLPrograms.js +5 -2
  228. package/src/renderers/webgl/WebGLState.js +37 -1
  229. package/src/renderers/webgl/WebGLTextures.js +29 -12
  230. package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
  231. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
  232. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
  233. package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
  234. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
  235. package/src/renderers/webgpu/WebGPUBackend.js +152 -56
  236. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
  237. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  238. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
  239. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
  240. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
  241. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
  242. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
  243. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
  244. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
  245. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
  246. package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
  247. package/src/renderers/webxr/WebXRManager.js +4 -4
  248. package/src/textures/Source.js +2 -2
  249. package/src/textures/Texture.js +2 -2
  250. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  251. package/src/nodes/display/BlendMode.js +0 -54
  252. package/src/nodes/display/FXAANode.js +0 -332
  253. package/src/nodes/utils/OscNode.js +0 -85
  254. package/src/nodes/utils/TimerNode.js +0 -97
  255. /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ColorManagement,
2
3
  FloatType,
3
4
  HalfFloatType,
4
5
  UnsignedByteType,
@@ -10,6 +11,7 @@ import {
10
11
  NoColorSpace,
11
12
  LinearSRGBColorSpace,
12
13
  SRGBColorSpace,
14
+ SRGBTransfer,
13
15
  DataTexture,
14
16
  REVISION,
15
17
  } from 'three';
@@ -43,6 +45,13 @@ import {
43
45
  VK_FORMAT_R8G8B8A8_UNORM,
44
46
  } from '../libs/ktx-parse.module.js';
45
47
 
48
+ /**
49
+ * References:
50
+ * - https://github.khronos.org/KTX-Specification/ktxspec.v2.html
51
+ * - https://registry.khronos.org/DataFormat/specs/1.3/dataformat.1.3.html
52
+ * - https://github.com/donmccurdy/KTX-Parse
53
+ */
54
+
46
55
  const VK_FORMAT_MAP = {
47
56
 
48
57
  [ RGBAFormat ]: {
@@ -95,14 +104,23 @@ const VK_FORMAT_MAP = {
95
104
 
96
105
  };
97
106
 
98
- const KHR_DF_CHANNEL_MAP = {
107
+ const KHR_DF_CHANNEL_MAP = [
99
108
 
100
- 0: KHR_DF_CHANNEL_RGBSDA_RED,
101
- 1: KHR_DF_CHANNEL_RGBSDA_GREEN,
102
- 2: KHR_DF_CHANNEL_RGBSDA_BLUE,
103
- 3: KHR_DF_CHANNEL_RGBSDA_ALPHA,
109
+ KHR_DF_CHANNEL_RGBSDA_RED,
110
+ KHR_DF_CHANNEL_RGBSDA_GREEN,
111
+ KHR_DF_CHANNEL_RGBSDA_BLUE,
112
+ KHR_DF_CHANNEL_RGBSDA_ALPHA,
104
113
 
105
- };
114
+ ];
115
+
116
+ // TODO: sampleLower and sampleUpper may change based on color space.
117
+ const KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER = {
118
+
119
+ [ FloatType ]: [ 0xbf800000, 0x3f800000 ],
120
+ [ HalfFloatType ]: [ 0xbf800000, 0x3f800000 ],
121
+ [ UnsignedByteType ]: [ 0, 255 ],
122
+
123
+ }
106
124
 
107
125
  const ERROR_INPUT = 'THREE.KTX2Exporter: Supported inputs are DataTexture, Data3DTexture, or WebGLRenderer and WebGLRenderTarget.';
108
126
  const ERROR_FORMAT = 'THREE.KTX2Exporter: Supported formats are RGBAFormat, RGFormat, or RedFormat.';
@@ -172,7 +190,7 @@ export class KTX2Exporter {
172
190
  basicDesc.colorPrimaries = texture.colorSpace === NoColorSpace
173
191
  ? KHR_DF_PRIMARIES_UNSPECIFIED
174
192
  : KHR_DF_PRIMARIES_BT709;
175
- basicDesc.transferFunction = texture.colorSpace === SRGBColorSpace
193
+ basicDesc.transferFunction = ColorManagement.getTransfer( texture.colorSpace ) === SRGBTransfer
176
194
  ? KHR_DF_TRANSFER_SRGB
177
195
  : KHR_DF_TRANSFER_LINEAR;
178
196
 
@@ -188,7 +206,8 @@ export class KTX2Exporter {
188
206
 
189
207
  let channelType = KHR_DF_CHANNEL_MAP[ i ];
190
208
 
191
- if ( texture.colorSpace === LinearSRGBColorSpace || texture.colorSpace === NoColorSpace ) {
209
+ // Assign KHR_DF_SAMPLE_DATATYPE_LINEAR if the channel is linear _and_ differs from the transfer function.
210
+ if ( channelType === KHR_DF_CHANNEL_RGBSDA_ALPHA && basicDesc.transferFunction !== KHR_DF_TRANSFER_LINEAR ) {
192
211
 
193
212
  channelType |= KHR_DF_SAMPLE_DATATYPE_LINEAR;
194
213
 
@@ -204,11 +223,11 @@ export class KTX2Exporter {
204
223
  basicDesc.samples.push( {
205
224
 
206
225
  channelType: channelType,
207
- bitOffset: i * array.BYTES_PER_ELEMENT,
226
+ bitOffset: i * array.BYTES_PER_ELEMENT * 8,
208
227
  bitLength: array.BYTES_PER_ELEMENT * 8 - 1,
209
228
  samplePosition: [ 0, 0, 0, 0 ],
210
- sampleLower: texture.type === UnsignedByteType ? 0 : - 1,
211
- sampleUpper: texture.type === UnsignedByteType ? 255 : 1,
229
+ sampleLower: KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER[ texture.type ][ 0 ],
230
+ sampleUpper: KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER[ texture.type ][ 1 ],
212
231
 
213
232
  } );
214
233
 
@@ -269,7 +288,11 @@ async function toDataTexture( renderer, rtt ) {
269
288
 
270
289
  }
271
290
 
272
- return new DataTexture( view, rtt.width, rtt.height, rtt.texture.format, rtt.texture.type );
291
+ const texture = new DataTexture( view, rtt.width, rtt.height, rtt.texture.format, rtt.texture.type );
292
+
293
+ texture.colorSpace = rtt.texture.colorSpace;
294
+
295
+ return texture;
273
296
 
274
297
  }
275
298
 
@@ -12,6 +12,12 @@ import { MMDParser } from '../libs/mmdparser.module.js';
12
12
 
13
13
  class MMDExporter {
14
14
 
15
+ constructor() {
16
+
17
+ console.warn( 'THREE.MMDExporter: The module has been deprecated and will be removed with r172. Please migrate to https://github.com/takahirox/three-mmd-loader instead.' );
18
+
19
+ }
20
+
15
21
  /* TODO: implement
16
22
  // mesh -> pmd
17
23
  this.parsePmd = function ( object ) {
@@ -9,10 +9,20 @@ import {
9
9
  zipSync,
10
10
  } from '../libs/fflate.module.js';
11
11
 
12
- import { decompress } from './../utils/TextureUtils.js';
13
-
14
12
  class USDZExporter {
15
13
 
14
+ constructor() {
15
+
16
+ this.textureUtils = null;
17
+
18
+ }
19
+
20
+ setTextureUtils( utils ) {
21
+
22
+ this.textureUtils = utils;
23
+
24
+ }
25
+
16
26
  parse( scene, onDone, onError, options ) {
17
27
 
18
28
  this.parseAsync( scene, options ).then( onDone ).catch( onError );
@@ -98,7 +108,15 @@ class USDZExporter {
98
108
 
99
109
  if ( texture.isCompressedTexture === true ) {
100
110
 
101
- texture = decompress( texture );
111
+ if ( this.textureUtils === null ) {
112
+
113
+ throw new Error( 'THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.' );
114
+
115
+ } else {
116
+
117
+ texture = await this.textureUtils.decompress( texture );
118
+
119
+ }
102
120
 
103
121
  }
104
122
 
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  BufferGeometry,
3
+ Euler,
3
4
  Float32BufferAttribute,
4
5
  Matrix3,
5
6
  Matrix4,
7
+ Mesh,
6
8
  Vector3
7
9
  } from 'three';
8
10
 
@@ -23,7 +25,7 @@ import {
23
25
 
24
26
  class DecalGeometry extends BufferGeometry {
25
27
 
26
- constructor( mesh, position, orientation, size ) {
28
+ constructor( mesh = new Mesh(), position = new Vector3(), orientation = new Euler(), size = new Vector3( 1, 1, 1 ) ) {
27
29
 
28
30
  super();
29
31
 
@@ -55,9 +57,16 @@ class DecalGeometry extends BufferGeometry {
55
57
  // build geometry
56
58
 
57
59
  this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
58
- this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
59
60
  this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
60
61
 
62
+ if ( normals.length > 0 ) {
63
+
64
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
65
+
66
+ }
67
+
68
+ //
69
+
61
70
  function generate() {
62
71
 
63
72
  let decalVertices = [];
@@ -86,22 +95,40 @@ class DecalGeometry extends BufferGeometry {
86
95
  for ( let i = 0; i < index.count; i ++ ) {
87
96
 
88
97
  vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
89
- normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
90
98
 
91
- pushDecalVertex( decalVertices, vertex, normal );
99
+ if ( normalAttribute ) {
100
+
101
+ normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
102
+ pushDecalVertex( decalVertices, vertex, normal );
103
+
104
+ } else {
105
+
106
+ pushDecalVertex( decalVertices, vertex );
107
+
108
+ }
92
109
 
93
110
  }
94
111
 
95
112
  } else {
96
113
 
114
+ if ( positionAttribute === undefined ) return; // empty geometry
115
+
97
116
  // non-indexed BufferGeometry
98
117
 
99
118
  for ( let i = 0; i < positionAttribute.count; i ++ ) {
100
119
 
101
120
  vertex.fromBufferAttribute( positionAttribute, i );
102
- normal.fromBufferAttribute( normalAttribute, i );
103
121
 
104
- pushDecalVertex( decalVertices, vertex, normal );
122
+ if ( normalAttribute ) {
123
+
124
+ normal.fromBufferAttribute( normalAttribute, i );
125
+ pushDecalVertex( decalVertices, vertex, normal );
126
+
127
+ } else {
128
+
129
+ pushDecalVertex( decalVertices, vertex );
130
+
131
+ }
105
132
 
106
133
  }
107
134
 
@@ -136,22 +163,34 @@ class DecalGeometry extends BufferGeometry {
136
163
  // now create vertex and normal buffer data
137
164
 
138
165
  vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
139
- normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
166
+
167
+ if ( decalVertex.normal !== null ) {
168
+
169
+ normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
170
+
171
+ }
140
172
 
141
173
  }
142
174
 
143
175
  }
144
176
 
145
- function pushDecalVertex( decalVertices, vertex, normal ) {
177
+ function pushDecalVertex( decalVertices, vertex, normal = null ) {
146
178
 
147
179
  // transform the vertex to world space, then to projector space
148
180
 
149
181
  vertex.applyMatrix4( mesh.matrixWorld );
150
182
  vertex.applyMatrix4( projectorMatrixInverse );
151
183
 
152
- normal.applyNormalMatrix( normalMatrix );
184
+ if ( normal ) {
185
+
186
+ normal.applyNormalMatrix( normalMatrix );
187
+ decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
188
+
189
+ } else {
153
190
 
154
- decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
191
+ decalVertices.push( new DecalVertex( vertex.clone() ) );
192
+
193
+ }
155
194
 
156
195
  }
157
196
 
@@ -313,18 +352,25 @@ class DecalGeometry extends BufferGeometry {
313
352
 
314
353
  const s0 = d0 / ( d0 - d1 );
315
354
 
316
- const v = new DecalVertex(
317
- new Vector3(
318
- v0.position.x + s0 * ( v1.position.x - v0.position.x ),
319
- v0.position.y + s0 * ( v1.position.y - v0.position.y ),
320
- v0.position.z + s0 * ( v1.position.z - v0.position.z )
321
- ),
322
- new Vector3(
355
+ const position = new Vector3(
356
+ v0.position.x + s0 * ( v1.position.x - v0.position.x ),
357
+ v0.position.y + s0 * ( v1.position.y - v0.position.y ),
358
+ v0.position.z + s0 * ( v1.position.z - v0.position.z )
359
+ );
360
+
361
+ let normal = null;
362
+
363
+ if ( v0.normal !== null && v1.normal !== null ) {
364
+
365
+ normal = new Vector3(
323
366
  v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ),
324
367
  v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ),
325
368
  v0.normal.z + s0 * ( v1.normal.z - v0.normal.z )
326
- )
327
- );
369
+ );
370
+
371
+ }
372
+
373
+ const v = new DecalVertex( position, normal );
328
374
 
329
375
  // need to clip more values (texture coordinates)? do it this way:
330
376
  // intersectpoint.value = a.value + s * ( b.value - a.value );
@@ -341,7 +387,7 @@ class DecalGeometry extends BufferGeometry {
341
387
 
342
388
  class DecalVertex {
343
389
 
344
- constructor( position, normal ) {
390
+ constructor( position, normal = null ) {
345
391
 
346
392
  this.position = position;
347
393
  this.normal = normal;
@@ -350,7 +396,10 @@ class DecalVertex {
350
396
 
351
397
  clone() {
352
398
 
353
- return new this.constructor( this.position.clone(), this.normal.clone() );
399
+ const position = this.position.clone();
400
+ const normal = ( this.normal !== null ) ? this.normal.clone() : null;
401
+
402
+ return new this.constructor( position, normal );
354
403
 
355
404
  }
356
405
 
@@ -78,6 +78,8 @@ class InstancedPointsGeometry extends InstancedBufferGeometry {
78
78
  this.computeBoundingBox();
79
79
  this.computeBoundingSphere();
80
80
 
81
+ this.instanceCount = points.length / 3;
82
+
81
83
  return this;
82
84
 
83
85
  }
@@ -0,0 +1,175 @@
1
+ import {
2
+ BoxGeometry,
3
+ BufferAttribute,
4
+ Mesh,
5
+ PlaneGeometry,
6
+ Vector3,
7
+ } from 'three';
8
+ import { NodeMaterial, texture as textureNode, cubeTexture, texture3D, float, vec4 } from 'three/tsl';
9
+ import { mergeGeometries } from '../utils/BufferGeometryUtils.js';
10
+
11
+ class TextureHelper extends Mesh {
12
+
13
+ constructor( texture, width = 1, height = 1, depth = 1 ) {
14
+
15
+ const material = new NodeMaterial();
16
+ material.name = 'TextureHelper';
17
+
18
+ let colorNode;
19
+
20
+ if ( texture.isCubeTexture ) {
21
+
22
+ colorNode = cubeTexture( texture );
23
+
24
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
25
+
26
+ colorNode = texture3D( texture );
27
+
28
+ } else {
29
+
30
+ colorNode = textureNode( texture );
31
+
32
+ }
33
+
34
+ const alphaNode = float( getAlpha( texture ) );
35
+
36
+ material.colorNode = vec4( colorNode.rgb, alphaNode );
37
+
38
+ const geometry = texture.isCubeTexture
39
+ ? createCubeGeometry( width, height, depth )
40
+ : createSliceGeometry( texture, width, height, depth );
41
+
42
+ super( geometry, material );
43
+
44
+ this.texture = texture;
45
+ this.type = 'TextureHelper';
46
+
47
+ }
48
+
49
+ dispose() {
50
+
51
+ this.geometry.dispose();
52
+ this.material.dispose();
53
+
54
+ }
55
+
56
+ }
57
+
58
+ function getImageCount( texture ) {
59
+
60
+ if ( texture.isCubeTexture ) {
61
+
62
+ return 6;
63
+
64
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
65
+
66
+ return texture.image.depth;
67
+
68
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
69
+
70
+ return texture.image.depth;
71
+
72
+ } else {
73
+
74
+ return 1;
75
+
76
+ }
77
+
78
+ }
79
+
80
+ function getAlpha( texture ) {
81
+
82
+ if ( texture.isCubeTexture ) {
83
+
84
+ return 1;
85
+
86
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
87
+
88
+ return Math.max( 1 / texture.image.depth, 0.25 );
89
+
90
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
91
+
92
+ return Math.max( 1 / texture.image.depth, 0.25 );
93
+
94
+ } else {
95
+
96
+ return 1;
97
+
98
+ }
99
+
100
+ }
101
+
102
+ function createCubeGeometry( width, height, depth ) {
103
+
104
+ const geometry = new BoxGeometry( width, height, depth );
105
+
106
+ const position = geometry.attributes.position;
107
+ const uv = geometry.attributes.uv;
108
+ const uvw = new BufferAttribute( new Float32Array( uv.count * 3 ), 3 );
109
+
110
+ const _direction = new Vector3();
111
+
112
+ for ( let j = 0, jl = uv.count; j < jl; ++ j ) {
113
+
114
+ _direction.fromBufferAttribute( position, j ).normalize();
115
+
116
+ const u = _direction.x;
117
+ const v = _direction.y;
118
+ const w = _direction.z;
119
+
120
+ uvw.setXYZ( j, u, v, w );
121
+
122
+ }
123
+
124
+ geometry.deleteAttribute( 'uv' );
125
+ geometry.setAttribute( 'uv', uvw );
126
+
127
+ return geometry;
128
+
129
+ }
130
+
131
+ function createSliceGeometry( texture, width, height, depth ) {
132
+
133
+ const sliceCount = getImageCount( texture );
134
+
135
+ const geometries = [];
136
+
137
+ for ( let i = 0; i < sliceCount; ++ i ) {
138
+
139
+ const geometry = new PlaneGeometry( width, height );
140
+
141
+ if ( sliceCount > 1 ) {
142
+
143
+ geometry.translate( 0, 0, depth * ( i / ( sliceCount - 1 ) - 0.5 ) );
144
+
145
+ }
146
+
147
+ const uv = geometry.attributes.uv;
148
+ const uvw = new BufferAttribute( new Float32Array( uv.count * 3 ), 3 );
149
+
150
+ for ( let j = 0, jl = uv.count; j < jl; ++ j ) {
151
+
152
+ const u = uv.getX( j );
153
+ const v = texture.flipY ? uv.getY( j ) : 1 - uv.getY( j );
154
+ const w = sliceCount === 1
155
+ ? 1
156
+ : texture.isDataArrayTexture || texture.isCompressedArrayTexture
157
+ ? i
158
+ : i / ( sliceCount - 1 );
159
+
160
+ uvw.setXYZ( j, u, v, w );
161
+
162
+ }
163
+
164
+ geometry.deleteAttribute( 'uv' );
165
+ geometry.setAttribute( 'uv', uvw );
166
+
167
+ geometries.push( geometry );
168
+
169
+ }
170
+
171
+ return mergeGeometries( geometries );
172
+
173
+ }
174
+
175
+ export { TextureHelper };
@@ -62,6 +62,7 @@ class HTMLTexture extends CanvasTexture {
62
62
  this.colorSpace = SRGBColorSpace;
63
63
  this.minFilter = LinearFilter;
64
64
  this.magFilter = LinearFilter;
65
+ this.generateMipmaps = false;
65
66
 
66
67
  // Create an observer on the DOM, and run html2canvas update in the next loop
67
68
  const observer = new MutationObserver( () => {
@@ -0,0 +1,18 @@
1
+ import { Lighting } from 'three/webgpu';
2
+ import { tiledLights } from '../tsl/lighting/TiledLightsNode.js';
3
+
4
+ export class TiledLighting extends Lighting {
5
+
6
+ constructor() {
7
+
8
+ super();
9
+
10
+ }
11
+
12
+ createNode( lights = [] ) {
13
+
14
+ return tiledLights().setLights( lights );
15
+
16
+ }
17
+
18
+ }
@@ -71,7 +71,7 @@ class RectAreaLightTexturesLib {
71
71
  LTC_HALF_2.needsUpdate = true;
72
72
 
73
73
  this.LTC_HALF_1 = LTC_HALF_1;
74
- this.LTC_HALF_1 = LTC_HALF_2;
74
+ this.LTC_HALF_2 = LTC_HALF_2;
75
75
 
76
76
  this.LTC_FLOAT_1 = LTC_FLOAT_1;
77
77
  this.LTC_FLOAT_2 = LTC_FLOAT_2;
@@ -62,6 +62,31 @@ class LineGeometry extends LineSegmentsGeometry {
62
62
 
63
63
  }
64
64
 
65
+ setFromPoints( points ) {
66
+
67
+ // converts a vector3 or vector2 array to pairs format
68
+
69
+ const length = points.length - 1;
70
+ const positions = new Float32Array( 6 * length );
71
+
72
+ for ( let i = 0; i < length; i ++ ) {
73
+
74
+ positions[ 6 * i ] = points[ i ].x;
75
+ positions[ 6 * i + 1 ] = points[ i ].y;
76
+ positions[ 6 * i + 2 ] = points[ i ].z || 0;
77
+
78
+ positions[ 6 * i + 3 ] = points[ i + 1 ].x;
79
+ positions[ 6 * i + 4 ] = points[ i + 1 ].y;
80
+ positions[ 6 * i + 5 ] = points[ i + 1 ].z || 0;
81
+
82
+ }
83
+
84
+ super.setPositions( positions );
85
+
86
+ return this;
87
+
88
+ }
89
+
65
90
  fromLine( line ) {
66
91
 
67
92
  const geometry = line.geometry;
@@ -410,7 +410,6 @@ class LineMaterial extends ShaderMaterial {
410
410
  super( {
411
411
 
412
412
  type: 'LineMaterial',
413
-
414
413
  uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
415
414
 
416
415
  vertexShader: ShaderLib[ 'line' ].vertexShader,
@@ -82,6 +82,8 @@ class LineSegmentsGeometry extends InstancedBufferGeometry {
82
82
  this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
83
83
  this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
84
84
 
85
+ this.instanceCount = this.attributes.instanceStart.count;
86
+
85
87
  //
86
88
 
87
89
  this.computeBoundingBox();
@@ -1,7 +1,8 @@
1
+ import { Line2NodeMaterial } from 'three/webgpu';
2
+
1
3
  import { LineSegments2 } from './LineSegments2.js';
2
4
  import { LineGeometry } from '../LineGeometry.js';
3
5
 
4
- import { Line2NodeMaterial } from 'three';
5
6
 
6
7
  class Line2 extends LineSegments2 {
7
8
 
@@ -10,10 +10,9 @@ import {
10
10
  Vector3,
11
11
  Vector4,
12
12
  Line2NodeMaterial
13
- } from 'three';
14
- import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
13
+ } from 'three/webgpu';
15
14
 
16
- const _viewport = new Vector4();
15
+ import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
17
16
 
18
17
  const _start = new Vector3();
19
18
  const _end = new Vector3();
@@ -358,19 +357,6 @@ class LineSegments2 extends Mesh {
358
357
 
359
358
  }
360
359
 
361
- onBeforeRender( renderer ) {
362
-
363
- const uniforms = this.material.uniforms;
364
-
365
- if ( uniforms && uniforms.resolution ) {
366
-
367
- renderer.getViewport( _viewport );
368
- this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
369
-
370
- }
371
-
372
- }
373
-
374
360
  }
375
361
 
376
362
  export { LineSegments2 };