super-three 0.163.0 → 0.165.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/README.md +3 -3
- package/build/three.cjs +1127 -452
- package/build/three.module.js +1127 -452
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +45 -1
- package/examples/jsm/exporters/USDZExporter.js +13 -5
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +283 -99
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +55 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -6
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +15 -13
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +109 -3
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +23 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +25 -18
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -6
- package/examples/jsm/nodes/core/PropertyNode.js +11 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +5 -3
- package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +210 -12
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +20 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +11 -2
- package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +28 -1
- package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +11 -7
- package/examples/jsm/nodes/materials/Materials.js +4 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +94 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +43 -45
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +57 -41
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +5 -5
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +10 -1
- package/examples/jsm/renderers/common/RenderObject.js +49 -1
- package/examples/jsm/renderers/common/Renderer.js +268 -25
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +31 -47
- package/examples/jsm/renderers/webgl/WebGLBackend.js +7 -21
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +5 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +23 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +114 -13
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +80 -46
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +85 -12
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/objects/BatchedMesh.js +114 -1
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +371 -109
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLCapabilities.js +33 -1
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +7 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +5 -36
- package/src/renderers/webgl/WebGLPrograms.js +19 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -4
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLTextures.js +206 -129
- package/src/renderers/webgl/WebGLUtils.js +3 -21
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +8 -6
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -318
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -792
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
|
@@ -1,104 +1,10 @@
|
|
|
1
|
-
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
3
2
|
import { varying } from '../core/VaryingNode.js';
|
|
4
|
-
import { normalize } from '../math/MathNode.js';
|
|
5
3
|
import { modelWorldMatrix, modelViewMatrix } from './ModelNode.js';
|
|
6
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.scope = scope;
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
isGlobal() {
|
|
19
|
-
|
|
20
|
-
return true;
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
getHash( /*builder*/ ) {
|
|
25
|
-
|
|
26
|
-
return `position-${this.scope}`;
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
generate( builder ) {
|
|
31
|
-
|
|
32
|
-
const scope = this.scope;
|
|
33
|
-
|
|
34
|
-
let outputNode = null;
|
|
35
|
-
|
|
36
|
-
if ( scope === PositionNode.GEOMETRY ) {
|
|
37
|
-
|
|
38
|
-
outputNode = attribute( 'position', 'vec3' );
|
|
39
|
-
|
|
40
|
-
} else if ( scope === PositionNode.LOCAL ) {
|
|
41
|
-
|
|
42
|
-
outputNode = varying( positionGeometry );
|
|
43
|
-
|
|
44
|
-
} else if ( scope === PositionNode.WORLD ) {
|
|
45
|
-
|
|
46
|
-
const vertexPositionNode = modelWorldMatrix.mul( positionLocal );
|
|
47
|
-
outputNode = varying( vertexPositionNode );
|
|
48
|
-
|
|
49
|
-
} else if ( scope === PositionNode.VIEW ) {
|
|
50
|
-
|
|
51
|
-
const vertexPositionNode = modelViewMatrix.mul( positionLocal );
|
|
52
|
-
outputNode = varying( vertexPositionNode );
|
|
53
|
-
|
|
54
|
-
} else if ( scope === PositionNode.VIEW_DIRECTION ) {
|
|
55
|
-
|
|
56
|
-
const vertexPositionNode = positionView.negate();
|
|
57
|
-
outputNode = normalize( varying( vertexPositionNode ) );
|
|
58
|
-
|
|
59
|
-
} else if ( scope === PositionNode.WORLD_DIRECTION ) {
|
|
60
|
-
|
|
61
|
-
const vertexPositionNode = positionLocal.transformDirection( modelWorldMatrix );
|
|
62
|
-
outputNode = normalize( varying( vertexPositionNode ) );
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return outputNode.build( builder, this.getNodeType( builder ) );
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
serialize( data ) {
|
|
71
|
-
|
|
72
|
-
super.serialize( data );
|
|
73
|
-
|
|
74
|
-
data.scope = this.scope;
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
deserialize( data ) {
|
|
79
|
-
|
|
80
|
-
super.deserialize( data );
|
|
81
|
-
|
|
82
|
-
this.scope = data.scope;
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
PositionNode.GEOMETRY = 'geometry';
|
|
89
|
-
PositionNode.LOCAL = 'local';
|
|
90
|
-
PositionNode.WORLD = 'world';
|
|
91
|
-
PositionNode.WORLD_DIRECTION = 'worldDirection';
|
|
92
|
-
PositionNode.VIEW = 'view';
|
|
93
|
-
PositionNode.VIEW_DIRECTION = 'viewDirection';
|
|
94
|
-
|
|
95
|
-
export default PositionNode;
|
|
96
|
-
|
|
97
|
-
export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY );
|
|
98
|
-
export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL ).temp( 'Position' );
|
|
99
|
-
export const positionWorld = nodeImmutable( PositionNode, PositionNode.WORLD );
|
|
100
|
-
export const positionWorldDirection = nodeImmutable( PositionNode, PositionNode.WORLD_DIRECTION );
|
|
101
|
-
export const positionView = nodeImmutable( PositionNode, PositionNode.VIEW );
|
|
102
|
-
export const positionViewDirection = nodeImmutable( PositionNode, PositionNode.VIEW_DIRECTION );
|
|
103
|
-
|
|
104
|
-
addNodeClass( 'PositionNode', PositionNode );
|
|
5
|
+
export const positionGeometry = /*#__PURE__*/ attribute( 'position', 'vec3' );
|
|
6
|
+
export const positionLocal = /*#__PURE__*/ positionGeometry.toVar( 'positionLocal' );
|
|
7
|
+
export const positionWorld = /*#__PURE__*/ varying( modelWorldMatrix.mul( positionLocal ).xyz, 'v_positionWorld' );
|
|
8
|
+
export const positionWorldDirection = /*#__PURE__*/ varying( positionLocal.transformDirection( modelWorldMatrix ), 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' );
|
|
9
|
+
export const positionView = /*#__PURE__*/ varying( modelViewMatrix.mul( positionLocal ).xyz, 'v_positionView' );
|
|
10
|
+
export const positionViewDirection = /*#__PURE__*/ varying( positionView.negate(), 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );
|
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import { cameraViewMatrix } from './CameraNode.js';
|
|
3
2
|
import { transformedNormalView } from './NormalNode.js';
|
|
4
3
|
import { positionViewDirection } from './PositionNode.js';
|
|
5
|
-
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
|
|
11
|
-
super( 'vec3' );
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getHash( /*builder*/ ) {
|
|
16
|
-
|
|
17
|
-
return 'reflectVector';
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
setup() {
|
|
22
|
-
|
|
23
|
-
const reflectView = positionViewDirection.negate().reflect( transformedNormalView );
|
|
24
|
-
|
|
25
|
-
return reflectView.transformDirection( cameraViewMatrix );
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default ReflectVectorNode;
|
|
32
|
-
|
|
33
|
-
export const reflectVector = nodeImmutable( ReflectVectorNode );
|
|
34
|
-
|
|
35
|
-
addNodeClass( 'ReflectVectorNode', ReflectVectorNode );
|
|
5
|
+
export const reflectView = /*#__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
|
|
6
|
+
export const reflectVector = /*#__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
|
|
@@ -18,6 +18,15 @@ class StorageBufferNode extends BufferNode {
|
|
|
18
18
|
this._attribute = null;
|
|
19
19
|
this._varying = null;
|
|
20
20
|
|
|
21
|
+
if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) {
|
|
22
|
+
|
|
23
|
+
// TOOD: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer
|
|
24
|
+
|
|
25
|
+
if ( value.isInstancedBufferAttribute ) value.isStorageInstancedBufferAttribute = true;
|
|
26
|
+
else value.isStorageBufferAttribute = true;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
getInputType( /*builder*/ ) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import TextureNode from './TextureNode.js';
|
|
3
3
|
import { nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { GPUStorageTextureAccess } from '../../renderers/webgpu/utils/WebGPUConstants.js';
|
|
4
5
|
|
|
5
|
-
class
|
|
6
|
+
class StorageTextureNode extends TextureNode {
|
|
6
7
|
|
|
7
8
|
constructor( value, uvNode, storeNode = null ) {
|
|
8
9
|
|
|
@@ -10,7 +11,9 @@ class TextureStoreNode extends TextureNode {
|
|
|
10
11
|
|
|
11
12
|
this.storeNode = storeNode;
|
|
12
13
|
|
|
13
|
-
this.
|
|
14
|
+
this.isStorageTextureNode = true;
|
|
15
|
+
|
|
16
|
+
this.access = GPUStorageTextureAccess.WriteOnly;
|
|
14
17
|
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -29,6 +32,13 @@ class TextureStoreNode extends TextureNode {
|
|
|
29
32
|
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
setAccess( value ) {
|
|
36
|
+
|
|
37
|
+
this.access = value;
|
|
38
|
+
return this;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
generate( builder, output ) {
|
|
33
43
|
|
|
34
44
|
let snippet;
|
|
@@ -65,13 +75,16 @@ class TextureStoreNode extends TextureNode {
|
|
|
65
75
|
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
export default
|
|
78
|
+
export default StorageTextureNode;
|
|
79
|
+
|
|
80
|
+
export const storageTexture = nodeProxy( StorageTextureNode );
|
|
69
81
|
|
|
70
|
-
const
|
|
82
|
+
export const storageTextureReadOnly = ( value, uvNode, storeNode ) => storageTexture( value, uvNode, storeNode ).setAccess( 'read-only' );
|
|
83
|
+
export const storageTextureReadWrite = ( value, uvNode, storeNode ) => storageTexture( value, uvNode, storeNode ).setAccess( 'read-write' );
|
|
71
84
|
|
|
72
85
|
export const textureStore = ( value, uvNode, storeNode ) => {
|
|
73
86
|
|
|
74
|
-
const node =
|
|
87
|
+
const node = storageTexture( value, uvNode, storeNode );
|
|
75
88
|
|
|
76
89
|
if ( storeNode !== null ) node.append();
|
|
77
90
|
|
|
@@ -79,4 +92,4 @@ export const textureStore = ( value, uvNode, storeNode ) => {
|
|
|
79
92
|
|
|
80
93
|
};
|
|
81
94
|
|
|
82
|
-
addNodeClass( '
|
|
95
|
+
addNodeClass( 'StorageTextureNode', StorageTextureNode );
|
|
@@ -1,109 +1,23 @@
|
|
|
1
|
-
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
3
|
-
import { temp } from '../core/VarNode.js';
|
|
4
2
|
import { varying } from '../core/VaryingNode.js';
|
|
5
|
-
import { normalize } from '../math/MathNode.js';
|
|
6
3
|
import { cameraViewMatrix } from './CameraNode.js';
|
|
7
4
|
import { modelViewMatrix } from './ModelNode.js';
|
|
8
|
-
import {
|
|
5
|
+
import { tslFn, vec4 } from '../shadernode/ShaderNode.js';
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.scope = scope;
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
getHash( /*builder*/ ) {
|
|
21
|
-
|
|
22
|
-
return `tangent-${this.scope}`;
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
getNodeType() {
|
|
27
|
-
|
|
28
|
-
const scope = this.scope;
|
|
29
|
-
|
|
30
|
-
if ( scope === TangentNode.GEOMETRY ) {
|
|
31
|
-
|
|
32
|
-
return 'vec4';
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return 'vec3';
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
generate( builder ) {
|
|
42
|
-
|
|
43
|
-
const scope = this.scope;
|
|
44
|
-
|
|
45
|
-
let outputNode = null;
|
|
46
|
-
|
|
47
|
-
if ( scope === TangentNode.GEOMETRY ) {
|
|
48
|
-
|
|
49
|
-
outputNode = attribute( 'tangent', 'vec4' );
|
|
50
|
-
|
|
51
|
-
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
|
|
52
|
-
|
|
53
|
-
builder.geometry.computeTangents();
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
} else if ( scope === TangentNode.LOCAL ) {
|
|
58
|
-
|
|
59
|
-
outputNode = varying( tangentGeometry.xyz );
|
|
60
|
-
|
|
61
|
-
} else if ( scope === TangentNode.VIEW ) {
|
|
62
|
-
|
|
63
|
-
const vertexNode = modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz;
|
|
64
|
-
outputNode = normalize( varying( vertexNode ) );
|
|
65
|
-
|
|
66
|
-
} else if ( scope === TangentNode.WORLD ) {
|
|
67
|
-
|
|
68
|
-
const vertexNode = tangentView.transformDirection( cameraViewMatrix );
|
|
69
|
-
outputNode = normalize( varying( vertexNode ) );
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return outputNode.build( builder, this.getNodeType( builder ) );
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
serialize( data ) {
|
|
78
|
-
|
|
79
|
-
super.serialize( data );
|
|
80
|
-
|
|
81
|
-
data.scope = this.scope;
|
|
11
|
+
builder.geometry.computeTangents();
|
|
82
12
|
|
|
83
13
|
}
|
|
84
14
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
super.deserialize( data );
|
|
88
|
-
|
|
89
|
-
this.scope = data.scope;
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
TangentNode.GEOMETRY = 'geometry';
|
|
96
|
-
TangentNode.LOCAL = 'local';
|
|
97
|
-
TangentNode.VIEW = 'view';
|
|
98
|
-
TangentNode.WORLD = 'world';
|
|
99
|
-
|
|
100
|
-
export default TangentNode;
|
|
15
|
+
return attribute( 'tangent', 'vec4' );
|
|
101
16
|
|
|
102
|
-
|
|
103
|
-
export const tangentLocal = nodeImmutable( TangentNode, TangentNode.LOCAL );
|
|
104
|
-
export const tangentView = nodeImmutable( TangentNode, TangentNode.VIEW );
|
|
105
|
-
export const tangentWorld = nodeImmutable( TangentNode, TangentNode.WORLD );
|
|
106
|
-
export const transformedTangentView = temp( tangentView, 'TransformedTangentView' );
|
|
107
|
-
export const transformedTangentWorld = normalize( transformedTangentView.transformDirection( cameraViewMatrix ) );
|
|
17
|
+
} )();
|
|
108
18
|
|
|
109
|
-
|
|
19
|
+
export const tangentLocal = /*#__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' );
|
|
20
|
+
export const tangentView = /*#__PURE__*/ varying( modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz, 'v_tangentView' ).normalize().toVar( 'tangentView' );
|
|
21
|
+
export const tangentWorld = /*#__PURE__*/ varying( tangentView.transformDirection( cameraViewMatrix ), 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
22
|
+
export const transformedTangentView = /*#__PURE__*/ tangentView.toVar( 'transformedTangentView' );
|
|
23
|
+
export const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import TextureNode from './TextureNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { nodeProxy, vec3, tslFn, If } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
const normal = tslFn( ( { texture, uv } ) => {
|
|
6
|
+
|
|
7
|
+
const epsilon = 0.0001;
|
|
8
|
+
|
|
9
|
+
const ret = vec3().temp();
|
|
10
|
+
|
|
11
|
+
If( uv.x.lessThan( epsilon ), () => {
|
|
12
|
+
|
|
13
|
+
ret.assign( vec3( 1, 0, 0 ) );
|
|
14
|
+
|
|
15
|
+
} ).elseif( uv.y.lessThan( epsilon ), () => {
|
|
16
|
+
|
|
17
|
+
ret.assign( vec3( 0, 1, 0 ) );
|
|
18
|
+
|
|
19
|
+
} ).elseif( uv.z.lessThan( epsilon ), () => {
|
|
20
|
+
|
|
21
|
+
ret.assign( vec3( 0, 0, 1 ) );
|
|
22
|
+
|
|
23
|
+
} ).elseif( uv.x.greaterThan( 1 - epsilon ), () => {
|
|
24
|
+
|
|
25
|
+
ret.assign( vec3( - 1, 0, 0 ) );
|
|
26
|
+
|
|
27
|
+
} ).elseif( uv.y.greaterThan( 1 - epsilon ), () => {
|
|
28
|
+
|
|
29
|
+
ret.assign( vec3( 0, - 1, 0 ) );
|
|
30
|
+
|
|
31
|
+
} ).elseif( uv.z.greaterThan( 1 - epsilon ), () => {
|
|
32
|
+
|
|
33
|
+
ret.assign( vec3( 0, 0, - 1 ) );
|
|
34
|
+
|
|
35
|
+
} ).else( () => {
|
|
36
|
+
|
|
37
|
+
const step = 0.01;
|
|
38
|
+
|
|
39
|
+
const x = texture.uv( uv.add( vec3( - step, 0.0, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( step, 0.0, 0.0 ) ) ).r );
|
|
40
|
+
const y = texture.uv( uv.add( vec3( 0.0, - step, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, step, 0.0 ) ) ).r );
|
|
41
|
+
const z = texture.uv( uv.add( vec3( 0.0, 0.0, - step ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, 0.0, step ) ) ).r );
|
|
42
|
+
|
|
43
|
+
ret.assign( vec3( x, y, z ) );
|
|
44
|
+
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
return ret.normalize();
|
|
48
|
+
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Texture3DNode extends TextureNode {
|
|
53
|
+
|
|
54
|
+
constructor( value, uvNode = null, levelNode = null ) {
|
|
55
|
+
|
|
56
|
+
super( value, uvNode, levelNode );
|
|
57
|
+
|
|
58
|
+
this.isTexture3DNode = true;
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getInputType( /*builder*/ ) {
|
|
63
|
+
|
|
64
|
+
return 'texture3D';
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getDefaultUV() {
|
|
69
|
+
|
|
70
|
+
return vec3( 0.5, 0.5, 0.5 );
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for 3d TextureNode
|
|
75
|
+
|
|
76
|
+
setupUV( builder, uvNode ) {
|
|
77
|
+
|
|
78
|
+
return uvNode;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
generateUV( builder, uvNode ) {
|
|
83
|
+
|
|
84
|
+
return uvNode.build( builder, 'vec3' );
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
normal( uvNode ) {
|
|
89
|
+
|
|
90
|
+
return normal( { texture: this, uv: uvNode } );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default Texture3DNode;
|
|
97
|
+
|
|
98
|
+
export const texture3D = nodeProxy( Texture3DNode );
|
|
99
|
+
|
|
100
|
+
addNodeClass( 'Texture3DNode', Texture3DNode );
|
|
@@ -20,6 +20,7 @@ class TextureNode extends UniformNode {
|
|
|
20
20
|
this.levelNode = levelNode;
|
|
21
21
|
this.compareNode = null;
|
|
22
22
|
this.depthNode = null;
|
|
23
|
+
this.gradNode = null;
|
|
23
24
|
|
|
24
25
|
this.sampler = true;
|
|
25
26
|
this.updateMatrix = false;
|
|
@@ -155,6 +156,7 @@ class TextureNode extends UniformNode {
|
|
|
155
156
|
properties.uvNode = uvNode;
|
|
156
157
|
properties.levelNode = levelNode;
|
|
157
158
|
properties.compareNode = this.compareNode;
|
|
159
|
+
properties.gradNode = this.gradNode;
|
|
158
160
|
properties.depthNode = this.depthNode;
|
|
159
161
|
|
|
160
162
|
}
|
|
@@ -165,7 +167,7 @@ class TextureNode extends UniformNode {
|
|
|
165
167
|
|
|
166
168
|
}
|
|
167
169
|
|
|
168
|
-
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet ) {
|
|
170
|
+
generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet, gradSnippet ) {
|
|
169
171
|
|
|
170
172
|
const texture = this.value;
|
|
171
173
|
|
|
@@ -175,6 +177,10 @@ class TextureNode extends UniformNode {
|
|
|
175
177
|
|
|
176
178
|
snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet );
|
|
177
179
|
|
|
180
|
+
} else if ( gradSnippet ) {
|
|
181
|
+
|
|
182
|
+
snippet = builder.generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet );
|
|
183
|
+
|
|
178
184
|
} else if ( compareSnippet ) {
|
|
179
185
|
|
|
180
186
|
snippet = builder.generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet );
|
|
@@ -223,18 +229,19 @@ class TextureNode extends UniformNode {
|
|
|
223
229
|
|
|
224
230
|
if ( propertyName === undefined ) {
|
|
225
231
|
|
|
226
|
-
const { uvNode, levelNode, compareNode, depthNode } = properties;
|
|
232
|
+
const { uvNode, levelNode, compareNode, depthNode, gradNode } = properties;
|
|
227
233
|
|
|
228
234
|
const uvSnippet = this.generateUV( builder, uvNode );
|
|
229
235
|
const levelSnippet = levelNode ? levelNode.build( builder, 'float' ) : null;
|
|
230
236
|
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
|
|
231
237
|
const compareSnippet = compareNode ? compareNode.build( builder, 'float' ) : null;
|
|
238
|
+
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
|
|
232
239
|
|
|
233
240
|
const nodeVar = builder.getVarFromNode( this );
|
|
234
241
|
|
|
235
242
|
propertyName = builder.getPropertyName( nodeVar );
|
|
236
243
|
|
|
237
|
-
const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet );
|
|
244
|
+
const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet, gradSnippet );
|
|
238
245
|
|
|
239
246
|
builder.addLineFlowCode( `${propertyName} = ${snippet}` );
|
|
240
247
|
|
|
@@ -324,6 +331,17 @@ class TextureNode extends UniformNode {
|
|
|
324
331
|
|
|
325
332
|
}
|
|
326
333
|
|
|
334
|
+
grad( gradNodeX, gradNodeY ) {
|
|
335
|
+
|
|
336
|
+
const textureNode = this.clone();
|
|
337
|
+
textureNode.gradNode = [ nodeObject( gradNodeX ), nodeObject( gradNodeY ) ];
|
|
338
|
+
|
|
339
|
+
textureNode.referenceNode = this;
|
|
340
|
+
|
|
341
|
+
return nodeObject( textureNode );
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
|
|
327
345
|
depth( depthNode ) {
|
|
328
346
|
|
|
329
347
|
const textureNode = this.clone();
|
|
@@ -20,7 +20,7 @@ class TextureSizeNode extends Node {
|
|
|
20
20
|
const textureProperty = this.textureNode.build( builder, 'property' );
|
|
21
21
|
const levelNode = this.levelNode.build( builder, 'int' );
|
|
22
22
|
|
|
23
|
-
return builder.format( `${builder.getMethod( 'textureDimensions' )}( ${textureProperty}, ${levelNode} )`, this.getNodeType( builder ), output );
|
|
23
|
+
return builder.format( `${ builder.getMethod( 'textureDimensions' ) }( ${ textureProperty }, ${ levelNode } )`, this.getNodeType( builder ), output );
|
|
24
24
|
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,47 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import AttributeNode from '../core/AttributeNode.js';
|
|
3
|
-
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
1
|
+
import { attribute } from '../core/AttributeNode.js';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
constructor( index = 0 ) {
|
|
8
|
-
|
|
9
|
-
super( null, 'vec2' );
|
|
10
|
-
|
|
11
|
-
this.isUVNode = true;
|
|
12
|
-
|
|
13
|
-
this.index = index;
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getAttributeName( /*builder*/ ) {
|
|
18
|
-
|
|
19
|
-
const index = this.index;
|
|
20
|
-
|
|
21
|
-
return 'uv' + ( index > 0 ? index : '' );
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
serialize( data ) {
|
|
26
|
-
|
|
27
|
-
super.serialize( data );
|
|
28
|
-
|
|
29
|
-
data.index = this.index;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
deserialize( data ) {
|
|
34
|
-
|
|
35
|
-
super.deserialize( data );
|
|
36
|
-
|
|
37
|
-
this.index = data.index;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default UVNode;
|
|
44
|
-
|
|
45
|
-
export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) );
|
|
46
|
-
|
|
47
|
-
addNodeClass( 'UVNode', UVNode );
|
|
3
|
+
export const uv = ( index ) => attribute( 'uv' + ( index > 0 ? index : '' ), 'vec2' );
|
|
@@ -127,12 +127,4 @@ const nativeFn = ( code, includes = [], language = '' ) => {
|
|
|
127
127
|
export const glslFn = ( code, includes ) => nativeFn( code, includes, 'glsl' );
|
|
128
128
|
export const wgslFn = ( code, includes ) => nativeFn( code, includes, 'wgsl' );
|
|
129
129
|
|
|
130
|
-
export const func = ( code, includes ) => { // @deprecated, r154
|
|
131
|
-
|
|
132
|
-
console.warn( 'TSL: func() is deprecated. Use nativeFn(), wgslFn() or glslFn() instead.' );
|
|
133
|
-
|
|
134
|
-
return nodeObject( new FunctionNode( code, includes ) );
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
|
|
138
130
|
addNodeClass( 'FunctionNode', FunctionNode );
|
|
@@ -4,10 +4,12 @@ import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
|
4
4
|
|
|
5
5
|
class AttributeNode extends Node {
|
|
6
6
|
|
|
7
|
-
constructor( attributeName, nodeType = null ) {
|
|
7
|
+
constructor( attributeName, nodeType = null, defaultNode = null ) {
|
|
8
8
|
|
|
9
9
|
super( nodeType );
|
|
10
10
|
|
|
11
|
+
this.defaultNode = defaultNode;
|
|
12
|
+
|
|
11
13
|
this._attributeName = attributeName;
|
|
12
14
|
|
|
13
15
|
}
|
|
@@ -93,7 +95,17 @@ class AttributeNode extends Node {
|
|
|
93
95
|
|
|
94
96
|
console.warn( `AttributeNode: Vertex attribute "${ attributeName }" not found on geometry.` );
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
const { defaultNode } = this;
|
|
99
|
+
|
|
100
|
+
if ( defaultNode !== null ) {
|
|
101
|
+
|
|
102
|
+
return defaultNode.build( builder, nodeType );
|
|
103
|
+
|
|
104
|
+
} else {
|
|
105
|
+
|
|
106
|
+
return builder.generateConst( nodeType );
|
|
107
|
+
|
|
108
|
+
}
|
|
97
109
|
|
|
98
110
|
}
|
|
99
111
|
|
|
@@ -103,6 +115,6 @@ class AttributeNode extends Node {
|
|
|
103
115
|
|
|
104
116
|
export default AttributeNode;
|
|
105
117
|
|
|
106
|
-
export const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) );
|
|
118
|
+
export const attribute = ( name, nodeType, defaultNode ) => nodeObject( new AttributeNode( name, nodeType, nodeObject( defaultNode ) ) );
|
|
107
119
|
|
|
108
120
|
addNodeClass( 'AttributeNode', AttributeNode );
|