super-three 0.172.0 → 0.173.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 (180) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +439 -380
  3. package/build/three.core.js +413 -41
  4. package/build/three.core.min.js +2 -2
  5. package/build/three.module.js +28 -344
  6. package/build/three.module.min.js +2 -2
  7. package/build/three.tsl.js +11 -3
  8. package/build/three.tsl.min.js +2 -2
  9. package/build/three.webgpu.js +7550 -1798
  10. package/build/three.webgpu.min.js +2 -2
  11. package/build/three.webgpu.nodes.js +7551 -1798
  12. package/build/three.webgpu.nodes.min.js +2 -2
  13. package/examples/jsm/animation/CCDIKSolver.js +6 -5
  14. package/examples/jsm/capabilities/WebGPU.js +1 -1
  15. package/examples/jsm/controls/ArcballControls.js +23 -21
  16. package/examples/jsm/exporters/GLTFExporter.js +26 -25
  17. package/examples/jsm/geometries/TextGeometry.js +1 -12
  18. package/examples/jsm/interactive/InteractiveGroup.js +108 -51
  19. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  20. package/examples/jsm/loaders/GCodeLoader.js +3 -1
  21. package/examples/jsm/loaders/GLTFLoader.js +0 -2
  22. package/examples/jsm/loaders/TDSLoader.js +0 -1
  23. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
  24. package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
  25. package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
  26. package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
  27. package/examples/jsm/misc/Volume.js +7 -5
  28. package/examples/jsm/misc/VolumeSlice.js +5 -3
  29. package/examples/jsm/objects/WaterMesh.js +25 -20
  30. package/examples/jsm/physics/JoltPhysics.js +7 -7
  31. package/examples/jsm/physics/RapierPhysics.js +4 -4
  32. package/examples/jsm/postprocessing/EffectComposer.js +23 -2
  33. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  34. package/examples/jsm/postprocessing/Pass.js +6 -1
  35. package/examples/jsm/shaders/OutputShader.js +5 -1
  36. package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
  37. package/examples/jsm/transpiler/TSLEncoder.js +2 -0
  38. package/package.json +1 -1
  39. package/src/Three.Core.js +2 -0
  40. package/src/Three.TSL.js +9 -1
  41. package/src/cameras/ArrayCamera.js +1 -0
  42. package/src/constants.js +6 -1
  43. package/src/core/BufferAttribute.js +4 -0
  44. package/src/core/EventDispatcher.js +8 -6
  45. package/src/extras/ImageUtils.js +1 -11
  46. package/src/loaders/nodes/NodeObjectLoader.js +1 -1
  47. package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
  48. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
  49. package/src/materials/nodes/NodeMaterial.js +5 -5
  50. package/src/materials/nodes/NodeMaterials.js +0 -1
  51. package/src/materials/nodes/PointsNodeMaterial.js +109 -7
  52. package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
  53. package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
  54. package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
  55. package/src/nodes/Nodes.js +4 -0
  56. package/src/nodes/TSL.js +4 -0
  57. package/src/nodes/accessors/Arrays.js +30 -8
  58. package/src/nodes/accessors/BatchNode.js +3 -3
  59. package/src/nodes/accessors/BufferAttributeNode.js +1 -1
  60. package/src/nodes/accessors/Camera.js +64 -3
  61. package/src/nodes/accessors/InstanceNode.js +1 -1
  62. package/src/nodes/accessors/MaterialNode.js +9 -9
  63. package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
  64. package/src/nodes/accessors/Normal.js +6 -2
  65. package/src/nodes/accessors/Object3DNode.js +0 -1
  66. package/src/nodes/accessors/Position.js +6 -6
  67. package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
  68. package/src/nodes/accessors/ReferenceNode.js +2 -3
  69. package/src/nodes/accessors/StorageBufferNode.js +42 -5
  70. package/src/nodes/accessors/Tangent.js +2 -2
  71. package/src/nodes/accessors/Texture3DNode.js +1 -1
  72. package/src/nodes/accessors/TextureNode.js +12 -5
  73. package/src/nodes/accessors/UniformArrayNode.js +9 -3
  74. package/src/nodes/accessors/VelocityNode.js +0 -2
  75. package/src/nodes/code/ScriptableNode.js +3 -3
  76. package/src/nodes/core/ArrayNode.js +125 -0
  77. package/src/nodes/core/ConstNode.js +8 -0
  78. package/src/nodes/core/Node.js +14 -1
  79. package/src/nodes/core/NodeBuilder.js +229 -19
  80. package/src/nodes/core/NodeUtils.js +11 -1
  81. package/src/nodes/core/NodeVar.js +17 -1
  82. package/src/nodes/core/OutputStructNode.js +19 -9
  83. package/src/nodes/core/StackNode.js +20 -1
  84. package/src/nodes/core/StructNode.js +121 -0
  85. package/src/nodes/core/StructType.js +13 -0
  86. package/src/nodes/core/StructTypeNode.js +82 -21
  87. package/src/nodes/core/TempNode.js +1 -1
  88. package/src/nodes/core/VarNode.js +94 -7
  89. package/src/nodes/core/VaryingNode.js +19 -3
  90. package/src/nodes/display/BlendModes.js +88 -1
  91. package/src/nodes/display/BumpMapNode.js +6 -6
  92. package/src/nodes/display/NormalMapNode.js +6 -6
  93. package/src/nodes/display/PassNode.js +3 -1
  94. package/src/nodes/display/ScreenNode.js +9 -0
  95. package/src/nodes/fog/Fog.js +17 -0
  96. package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
  97. package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
  98. package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
  99. package/src/nodes/lighting/ShadowNode.js +1 -1
  100. package/src/nodes/math/ConditionalNode.js +8 -1
  101. package/src/nodes/math/MathNode.js +14 -1
  102. package/src/nodes/math/OperatorNode.js +96 -18
  103. package/src/nodes/pmrem/PMREMUtils.js +1 -1
  104. package/src/nodes/shapes/Shapes.js +33 -0
  105. package/src/nodes/tsl/TSLBase.js +1 -0
  106. package/src/nodes/tsl/TSLCore.js +22 -2
  107. package/src/nodes/utils/ArrayElementNode.js +1 -1
  108. package/src/nodes/utils/LoopNode.js +8 -1
  109. package/src/nodes/utils/MemberNode.js +68 -0
  110. package/src/nodes/utils/StorageArrayElementNode.js +14 -0
  111. package/src/nodes/utils/Timer.js +21 -0
  112. package/src/objects/BatchedMesh.js +1 -1
  113. package/src/objects/Line.js +6 -6
  114. package/src/renderers/WebGLRenderer.js +7 -0
  115. package/src/renderers/common/Animation.js +23 -1
  116. package/src/renderers/common/Backend.js +58 -15
  117. package/src/renderers/common/Background.js +14 -0
  118. package/src/renderers/common/Binding.js +1 -1
  119. package/src/renderers/common/BufferUtils.js +1 -1
  120. package/src/renderers/common/BundleGroup.js +1 -1
  121. package/src/renderers/common/ChainMap.js +9 -7
  122. package/src/renderers/common/ClippingContext.js +1 -1
  123. package/src/renderers/common/Color4.js +7 -3
  124. package/src/renderers/common/Geometries.js +2 -23
  125. package/src/renderers/common/Info.js +1 -45
  126. package/src/renderers/common/Lighting.js +8 -6
  127. package/src/renderers/common/Pipelines.js +3 -3
  128. package/src/renderers/common/PostProcessing.js +24 -8
  129. package/src/renderers/common/QuadMesh.js +1 -1
  130. package/src/renderers/common/RenderBundles.js +9 -3
  131. package/src/renderers/common/RenderContext.js +37 -3
  132. package/src/renderers/common/RenderContexts.js +30 -17
  133. package/src/renderers/common/RenderList.js +2 -2
  134. package/src/renderers/common/RenderLists.js +9 -3
  135. package/src/renderers/common/RenderObject.js +76 -17
  136. package/src/renderers/common/RenderObjects.js +9 -7
  137. package/src/renderers/common/Renderer.js +86 -67
  138. package/src/renderers/common/SampledTexture.js +0 -1
  139. package/src/renderers/common/StorageBufferAttribute.js +1 -1
  140. package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
  141. package/src/renderers/common/StorageTexture.js +1 -1
  142. package/src/renderers/common/Textures.js +14 -7
  143. package/src/renderers/common/TimestampQueryPool.js +39 -0
  144. package/src/renderers/common/Uniform.js +37 -1
  145. package/src/renderers/common/UniformsGroup.js +2 -0
  146. package/src/renderers/common/XRManager.js +1193 -0
  147. package/src/renderers/common/XRRenderTarget.js +74 -0
  148. package/src/renderers/common/extras/PMREMGenerator.js +53 -8
  149. package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
  150. package/src/renderers/common/nodes/NodeLibrary.js +5 -5
  151. package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
  152. package/src/renderers/common/nodes/NodeUniform.js +54 -2
  153. package/src/renderers/common/nodes/Nodes.js +25 -18
  154. package/src/renderers/webgl/WebGLBackground.js +4 -0
  155. package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
  156. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
  157. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
  158. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
  159. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
  160. package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
  161. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
  162. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
  163. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
  164. package/src/renderers/webgpu/WebGPUBackend.js +132 -149
  165. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
  166. package/src/renderers/webgpu/WebGPURenderer.js +5 -4
  167. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
  168. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
  169. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
  170. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
  171. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
  172. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
  173. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
  174. package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
  175. package/src/renderers/webxr/WebXRManager.js +13 -2
  176. package/src/textures/VideoFrameTexture.js +35 -0
  177. package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
  178. package/examples/jsm/objects/InstancedPoints.js +0 -19
  179. package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
  180. package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
