@plastic-software/three 0.182.0 → 0.183.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 (298) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +11520 -10877
  3. package/build/three.core.js +11732 -11340
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +509 -262
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +7 -11
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +3072 -2607
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +3071 -2607
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/Addons.js +0 -3
  14. package/examples/jsm/animation/CCDIKSolver.js +2 -2
  15. package/examples/jsm/controls/ArcballControls.js +3 -3
  16. package/examples/jsm/controls/OrbitControls.js +103 -0
  17. package/examples/jsm/effects/AnaglyphEffect.js +102 -7
  18. package/examples/jsm/environments/ColorEnvironment.js +59 -0
  19. package/examples/jsm/environments/RoomEnvironment.js +1 -0
  20. package/examples/jsm/exporters/EXRExporter.js +1 -1
  21. package/examples/jsm/exporters/GLTFExporter.js +131 -4
  22. package/examples/jsm/exporters/USDZExporter.js +22 -3
  23. package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
  24. package/examples/jsm/helpers/ViewHelper.js +67 -8
  25. package/examples/jsm/inspector/Inspector.js +21 -5
  26. package/examples/jsm/inspector/tabs/Console.js +39 -5
  27. package/examples/jsm/inspector/tabs/Parameters.js +16 -0
  28. package/examples/jsm/inspector/ui/Style.js +25 -1
  29. package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
  30. package/examples/jsm/lines/LineMaterial.js +6 -0
  31. package/examples/jsm/loaders/3MFLoader.js +2 -2
  32. package/examples/jsm/loaders/AMFLoader.js +2 -2
  33. package/examples/jsm/loaders/ColladaLoader.js +24 -4026
  34. package/examples/jsm/loaders/EXRLoader.js +5 -5
  35. package/examples/jsm/loaders/FBXLoader.js +2 -2
  36. package/examples/jsm/loaders/GCodeLoader.js +34 -8
  37. package/examples/jsm/loaders/GLTFLoader.js +122 -171
  38. package/examples/jsm/loaders/KMZLoader.js +5 -5
  39. package/examples/jsm/loaders/KTX2Loader.js +5 -5
  40. package/examples/jsm/loaders/LWOLoader.js +7 -39
  41. package/examples/jsm/loaders/NRRDLoader.js +2 -2
  42. package/examples/jsm/loaders/PCDLoader.js +3 -2
  43. package/examples/jsm/loaders/USDLoader.js +100 -40
  44. package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
  45. package/examples/jsm/loaders/VRMLLoader.js +77 -0
  46. package/examples/jsm/loaders/VTKLoader.js +37 -24
  47. package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
  48. package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
  49. package/examples/jsm/loaders/usd/USDAParser.js +447 -366
  50. package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
  51. package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
  52. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
  53. package/examples/jsm/objects/LensflareMesh.js +1 -1
  54. package/examples/jsm/objects/Sky.js +76 -4
  55. package/examples/jsm/objects/SkyMesh.js +114 -7
  56. package/examples/jsm/objects/Water.js +4 -3
  57. package/examples/jsm/objects/Water2.js +5 -3
  58. package/examples/jsm/objects/WaterMesh.js +5 -7
  59. package/examples/jsm/physics/JoltPhysics.js +7 -5
  60. package/examples/jsm/physics/RapierPhysics.js +6 -4
  61. package/examples/jsm/postprocessing/EffectComposer.js +7 -5
  62. package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
  63. package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
  64. package/examples/jsm/renderers/SVGRenderer.js +2 -2
  65. package/examples/jsm/shaders/GTAOShader.js +19 -6
  66. package/examples/jsm/shaders/HalftoneShader.js +12 -1
  67. package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
  68. package/examples/jsm/shaders/SAOShader.js +17 -4
  69. package/examples/jsm/shaders/SSAOShader.js +11 -1
  70. package/examples/jsm/shaders/SSRShader.js +6 -5
  71. package/examples/jsm/shaders/VignetteShader.js +1 -1
  72. package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
  73. package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
  74. package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
  75. package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
  76. package/examples/jsm/tsl/display/BloomNode.js +5 -5
  77. package/examples/jsm/tsl/display/CRT.js +150 -0
  78. package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
  79. package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
  80. package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
  81. package/examples/jsm/tsl/display/FXAANode.js +2 -2
  82. package/examples/jsm/tsl/display/GTAONode.js +2 -2
  83. package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
  84. package/examples/jsm/tsl/display/GodraysNode.js +624 -0
  85. package/examples/jsm/tsl/display/LensflareNode.js +1 -1
  86. package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
  87. package/examples/jsm/tsl/display/OutlineNode.js +3 -3
  88. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
  89. package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
  90. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
  91. package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
  92. package/examples/jsm/tsl/display/SMAANode.js +2 -2
  93. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  94. package/examples/jsm/tsl/display/SSGINode.js +2 -2
  95. package/examples/jsm/tsl/display/SSRNode.js +7 -7
  96. package/examples/jsm/tsl/display/SSSNode.js +2 -2
  97. package/examples/jsm/tsl/display/Shape.js +29 -0
  98. package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
  99. package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
  100. package/examples/jsm/tsl/display/TRAANode.js +9 -12
  101. package/examples/jsm/tsl/display/TransitionNode.js +1 -1
  102. package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
  103. package/examples/jsm/tsl/math/Bayer.js +40 -1
  104. package/examples/jsm/utils/LDrawUtils.js +1 -1
  105. package/package.json +11 -19
  106. package/src/Three.Core.js +1 -1
  107. package/src/Three.TSL.js +5 -9
  108. package/src/Three.WebGPU.Nodes.js +2 -0
  109. package/src/Three.WebGPU.js +3 -0
  110. package/src/Three.js +1 -0
  111. package/src/animation/AnimationAction.js +1 -1
  112. package/src/animation/AnimationClip.js +1 -1
  113. package/src/animation/AnimationMixer.js +6 -0
  114. package/src/animation/KeyframeTrack.js +46 -7
  115. package/src/animation/PropertyMixer.js +4 -4
  116. package/src/audio/Audio.js +1 -1
  117. package/src/audio/AudioListener.js +5 -3
  118. package/src/cameras/Camera.js +32 -2
  119. package/src/cameras/CubeCamera.js +20 -0
  120. package/src/constants.js +30 -1
  121. package/src/core/Clock.js +7 -0
  122. package/src/core/Object3D.js +56 -4
  123. package/src/core/RenderTarget.js +3 -4
  124. package/src/extras/PMREMGenerator.js +4 -8
  125. package/src/geometries/TorusGeometry.js +8 -3
  126. package/src/helpers/CameraHelper.js +3 -0
  127. package/src/helpers/DirectionalLightHelper.js +4 -1
  128. package/src/helpers/HemisphereLightHelper.js +3 -0
  129. package/src/helpers/PointLightHelper.js +0 -24
  130. package/src/helpers/SpotLightHelper.js +3 -0
  131. package/src/lights/LightShadow.js +15 -3
  132. package/src/lights/webgpu/IESSpotLight.js +2 -1
  133. package/src/loaders/Cache.js +28 -0
  134. package/src/loaders/FileLoader.js +1 -1
  135. package/src/loaders/ImageBitmapLoader.js +8 -3
  136. package/src/loaders/Loader.js +6 -0
  137. package/src/loaders/ObjectLoader.js +18 -1
  138. package/src/materials/MeshLambertMaterial.js +9 -0
  139. package/src/materials/MeshPhongMaterial.js +9 -0
  140. package/src/materials/nodes/Line2NodeMaterial.js +5 -5
  141. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
  142. package/src/materials/nodes/NodeMaterial.js +15 -24
  143. package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
  144. package/src/math/Line3.js +3 -5
  145. package/src/math/MathUtils.js +10 -10
  146. package/src/math/Matrix4.js +35 -26
  147. package/src/math/Quaternion.js +3 -29
  148. package/src/math/Vector3.js +3 -3
  149. package/src/math/interpolants/BezierInterpolant.js +108 -0
  150. package/src/nodes/Nodes.js +87 -68
  151. package/src/nodes/TSL.js +2 -5
  152. package/src/nodes/accessors/Arrays.js +1 -1
  153. package/src/nodes/accessors/Bitangent.js +5 -5
  154. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  155. package/src/nodes/accessors/Camera.js +149 -28
  156. package/src/nodes/accessors/InstanceNode.js +105 -40
  157. package/src/nodes/accessors/Normal.js +9 -9
  158. package/src/nodes/accessors/Position.js +34 -2
  159. package/src/nodes/accessors/SceneProperties.js +53 -0
  160. package/src/nodes/accessors/SkinningNode.js +12 -24
  161. package/src/nodes/accessors/StorageBufferNode.js +0 -19
  162. package/src/nodes/accessors/StorageTextureNode.js +37 -1
  163. package/src/nodes/accessors/Tangent.js +3 -3
  164. package/src/nodes/accessors/Texture3DNode.js +6 -34
  165. package/src/nodes/accessors/TextureNode.js +58 -22
  166. package/src/nodes/accessors/UniformArrayNode.js +2 -0
  167. package/src/nodes/core/MRTNode.js +48 -2
  168. package/src/nodes/core/Node.js +29 -3
  169. package/src/nodes/core/NodeBuilder.js +115 -40
  170. package/src/nodes/core/NodeError.js +28 -0
  171. package/src/nodes/core/NodeUtils.js +5 -3
  172. package/src/nodes/core/OutputStructNode.js +12 -10
  173. package/src/nodes/core/ParameterNode.js +2 -1
  174. package/src/nodes/core/StackNode.js +9 -8
  175. package/src/nodes/core/StackTrace.js +139 -0
  176. package/src/nodes/core/StructNode.js +15 -0
  177. package/src/nodes/core/SubBuildNode.js +1 -1
  178. package/src/nodes/core/UniformNode.js +2 -1
  179. package/src/nodes/core/VarNode.js +1 -1
  180. package/src/nodes/core/VaryingNode.js +1 -18
  181. package/src/nodes/display/BlendModes.js +0 -64
  182. package/src/nodes/display/ColorAdjustment.js +17 -0
  183. package/src/nodes/display/ColorSpaceNode.js +3 -3
  184. package/src/nodes/display/NormalMapNode.js +2 -2
  185. package/src/nodes/display/PassNode.js +21 -2
  186. package/src/nodes/display/RenderOutputNode.js +3 -3
  187. package/src/nodes/display/ScreenNode.js +2 -1
  188. package/src/nodes/display/ToneMappingNode.js +1 -1
  189. package/src/nodes/display/ToonOutlinePassNode.js +2 -2
  190. package/src/nodes/display/ViewportDepthNode.js +52 -4
  191. package/src/nodes/display/ViewportTextureNode.js +21 -4
  192. package/src/nodes/fog/Fog.js +18 -35
  193. package/src/nodes/functions/PhysicalLightingModel.js +25 -3
  194. package/src/nodes/geometry/RangeNode.js +4 -2
  195. package/src/nodes/gpgpu/ComputeNode.js +5 -4
  196. package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
  197. package/src/nodes/lighting/EnvironmentNode.js +28 -3
  198. package/src/nodes/lighting/PointShadowNode.js +24 -12
  199. package/src/nodes/lighting/ShadowFilterNode.js +15 -43
  200. package/src/nodes/lighting/ShadowNode.js +54 -32
  201. package/src/nodes/math/ConditionalNode.js +2 -2
  202. package/src/nodes/math/MathNode.js +3 -40
  203. package/src/nodes/math/OperatorNode.js +2 -1
  204. package/src/nodes/pmrem/PMREMUtils.js +9 -15
  205. package/src/nodes/tsl/TSLCore.js +13 -10
  206. package/src/nodes/utils/DebugNode.js +11 -11
  207. package/src/nodes/utils/JoinNode.js +2 -2
  208. package/src/nodes/utils/LoopNode.js +1 -1
  209. package/src/nodes/utils/MemberNode.js +1 -1
  210. package/src/nodes/utils/RTTNode.js +1 -1
  211. package/src/nodes/utils/ReflectorNode.js +2 -3
  212. package/src/nodes/utils/SpriteSheetUV.js +35 -0
  213. package/src/nodes/utils/UVUtils.js +4 -2
  214. package/src/objects/BatchedMesh.js +22 -12
  215. package/src/objects/InstancedMesh.js +11 -0
  216. package/src/renderers/WebGLRenderer.js +34 -60
  217. package/src/renderers/common/Backend.js +21 -0
  218. package/src/renderers/common/Background.js +7 -4
  219. package/src/renderers/common/BindGroup.js +1 -9
  220. package/src/renderers/common/Bindings.js +20 -5
  221. package/src/renderers/common/BlendMode.js +143 -0
  222. package/src/renderers/common/BundleGroup.js +1 -1
  223. package/src/renderers/common/CubeRenderTarget.js +50 -6
  224. package/src/renderers/common/Geometries.js +17 -3
  225. package/src/renderers/common/Lighting.js +5 -21
  226. package/src/renderers/common/Pipelines.js +4 -4
  227. package/src/renderers/common/PostProcessing.js +8 -206
  228. package/src/renderers/common/RenderBundles.js +2 -1
  229. package/src/renderers/common/RenderContext.js +16 -0
  230. package/src/renderers/common/RenderContexts.js +33 -56
  231. package/src/renderers/common/RenderLists.js +2 -1
  232. package/src/renderers/common/RenderObject.js +2 -3
  233. package/src/renderers/common/RenderObjectPipeline.js +40 -0
  234. package/src/renderers/common/RenderObjects.js +18 -2
  235. package/src/renderers/common/RenderPipeline.js +203 -17
  236. package/src/renderers/common/Renderer.js +207 -40
  237. package/src/renderers/common/Sampler.js +4 -4
  238. package/src/renderers/common/StorageBuffer.js +13 -1
  239. package/src/renderers/common/Textures.js +16 -0
  240. package/src/renderers/common/TimestampQueryPool.js +5 -3
  241. package/src/renderers/common/Uniform.js +8 -0
  242. package/src/renderers/common/UniformsGroup.js +60 -0
  243. package/src/renderers/common/XRManager.js +2 -2
  244. package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
  245. package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
  246. package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
  247. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
  248. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
  249. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
  250. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
  251. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
  252. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
  253. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
  254. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
  255. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
  256. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
  257. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
  258. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
  259. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
  260. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  261. package/src/renderers/shaders/ShaderLib.js +4 -2
  262. package/src/renderers/shaders/UniformsLib.js +0 -3
  263. package/src/renderers/webgl/WebGLBackground.js +2 -2
  264. package/src/renderers/webgl/WebGLBindingStates.js +99 -27
  265. package/src/renderers/webgl/WebGLEnvironments.js +228 -0
  266. package/src/renderers/webgl/WebGLGeometries.js +10 -7
  267. package/src/renderers/webgl/WebGLMaterials.js +12 -0
  268. package/src/renderers/webgl/WebGLObjects.js +3 -1
  269. package/src/renderers/webgl/WebGLProgram.js +2 -2
  270. package/src/renderers/webgl/WebGLPrograms.js +10 -4
  271. package/src/renderers/webgl/WebGLRenderLists.js +15 -0
  272. package/src/renderers/webgl/WebGLShadowMap.js +5 -4
  273. package/src/renderers/webgl/WebGLState.js +12 -17
  274. package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
  275. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
  276. package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
  277. package/src/renderers/webgpu/WebGPUBackend.js +58 -9
  278. package/src/renderers/webgpu/WebGPURenderer.js +1 -0
  279. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
  280. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
  281. package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
  282. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
  283. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
  284. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
  285. package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
  286. package/src/renderers/webxr/WebXRManager.js +2 -2
  287. package/src/textures/Texture.js +2 -2
  288. package/src/utils.js +246 -3
  289. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
  290. package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
  291. package/examples/jsm/shaders/GodRaysShader.js +0 -333
  292. package/src/nodes/accessors/SceneNode.js +0 -145
  293. package/src/nodes/code/ScriptableNode.js +0 -726
  294. package/src/nodes/code/ScriptableValueNode.js +0 -253
  295. package/src/nodes/display/PosterizeNode.js +0 -65
  296. package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
  297. package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
  298. package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
