super-three 0.177.0 → 0.179.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 (211) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +959 -231
  3. package/build/three.core.js +751 -170
  4. package/build/three.core.min.js +1 -1
  5. package/build/three.module.js +210 -64
  6. package/build/three.module.min.js +1 -1
  7. package/build/three.tsl.js +78 -29
  8. package/build/three.tsl.min.js +1 -1
  9. package/build/three.webgpu.js +3269 -1545
  10. package/build/three.webgpu.min.js +1 -1
  11. package/build/three.webgpu.nodes.js +3093 -1545
  12. package/build/three.webgpu.nodes.min.js +1 -1
  13. package/examples/jsm/Addons.js +1 -2
  14. package/examples/jsm/capabilities/WebGL.js +0 -27
  15. package/examples/jsm/capabilities/WebGPU.js +1 -1
  16. package/examples/jsm/controls/ArcballControls.js +1 -1
  17. package/examples/jsm/controls/TransformControls.js +61 -14
  18. package/examples/jsm/csm/CSMShadowNode.js +4 -4
  19. package/examples/jsm/environments/RoomEnvironment.js +8 -3
  20. package/examples/jsm/exporters/USDZExporter.js +676 -299
  21. package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
  22. package/examples/jsm/interactive/HTMLMesh.js +5 -3
  23. package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
  24. package/examples/jsm/lights/LightProbeGenerator.js +14 -3
  25. package/examples/jsm/loaders/ColladaLoader.js +1 -1
  26. package/examples/jsm/loaders/EXRLoader.js +210 -22
  27. package/examples/jsm/loaders/FBXLoader.js +2 -2
  28. package/examples/jsm/loaders/MaterialXLoader.js +212 -30
  29. package/examples/jsm/loaders/TTFLoader.js +13 -1
  30. package/examples/jsm/loaders/USDLoader.js +219 -0
  31. package/examples/jsm/loaders/USDZLoader.js +4 -892
  32. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  33. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  34. package/examples/jsm/objects/LensflareMesh.js +3 -3
  35. package/examples/jsm/objects/SkyMesh.js +2 -2
  36. package/examples/jsm/physics/RapierPhysics.js +95 -16
  37. package/examples/jsm/postprocessing/GTAOPass.js +10 -9
  38. package/examples/jsm/postprocessing/OutlinePass.js +17 -17
  39. package/examples/jsm/postprocessing/SSAOPass.js +10 -9
  40. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
  41. package/examples/jsm/transpiler/AST.js +381 -30
  42. package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
  43. package/examples/jsm/transpiler/Linker.js +327 -0
  44. package/examples/jsm/transpiler/TSLEncoder.js +197 -92
  45. package/examples/jsm/transpiler/Transpiler.js +17 -1
  46. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  47. package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
  48. package/examples/jsm/tsl/display/BloomNode.js +8 -7
  49. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
  50. package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
  51. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  52. package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
  53. package/examples/jsm/tsl/display/hashBlur.js +3 -3
  54. package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
  55. package/package.json +1 -1
  56. package/src/Three.Core.js +1 -0
  57. package/src/Three.TSL.js +77 -28
  58. package/src/Three.WebGPU.js +2 -0
  59. package/src/animation/KeyframeTrack.js +1 -1
  60. package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
  61. package/src/animation/tracks/StringKeyframeTrack.js +1 -1
  62. package/src/cameras/Camera.js +14 -0
  63. package/src/cameras/OrthographicCamera.js +1 -1
  64. package/src/cameras/PerspectiveCamera.js +1 -1
  65. package/src/constants.js +3 -3
  66. package/src/core/BufferAttribute.js +3 -3
  67. package/src/core/Clock.js +2 -8
  68. package/src/core/GLBufferAttribute.js +13 -1
  69. package/src/core/Object3D.js +1 -1
  70. package/{examples/jsm/misc → src/core}/Timer.js +4 -42
  71. package/src/extras/PMREMGenerator.js +11 -0
  72. package/src/extras/core/Path.js +22 -22
  73. package/src/helpers/CameraHelper.js +41 -11
  74. package/src/helpers/SkeletonHelper.js +35 -6
  75. package/src/lights/LightShadow.js +21 -8
  76. package/src/lights/PointLightShadow.js +1 -1
  77. package/src/loaders/FileLoader.js +27 -4
  78. package/src/loaders/ImageBitmapLoader.js +27 -4
  79. package/src/loaders/ImageLoader.js +55 -8
  80. package/src/loaders/Loader.js +14 -0
  81. package/src/loaders/LoadingManager.js +23 -0
  82. package/src/materials/MeshBasicMaterial.js +1 -1
  83. package/src/materials/nodes/Line2NodeMaterial.js +0 -8
  84. package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
  85. package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
  86. package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
  87. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
  88. package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
  89. package/src/materials/nodes/NodeMaterial.js +28 -5
  90. package/src/materials/nodes/PointsNodeMaterial.js +5 -0
  91. package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
  92. package/src/math/Frustum.js +25 -9
  93. package/src/math/FrustumArray.js +10 -5
  94. package/src/math/Line3.js +129 -2
  95. package/src/math/Matrix4.js +48 -27
  96. package/src/math/Quaternion.js +1 -1
  97. package/src/math/Spherical.js +2 -2
  98. package/src/nodes/Nodes.js +2 -3
  99. package/src/nodes/TSL.js +5 -3
  100. package/src/nodes/accessors/AccessorsUtils.js +7 -8
  101. package/src/nodes/accessors/Bitangent.js +31 -25
  102. package/src/nodes/accessors/Camera.js +12 -12
  103. package/src/nodes/accessors/Normal.js +95 -29
  104. package/src/nodes/accessors/Object3DNode.js +1 -1
  105. package/src/nodes/accessors/Position.js +7 -7
  106. package/src/nodes/accessors/ReferenceNode.js +18 -3
  107. package/src/nodes/accessors/ReflectVector.js +3 -3
  108. package/src/nodes/accessors/SceneNode.js +1 -1
  109. package/src/nodes/accessors/StorageTextureNode.js +1 -1
  110. package/src/nodes/accessors/Tangent.js +25 -17
  111. package/src/nodes/accessors/TangentUtils.js +46 -0
  112. package/src/nodes/accessors/TextureBicubic.js +21 -3
  113. package/src/nodes/accessors/TextureNode.js +12 -0
  114. package/src/nodes/accessors/UniformArrayNode.js +0 -16
  115. package/src/nodes/core/ArrayNode.js +12 -0
  116. package/src/nodes/core/AssignNode.js +3 -0
  117. package/src/nodes/core/CacheNode.js +0 -14
  118. package/src/nodes/core/ContextNode.js +20 -1
  119. package/src/nodes/core/Node.js +15 -3
  120. package/src/nodes/core/NodeBuilder.js +228 -92
  121. package/src/nodes/core/NodeUtils.js +4 -1
  122. package/src/nodes/core/StackNode.js +49 -29
  123. package/src/nodes/core/SubBuildNode.js +89 -0
  124. package/src/nodes/core/UniformNode.js +63 -5
  125. package/src/nodes/core/VarNode.js +91 -2
  126. package/src/nodes/core/VaryingNode.js +6 -4
  127. package/src/nodes/display/BlendModes.js +2 -2
  128. package/src/nodes/display/FrontFacingNode.js +34 -2
  129. package/src/nodes/display/NormalMapNode.js +19 -50
  130. package/src/nodes/display/PassNode.js +157 -9
  131. package/src/nodes/display/ScreenNode.js +0 -26
  132. package/src/nodes/display/ViewportTextureNode.js +67 -7
  133. package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
  134. package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
  135. package/src/nodes/functions/PhongLightingModel.js +3 -3
  136. package/src/nodes/functions/PhysicalLightingModel.js +16 -16
  137. package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
  138. package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
  139. package/src/nodes/gpgpu/ComputeNode.js +67 -23
  140. package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
  141. package/src/nodes/lighting/EnvironmentNode.js +5 -5
  142. package/src/nodes/lighting/LightsNode.js +4 -4
  143. package/src/nodes/lighting/ProjectorLightNode.js +19 -6
  144. package/src/nodes/lighting/ShadowFilterNode.js +1 -1
  145. package/src/nodes/lighting/ShadowNode.js +2 -2
  146. package/src/nodes/materialx/MaterialXNodes.js +131 -2
  147. package/src/nodes/materialx/lib/mx_noise.js +165 -1
  148. package/src/nodes/math/ConditionalNode.js +1 -20
  149. package/src/nodes/math/MathNode.js +90 -55
  150. package/src/nodes/math/OperatorNode.js +22 -39
  151. package/src/nodes/tsl/TSLBase.js +1 -0
  152. package/src/nodes/tsl/TSLCore.js +114 -55
  153. package/src/nodes/utils/DebugNode.js +1 -1
  154. package/src/nodes/utils/EquirectUV.js +27 -0
  155. package/src/nodes/utils/EventNode.js +83 -0
  156. package/src/nodes/utils/LoopNode.js +0 -17
  157. package/src/nodes/utils/MatcapUV.js +22 -0
  158. package/src/nodes/utils/RTTNode.js +22 -5
  159. package/src/nodes/utils/ReflectorNode.js +11 -4
  160. package/src/nodes/utils/SampleNode.js +81 -0
  161. package/src/nodes/utils/TriplanarTextures.js +65 -0
  162. package/src/objects/BatchedMesh.js +4 -2
  163. package/src/renderers/WebGLRenderer.js +26 -24
  164. package/src/renderers/common/Background.js +2 -2
  165. package/src/renderers/common/Bindings.js +19 -18
  166. package/src/renderers/common/Color4.js +2 -2
  167. package/src/renderers/common/CubeRenderTarget.js +1 -1
  168. package/src/renderers/common/PostProcessing.js +60 -5
  169. package/src/renderers/common/RenderObject.js +68 -3
  170. package/src/renderers/common/Renderer.js +19 -16
  171. package/src/renderers/common/SampledTexture.js +3 -71
  172. package/src/renderers/common/Sampler.js +79 -0
  173. package/src/renderers/common/Storage3DTexture.js +100 -0
  174. package/src/renderers/common/StorageArrayTexture.js +84 -0
  175. package/src/renderers/common/StorageTexture.js +19 -0
  176. package/src/renderers/common/Textures.js +19 -3
  177. package/src/renderers/common/XRManager.js +31 -12
  178. package/src/renderers/common/XRRenderTarget.js +21 -4
  179. package/src/renderers/common/extras/PMREMGenerator.js +1 -1
  180. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
  181. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
  182. package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
  183. package/src/renderers/webgl/WebGLAttributes.js +4 -0
  184. package/src/renderers/webgl/WebGLCapabilities.js +2 -2
  185. package/src/renderers/webgl/WebGLProgram.js +12 -6
  186. package/src/renderers/webgl/WebGLPrograms.js +6 -4
  187. package/src/renderers/webgl/WebGLShadowMap.js +11 -1
  188. package/src/renderers/webgl/WebGLState.js +4 -4
  189. package/src/renderers/webgl/WebGLTextures.js +19 -7
  190. package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
  191. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
  192. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
  193. package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
  194. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
  195. package/src/renderers/webgpu/WebGPUBackend.js +63 -16
  196. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
  197. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
  198. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
  199. package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
  200. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
  201. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
  202. package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
  203. package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
  204. package/src/renderers/webxr/WebXRManager.js +68 -6
  205. package/src/textures/ExternalTexture.js +45 -0
  206. package/src/textures/FramebufferTexture.js +2 -2
  207. package/src/textures/Source.js +11 -1
  208. package/src/textures/VideoTexture.js +30 -2
  209. package/src/nodes/utils/EquirectUVNode.js +0 -65
  210. package/src/nodes/utils/MatcapUVNode.js +0 -49
  211. package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
