super-three 0.167.0 → 0.168.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 +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
4
|
import { textureCubeUV } from './PMREMUtils.js';
|
|
5
5
|
import { uniform } from '../core/UniformNode.js';
|
|
6
6
|
import { NodeUpdateType } from '../core/constants.js';
|
|
7
|
-
import { nodeProxy, vec3 } from '../
|
|
7
|
+
import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
8
8
|
|
|
9
9
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
10
|
+
import { Texture } from '../../textures/Texture.js';
|
|
10
11
|
|
|
11
12
|
let _generator = null;
|
|
12
13
|
|
|
@@ -32,25 +33,32 @@ function _getPMREMFromTexture( texture ) {
|
|
|
32
33
|
|
|
33
34
|
if ( pmremVersion !== texture.pmremVersion ) {
|
|
34
35
|
|
|
36
|
+
const image = texture.image;
|
|
37
|
+
|
|
35
38
|
if ( texture.isCubeTexture ) {
|
|
36
39
|
|
|
37
|
-
if (
|
|
40
|
+
if ( isCubeMapReady( image ) ) {
|
|
41
|
+
|
|
42
|
+
cacheTexture = _generator.fromCubemap( texture, cacheTexture );
|
|
43
|
+
|
|
44
|
+
} else {
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
return null;
|
|
40
47
|
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
cacheTexture = _generator.fromCubemap( texture, cacheTexture );
|
|
44
50
|
|
|
45
51
|
} else {
|
|
46
52
|
|
|
47
|
-
if (
|
|
53
|
+
if ( isEquirectangularMapReady( image ) ) {
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
cacheTexture = _generator.fromEquirectangular( texture, cacheTexture );
|
|
50
56
|
|
|
51
|
-
}
|
|
57
|
+
} else {
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
return null;
|
|
60
|
+
|
|
61
|
+
}
|
|
54
62
|
|
|
55
63
|
}
|
|
56
64
|
|
|
@@ -77,7 +85,12 @@ class PMREMNode extends TempNode {
|
|
|
77
85
|
this.levelNode = levelNode;
|
|
78
86
|
|
|
79
87
|
this._generator = null;
|
|
80
|
-
|
|
88
|
+
|
|
89
|
+
const defaultTexture = new Texture();
|
|
90
|
+
defaultTexture.isRenderTargetTexture = true;
|
|
91
|
+
|
|
92
|
+
this._texture = texture( defaultTexture );
|
|
93
|
+
|
|
81
94
|
this._width = uniform( 0 );
|
|
82
95
|
this._height = uniform( 0 );
|
|
83
96
|
this._maxMip = uniform( 0 );
|
|
@@ -129,9 +142,13 @@ class PMREMNode extends TempNode {
|
|
|
129
142
|
|
|
130
143
|
}
|
|
131
144
|
|
|
132
|
-
|
|
145
|
+
if ( pmrem !== null ) {
|
|
146
|
+
|
|
147
|
+
this._pmrem = pmrem;
|
|
133
148
|
|
|
134
|
-
|
|
149
|
+
this.updateFromTexture( pmrem );
|
|
150
|
+
|
|
151
|
+
}
|
|
135
152
|
|
|
136
153
|
}
|
|
137
154
|
|
|
@@ -187,8 +204,34 @@ class PMREMNode extends TempNode {
|
|
|
187
204
|
|
|
188
205
|
}
|
|
189
206
|
|
|
190
|
-
export
|
|
207
|
+
export default PMREMNode;
|
|
191
208
|
|
|
192
|
-
|
|
209
|
+
PMREMNode.type = /*@__PURE__*/ registerNode( 'PMREM', PMREMNode );
|
|
193
210
|
|
|
194
|
-
|
|
211
|
+
function isCubeMapReady( image ) {
|
|
212
|
+
|
|
213
|
+
if ( image === null || image === undefined ) return false;
|
|
214
|
+
|
|
215
|
+
let count = 0;
|
|
216
|
+
const length = 6;
|
|
217
|
+
|
|
218
|
+
for ( let i = 0; i < length; i ++ ) {
|
|
219
|
+
|
|
220
|
+
if ( image[ i ] !== undefined ) count ++;
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return count === length;
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function isEquirectangularMapReady( image ) {
|
|
230
|
+
|
|
231
|
+
if ( image === null || image === undefined ) return false;
|
|
232
|
+
|
|
233
|
+
return image.height > 0;
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const pmremTexture = /*@__PURE__*/ nodeProxy( PMREMNode );
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fn, int, float, vec2, vec3, vec4, If } from '../tsl/TSLBase.js';
|
|
2
2
|
import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross, all } from '../math/MathNode.js';
|
|
3
3
|
import { mul } from '../math/OperatorNode.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { select } from '../math/ConditionalNode.js';
|
|
5
|
+
import { Loop, Break } from '../utils/LoopNode.js';
|
|
6
6
|
|
|
7
7
|
// These defines must match with PMREMGenerator
|
|
8
8
|
|
|
9
|
-
const cubeUV_r0 = float( 1.0 );
|
|
10
|
-
const cubeUV_m0 = float( - 2.0 );
|
|
11
|
-
const cubeUV_r1 = float( 0.8 );
|
|
12
|
-
const cubeUV_m1 = float( - 1.0 );
|
|
13
|
-
const cubeUV_r4 = float( 0.4 );
|
|
14
|
-
const cubeUV_m4 = float( 2.0 );
|
|
15
|
-
const cubeUV_r5 = float( 0.305 );
|
|
16
|
-
const cubeUV_m5 = float( 3.0 );
|
|
17
|
-
const cubeUV_r6 = float( 0.21 );
|
|
18
|
-
const cubeUV_m6 = float( 4.0 );
|
|
9
|
+
const cubeUV_r0 = /*@__PURE__*/ float( 1.0 );
|
|
10
|
+
const cubeUV_m0 = /*@__PURE__*/ float( - 2.0 );
|
|
11
|
+
const cubeUV_r1 = /*@__PURE__*/ float( 0.8 );
|
|
12
|
+
const cubeUV_m1 = /*@__PURE__*/ float( - 1.0 );
|
|
13
|
+
const cubeUV_r4 = /*@__PURE__*/ float( 0.4 );
|
|
14
|
+
const cubeUV_m4 = /*@__PURE__*/ float( 2.0 );
|
|
15
|
+
const cubeUV_r5 = /*@__PURE__*/ float( 0.305 );
|
|
16
|
+
const cubeUV_m5 = /*@__PURE__*/ float( 3.0 );
|
|
17
|
+
const cubeUV_r6 = /*@__PURE__*/ float( 0.21 );
|
|
18
|
+
const cubeUV_m6 = /*@__PURE__*/ float( 4.0 );
|
|
19
19
|
|
|
20
|
-
const cubeUV_minMipLevel = float( 4.0 );
|
|
21
|
-
const cubeUV_minTileSize = float( 16.0 );
|
|
20
|
+
const cubeUV_minMipLevel = /*@__PURE__*/ float( 4.0 );
|
|
21
|
+
const cubeUV_minTileSize = /*@__PURE__*/ float( 16.0 );
|
|
22
22
|
|
|
23
23
|
// These shader functions convert between the UV coordinates of a single face of
|
|
24
24
|
// a cubemap, the 0-5 integer index of a cube face, and the direction vector for
|
|
25
25
|
// sampling a textureCube (not generally normalized ).
|
|
26
26
|
|
|
27
|
-
const getFace =
|
|
27
|
+
const getFace = /*@__PURE__*/ Fn( ( [ direction ] ) => {
|
|
28
28
|
|
|
29
29
|
const absDirection = vec3( abs( direction ) ).toVar();
|
|
30
30
|
const face = float( - 1.0 ).toVar();
|
|
@@ -33,23 +33,23 @@ const getFace = tslFn( ( [ direction ] ) => {
|
|
|
33
33
|
|
|
34
34
|
If( absDirection.x.greaterThan( absDirection.y ), () => {
|
|
35
35
|
|
|
36
|
-
face.assign(
|
|
36
|
+
face.assign( select( direction.x.greaterThan( 0.0 ), 0.0, 3.0 ) );
|
|
37
37
|
|
|
38
|
-
} ).
|
|
38
|
+
} ).Else( () => {
|
|
39
39
|
|
|
40
|
-
face.assign(
|
|
40
|
+
face.assign( select( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
|
|
41
41
|
|
|
42
42
|
} );
|
|
43
43
|
|
|
44
|
-
} ).
|
|
44
|
+
} ).Else( () => {
|
|
45
45
|
|
|
46
46
|
If( absDirection.z.greaterThan( absDirection.y ), () => {
|
|
47
47
|
|
|
48
|
-
face.assign(
|
|
48
|
+
face.assign( select( direction.z.greaterThan( 0.0 ), 2.0, 5.0 ) );
|
|
49
49
|
|
|
50
|
-
} ).
|
|
50
|
+
} ).Else( () => {
|
|
51
51
|
|
|
52
|
-
face.assign(
|
|
52
|
+
face.assign( select( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
|
|
53
53
|
|
|
54
54
|
} );
|
|
55
55
|
|
|
@@ -66,7 +66,7 @@ const getFace = tslFn( ( [ direction ] ) => {
|
|
|
66
66
|
} );
|
|
67
67
|
|
|
68
68
|
// RH coordinate system; PMREM face-indexing convention
|
|
69
|
-
const getUV =
|
|
69
|
+
const getUV = /*@__PURE__*/ Fn( ( [ direction, face ] ) => {
|
|
70
70
|
|
|
71
71
|
const uv = vec2().toVar();
|
|
72
72
|
|
|
@@ -74,23 +74,23 @@ const getUV = tslFn( ( [ direction, face ] ) => {
|
|
|
74
74
|
|
|
75
75
|
uv.assign( vec2( direction.z, direction.y ).div( abs( direction.x ) ) ); // pos x
|
|
76
76
|
|
|
77
|
-
} ).
|
|
77
|
+
} ).ElseIf( face.equal( 1.0 ), () => {
|
|
78
78
|
|
|
79
79
|
uv.assign( vec2( direction.x.negate(), direction.z.negate() ).div( abs( direction.y ) ) ); // pos y
|
|
80
80
|
|
|
81
|
-
} ).
|
|
81
|
+
} ).ElseIf( face.equal( 2.0 ), () => {
|
|
82
82
|
|
|
83
83
|
uv.assign( vec2( direction.x.negate(), direction.y ).div( abs( direction.z ) ) ); // pos z
|
|
84
84
|
|
|
85
|
-
} ).
|
|
85
|
+
} ).ElseIf( face.equal( 3.0 ), () => {
|
|
86
86
|
|
|
87
87
|
uv.assign( vec2( direction.z.negate(), direction.y ).div( abs( direction.x ) ) ); // neg x
|
|
88
88
|
|
|
89
|
-
} ).
|
|
89
|
+
} ).ElseIf( face.equal( 4.0 ), () => {
|
|
90
90
|
|
|
91
91
|
uv.assign( vec2( direction.x.negate(), direction.z ).div( abs( direction.y ) ) ); // neg y
|
|
92
92
|
|
|
93
|
-
} ).
|
|
93
|
+
} ).Else( () => {
|
|
94
94
|
|
|
95
95
|
uv.assign( vec2( direction.x, direction.y ).div( abs( direction.z ) ) ); // neg z
|
|
96
96
|
|
|
@@ -107,7 +107,7 @@ const getUV = tslFn( ( [ direction, face ] ) => {
|
|
|
107
107
|
]
|
|
108
108
|
} );
|
|
109
109
|
|
|
110
|
-
const roughnessToMip =
|
|
110
|
+
const roughnessToMip = /*@__PURE__*/ Fn( ( [ roughness ] ) => {
|
|
111
111
|
|
|
112
112
|
const mip = float( 0.0 ).toVar();
|
|
113
113
|
|
|
@@ -115,19 +115,19 @@ const roughnessToMip = tslFn( ( [ roughness ] ) => {
|
|
|
115
115
|
|
|
116
116
|
mip.assign( cubeUV_r0.sub( roughness ).mul( cubeUV_m1.sub( cubeUV_m0 ) ).div( cubeUV_r0.sub( cubeUV_r1 ) ).add( cubeUV_m0 ) );
|
|
117
117
|
|
|
118
|
-
} ).
|
|
118
|
+
} ).ElseIf( roughness.greaterThanEqual( cubeUV_r4 ), () => {
|
|
119
119
|
|
|
120
120
|
mip.assign( cubeUV_r1.sub( roughness ).mul( cubeUV_m4.sub( cubeUV_m1 ) ).div( cubeUV_r1.sub( cubeUV_r4 ) ).add( cubeUV_m1 ) );
|
|
121
121
|
|
|
122
|
-
} ).
|
|
122
|
+
} ).ElseIf( roughness.greaterThanEqual( cubeUV_r5 ), () => {
|
|
123
123
|
|
|
124
124
|
mip.assign( cubeUV_r4.sub( roughness ).mul( cubeUV_m5.sub( cubeUV_m4 ) ).div( cubeUV_r4.sub( cubeUV_r5 ) ).add( cubeUV_m4 ) );
|
|
125
125
|
|
|
126
|
-
} ).
|
|
126
|
+
} ).ElseIf( roughness.greaterThanEqual( cubeUV_r6 ), () => {
|
|
127
127
|
|
|
128
128
|
mip.assign( cubeUV_r5.sub( roughness ).mul( cubeUV_m6.sub( cubeUV_m5 ) ).div( cubeUV_r5.sub( cubeUV_r6 ) ).add( cubeUV_m5 ) );
|
|
129
129
|
|
|
130
|
-
} ).
|
|
130
|
+
} ).Else( () => {
|
|
131
131
|
|
|
132
132
|
mip.assign( float( - 2.0 ).mul( log2( mul( 1.16, roughness ) ) ) ); // 1.16 = 1.79^0.25
|
|
133
133
|
|
|
@@ -144,7 +144,7 @@ const roughnessToMip = tslFn( ( [ roughness ] ) => {
|
|
|
144
144
|
} );
|
|
145
145
|
|
|
146
146
|
// RH coordinate system; PMREM face-indexing convention
|
|
147
|
-
export const getDirection =
|
|
147
|
+
export const getDirection = /*@__PURE__*/ Fn( ( [ uv_immutable, face ] ) => {
|
|
148
148
|
|
|
149
149
|
const uv = uv_immutable.toVar();
|
|
150
150
|
uv.assign( mul( 2.0, uv ).sub( 1.0 ) );
|
|
@@ -154,26 +154,26 @@ export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
|
|
|
154
154
|
|
|
155
155
|
direction.assign( direction.zyx ); // ( 1, v, u ) pos x
|
|
156
156
|
|
|
157
|
-
} ).
|
|
157
|
+
} ).ElseIf( face.equal( 1.0 ), () => {
|
|
158
158
|
|
|
159
159
|
direction.assign( direction.xzy );
|
|
160
160
|
direction.xz.mulAssign( - 1.0 ); // ( -u, 1, -v ) pos y
|
|
161
161
|
|
|
162
|
-
} ).
|
|
162
|
+
} ).ElseIf( face.equal( 2.0 ), () => {
|
|
163
163
|
|
|
164
164
|
direction.x.mulAssign( - 1.0 ); // ( -u, v, 1 ) pos z
|
|
165
165
|
|
|
166
|
-
} ).
|
|
166
|
+
} ).ElseIf( face.equal( 3.0 ), () => {
|
|
167
167
|
|
|
168
168
|
direction.assign( direction.zyx );
|
|
169
169
|
direction.xz.mulAssign( - 1.0 ); // ( -1, v, -u ) neg x
|
|
170
170
|
|
|
171
|
-
} ).
|
|
171
|
+
} ).ElseIf( face.equal( 4.0 ), () => {
|
|
172
172
|
|
|
173
173
|
direction.assign( direction.xzy );
|
|
174
174
|
direction.xy.mulAssign( - 1.0 ); // ( -u, -1, v ) neg y
|
|
175
175
|
|
|
176
|
-
} ).
|
|
176
|
+
} ).ElseIf( face.equal( 5.0 ), () => {
|
|
177
177
|
|
|
178
178
|
direction.z.mulAssign( - 1.0 ); // ( u, v, -1 ) neg zS
|
|
179
179
|
|
|
@@ -192,7 +192,7 @@ export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
|
|
|
192
192
|
|
|
193
193
|
//
|
|
194
194
|
|
|
195
|
-
export const textureCubeUV =
|
|
195
|
+
export const textureCubeUV = /*@__PURE__*/ Fn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
|
|
196
196
|
|
|
197
197
|
const roughness = float( roughness_immutable );
|
|
198
198
|
const sampleDir = vec3( sampleDir_immutable );
|
|
@@ -214,7 +214,7 @@ export const textureCubeUV = tslFn( ( [ envMap, sampleDir_immutable, roughness_i
|
|
|
214
214
|
|
|
215
215
|
} );
|
|
216
216
|
|
|
217
|
-
const bilinearCubeUV =
|
|
217
|
+
const bilinearCubeUV = /*@__PURE__*/ Fn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
|
|
218
218
|
|
|
219
219
|
const mipInt = float( mipInt_immutable ).toVar();
|
|
220
220
|
const direction = vec3( direction_immutable );
|
|
@@ -241,7 +241,7 @@ const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable,
|
|
|
241
241
|
|
|
242
242
|
} );
|
|
243
243
|
|
|
244
|
-
const getSample =
|
|
244
|
+
const getSample = /*@__PURE__*/ Fn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
|
|
245
245
|
|
|
246
246
|
const cosTheta = cos( theta );
|
|
247
247
|
|
|
@@ -254,9 +254,9 @@ const getSample = tslFn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEU
|
|
|
254
254
|
|
|
255
255
|
} );
|
|
256
256
|
|
|
257
|
-
export const blur =
|
|
257
|
+
export const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
|
|
258
258
|
|
|
259
|
-
const axis = vec3(
|
|
259
|
+
const axis = vec3( select( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar();
|
|
260
260
|
|
|
261
261
|
If( all( axis.equals( vec3( 0.0 ) ) ), () => {
|
|
262
262
|
|
|
@@ -269,7 +269,7 @@ export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weight
|
|
|
269
269
|
const gl_FragColor = vec3().toVar();
|
|
270
270
|
gl_FragColor.addAssign( weights.element( int( 0 ) ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
Loop( { start: int( 1 ), end: n }, ( { i } ) => {
|
|
273
273
|
|
|
274
274
|
If( i.greaterThanEqual( samples ), () => {
|
|
275
275
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { uv } from '../accessors/UV.js';
|
|
2
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
3
|
+
|
|
4
|
+
export const checker = /*@__PURE__*/ Fn( ( [ coord = uv() ] ) => {
|
|
5
|
+
|
|
6
|
+
const uv = coord.mul( 2.0 );
|
|
7
|
+
|
|
8
|
+
const cx = uv.x.floor();
|
|
9
|
+
const cy = uv.y.floor();
|
|
10
|
+
const result = cx.add( cy ).mod( 2.0 );
|
|
11
|
+
|
|
12
|
+
return result.sign();
|
|
13
|
+
|
|
14
|
+
} );
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Non-PURE exports list, side-effects are required here.
|
|
2
|
+
// TSL Base Syntax
|
|
3
|
+
|
|
4
|
+
export * from './TSLCore.js'; // float(), vec2(), vec3(), vec4(), mat3(), mat4(), Fn(), If(), element(), nodeObject(), nodeProxy(), ...
|
|
5
|
+
export * from '../core/UniformNode.js'; // uniform()
|
|
6
|
+
export * from '../core/PropertyNode.js'; // property() <-> TODO: Seperate Material Properties in other file
|
|
7
|
+
export * from '../core/AssignNode.js'; // .assign()
|
|
8
|
+
export * from '../code/FunctionCallNode.js'; // .call()
|
|
9
|
+
export * from '../math/OperatorNode.js'; // .add(), .sub(), ...
|
|
10
|
+
export * from '../math/MathNode.js'; // abs(), floor(), ...
|
|
11
|
+
export * from '../math/ConditionalNode.js'; // select(), ...
|
|
12
|
+
export * from '../core/ContextNode.js'; // .context()
|
|
13
|
+
export * from '../core/VarNode.js'; // .var() -> TODO: Maybe rename .toVar() -> .var()
|
|
14
|
+
export * from '../core/VaryingNode.js'; // varying() -> TODO: Add vertexStage()
|
|
15
|
+
export * from '../display/ColorSpaceNode.js'; // .toColorSpace()
|
|
16
|
+
export * from '../display/ToneMappingNode.js'; // .toToneMapping()
|
|
17
|
+
export * from '../accessors/BufferAttributeNode.js'; // .toAttribute()
|
|
18
|
+
export * from '../gpgpu/ComputeNode.js'; // .compute()
|
|
19
|
+
export * from '../core/CacheNode.js'; // .cache()
|
|
20
|
+
export * from '../core/BypassNode.js'; // .bypass()
|
|
21
|
+
export * from '../utils/RemapNode.js'; // .remap(), .remapClamp()
|
|
22
|
+
export * from '../code/ExpressionNode.js'; // expression()
|
|
23
|
+
export * from '../utils/Discard.js'; // Discard(), Return()
|
|
24
|
+
export * from '../display/RenderOutputNode.js'; // .renderOutput()
|
|
25
|
+
|
|
26
|
+
export function addNodeElement( name/*, nodeElement*/ ) {
|
|
27
|
+
|
|
28
|
+
console.warn( 'THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add', name );
|
|
29
|
+
|
|
30
|
+
}
|