@@ -1,253 +0,0 @@
1
- import Node from '../core/Node.js';
2
- import { arrayBufferToBase64, base64ToArrayBuffer } from '../core/NodeUtils.js';
3
- import { nodeProxy, float } from '../tsl/TSLBase.js';
4
-
5
- import { EventDispatcher } from '../../core/EventDispatcher.js';
6
-
7
- /**
8
- * `ScriptableNode` uses this class to manage script inputs and outputs.
9
- *
10
- * @augments Node
11
- */
12
- class ScriptableValueNode extends Node {
13
-
14
- static get type() {
15
-
16
- return 'ScriptableValueNode';
17
-
18
- }
19
-
20
- /**
21
- * Constructs a new scriptable node.
22
- *
23
- * @param {any} [value=null] - The value.
24
- */
25
- constructor( value = null ) {
26
-
27
- super();
28
-
29
- /**
30
- * A reference to the value.
31
- *
32
- * @private
33
- * @default null
34
- */
35
- this._value = value;
36
-
37
- /**
38
- * Depending on the type of `_value`, this property might cache parsed data.
39
- *
40
- * @private
41
- * @default null
42
- */
43
- this._cache = null;
44
-
45
- /**
46
- * If this node represents an input, this property represents the input type.
47
- *
48
- * @type {?string}
49
- * @default null
50
- */
51
- this.inputType = null;
52
-
53
- /**
54
- * If this node represents an output, this property represents the output type.
55
- *
56
- * @type {?string}
57
- * @default null
58
- */
59
- this.outputType = null;
60
-
61
- /**
62
- * An event dispatcher for managing events.
63
- *
64
- * @type {EventDispatcher}
65
- */
66
- this.events = new EventDispatcher();
67
-
68
- /**
69
- * This flag can be used for type testing.
70
- *
71
- * @type {boolean}
72
- * @readonly
73
- * @default true
74
- */
75
- this.isScriptableValueNode = true;
76
-
77
- }
78
-
79
- /**
80
- * Whether this node represents an output or not.
81
- *
82
- * @type {boolean}
83
- * @readonly
84
- * @default true
85
- */
86
- get isScriptableOutputNode() {
87
-
88
- return this.outputType !== null;
89
-
90
- }
91
-
92
- set value( val ) {
93
-
94
- if ( this._value === val ) return;
95
-
96
- if ( this._cache && this.inputType === 'URL' && this.value.value instanceof ArrayBuffer ) {
97
-
98
- URL.revokeObjectURL( this._cache );
99
-
100
- this._cache = null;
101
-
102
- }
103
-
104
- this._value = val;
105
-
106
- this.events.dispatchEvent( { type: 'change' } );
107
-
108
- this.refresh();
109
-
110
- }
111
-
112
- /**
113
- * The node's value.
114
- *
115
- * @type {any}
116
- */
117
- get value() {
118
-
119
- return this._value;
120
-
121
- }
122
-
123
- /**
124
- * Dispatches the `refresh` event.
125
- */
126
- refresh() {
127
-
128
- this.events.dispatchEvent( { type: 'refresh' } );
129
-
130
- }
131
-
132
- /**
133
- * The `value` property usually represents a node or even binary data in form of array buffers.
134
- * In this case, this method tries to return the actual value behind the complex type.
135
- *
136
- * @return {any} The value.
137
- */
138
- getValue() {
139
-
140
- const value = this.value;
141
-
142
- if ( value && this._cache === null && this.inputType === 'URL' && value.value instanceof ArrayBuffer ) {
143
-
144
- this._cache = URL.createObjectURL( new Blob( [ value.value ] ) );
145
-
146
- } else if ( value && value.value !== null && value.value !== undefined && (
147
- ( ( this.inputType === 'URL' || this.inputType === 'String' ) && typeof value.value === 'string' ) ||
148
- ( this.inputType === 'Number' && typeof value.value === 'number' ) ||
149
- ( this.inputType === 'Vector2' && value.value.isVector2 ) ||
150
- ( this.inputType === 'Vector3' && value.value.isVector3 ) ||
151
- ( this.inputType === 'Vector4' && value.value.isVector4 ) ||
152
- ( this.inputType === 'Color' && value.value.isColor ) ||
153
- ( this.inputType === 'Matrix3' && value.value.isMatrix3 ) ||
154
- ( this.inputType === 'Matrix4' && value.value.isMatrix4 )
155
- ) ) {
156
-
157
- return value.value;
158
-
159
- }
160
-
161
- return this._cache || value;
162
-
163
- }
164
-
165
- /**
166
- * Overwritten since the node type is inferred from the value.
167
- *
168
- * @param {NodeBuilder} builder - The current node builder.
169
- * @return {string} The node type.
170
- */
171
- getNodeType( builder ) {
172
-
173
- return this.value && this.value.isNode ? this.value.getNodeType( builder ) : 'float';
174
-
175
- }
176
-
177
- setup() {
178
-
179
- return this.value && this.value.isNode ? this.value : float();
180
-
181
- }
182
-
183
- serialize( data ) {
184
-
185
- super.serialize( data );
186
-
187
- if ( this.value !== null ) {
188
-
189
- if ( this.inputType === 'ArrayBuffer' ) {
190
-
191
- data.value = arrayBufferToBase64( this.value );
192
-
193
- } else {
194
-
195
- data.value = this.value ? this.value.toJSON( data.meta ).uuid : null;
196
-
197
- }
198
-
199
- } else {
200
-
201
- data.value = null;
202
-
203
- }
204
-
205
- data.inputType = this.inputType;
206
- data.outputType = this.outputType;
207
-
208
- }
209
-
210
- deserialize( data ) {
211
-
212
- super.deserialize( data );
213
-
214
- let value = null;
215
-
216
- if ( data.value !== null ) {
217
-
218
- if ( data.inputType === 'ArrayBuffer' ) {
219
-
220
- value = base64ToArrayBuffer( data.value );
221
-
222
- } else if ( data.inputType === 'Texture' ) {
223
-
224
- value = data.meta.textures[ data.value ];
225
-
226
- } else {
227
-
228
- value = data.meta.nodes[ data.value ] || null;
229
-
230
- }
231
-
232
- }
233
-
234
- this.value = value;
235
-
236
- this.inputType = data.inputType;
237
- this.outputType = data.outputType;
238
-
239
- }
240
-
241
- }
242
-
243
- export default ScriptableValueNode;
244
-
245
- /**
246
- * TSL function for creating a scriptable value node.
247
- *
248
- * @tsl
249
- * @function
250
- * @param {any} [value] - The value.
251
- * @returns {ScriptableValueNode}
252
- */
253
- export const scriptableValue = /*@__PURE__*/ nodeProxy( ScriptableValueNode ).setParameterLength( 1 );
@@ -1,65 +0,0 @@
1
- import TempNode from '../core/TempNode.js';
2
- import { nodeProxy } from '../tsl/TSLBase.js';
3
-
4
- /**
5
- * Represents a posterize effect which reduces the number of colors
6
- * in an image, resulting in a more blocky and stylized appearance.
7
- *
8
- * @augments TempNode
9
- */
10
- class PosterizeNode extends TempNode {
11
-
12
- static get type() {
13
-
14
- return 'PosterizeNode';
15
-
16
- }
17
-
18
- /**
19
- * Constructs a new posterize node.
20
- *
21
- * @param {Node} sourceNode - The input color.
22
- * @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
23
- */
24
- constructor( sourceNode, stepsNode ) {
25
-
26
- super();
27
-
28
- /**
29
- * The input color.
30
- *
31
- * @type {Node}
32
- */
33
- this.sourceNode = sourceNode;
34
-
35
- /**
36
- * Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
37
- *
38
- * @type {Node}
39
- */
40
- this.stepsNode = stepsNode;
41
-
42
- }
43
-
44
- setup() {
45
-
46
- const { sourceNode, stepsNode } = this;
47
-
48
- return sourceNode.mul( stepsNode ).floor().div( stepsNode );
49
-
50
- }
51
-
52
- }
53
-
54
- export default PosterizeNode;
55
-
56
- /**
57
- * TSL function for creating a posterize node.
58
- *
59
- * @tsl
60
- * @function
61
- * @param {Node} sourceNode - The input color.
62
- * @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
63
- * @returns {PosterizeNode}
64
- */
65
- export const posterize = /*@__PURE__*/ nodeProxy( PosterizeNode ).setParameterLength( 2 );
@@ -1,90 +0,0 @@
1
- import Node from '../core/Node.js';
2
- import { uv } from '../accessors/UV.js';
3
- import { nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
4
-
5
- /**
6
- * Can be used to compute texture coordinates for animated sprite sheets.
7
- *
8
- * ```js
9
- * const uvNode = spritesheetUV( vec2( 6, 6 ), uv(), time.mul( animationSpeed ) );
10
- *
11
- * material.colorNode = texture( spriteSheet, uvNode );
12
- * ```
13
- *
14
- * @augments Node
15
- */
16
- class SpriteSheetUVNode extends Node {
17
-
18
- static get type() {
19
-
20
- return 'SpriteSheetUVNode';
21
-
22
- }
23
-
24
- /**
25
- * Constructs a new sprite sheet uv node.
26
- *
27
- * @param {Node<vec2>} countNode - The node that defines the number of sprites in the x and y direction (e.g 6x6).
28
- * @param {Node<vec2>} [uvNode=uv()] - The uv node.
29
- * @param {Node<float>} [frameNode=float()] - The node that defines the current frame/sprite.
30
- */
31
- constructor( countNode, uvNode = uv(), frameNode = float( 0 ) ) {
32
-
33
- super( 'vec2' );
34
-
35
- /**
36
- * The node that defines the number of sprites in the x and y direction (e.g 6x6).
37
- *
38
- * @type {Node<vec2>}
39
- */
40
- this.countNode = countNode;
41
-
42
- /**
43
- * The uv node.
44
- *
45
- * @type {Node<vec2>}
46
- */
47
- this.uvNode = uvNode;
48
-
49
- /**
50
- * The node that defines the current frame/sprite.
51
- *
52
- * @type {Node<float>}
53
- */
54
- this.frameNode = frameNode;
55
-
56
- }
57
-
58
- setup() {
59
-
60
- const { frameNode, uvNode, countNode } = this;
61
-
62
- const { width, height } = countNode;
63
-
64
- const frameNum = frameNode.mod( width.mul( height ) ).floor();
65
-
66
- const column = frameNum.mod( width );
67
- const row = height.sub( frameNum.add( 1 ).div( width ).ceil() );
68
-
69
- const scale = countNode.reciprocal();
70
- const uvFrameOffset = vec2( column, row );
71
-
72
- return uvNode.add( uvFrameOffset ).mul( scale );
73
-
74
- }
75
-
76
- }
77
-
78
- export default SpriteSheetUVNode;
79
-
80
- /**
81
- * TSL function for creating a sprite sheet uv node.
82
- *
83
- * @tsl
84
- * @function
85
- * @param {Node<vec2>} countNode - The node that defines the number of sprites in the x and y direction (e.g 6x6).
86
- * @param {?Node<vec2>} [uvNode=uv()] - The uv node.
87
- * @param {?Node<float>} [frameNode=float()] - The node that defines the current frame/sprite.
88
- * @returns {SpriteSheetUVNode}
89
- */
90
- export const spritesheetUV = /*@__PURE__*/ nodeProxy( SpriteSheetUVNode ).setParameterLength( 3 );
@@ -1,99 +0,0 @@
1
- import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js';
2
- import { WebGLCubeRenderTarget } from '../WebGLCubeRenderTarget.js';
3
-
4
- function WebGLCubeMaps( renderer ) {
5
-
6
- let cubemaps = new WeakMap();
7
-
8
- function mapTextureMapping( texture, mapping ) {
9
-
10
- if ( mapping === EquirectangularReflectionMapping ) {
11
-
12
- texture.mapping = CubeReflectionMapping;
13
-
14
- } else if ( mapping === EquirectangularRefractionMapping ) {
15
-
16
- texture.mapping = CubeRefractionMapping;
17
-
18
- }
19
-
20
- return texture;
21
-
22
- }
23
-
24
- function get( texture ) {
25
-
26
- if ( texture && texture.isTexture ) {
27
-
28
- const mapping = texture.mapping;
29
-
30
- if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) {
31
-
32
- if ( cubemaps.has( texture ) ) {
33
-
34
- const cubemap = cubemaps.get( texture ).texture;
35
- return mapTextureMapping( cubemap, texture.mapping );
36
-
37
- } else {
38
-
39
- const image = texture.image;
40
-
41
- if ( image && image.height > 0 ) {
42
-
43
- const renderTarget = new WebGLCubeRenderTarget( image.height );
44
- renderTarget.fromEquirectangularTexture( renderer, texture );
45
- cubemaps.set( texture, renderTarget );
46
-
47
- texture.addEventListener( 'dispose', onTextureDispose );
48
-
49
- return mapTextureMapping( renderTarget.texture, texture.mapping );
50
-
51
- } else {
52
-
53
- // image not yet ready. try the conversion next frame
54
-
55
- return null;
56
-
57
- }
58
-
59
- }
60
-
61
- }
62
-
63
- }
64
-
65
- return texture;
66
-
67
- }
68
-
69
- function onTextureDispose( event ) {
70
-
71
- const texture = event.target;
72
-
73
- texture.removeEventListener( 'dispose', onTextureDispose );
74
-
75
- const cubemap = cubemaps.get( texture );
76
-
77
- if ( cubemap !== undefined ) {
78
-
79
- cubemaps.delete( texture );
80
- cubemap.dispose();
81
-
82
- }
83
-
84
- }
85
-
86
- function dispose() {
87
-
88
- cubemaps = new WeakMap();
89
-
90
- }
91
-
92
- return {
93
- get: get,
94
- dispose: dispose
95
- };
96
-
97
- }
98
-
99
- export { WebGLCubeMaps };
@@ -1,134 +0,0 @@
1
- import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js';
2
- import { PMREMGenerator } from '../../extras/PMREMGenerator.js';
3
-
4
- function WebGLCubeUVMaps( renderer ) {
5
-
6
- let cubeUVmaps = new WeakMap();
7
-
8
- let pmremGenerator = null;
9
-
10
- function get( texture ) {
11
-
12
- if ( texture && texture.isTexture ) {
13
-
14
- const mapping = texture.mapping;
15
-
16
- const isEquirectMap = ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping );
17
- const isCubeMap = ( mapping === CubeReflectionMapping || mapping === CubeRefractionMapping );
18
-
19
- // equirect/cube map to cubeUV conversion
20
-
21
- if ( isEquirectMap || isCubeMap ) {
22
-
23
- let renderTarget = cubeUVmaps.get( texture );
24
-
25
- const currentPMREMVersion = renderTarget !== undefined ? renderTarget.texture.pmremVersion : 0;
26
-
27
- if ( texture.isRenderTargetTexture && texture.pmremVersion !== currentPMREMVersion ) {
28
-
29
- if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
30
-
31
- renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture, renderTarget ) : pmremGenerator.fromCubemap( texture, renderTarget );
32
- renderTarget.texture.pmremVersion = texture.pmremVersion;
33
-
34
- cubeUVmaps.set( texture, renderTarget );
35
-
36
- return renderTarget.texture;
37
-
38
- } else {
39
-
40
- if ( renderTarget !== undefined ) {
41
-
42
- return renderTarget.texture;
43
-
44
- } else {
45
-
46
- const image = texture.image;
47
-
48
- if ( ( isEquirectMap && image && image.height > 0 ) || ( isCubeMap && image && isCubeTextureComplete( image ) ) ) {
49
-
50
- if ( pmremGenerator === null ) pmremGenerator = new PMREMGenerator( renderer );
51
-
52
- renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular( texture ) : pmremGenerator.fromCubemap( texture );
53
- renderTarget.texture.pmremVersion = texture.pmremVersion;
54
-
55
- cubeUVmaps.set( texture, renderTarget );
56
-
57
- texture.addEventListener( 'dispose', onTextureDispose );
58
-
59
- return renderTarget.texture;
60
-
61
- } else {
62
-
63
- // image not yet ready. try the conversion next frame
64
-
65
- return null;
66
-
67
- }
68
-
69
- }
70
-
71
- }
72
-
73
- }
74
-
75
- }
76
-
77
- return texture;
78
-
79
- }
80
-
81
- function isCubeTextureComplete( image ) {
82
-
83
- let count = 0;
84
- const length = 6;
85
-
86
- for ( let i = 0; i < length; i ++ ) {
87
-
88
- if ( image[ i ] !== undefined ) count ++;
89
-
90
- }
91
-
92
- return count === length;
93
-
94
-
95
- }
96
-
97
- function onTextureDispose( event ) {
98
-
99
- const texture = event.target;
100
-
101
- texture.removeEventListener( 'dispose', onTextureDispose );
102
-
103
- const cubemapUV = cubeUVmaps.get( texture );
104
-
105
- if ( cubemapUV !== undefined ) {
106
-
107
- cubeUVmaps.delete( texture );
108
- cubemapUV.dispose();
109
-
110
- }
111
-
112
- }
113
-
114
- function dispose() {
115
-
116
- cubeUVmaps = new WeakMap();
117
-
118
- if ( pmremGenerator !== null ) {
119
-
120
- pmremGenerator.dispose();
121
- pmremGenerator = null;
122
-
123
- }
124
-
125
- }
126
-
127
- return {
128
- get: get,
129
- dispose: dispose
130
- };
131
-
132
- }
133
-
134
- export { WebGLCubeUVMaps };