@@ -10,6 +10,7 @@ import { WebGLMultiviewRenderTarget } from '../WebGLMultiviewRenderTarget.js';
10
10
  import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
11
11
  import { WebXRController } from './WebXRController.js';
12
12
  import { DepthTexture } from '../../textures/DepthTexture.js';
13
+ import { ExternalTexture } from '../../textures/ExternalTexture.js';
13
14
  import { DepthFormat, DepthStencilFormat, RGBAFormat, UnsignedByteType, UnsignedIntType, UnsignedInt248Type } from '../../constants.js';
14
15
  import { WebXRDepthSensing } from './WebXRDepthSensing.js';
15
16
 
@@ -56,6 +57,7 @@ class WebXRManager extends EventDispatcher {
56
57
  let xrFrame = null;
57
58
 
58
59
  const depthSensing = new WebXRDepthSensing();
60
+ const cameraAccessTextures = {};
59
61
  const attributes = gl.getContextAttributes();
60
62
 
61
63
  let initialRenderTarget = null;
@@ -243,6 +245,11 @@ class WebXRManager extends EventDispatcher {
243
245
  _currentDepthFar = null;
244
246
 
245
247
  depthSensing.reset();
248
+ for ( const key in cameraAccessTextures ) {
249
+
250
+ delete cameraAccessTextures[ key ];
251
+
252
+ }
246
253
 
247
254
  // restore framebuffer/rendering state
248
255
 
@@ -415,9 +422,15 @@ class WebXRManager extends EventDispatcher {
415
422
  currentPixelRatio = renderer.getPixelRatio();
416
423
  renderer.getSize( currentSize );
417
424
 
425
+ if ( typeof XRWebGLBinding !== 'undefined' ) {
426
+
427
+ glBinding = new XRWebGLBinding( session, gl );
428
+
429
+ }
430
+
418
431
  // Check that the browser implements the necessary APIs to use an
419
432
  // XRProjectionLayer rather than an XRWebGLLayer
420
- const useLayers = typeof XRWebGLBinding !== 'undefined' && 'createProjectionLayer' in XRWebGLBinding.prototype;
433
+ const useLayers = glBinding !== null && 'createProjectionLayer' in XRWebGLBinding.prototype;
421
434
 
422
435
  if ( ! useLayers ) {
423
436
 
@@ -788,9 +801,10 @@ class WebXRManager extends EventDispatcher {
788
801
 
789
802
  }
790
803
 
791
- cameraL.layers.mask = camera.layers.mask | 0b010;
792
- cameraR.layers.mask = camera.layers.mask | 0b100;
793
- cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
804
+ // inherit camera layers and enable eye layers (1 = left, 2 = right)
805
+ cameraXR.layers.mask = camera.layers.mask | 0b110;
806
+ cameraL.layers.mask = cameraXR.layers.mask & 0b011;
807
+ cameraR.layers.mask = cameraXR.layers.mask & 0b101;
794
808
 
795
809
  const cameras = cameraXR.cameras;
796
810
  var object = poseTarget || camera;
@@ -872,7 +886,7 @@ class WebXRManager extends EventDispatcher {
872
886
  /**
873
887
  * Returns the amount of foveation used by the XR compositor for the projection layer.
874
888
  *
875
- * @return {number} The amount of foveation.
889
+ * @return {number|undefined} The amount of foveation.
876
890
  */
877
891
  this.getFoveation = function () {
878
892
 
@@ -935,6 +949,19 @@ class WebXRManager extends EventDispatcher {
935
949
 
936
950
  };
937
951
 
952
+ /**
953
+ * Retrieves an opaque texture from the view-aligned {@link XRCamera}.
954
+ * Only available during the current animation loop.
955
+ *
956
+ * @param {XRCamera} xrCamera - The camera to query.
957
+ * @return {?Texture} An opaque texture representing the current raw camera frame.
958
+ */
959
+ this.getCameraTexture = function ( xrCamera ) {
960
+
961
+ return cameraAccessTextures[ xrCamera ];
962
+
963
+ };
964
+
938
965
  // Animation Loop
939
966
 
940
967
  let onAnimationFrameCallback = null;
@@ -1040,7 +1067,42 @@ class WebXRManager extends EventDispatcher {
1040
1067
 
1041
1068
  if ( depthData && depthData.isValid && depthData.texture ) {
1042
1069
 
1043
- depthSensing.init( renderer, depthData, session.renderState );
1070
+ depthSensing.init( depthData, session.renderState );
1071
+
1072
+ }
1073
+
1074
+ }
1075
+
1076
+ const cameraAccessEnabled = enabledFeatures &&
1077
+ enabledFeatures.includes( 'camera-access' );
1078
+
1079
+ if ( cameraAccessEnabled ) {
1080
+
1081
+ renderer.state.unbindTexture();
1082
+
1083
+ if ( glBinding ) {
1084
+
1085
+ for ( let i = 0; i < views.length; i ++ ) {
1086
+
1087
+ const camera = views[ i ].camera;
1088
+
1089
+ if ( camera ) {
1090
+
1091
+ let cameraTex = cameraAccessTextures[ camera ];
1092
+
1093
+ if ( ! cameraTex ) {
1094
+
1095
+ cameraTex = new ExternalTexture();
1096
+ cameraAccessTextures[ camera ] = cameraTex;
1097
+
1098
+ }
1099
+
1100
+ const glTexture = glBinding.getCameraImage( camera );
1101
+ cameraTex.sourceTexture = glTexture;
1102
+
1103
+ }
1104
+
1105
+ }
1044
1106
 
1045
1107
  }
1046
1108
 
@@ -0,0 +1,45 @@
1
+ import { Texture } from './Texture.js';
2
+
3
+ /**
4
+ * Represents a texture created externally from the renderer context.
5
+ *
6
+ * This may be a texture from a protected media stream, device camera feed,
7
+ * or other data feeds like a depth sensor.
8
+ *
9
+ * Note that this class is only supported in {@link WebGLRenderer} right now.
10
+ *
11
+ * @augments Texture
12
+ */
13
+ class ExternalTexture extends Texture {
14
+
15
+ /**
16
+ * Creates a new raw texture.
17
+ *
18
+ * @param {?WebGLTexture} [sourceTexture=null] - The external texture.
19
+ */
20
+ constructor( sourceTexture = null ) {
21
+
22
+ super();
23
+
24
+ /**
25
+ * The external source texture.
26
+ *
27
+ * @type {?WebGLTexture}
28
+ * @default null
29
+ */
30
+ this.sourceTexture = sourceTexture;
31
+
32
+ /**
33
+ * This flag can be used for type testing.
34
+ *
35
+ * @type {boolean}
36
+ * @readonly
37
+ * @default true
38
+ */
39
+ this.isExternalTexture = true;
40
+
41
+ }
42
+
43
+ }
44
+
45
+ export { ExternalTexture };
@@ -30,8 +30,8 @@ class FramebufferTexture extends Texture {
30
30
  /**
31
31
  * Constructs a new framebuffer texture.
32
32
  *
33
- * @param {number} width - The width of the texture.
34
- * @param {number} height - The height of the texture.
33
+ * @param {number} [width] - The width of the texture.
34
+ * @param {number} [height] - The height of the texture.
35
35
  */
36
36
  constructor( width, height ) {
37
37
 
@@ -73,13 +73,23 @@ class Source {
73
73
 
74
74
  }
75
75
 
76
+ /**
77
+ * Returns the dimensions of the source into the given target vector.
78
+ *
79
+ * @param {(Vector2|Vector3)} target - The target object the result is written into.
80
+ * @return {(Vector2|Vector3)} The dimensions of the source.
81
+ */
76
82
  getSize( target ) {
77
83
 
78
84
  const data = this.data;
79
85
 
80
86
  if ( data instanceof HTMLVideoElement ) {
81
87
 
82
- target.set( data.videoWidth, data.videoHeight );
88
+ target.set( data.videoWidth, data.videoHeight, 0 );
89
+
90
+ } else if ( data instanceof VideoFrame ) {
91
+
92
+ target.set( data.displayHeight, data.displayWidth, 0 );
83
93
 
84
94
  } else if ( data !== null ) {
85
95
 
@@ -10,6 +10,9 @@ import { Texture } from './Texture.js';
10
10
  * const texture = new THREE.VideoTexture( video );
11
11
  * ```
12
12
  *
13
+ * Note: When using video textures with {@link WebGPURenderer}, {@link Texture#colorSpace} must be
14
+ * set to THREE.SRGBColorSpace.
15
+ *
13
16
  * Note: After the initial use of a texture, its dimensions, format, and type
14
17
  * cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.
15
18
  *
@@ -53,18 +56,28 @@ class VideoTexture extends Texture {
53
56
  */
54
57
  this.generateMipmaps = false;
55
58
 
59
+ /**
60
+ * The video frame request callback identifier, which is a positive integer.
61
+ *
62
+ * Value of 0 represents no scheduled rVFC.
63
+ *
64
+ * @private
65
+ * @type {number}
66
+ */
67
+ this._requestVideoFrameCallbackId = 0;
68
+
56
69
  const scope = this;
57
70
 
58
71
  function updateVideo() {
59
72
 
60
73
  scope.needsUpdate = true;
61
- video.requestVideoFrameCallback( updateVideo );
74
+ scope._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
62
75
 
63
76
  }
64
77
 
65
78
  if ( 'requestVideoFrameCallback' in video ) {
66
79
 
67
- video.requestVideoFrameCallback( updateVideo );
80
+ this._requestVideoFrameCallbackId = video.requestVideoFrameCallback( updateVideo );
68
81
 
69
82
  }
70
83
 
@@ -95,6 +108,21 @@ class VideoTexture extends Texture {
95
108
 
96
109
  }
97
110
 
111
+ /**
112
+ * @override
113
+ */
114
+ dispose() {
115
+
116
+ if ( this._requestVideoFrameCallbackId !== 0 ) {
117
+
118
+ this.source.data.cancelVideoFrameCallback( this._requestVideoFrameCallbackId );
119
+
120
+ }
121
+
122
+ super.dispose();
123
+
124
+ }
125
+
98
126
  }
99
127
 
100
128
  export { VideoTexture };
@@ -1,65 +0,0 @@
1
- import TempNode from '../core/TempNode.js';
2
- import { positionWorldDirection } from '../accessors/Position.js';
3
- import { nodeProxy, vec2 } from '../tsl/TSLBase.js';
4
-
5
- /**
6
- * Can be used to compute texture coordinates for projecting an
7
- * equirectangular texture onto a mesh for using it as the scene's
8
- * background.
9
- *
10
- * ```js
11
- * scene.backgroundNode = texture( equirectTexture, equirectUV() );
12
- * ```
13
- *
14
- * @augments TempNode
15
- */
16
- class EquirectUVNode extends TempNode {
17
-
18
- static get type() {
19
-
20
- return 'EquirectUVNode';
21
-
22
- }
23
-
24
- /**
25
- * Constructs a new equirect uv node.
26
- *
27
- * @param {Node<vec3>} [dirNode=positionWorldDirection] - A direction vector for sampling which is by default `positionWorldDirection`.
28
- */
29
- constructor( dirNode = positionWorldDirection ) {
30
-
31
- super( 'vec2' );
32
-
33
- /**
34
- * A direction vector for sampling why is by default `positionWorldDirection`.
35
- *
36
- * @type {Node<vec3>}
37
- */
38
- this.dirNode = dirNode;
39
-
40
- }
41
-
42
- setup() {
43
-
44
- const dir = this.dirNode;
45
-
46
- const u = dir.z.atan( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
47
- const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
48
-
49
- return vec2( u, v );
50
-
51
- }
52
-
53
- }
54
-
55
- export default EquirectUVNode;
56
-
57
- /**
58
- * TSL function for creating an equirect uv node.
59
- *
60
- * @tsl
61
- * @function
62
- * @param {?Node<vec3>} [dirNode=positionWorldDirection] - A direction vector for sampling which is by default `positionWorldDirection`.
63
- * @returns {EquirectUVNode}
64
- */
65
- export const equirectUV = /*@__PURE__*/ nodeProxy( EquirectUVNode ).setParameterLength( 0, 1 );
@@ -1,49 +0,0 @@
1
- import TempNode from '../core/TempNode.js';
2
- import { transformedNormalView } from '../accessors/Normal.js';
3
- import { positionViewDirection } from '../accessors/Position.js';
4
- import { nodeImmutable, vec2, vec3 } from '../tsl/TSLBase.js';
5
-
6
- /**
7
- * Can be used to compute texture coordinates for projecting a
8
- * matcap onto a mesh. Used by {@link MeshMatcapNodeMaterial}.
9
- *
10
- * @augments TempNode
11
- */
12
- class MatcapUVNode extends TempNode {
13
-
14
- static get type() {
15
-
16
- return 'MatcapUVNode';
17
-
18
- }
19
-
20
- /**
21
- * Constructs a new matcap uv node.
22
- */
23
- constructor() {
24
-
25
- super( 'vec2' );
26
-
27
- }
28
-
29
- setup() {
30
-
31
- const x = vec3( positionViewDirection.z, 0, positionViewDirection.x.negate() ).normalize();
32
- const y = positionViewDirection.cross( x );
33
-
34
- return vec2( x.dot( transformedNormalView ), y.dot( transformedNormalView ) ).mul( 0.495 ).add( 0.5 ); // 0.495 to remove artifacts caused by undersized matcap disks
35
-
36
- }
37
-
38
- }
39
-
40
- export default MatcapUVNode;
41
-
42
- /**
43
- * TSL function for creating a matcap uv node.
44
- *
45
- * @tsl
46
- * @function
47
- * @returns {MatcapUVNode}
48
- */
49
- export const matcapUV = /*@__PURE__*/ nodeImmutable( MatcapUVNode );
@@ -1,148 +0,0 @@
1
- import Node from '../core/Node.js';
2
- import { add } from '../math/OperatorNode.js';
3
- import { normalLocal } from '../accessors/Normal.js';
4
- import { positionLocal } from '../accessors/Position.js';
5
- import { texture } from '../accessors/TextureNode.js';
6
- import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
7
-
8
- /**
9
- * Can be used for triplanar texture mapping.
10
- *
11
- * ```js
12
- * material.colorNode = triplanarTexture( texture( diffuseMap ) );
13
- * ```
14
- *
15
- * @augments Node
16
- */
17
- class TriplanarTexturesNode extends Node {
18
-
19
- static get type() {
20
-
21
- return 'TriplanarTexturesNode';
22
-
23
- }
24
-
25
- /**
26
- * Constructs a new triplanar textures node.
27
- *
28
- * @param {Node} textureXNode - First texture node.
29
- * @param {?Node} [textureYNode=null] - Second texture node. When not set, the shader will sample from `textureXNode` instead.
30
- * @param {?Node} [textureZNode=null] - Third texture node. When not set, the shader will sample from `textureXNode` instead.
31
- * @param {?Node<float>} [scaleNode=float(1)] - The scale node.
32
- * @param {?Node<vec3>} [positionNode=positionLocal] - Vertex positions in local space.
33
- * @param {?Node<vec3>} [normalNode=normalLocal] - Normals in local space.
34
- */
35
- constructor( textureXNode, textureYNode = null, textureZNode = null, scaleNode = float( 1 ), positionNode = positionLocal, normalNode = normalLocal ) {
36
-
37
- super( 'vec4' );
38
-
39
- /**
40
- * First texture node.
41
- *
42
- * @type {Node}
43
- */
44
- this.textureXNode = textureXNode;
45
-
46
- /**
47
- * Second texture node. When not set, the shader will sample from `textureXNode` instead.
48
- *
49
- * @type {?Node}
50
- * @default null
51
- */
52
- this.textureYNode = textureYNode;
53
-
54
- /**
55
- * Third texture node. When not set, the shader will sample from `textureXNode` instead.
56
- *
57
- * @type {?Node}
58
- * @default null
59
- */
60
- this.textureZNode = textureZNode;
61
-
62
- /**
63
- * The scale node.
64
- *
65
- * @type {Node<float>}
66
- * @default float(1)
67
- */
68
- this.scaleNode = scaleNode;
69
-
70
- /**
71
- * Vertex positions in local space.
72
- *
73
- * @type {Node<vec3>}
74
- * @default positionLocal
75
- */
76
- this.positionNode = positionNode;
77
-
78
- /**
79
- * Normals in local space.
80
- *
81
- * @type {Node<vec3>}
82
- * @default normalLocal
83
- */
84
- this.normalNode = normalNode;
85
-
86
- }
87
-
88
- setup() {
89
-
90
- const { textureXNode, textureYNode, textureZNode, scaleNode, positionNode, normalNode } = this;
91
-
92
- // Ref: https://github.com/keijiro/StandardTriplanar
93
-
94
- // Blending factor of triplanar mapping
95
- let bf = normalNode.abs().normalize();
96
- bf = bf.div( bf.dot( vec3( 1.0 ) ) );
97
-
98
- // Triplanar mapping
99
- const tx = positionNode.yz.mul( scaleNode );
100
- const ty = positionNode.zx.mul( scaleNode );
101
- const tz = positionNode.xy.mul( scaleNode );
102
-
103
- // Base color
104
- const textureX = textureXNode.value;
105
- const textureY = textureYNode !== null ? textureYNode.value : textureX;
106
- const textureZ = textureZNode !== null ? textureZNode.value : textureX;
107
-
108
- const cx = texture( textureX, tx ).mul( bf.x );
109
- const cy = texture( textureY, ty ).mul( bf.y );
110
- const cz = texture( textureZ, tz ).mul( bf.z );
111
-
112
- return add( cx, cy, cz );
113
-
114
- }
115
-
116
- }
117
-
118
- export default TriplanarTexturesNode;
119
-
120
- /**
121
- * TSL function for creating a triplanar textures node.
122
- *
123
- * @tsl
124
- * @function
125
- * @param {Node} textureXNode - First texture node.
126
- * @param {?Node} [textureYNode=null] - Second texture node. When not set, the shader will sample from `textureXNode` instead.
127
- * @param {?Node} [textureZNode=null] - Third texture node. When not set, the shader will sample from `textureXNode` instead.
128
- * @param {?Node<float>} [scaleNode=float(1)] - The scale node.
129
- * @param {?Node<vec3>} [positionNode=positionLocal] - Vertex positions in local space.
130
- * @param {?Node<vec3>} [normalNode=normalLocal] - Normals in local space.
131
- * @returns {TriplanarTexturesNode}
132
- */
133
- export const triplanarTextures = /*@__PURE__*/ nodeProxy( TriplanarTexturesNode ).setParameterLength( 1, 6 );
134
-
135
- /**
136
- * TSL function for creating a triplanar textures node.
137
- *
138
- * @tsl
139
- * @function
140
- * @param {Node} textureXNode - First texture node.
141
- * @param {?Node} [textureYNode=null] - Second texture node. When not set, the shader will sample from `textureXNode` instead.
142
- * @param {?Node} [textureZNode=null] - Third texture node. When not set, the shader will sample from `textureXNode` instead.
143
- * @param {?Node<float>} [scaleNode=float(1)] - The scale node.
144
- * @param {?Node<vec3>} [positionNode=positionLocal] - Vertex positions in local space.
145
- * @param {?Node<vec3>} [normalNode=normalLocal] - Normals in local space.
146
- * @returns {TriplanarTexturesNode}
147
- */
148
- export const triplanarTexture = ( ...params ) => triplanarTextures( ...params );