@plastic-software/three 0.183.4 → 0.184.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.
- package/build/three.cjs +773 -286
- package/build/three.core.js +372 -110
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +426 -180
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +7 -1
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +2979 -1281
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2942 -1281
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +11 -0
- package/examples/jsm/animation/CCDIKSolver.js +5 -1
- package/examples/jsm/controls/ArcballControls.js +4 -1
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +2 -2
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +21 -5
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +169 -114
- package/examples/jsm/inspector/RendererInspector.js +2 -2
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +34 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +105 -3
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +273 -176
- package/examples/jsm/inspector/ui/Style.js +64 -10
- package/examples/jsm/inspector/ui/Tab.js +39 -7
- package/examples/jsm/inspector/ui/Values.js +39 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +8 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +682 -43
- package/examples/jsm/loaders/FBXLoader.js +233 -33
- package/examples/jsm/loaders/GLTFLoader.js +24 -7
- package/examples/jsm/loaders/HDRLoader.js +1 -1
- package/examples/jsm/loaders/KTX2Loader.js +8 -2
- package/examples/jsm/loaders/LDrawLoader.js +39 -47
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/VTKLoader.js +5 -1
- package/examples/jsm/loaders/collada/ColladaComposer.js +101 -7
- package/examples/jsm/loaders/collada/ColladaParser.js +19 -4
- package/examples/jsm/loaders/usd/USDAParser.js +6 -0
- package/examples/jsm/loaders/usd/USDCParser.js +26 -0
- package/examples/jsm/loaders/usd/USDComposer.js +656 -103
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +14 -2
- package/examples/jsm/objects/SkyMesh.js +23 -6
- package/examples/jsm/renderers/Projector.js +18 -38
- package/examples/jsm/renderers/SVGRenderer.js +6 -25
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +10 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +11 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +10 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/GTAONode.js +2 -1
- package/examples/jsm/tsl/display/GaussianBlurNode.js +10 -0
- package/examples/jsm/tsl/display/GodraysNode.js +2 -11
- package/examples/jsm/tsl/display/OutlineNode.js +66 -16
- package/examples/jsm/tsl/display/SSGINode.js +0 -4
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +48 -7
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +13 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +4 -4
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +6 -0
- package/src/Three.WebGPU.Nodes.js +3 -0
- package/src/Three.WebGPU.js +6 -0
- package/src/animation/AnimationAction.js +11 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/Clock.js +1 -1
- package/src/core/Object3D.js +1 -5
- package/src/core/RenderTarget.js +1 -0
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +1 -2
- package/src/loaders/ImageBitmapLoader.js +4 -6
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/loaders/ObjectLoader.js +25 -4
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +27 -0
- package/src/materials/nodes/NodeMaterial.js +0 -27
- package/src/materials/nodes/manager/NodeMaterialObserver.js +188 -89
- package/src/math/Line3.js +3 -0
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +13 -9
- package/src/math/Plane.js +4 -3
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +12 -8
- package/src/math/Vector4.js +13 -9
- package/src/nodes/Nodes.js +0 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/BufferAttributeNode.js +9 -3
- package/src/nodes/accessors/CubeTextureNode.js +7 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -2
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/SceneProperties.js +2 -8
- package/src/nodes/accessors/StorageBufferNode.js +10 -4
- package/src/nodes/accessors/StorageTextureNode.js +4 -9
- package/src/nodes/accessors/TextureNode.js +10 -2
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +1 -1
- package/src/nodes/core/ArrayNode.js +1 -1
- package/src/nodes/core/AssignNode.js +1 -1
- package/src/nodes/core/AttributeNode.js +1 -1
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +1 -1
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/Node.js +83 -12
- package/src/nodes/core/NodeBuilder.js +117 -16
- package/src/nodes/core/NodeUtils.js +1 -1
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/ParameterNode.js +1 -1
- package/src/nodes/core/StackNode.js +1 -1
- package/src/nodes/core/StructNode.js +1 -1
- package/src/nodes/core/StructTypeNode.js +1 -1
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +27 -7
- package/src/nodes/display/RenderOutputNode.js +4 -4
- package/src/nodes/display/ScreenNode.js +1 -1
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +18 -7
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/geometry/RangeNode.js +1 -1
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +69 -44
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/lighting/LightsNode.js +6 -27
- package/src/nodes/lighting/ShadowNode.js +24 -2
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +73 -1
- package/src/nodes/math/OperatorNode.js +1 -1
- package/src/nodes/math/PackFloatNode.js +1 -1
- package/src/nodes/math/UnpackFloatNode.js +1 -1
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +21 -3
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +30 -0
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/objects/BatchedMesh.js +17 -2
- package/src/objects/InstancedMesh.js +19 -3
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +147 -48
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +0 -8
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/BindGroup.js +1 -8
- package/src/renderers/common/Bindings.js +2 -2
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Pipelines.js +36 -3
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +5 -2
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/RenderObjects.js +3 -3
- package/src/renderers/common/RenderPipeline.js +35 -6
- package/src/renderers/common/Renderer.js +232 -53
- package/src/renderers/common/Textures.js +72 -3
- package/src/renderers/common/UniformsGroup.js +1 -1
- package/src/renderers/common/XRManager.js +34 -27
- package/src/renderers/common/extras/PMREMGenerator.js +23 -15
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeManager.js +230 -99
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -3
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +0 -1
- package/src/renderers/shaders/UniformsLib.js +7 -2
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +13 -13
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +6 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLMaterials.js +12 -13
- package/src/renderers/webgl/WebGLOutput.js +4 -1
- package/src/renderers/webgl/WebGLProgram.js +4 -0
- package/src/renderers/webgl/WebGLPrograms.js +19 -3
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLState.js +43 -0
- package/src/renderers/webgl/WebGLTextures.js +129 -26
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +106 -65
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +29 -51
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +42 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +63 -50
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +160 -146
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +55 -33
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +103 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +8 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +91 -17
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -2
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +13 -2
- package/src/utils.js +23 -1
- package/src/nodes/utils/RemapNode.js +0 -125
|
@@ -165,6 +165,8 @@ class BufferAttributeNode extends InputNode {
|
|
|
165
165
|
*/
|
|
166
166
|
getHash( builder ) {
|
|
167
167
|
|
|
168
|
+
let id;
|
|
169
|
+
|
|
168
170
|
if ( this.bufferStride === 0 && this.bufferOffset === 0 ) {
|
|
169
171
|
|
|
170
172
|
let bufferData = builder.globalCache.getData( this.value );
|
|
@@ -179,11 +181,15 @@ class BufferAttributeNode extends InputNode {
|
|
|
179
181
|
|
|
180
182
|
}
|
|
181
183
|
|
|
182
|
-
|
|
184
|
+
id = bufferData.node.id;
|
|
185
|
+
|
|
186
|
+
} else {
|
|
187
|
+
|
|
188
|
+
id = this.id;
|
|
183
189
|
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
return
|
|
192
|
+
return String( id );
|
|
187
193
|
|
|
188
194
|
}
|
|
189
195
|
|
|
@@ -194,7 +200,7 @@ class BufferAttributeNode extends InputNode {
|
|
|
194
200
|
* @param {NodeBuilder} builder - The current node builder.
|
|
195
201
|
* @return {string} The node type.
|
|
196
202
|
*/
|
|
197
|
-
|
|
203
|
+
generateNodeType( builder ) {
|
|
198
204
|
|
|
199
205
|
if ( this.bufferType === null ) {
|
|
200
206
|
|
|
@@ -124,13 +124,19 @@ class CubeTextureNode extends TextureNode {
|
|
|
124
124
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// rotate first
|
|
128
|
+
|
|
129
|
+
uvNode = materialEnvRotation.mul( uvNode );
|
|
130
|
+
|
|
131
|
+
// flip
|
|
132
|
+
|
|
127
133
|
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem || ! texture.isRenderTargetTexture ) {
|
|
128
134
|
|
|
129
135
|
uvNode = vec3( uvNode.x.negate(), uvNode.yz );
|
|
130
136
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
return
|
|
139
|
+
return uvNode;
|
|
134
140
|
|
|
135
141
|
}
|
|
136
142
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Euler } from '../../math/Euler.js';
|
|
2
1
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
3
2
|
import { uniform } from '../core/UniformNode.js';
|
|
4
3
|
|
|
5
|
-
const _e1 = /*@__PURE__*/ new Euler();
|
|
6
4
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
7
5
|
|
|
8
6
|
/**
|
|
@@ -44,9 +42,8 @@ export const materialEnvRotation = /*@__PURE__*/ uniform( new Matrix4() ).onRefe
|
|
|
44
42
|
|
|
45
43
|
if ( rotation ) {
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_m1.makeRotationFromEuler( _e1 );
|
|
45
|
+
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
46
|
+
_m1.makeRotationFromEuler( rotation ).transpose();
|
|
50
47
|
|
|
51
48
|
} else {
|
|
52
49
|
|
|
@@ -57,7 +57,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
57
57
|
*
|
|
58
58
|
* @return {string} The node type.
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
generateNodeType() {
|
|
61
61
|
|
|
62
62
|
return this.referenceNode.uniformType;
|
|
63
63
|
|
|
@@ -230,7 +230,7 @@ class ReferenceBaseNode extends Node {
|
|
|
230
230
|
* @param {NodeBuilder} builder - The current node builder.
|
|
231
231
|
* @return {string} The node type.
|
|
232
232
|
*/
|
|
233
|
-
|
|
233
|
+
generateNodeType( builder ) {
|
|
234
234
|
|
|
235
235
|
if ( this.node === null ) {
|
|
236
236
|
|
|
@@ -62,7 +62,7 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
62
62
|
*
|
|
63
63
|
* @return {string} The node type.
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
generateNodeType() {
|
|
66
66
|
|
|
67
67
|
return this.referenceNode.uniformType;
|
|
68
68
|
|
|
@@ -71,8 +71,8 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
71
71
|
generate( builder ) {
|
|
72
72
|
|
|
73
73
|
const snippet = super.generate( builder );
|
|
74
|
-
const arrayType = this.referenceNode.getNodeType();
|
|
75
|
-
const elementType = this.getNodeType();
|
|
74
|
+
const arrayType = this.referenceNode.getNodeType( builder );
|
|
75
|
+
const elementType = this.getNodeType( builder );
|
|
76
76
|
|
|
77
77
|
return builder.format( snippet, arrayType, elementType );
|
|
78
78
|
|
|
@@ -296,7 +296,7 @@ class ReferenceNode extends Node {
|
|
|
296
296
|
* @param {NodeBuilder} builder - The current node builder.
|
|
297
297
|
* @return {string} The node type.
|
|
298
298
|
*/
|
|
299
|
-
|
|
299
|
+
generateNodeType( builder ) {
|
|
300
300
|
|
|
301
301
|
if ( this.node === null ) {
|
|
302
302
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { UVMapping } from '../../constants.js';
|
|
2
|
-
import { Euler } from '../../math/Euler.js';
|
|
3
2
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
4
3
|
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
5
4
|
import { uniform } from '../tsl/TSLBase.js';
|
|
6
5
|
|
|
7
|
-
const _e1 = /*@__PURE__*/ new Euler();
|
|
8
6
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -35,12 +33,8 @@ export const backgroundRotation = /*@__PURE__*/ uniform( new Matrix4() ).setGrou
|
|
|
35
33
|
|
|
36
34
|
if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// accommodate left-handed frame
|
|
41
|
-
_e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
|
|
42
|
-
|
|
43
|
-
_m1.makeRotationFromEuler( _e1 );
|
|
36
|
+
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
37
|
+
_m1.makeRotationFromEuler( scene.backgroundRotation ).transpose();
|
|
44
38
|
|
|
45
39
|
} else {
|
|
46
40
|
|
|
@@ -168,6 +168,8 @@ class StorageBufferNode extends BufferNode {
|
|
|
168
168
|
*/
|
|
169
169
|
getHash( builder ) {
|
|
170
170
|
|
|
171
|
+
let id;
|
|
172
|
+
|
|
171
173
|
if ( this.bufferCount === 0 ) {
|
|
172
174
|
|
|
173
175
|
let bufferData = builder.globalCache.getData( this.value );
|
|
@@ -182,11 +184,15 @@ class StorageBufferNode extends BufferNode {
|
|
|
182
184
|
|
|
183
185
|
}
|
|
184
186
|
|
|
185
|
-
|
|
187
|
+
id = bufferData.node.id;
|
|
188
|
+
|
|
189
|
+
} else {
|
|
190
|
+
|
|
191
|
+
id = this.id;
|
|
186
192
|
|
|
187
193
|
}
|
|
188
194
|
|
|
189
|
-
return
|
|
195
|
+
return String( id );
|
|
190
196
|
|
|
191
197
|
}
|
|
192
198
|
|
|
@@ -317,7 +323,7 @@ class StorageBufferNode extends BufferNode {
|
|
|
317
323
|
* @param {NodeBuilder} builder - The current node builder.
|
|
318
324
|
* @return {string} The node type.
|
|
319
325
|
*/
|
|
320
|
-
|
|
326
|
+
generateNodeType( builder ) {
|
|
321
327
|
|
|
322
328
|
if ( this.structTypeNode !== null ) {
|
|
323
329
|
|
|
@@ -327,7 +333,7 @@ class StorageBufferNode extends BufferNode {
|
|
|
327
333
|
|
|
328
334
|
if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
|
|
329
335
|
|
|
330
|
-
return super.
|
|
336
|
+
return super.generateNodeType( builder );
|
|
331
337
|
|
|
332
338
|
}
|
|
333
339
|
|
|
@@ -146,19 +146,14 @@ class StorageTextureNode extends TextureNode {
|
|
|
146
146
|
*/
|
|
147
147
|
generate( builder, output ) {
|
|
148
148
|
|
|
149
|
-
let snippet;
|
|
150
|
-
|
|
151
149
|
if ( this.storeNode !== null ) {
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else {
|
|
156
|
-
|
|
157
|
-
snippet = super.generate( builder, output );
|
|
151
|
+
this.generateStore( builder );
|
|
152
|
+
return '';
|
|
158
153
|
|
|
159
154
|
}
|
|
160
155
|
|
|
161
|
-
return
|
|
156
|
+
return super.generate( builder, output );
|
|
162
157
|
|
|
163
158
|
}
|
|
164
159
|
|
|
@@ -233,7 +228,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
233
228
|
const storeSnippet = storeNode.build( builder, 'vec4' );
|
|
234
229
|
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
|
|
235
230
|
|
|
236
|
-
const snippet = builder.generateTextureStore(
|
|
231
|
+
const snippet = builder.generateTextureStore( this.value, textureProperty, uvSnippet, depthSnippet, storeSnippet );
|
|
237
232
|
|
|
238
233
|
builder.addLineFlowCode( snippet, this );
|
|
239
234
|
|
|
@@ -217,7 +217,7 @@ class TextureNode extends UniformNode {
|
|
|
217
217
|
* @param {NodeBuilder} builder - The current node builder.
|
|
218
218
|
* @return {string} The node type.
|
|
219
219
|
*/
|
|
220
|
-
|
|
220
|
+
generateNodeType( /*builder*/ ) {
|
|
221
221
|
|
|
222
222
|
if ( this.value.isDepthTexture === true ) return 'float';
|
|
223
223
|
|
|
@@ -553,11 +553,19 @@ class TextureNode extends UniformNode {
|
|
|
553
553
|
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
|
|
554
554
|
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;
|
|
555
555
|
|
|
556
|
+
let finalDepthSnippet = depthSnippet;
|
|
557
|
+
|
|
558
|
+
if ( finalDepthSnippet === null && texture.isArrayTexture && this.isTexture3DNode !== true ) {
|
|
559
|
+
|
|
560
|
+
finalDepthSnippet = '0';
|
|
561
|
+
|
|
562
|
+
}
|
|
563
|
+
|
|
556
564
|
const nodeVar = builder.getVarFromNode( this );
|
|
557
565
|
|
|
558
566
|
propertyName = builder.getPropertyName( nodeVar );
|
|
559
567
|
|
|
560
|
-
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet,
|
|
568
|
+
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, finalDepthSnippet, compareSnippet, gradSnippet, offsetSnippet );
|
|
561
569
|
|
|
562
570
|
if ( compareStepSnippet !== null ) {
|
|
563
571
|
|
|
@@ -41,7 +41,7 @@ class UniformArrayElementNode extends ArrayElementNode {
|
|
|
41
41
|
generate( builder ) {
|
|
42
42
|
|
|
43
43
|
const snippet = super.generate( builder );
|
|
44
|
-
const type = this.getNodeType();
|
|
44
|
+
const type = this.getNodeType( builder );
|
|
45
45
|
const paddedType = this.node.getPaddedType();
|
|
46
46
|
|
|
47
47
|
return builder.format( snippet, paddedType, type );
|
|
@@ -135,7 +135,7 @@ class UniformArrayNode extends BufferNode {
|
|
|
135
135
|
* @param {NodeBuilder} builder - The current node builder.
|
|
136
136
|
* @return {string} The node type.
|
|
137
137
|
*/
|
|
138
|
-
|
|
138
|
+
generateNodeType( /*builder*/ ) {
|
|
139
139
|
|
|
140
140
|
return this.paddedType;
|
|
141
141
|
|
|
@@ -76,7 +76,7 @@ class FunctionCallNode extends TempNode {
|
|
|
76
76
|
* @param {NodeBuilder} builder - The current node builder.
|
|
77
77
|
* @returns {string} The type of this node.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
generateNodeType( builder ) {
|
|
80
80
|
|
|
81
81
|
return this.functionNode.getNodeType( builder );
|
|
82
82
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
|
-
import { nodeImmutable
|
|
2
|
+
import { nodeImmutable } from '../tsl/TSLCore.js';
|
|
3
|
+
import { varying } from './VaryingNode.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class represents shader indices of different types. The following predefined node
|
package/src/nodes/core/Node.js
CHANGED
|
@@ -68,14 +68,6 @@ class Node extends EventDispatcher {
|
|
|
68
68
|
*/
|
|
69
69
|
this.updateAfterType = NodeUpdateType.NONE;
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* The UUID of the node.
|
|
73
|
-
*
|
|
74
|
-
* @type {string}
|
|
75
|
-
* @readonly
|
|
76
|
-
*/
|
|
77
|
-
this.uuid = MathUtils.generateUUID();
|
|
78
|
-
|
|
79
71
|
/**
|
|
80
72
|
* The version of the node. The version automatically is increased when {@link Node#needsUpdate} is set to `true`.
|
|
81
73
|
*
|
|
@@ -133,6 +125,15 @@ class Node extends EventDispatcher {
|
|
|
133
125
|
*/
|
|
134
126
|
this._cacheKey = null;
|
|
135
127
|
|
|
128
|
+
/**
|
|
129
|
+
* The UUID of the node.
|
|
130
|
+
*
|
|
131
|
+
* @type {string}
|
|
132
|
+
* @default null
|
|
133
|
+
* @private
|
|
134
|
+
*/
|
|
135
|
+
this._uuid = null;
|
|
136
|
+
|
|
136
137
|
/**
|
|
137
138
|
* The cache key's version.
|
|
138
139
|
*
|
|
@@ -142,7 +143,13 @@ class Node extends EventDispatcher {
|
|
|
142
143
|
*/
|
|
143
144
|
this._cacheKeyVersion = 0;
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
/**
|
|
147
|
+
* The unique ID of the node.
|
|
148
|
+
*
|
|
149
|
+
* @type {number}
|
|
150
|
+
* @readonly
|
|
151
|
+
*/
|
|
152
|
+
this.id = _nodeId ++;
|
|
146
153
|
|
|
147
154
|
/**
|
|
148
155
|
* The stack trace of the node for debugging purposes.
|
|
@@ -177,6 +184,24 @@ class Node extends EventDispatcher {
|
|
|
177
184
|
|
|
178
185
|
}
|
|
179
186
|
|
|
187
|
+
/**
|
|
188
|
+
* The UUID of the node.
|
|
189
|
+
*
|
|
190
|
+
* @type {string}
|
|
191
|
+
* @readonly
|
|
192
|
+
*/
|
|
193
|
+
get uuid() {
|
|
194
|
+
|
|
195
|
+
if ( this._uuid === null ) {
|
|
196
|
+
|
|
197
|
+
this._uuid = MathUtils.generateUUID();
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return this._uuid;
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
180
205
|
/**
|
|
181
206
|
* The type of the class. The value is usually the constructor name.
|
|
182
207
|
*
|
|
@@ -469,7 +494,7 @@ class Node extends EventDispatcher {
|
|
|
469
494
|
*/
|
|
470
495
|
getHash( /*builder*/ ) {
|
|
471
496
|
|
|
472
|
-
return this.
|
|
497
|
+
return String( this.id );
|
|
473
498
|
|
|
474
499
|
}
|
|
475
500
|
|
|
@@ -540,15 +565,61 @@ class Node extends EventDispatcher {
|
|
|
540
565
|
* Returns the node's type.
|
|
541
566
|
*
|
|
542
567
|
* @param {NodeBuilder} builder - The current node builder.
|
|
568
|
+
* @param {string} [output=null] - The output of the node.
|
|
569
|
+
* @return {string} The type of the node.
|
|
570
|
+
*/
|
|
571
|
+
getNodeType( builder, output = null ) {
|
|
572
|
+
|
|
573
|
+
const nodeData = builder.getDataFromNode( this );
|
|
574
|
+
|
|
575
|
+
let type;
|
|
576
|
+
|
|
577
|
+
if ( output !== null ) {
|
|
578
|
+
|
|
579
|
+
nodeData.typeFromOutput = nodeData.typeFromOutput || {};
|
|
580
|
+
|
|
581
|
+
type = nodeData.typeFromOutput[ output ];
|
|
582
|
+
|
|
583
|
+
if ( type === undefined ) {
|
|
584
|
+
|
|
585
|
+
type = this.generateNodeType( builder, output );
|
|
586
|
+
|
|
587
|
+
nodeData.typeFromOutput[ output ] = type;
|
|
588
|
+
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
} else {
|
|
592
|
+
|
|
593
|
+
type = nodeData.type;
|
|
594
|
+
|
|
595
|
+
if ( type === undefined ) {
|
|
596
|
+
|
|
597
|
+
type = this.generateNodeType( builder );
|
|
598
|
+
|
|
599
|
+
nodeData.type = type;
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return type;
|
|
606
|
+
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Returns the node's type.
|
|
611
|
+
*
|
|
612
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
613
|
+
* @param {string} [output=null] - The output of the node.
|
|
543
614
|
* @return {string} The type of the node.
|
|
544
615
|
*/
|
|
545
|
-
|
|
616
|
+
generateNodeType( builder, output = null ) {
|
|
546
617
|
|
|
547
618
|
const nodeProperties = builder.getNodeProperties( this );
|
|
548
619
|
|
|
549
620
|
if ( nodeProperties.outputNode ) {
|
|
550
621
|
|
|
551
|
-
return nodeProperties.outputNode.getNodeType( builder );
|
|
622
|
+
return nodeProperties.outputNode.getNodeType( builder, output );
|
|
552
623
|
|
|
553
624
|
}
|
|
554
625
|
|