@@ -1,209 +0,0 @@
1
- import NodeMaterial from './NodeMaterial.js';
2
- import { attribute } from '../../nodes/core/AttributeNode.js';
3
- import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
4
- import { materialColor, materialOpacity, materialPointWidth } from '../../nodes/accessors/MaterialNode.js'; // or should this be a property, instead?
5
- import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
6
- import { positionGeometry } from '../../nodes/accessors/Position.js';
7
- import { smoothstep, lengthSq } from '../../nodes/math/MathNode.js';
8
- import { Fn, vec4, float } from '../../nodes/tsl/TSLBase.js';
9
- import { uv } from '../../nodes/accessors/UV.js';
10
- import { viewport } from '../../nodes/display/ScreenNode.js';
11
-
12
- import { PointsMaterial } from '../PointsMaterial.js';
13
-
14
- const _defaultValues = /*@__PURE__*/ new PointsMaterial();
15
-
16
- /**
17
- * Unlike WebGL, WebGPU can render point primitives only with a size
18
- * of one pixel. This type node material can be used to mimic the WebGL
19
- * points rendering by rendering small planes via instancing.
20
- *
21
- * This material should be used with {@link InstancedPointsGeometry}.
22
- *
23
- * @augments NodeMaterial
24
- */
25
- class InstancedPointsNodeMaterial extends NodeMaterial {
26
-
27
- static get type() {
28
-
29
- return 'InstancedPointsNodeMaterial';
30
-
31
- }
32
-
33
- /**
34
- * Constructs a new instanced points node material.
35
- *
36
- * @param {Object?} parameters - The configuration parameter.
37
- */
38
- constructor( parameters = {} ) {
39
-
40
- super();
41
-
42
- /**
43
- * This flag can be used for type testing.
44
- *
45
- * @type {Boolean}
46
- * @readonly
47
- * @default true
48
- */
49
- this.isInstancedPointsNodeMaterial = true;
50
-
51
- /**
52
- * Whether vertex colors should be used or not. If set to `true`,
53
- * each point instance can receive a custom color value.
54
- *
55
- * @type {Boolean}
56
- * @default false
57
- */
58
- this.useColor = parameters.vertexColors;
59
-
60
- /**
61
- * The points width in pixels.
62
- *
63
- * @type {Number}
64
- * @default 1
65
- */
66
- this.pointWidth = 1;
67
-
68
- /**
69
- * This node can be used to define the colors for each instance.
70
- *
71
- * @type {Node<vec3>?}
72
- * @default null
73
- */
74
- this.pointColorNode = null;
75
-
76
- /**
77
- * This node can be used to define the width for each point instance.
78
- *
79
- * @type {Node<float>?}
80
- * @default null
81
- */
82
- this.pointWidthNode = null;
83
-
84
- this._useAlphaToCoverage = true;
85
-
86
- this.setDefaultValues( _defaultValues );
87
-
88
- this.setValues( parameters );
89
-
90
- }
91
-
92
- /**
93
- * Setups the vertex and fragment stage of this node material.
94
- *
95
- * @param {NodeBuilder} builder - The current node builder.
96
- */
97
- setup( builder ) {
98
-
99
- const { renderer } = builder;
100
-
101
- const useAlphaToCoverage = this._useAlphaToCoverage;
102
- const useColor = this.useColor;
103
-
104
- this.vertexNode = Fn( () => {
105
-
106
- const instancePosition = attribute( 'instancePosition' ).xyz;
107
-
108
- // camera space
109
- const mvPos = vec4( modelViewMatrix.mul( vec4( instancePosition, 1.0 ) ) );
110
-
111
- const aspect = viewport.z.div( viewport.w );
112
-
113
- // clip space
114
- const clipPos = cameraProjectionMatrix.mul( mvPos );
115
-
116
- // offset in ndc space
117
- const offset = positionGeometry.xy.toVar();
118
-
119
- offset.mulAssign( this.pointWidthNode ? this.pointWidthNode : materialPointWidth );
120
-
121
- offset.assign( offset.div( viewport.z ) );
122
- offset.y.assign( offset.y.mul( aspect ) );
123
-
124
- // back to clip space
125
- offset.assign( offset.mul( clipPos.w ) );
126
-
127
- //clipPos.xy += offset;
128
- clipPos.addAssign( vec4( offset, 0, 0 ) );
129
-
130
- return clipPos;
131
-
132
- } )();
133
-
134
- this.fragmentNode = Fn( () => {
135
-
136
- const alpha = float( 1 ).toVar();
137
-
138
- const len2 = lengthSq( uv().mul( 2 ).sub( 1 ) );
139
-
140
- if ( useAlphaToCoverage && renderer.samples > 1 ) {
141
-
142
- const dlen = float( len2.fwidth() ).toVar();
143
-
144
- alpha.assign( smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus() );
145
-
146
- } else {
147
-
148
- len2.greaterThan( 1.0 ).discard();
149
-
150
- }
151
-
152
- let pointColorNode;
153
-
154
- if ( this.pointColorNode ) {
155
-
156
- pointColorNode = this.pointColorNode;
157
-
158
- } else {
159
-
160
- if ( useColor ) {
161
-
162
- const instanceColor = attribute( 'instanceColor' );
163
-
164
- pointColorNode = instanceColor.mul( materialColor );
165
-
166
- } else {
167
-
168
- pointColorNode = materialColor;
169
-
170
- }
171
-
172
- }
173
-
174
- alpha.mulAssign( materialOpacity );
175
-
176
- return vec4( pointColorNode, alpha );
177
-
178
- } )();
179
-
180
- super.setup( builder );
181
-
182
- }
183
-
184
- /**
185
- * Whether alpha to coverage should be used or not.
186
- *
187
- * @type {Boolean}
188
- * @default true
189
- */
190
- get alphaToCoverage() {
191
-
192
- return this._useAlphaToCoverage;
193
-
194
- }
195
-
196
- set alphaToCoverage( value ) {
197
-
198
- if ( this._useAlphaToCoverage !== value ) {
199
-
200
- this._useAlphaToCoverage = value;
201
- this.needsUpdate = true;
202
-
203
- }
204
-
205
- }
206
-
207
- }
208
-
209
- export default InstancedPointsNodeMaterial;
@@ -1,37 +0,0 @@
1
- import MaterialNode from './MaterialNode.js';
2
- import { nodeImmutable } from '../tsl/TSLBase.js';
3
-
4
- /** @module InstancedPointsMaterialNode **/
5
-
6
- /**
7
- * An extension of material node to provide pre-defined
8
- * TSL objects in context of `InstancedPointsNodeMaterial`.
9
- *
10
- * @augments module:MaterialNode~MaterialNode
11
- */
12
- class InstancedPointsMaterialNode extends MaterialNode {
13
-
14
- static get type() {
15
-
16
- return 'InstancedPointsMaterialNode';
17
-
18
- }
19
-
20
- setup( /*builder*/ ) {
21
-
22
- return this.getFloat( this.scope );
23
-
24
- }
25
-
26
- }
27
-
28
- InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth';
29
-
30
- export default InstancedPointsMaterialNode;
31
-
32
- /**
33
- * TSL object that represents the point width of the current points material.
34
- *
35
- * @type {InstancedPointsMaterialNode<float>}
36
- */
37
- export const materialPointWidth = /*@__PURE__*/ nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );