super-three 0.167.0 → 0.169.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 +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- 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 +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- 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/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- 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/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- 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 +34 -33
- 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/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- 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} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -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 +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- 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/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -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 +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- 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 +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- 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 +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- 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/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- 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/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
3
3
|
import ConvertNode from '../utils/ConvertNode.js';
|
|
4
4
|
import JoinNode from '../utils/JoinNode.js';
|
|
5
5
|
import SplitNode from '../utils/SplitNode.js';
|
|
6
6
|
import SetNode from '../utils/SetNode.js';
|
|
7
|
+
import FlipNode from '../utils/FlipNode.js';
|
|
7
8
|
import ConstNode from '../core/ConstNode.js';
|
|
8
9
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
9
10
|
|
|
@@ -11,13 +12,13 @@ import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
|
11
12
|
|
|
12
13
|
let currentStack = null;
|
|
13
14
|
|
|
14
|
-
const NodeElements = new Map();
|
|
15
|
+
const NodeElements = new Map();
|
|
15
16
|
|
|
16
|
-
export function
|
|
17
|
+
export function addMethodChaining( name, nodeElement ) {
|
|
17
18
|
|
|
18
19
|
if ( NodeElements.has( name ) ) {
|
|
19
20
|
|
|
20
|
-
console.warn( `Redefinition of
|
|
21
|
+
console.warn( `Redefinition of method chaining ${ name }` );
|
|
21
22
|
return;
|
|
22
23
|
|
|
23
24
|
}
|
|
@@ -29,6 +30,7 @@ export function addNodeElement( name, nodeElement ) {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
const parseSwizzle = ( props ) => props.replace( /r|s/g, 'x' ).replace( /g|t/g, 'y' ).replace( /b|p/g, 'z' ).replace( /a|q/g, 'w' );
|
|
33
|
+
const parseSwizzleAndSort = ( props ) => parseSwizzle( props ).split( '' ).sort().join( '' );
|
|
32
34
|
|
|
33
35
|
const shaderNodeHandler = {
|
|
34
36
|
|
|
@@ -80,15 +82,19 @@ const shaderNodeHandler = {
|
|
|
80
82
|
|
|
81
83
|
} else if ( /^set[XYZWRGBASTPQ]{1,4}$/.test( prop ) === true ) {
|
|
82
84
|
|
|
83
|
-
// set properties ( swizzle )
|
|
85
|
+
// set properties ( swizzle ) and sort to xyzw sequence
|
|
84
86
|
|
|
85
|
-
prop =
|
|
87
|
+
prop = parseSwizzleAndSort( prop.slice( 3 ).toLowerCase() );
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
return ( value ) => nodeObject( new SetNode( node, prop, value ) );
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
} else if ( /^flip[XYZWRGBASTPQ]{1,4}$/.test( prop ) === true ) {
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
// set properties ( swizzle ) and sort to xyzw sequence
|
|
94
|
+
|
|
95
|
+
prop = parseSwizzleAndSort( prop.slice( 4 ).toLowerCase() );
|
|
96
|
+
|
|
97
|
+
return () => nodeObject( new FlipNode( nodeObject( node ), prop ) );
|
|
92
98
|
|
|
93
99
|
} else if ( prop === 'width' || prop === 'height' || prop === 'depth' ) {
|
|
94
100
|
|
|
@@ -164,7 +170,7 @@ const ShaderNodeObject = function ( obj, altType = null ) {
|
|
|
164
170
|
|
|
165
171
|
} else if ( type === 'shader' ) {
|
|
166
172
|
|
|
167
|
-
return
|
|
173
|
+
return Fn( obj );
|
|
168
174
|
|
|
169
175
|
}
|
|
170
176
|
|
|
@@ -251,15 +257,7 @@ class ShaderCallNodeInternal extends Node {
|
|
|
251
257
|
|
|
252
258
|
getNodeType( builder ) {
|
|
253
259
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if ( properties.outputNode === null ) {
|
|
257
|
-
|
|
258
|
-
properties.outputNode = this.setupOutput( builder );
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return properties.outputNode.getNodeType( builder );
|
|
260
|
+
return this.shaderNode.nodeType || this.getOutputNode( builder ).getNodeType( builder );
|
|
263
261
|
|
|
264
262
|
}
|
|
265
263
|
|
|
@@ -267,6 +265,13 @@ class ShaderCallNodeInternal extends Node {
|
|
|
267
265
|
|
|
268
266
|
const { shaderNode, inputNodes } = this;
|
|
269
267
|
|
|
268
|
+
const properties = builder.getNodeProperties( shaderNode );
|
|
269
|
+
if ( properties.onceOutput ) return properties.onceOutput;
|
|
270
|
+
|
|
271
|
+
//
|
|
272
|
+
|
|
273
|
+
let result = null;
|
|
274
|
+
|
|
270
275
|
if ( shaderNode.layout ) {
|
|
271
276
|
|
|
272
277
|
let functionNodesCacheMap = nodeBuilderFunctionsCacheMap.get( builder.constructor );
|
|
@@ -295,22 +300,44 @@ class ShaderCallNodeInternal extends Node {
|
|
|
295
300
|
|
|
296
301
|
}
|
|
297
302
|
|
|
298
|
-
|
|
303
|
+
result = nodeObject( functionNode.call( inputNodes ) );
|
|
304
|
+
|
|
305
|
+
} else {
|
|
306
|
+
|
|
307
|
+
const jsFunc = shaderNode.jsFunc;
|
|
308
|
+
const outputNode = inputNodes !== null ? jsFunc( inputNodes, builder ) : jsFunc( builder );
|
|
309
|
+
|
|
310
|
+
result = nodeObject( outputNode );
|
|
299
311
|
|
|
300
312
|
}
|
|
301
313
|
|
|
302
|
-
|
|
303
|
-
|
|
314
|
+
if ( shaderNode.once ) {
|
|
315
|
+
|
|
316
|
+
properties.onceOutput = result;
|
|
317
|
+
|
|
318
|
+
}
|
|
304
319
|
|
|
305
|
-
return
|
|
320
|
+
return result;
|
|
306
321
|
|
|
307
322
|
}
|
|
308
323
|
|
|
309
|
-
|
|
324
|
+
getOutputNode( builder ) {
|
|
325
|
+
|
|
326
|
+
const properties = builder.getNodeProperties( this );
|
|
310
327
|
|
|
311
|
-
|
|
328
|
+
if ( properties.outputNode === null ) {
|
|
312
329
|
|
|
313
|
-
|
|
330
|
+
properties.outputNode = this.setupOutput( builder );
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return properties.outputNode;
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
setup( builder ) {
|
|
339
|
+
|
|
340
|
+
return this.getOutputNode( builder );
|
|
314
341
|
|
|
315
342
|
}
|
|
316
343
|
|
|
@@ -326,17 +353,9 @@ class ShaderCallNodeInternal extends Node {
|
|
|
326
353
|
|
|
327
354
|
generate( builder, output ) {
|
|
328
355
|
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
if ( outputNode === null ) {
|
|
356
|
+
const outputNode = this.getOutputNode( builder );
|
|
332
357
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return this.call( builder ).build( builder, output );
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return super.generate( builder, output );
|
|
358
|
+
return outputNode.build( builder, output );
|
|
340
359
|
|
|
341
360
|
}
|
|
342
361
|
|
|
@@ -344,20 +363,16 @@ class ShaderCallNodeInternal extends Node {
|
|
|
344
363
|
|
|
345
364
|
class ShaderNodeInternal extends Node {
|
|
346
365
|
|
|
347
|
-
constructor( jsFunc ) {
|
|
366
|
+
constructor( jsFunc, nodeType ) {
|
|
348
367
|
|
|
349
|
-
super();
|
|
368
|
+
super( nodeType );
|
|
350
369
|
|
|
351
370
|
this.jsFunc = jsFunc;
|
|
352
371
|
this.layout = null;
|
|
353
372
|
|
|
354
373
|
this.global = true;
|
|
355
374
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
get isArrayInput() {
|
|
359
|
-
|
|
360
|
-
return /^\((\s+)?\[/.test( this.jsFunc.toString() );
|
|
375
|
+
this.once = false;
|
|
361
376
|
|
|
362
377
|
}
|
|
363
378
|
|
|
@@ -472,7 +487,7 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
472
487
|
|
|
473
488
|
// exports
|
|
474
489
|
|
|
475
|
-
export const defined = (
|
|
490
|
+
export const defined = ( v ) => typeof v === 'object' && v !== null ? v.value : v; // TODO: remove boolean conversion and defined function
|
|
476
491
|
|
|
477
492
|
// utils
|
|
478
493
|
|
|
@@ -480,9 +495,9 @@ export const getConstNodeType = ( value ) => ( value !== undefined && value !==
|
|
|
480
495
|
|
|
481
496
|
// shader node base
|
|
482
497
|
|
|
483
|
-
export function ShaderNode( jsFunc ) {
|
|
498
|
+
export function ShaderNode( jsFunc, nodeType ) {
|
|
484
499
|
|
|
485
|
-
return new Proxy( new ShaderNodeInternal( jsFunc ), shaderNodeHandler );
|
|
500
|
+
return new Proxy( new ShaderNodeInternal( jsFunc, nodeType ), shaderNodeHandler );
|
|
486
501
|
|
|
487
502
|
}
|
|
488
503
|
|
|
@@ -492,9 +507,9 @@ export const nodeArray = ( val, altType = null ) => new ShaderNodeArray( val, al
|
|
|
492
507
|
export const nodeProxy = ( ...params ) => new ShaderNodeProxy( ...params );
|
|
493
508
|
export const nodeImmutable = ( ...params ) => new ShaderNodeImmutable( ...params );
|
|
494
509
|
|
|
495
|
-
export const
|
|
510
|
+
export const Fn = ( jsFunc, nodeType ) => {
|
|
496
511
|
|
|
497
|
-
const shaderNode = new ShaderNode( jsFunc );
|
|
512
|
+
const shaderNode = new ShaderNode( jsFunc, nodeType );
|
|
498
513
|
|
|
499
514
|
const fn = ( ...params ) => {
|
|
500
515
|
|
|
@@ -517,6 +532,7 @@ export const tslFn = ( jsFunc ) => {
|
|
|
517
532
|
};
|
|
518
533
|
|
|
519
534
|
fn.shaderNode = shaderNode;
|
|
535
|
+
|
|
520
536
|
fn.setLayout = ( layout ) => {
|
|
521
537
|
|
|
522
538
|
shaderNode.setLayout( layout );
|
|
@@ -525,15 +541,28 @@ export const tslFn = ( jsFunc ) => {
|
|
|
525
541
|
|
|
526
542
|
};
|
|
527
543
|
|
|
544
|
+
fn.once = () => {
|
|
545
|
+
|
|
546
|
+
shaderNode.once = true;
|
|
547
|
+
|
|
548
|
+
return fn;
|
|
549
|
+
|
|
550
|
+
};
|
|
551
|
+
|
|
528
552
|
return fn;
|
|
529
553
|
|
|
530
554
|
};
|
|
531
555
|
|
|
532
|
-
|
|
556
|
+
export const tslFn = ( ...params ) => { // @deprecated, r168
|
|
557
|
+
|
|
558
|
+
console.warn( 'TSL.ShaderNode: tslFn() has been renamed to Fn().' );
|
|
559
|
+
return Fn( ...params );
|
|
560
|
+
|
|
561
|
+
};
|
|
533
562
|
|
|
534
563
|
//
|
|
535
564
|
|
|
536
|
-
|
|
565
|
+
addMethodChaining( 'toGlobal', ( node ) => {
|
|
537
566
|
|
|
538
567
|
node.global = true;
|
|
539
568
|
|
|
@@ -557,7 +586,7 @@ export const setCurrentStack = ( stack ) => {
|
|
|
557
586
|
|
|
558
587
|
export const getCurrentStack = () => currentStack;
|
|
559
588
|
|
|
560
|
-
export const If = ( ...params ) => currentStack.
|
|
589
|
+
export const If = ( ...params ) => currentStack.If( ...params );
|
|
561
590
|
|
|
562
591
|
export function append( node ) {
|
|
563
592
|
|
|
@@ -567,10 +596,9 @@ export function append( node ) {
|
|
|
567
596
|
|
|
568
597
|
}
|
|
569
598
|
|
|
570
|
-
|
|
599
|
+
addMethodChaining( 'append', append );
|
|
571
600
|
|
|
572
601
|
// types
|
|
573
|
-
// @TODO: Maybe export from ConstNode.js?
|
|
574
602
|
|
|
575
603
|
export const color = new ConvertType( 'color' );
|
|
576
604
|
|
|
@@ -595,58 +623,38 @@ export const uvec4 = new ConvertType( 'uvec4' );
|
|
|
595
623
|
export const bvec4 = new ConvertType( 'bvec4' );
|
|
596
624
|
|
|
597
625
|
export const mat2 = new ConvertType( 'mat2' );
|
|
598
|
-
export const imat2 = new ConvertType( 'imat2' );
|
|
599
|
-
export const umat2 = new ConvertType( 'umat2' );
|
|
600
|
-
export const bmat2 = new ConvertType( 'bmat2' );
|
|
601
|
-
|
|
602
626
|
export const mat3 = new ConvertType( 'mat3' );
|
|
603
|
-
export const imat3 = new ConvertType( 'imat3' );
|
|
604
|
-
export const umat3 = new ConvertType( 'umat3' );
|
|
605
|
-
export const bmat3 = new ConvertType( 'bmat3' );
|
|
606
|
-
|
|
607
627
|
export const mat4 = new ConvertType( 'mat4' );
|
|
608
|
-
export const imat4 = new ConvertType( 'imat4' );
|
|
609
|
-
export const umat4 = new ConvertType( 'umat4' );
|
|
610
|
-
export const bmat4 = new ConvertType( 'bmat4' );
|
|
611
628
|
|
|
612
629
|
export const string = ( value = '' ) => nodeObject( new ConstNode( value, 'string' ) );
|
|
613
630
|
export const arrayBuffer = ( value ) => nodeObject( new ConstNode( value, 'ArrayBuffer' ) );
|
|
614
631
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
addNodeElement( 'toBmat2', bmat2 );
|
|
636
|
-
addNodeElement( 'toMat3', mat3 );
|
|
637
|
-
addNodeElement( 'toImat3', imat3 );
|
|
638
|
-
addNodeElement( 'toUmat3', umat3 );
|
|
639
|
-
addNodeElement( 'toBmat3', bmat3 );
|
|
640
|
-
addNodeElement( 'toMat4', mat4 );
|
|
641
|
-
addNodeElement( 'toImat4', imat4 );
|
|
642
|
-
addNodeElement( 'toUmat4', umat4 );
|
|
643
|
-
addNodeElement( 'toBmat4', bmat4 );
|
|
632
|
+
addMethodChaining( 'toColor', color );
|
|
633
|
+
addMethodChaining( 'toFloat', float );
|
|
634
|
+
addMethodChaining( 'toInt', int );
|
|
635
|
+
addMethodChaining( 'toUint', uint );
|
|
636
|
+
addMethodChaining( 'toBool', bool );
|
|
637
|
+
addMethodChaining( 'toVec2', vec2 );
|
|
638
|
+
addMethodChaining( 'toIVec2', ivec2 );
|
|
639
|
+
addMethodChaining( 'toUVec2', uvec2 );
|
|
640
|
+
addMethodChaining( 'toBVec2', bvec2 );
|
|
641
|
+
addMethodChaining( 'toVec3', vec3 );
|
|
642
|
+
addMethodChaining( 'toIVec3', ivec3 );
|
|
643
|
+
addMethodChaining( 'toUVec3', uvec3 );
|
|
644
|
+
addMethodChaining( 'toBVec3', bvec3 );
|
|
645
|
+
addMethodChaining( 'toVec4', vec4 );
|
|
646
|
+
addMethodChaining( 'toIVec4', ivec4 );
|
|
647
|
+
addMethodChaining( 'toUVec4', uvec4 );
|
|
648
|
+
addMethodChaining( 'toBVec4', bvec4 );
|
|
649
|
+
addMethodChaining( 'toMat2', mat2 );
|
|
650
|
+
addMethodChaining( 'toMat3', mat3 );
|
|
651
|
+
addMethodChaining( 'toMat4', mat4 );
|
|
644
652
|
|
|
645
653
|
// basic nodes
|
|
646
|
-
|
|
647
|
-
export const element = nodeProxy( ArrayElementNode );
|
|
654
|
+
|
|
655
|
+
export const element = /*@__PURE__*/ nodeProxy( ArrayElementNode );
|
|
648
656
|
export const convert = ( node, types ) => nodeObject( new ConvertNode( nodeObject( node ), types ) );
|
|
649
657
|
export const split = ( node, channels ) => nodeObject( new SplitNode( nodeObject( node ), channels ) );
|
|
650
658
|
|
|
651
|
-
|
|
652
|
-
|
|
659
|
+
addMethodChaining( 'element', element );
|
|
660
|
+
addMethodChaining( 'convert', convert );
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
|
|
3
|
-
class ArrayElementNode extends Node {
|
|
3
|
+
class ArrayElementNode extends Node {
|
|
4
|
+
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'ArrayElementNode';
|
|
8
|
+
|
|
9
|
+
} // @TODO: If extending from TempNode it breaks webgpu_compute
|
|
4
10
|
|
|
5
11
|
constructor( node, indexNode ) {
|
|
6
12
|
|
|
@@ -31,5 +37,3 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
|
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
export default ArrayElementNode;
|
|
34
|
-
|
|
35
|
-
addNodeClass( 'ArrayElementNode', ArrayElementNode );
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
|
|
3
3
|
class ConvertNode extends Node {
|
|
4
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'ConvertNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
constructor( node, convertTo ) {
|
|
6
12
|
|
|
7
13
|
super();
|
|
@@ -61,5 +67,3 @@ class ConvertNode extends Node {
|
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
export default ConvertNode;
|
|
64
|
-
|
|
65
|
-
addNodeClass( 'ConvertNode', ConvertNode );
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
4
|
+
import { CubeTexture } from '../../textures/CubeTexture.js';
|
|
5
|
+
import { cubeTexture } from '../accessors/CubeTextureNode.js';
|
|
6
|
+
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
7
|
+
import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js';
|
|
8
|
+
|
|
9
|
+
const _cache = new WeakMap();
|
|
10
|
+
|
|
11
|
+
class CubeMapNode extends TempNode {
|
|
12
|
+
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'CubeMapNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor( envNode ) {
|
|
20
|
+
|
|
21
|
+
super( 'vec3' );
|
|
22
|
+
|
|
23
|
+
this.envNode = envNode;
|
|
24
|
+
|
|
25
|
+
this._cubeTexture = null;
|
|
26
|
+
this._cubeTextureNode = cubeTexture();
|
|
27
|
+
|
|
28
|
+
const defaultTexture = new CubeTexture();
|
|
29
|
+
defaultTexture.isRenderTargetTexture = true;
|
|
30
|
+
|
|
31
|
+
this._defaultTexture = defaultTexture;
|
|
32
|
+
|
|
33
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
updateBefore( frame ) {
|
|
38
|
+
|
|
39
|
+
const { renderer, material } = frame;
|
|
40
|
+
|
|
41
|
+
const envNode = this.envNode;
|
|
42
|
+
|
|
43
|
+
if ( envNode.isTextureNode || envNode.isMaterialReferenceNode ) {
|
|
44
|
+
|
|
45
|
+
const texture = ( envNode.isTextureNode ) ? envNode.value : material[ envNode.property ];
|
|
46
|
+
|
|
47
|
+
if ( texture && texture.isTexture ) {
|
|
48
|
+
|
|
49
|
+
const mapping = texture.mapping;
|
|
50
|
+
|
|
51
|
+
if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) {
|
|
52
|
+
|
|
53
|
+
// check for converted cubemap map
|
|
54
|
+
|
|
55
|
+
if ( _cache.has( texture ) ) {
|
|
56
|
+
|
|
57
|
+
const cubeMap = _cache.get( texture );
|
|
58
|
+
|
|
59
|
+
mapTextureMapping( cubeMap, texture.mapping );
|
|
60
|
+
this._cubeTexture = cubeMap;
|
|
61
|
+
|
|
62
|
+
} else {
|
|
63
|
+
|
|
64
|
+
// create cube map from equirectangular map
|
|
65
|
+
|
|
66
|
+
const image = texture.image;
|
|
67
|
+
|
|
68
|
+
if ( isEquirectangularMapReady( image ) ) {
|
|
69
|
+
|
|
70
|
+
const renderTarget = new CubeRenderTarget( image.height );
|
|
71
|
+
renderTarget.fromEquirectangularTexture( renderer, texture );
|
|
72
|
+
|
|
73
|
+
mapTextureMapping( renderTarget.texture, texture.mapping );
|
|
74
|
+
this._cubeTexture = renderTarget.texture;
|
|
75
|
+
|
|
76
|
+
_cache.set( texture, renderTarget.texture );
|
|
77
|
+
|
|
78
|
+
texture.addEventListener( 'dispose', onTextureDispose );
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
|
|
82
|
+
// default cube texture as fallback when equirectangular texture is not yet loaded
|
|
83
|
+
|
|
84
|
+
this._cubeTexture = this._defaultTexture;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//
|
|
91
|
+
|
|
92
|
+
this._cubeTextureNode.value = this._cubeTexture;
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
|
|
96
|
+
// envNode already refers to a cube map
|
|
97
|
+
|
|
98
|
+
this._cubeTextureNode = this.envNode;
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setup( builder ) {
|
|
109
|
+
|
|
110
|
+
this.updateBefore( builder );
|
|
111
|
+
|
|
112
|
+
return this._cubeTextureNode;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default CubeMapNode;
|
|
119
|
+
|
|
120
|
+
function isEquirectangularMapReady( image ) {
|
|
121
|
+
|
|
122
|
+
if ( image === null || image === undefined ) return false;
|
|
123
|
+
|
|
124
|
+
return image.height > 0;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function onTextureDispose( event ) {
|
|
129
|
+
|
|
130
|
+
const texture = event.target;
|
|
131
|
+
|
|
132
|
+
texture.removeEventListener( 'dispose', onTextureDispose );
|
|
133
|
+
|
|
134
|
+
const renderTarget = _cache.get( texture );
|
|
135
|
+
|
|
136
|
+
if ( renderTarget !== undefined ) {
|
|
137
|
+
|
|
138
|
+
_cache.delete( texture );
|
|
139
|
+
|
|
140
|
+
renderTarget.dispose();
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function mapTextureMapping( texture, mapping ) {
|
|
147
|
+
|
|
148
|
+
if ( mapping === EquirectangularReflectionMapping ) {
|
|
149
|
+
|
|
150
|
+
texture.mapping = CubeReflectionMapping;
|
|
151
|
+
|
|
152
|
+
} else if ( mapping === EquirectangularRefractionMapping ) {
|
|
153
|
+
|
|
154
|
+
texture.mapping = CubeRefractionMapping;
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const cubeMapNode = /*@__PURE__*/ nodeProxy( CubeMapNode );
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { select } from '../math/ConditionalNode.js';
|
|
2
|
+
import { expression } from '../code/ExpressionNode.js';
|
|
3
|
+
import { addMethodChaining } from '../tsl/TSLCore.js';
|
|
4
|
+
|
|
5
|
+
export const Discard = ( conditional ) => ( conditional ? select( conditional, expression( 'discard' ) ) : expression( 'discard' ) ).append();
|
|
6
|
+
export const Return = () => expression( 'return' ).append();
|
|
7
|
+
|
|
8
|
+
addMethodChaining( 'discard', Discard );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { positionWorldDirection } from '../accessors/
|
|
3
|
-
import { nodeProxy, vec2 } from '../
|
|
4
|
-
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import { positionWorldDirection } from '../accessors/Position.js';
|
|
3
|
+
import { nodeProxy, vec2 } from '../tsl/TSLBase.js';
|
|
5
4
|
|
|
6
5
|
class EquirectUVNode extends TempNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'EquirectUVNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( dirNode = positionWorldDirection ) {
|
|
9
14
|
|
|
10
15
|
super( 'vec2' );
|
|
@@ -28,6 +33,4 @@ class EquirectUVNode extends TempNode {
|
|
|
28
33
|
|
|
29
34
|
export default EquirectUVNode;
|
|
30
35
|
|
|
31
|
-
export const equirectUV = nodeProxy( EquirectUVNode );
|
|
32
|
-
|
|
33
|
-
addNodeClass( 'EquirectUVNode', EquirectUVNode );
|
|
36
|
+
export const equirectUV = /*@__PURE__*/ nodeProxy( EquirectUVNode );
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { vectorComponents } from '../core/constants.js';
|
|
3
|
+
|
|
4
|
+
class FlipNode extends TempNode {
|
|
5
|
+
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'FlipNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor( sourceNode, components ) {
|
|
13
|
+
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
this.sourceNode = sourceNode;
|
|
17
|
+
this.components = components;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getNodeType( builder ) {
|
|
22
|
+
|
|
23
|
+
return this.sourceNode.getNodeType( builder );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
generate( builder ) {
|
|
28
|
+
|
|
29
|
+
const { components, sourceNode } = this;
|
|
30
|
+
|
|
31
|
+
const sourceType = this.getNodeType( builder );
|
|
32
|
+
const sourceSnippet = sourceNode.build( builder );
|
|
33
|
+
|
|
34
|
+
const sourceCache = builder.getVarFromNode( this );
|
|
35
|
+
const sourceProperty = builder.getPropertyName( sourceCache );
|
|
36
|
+
|
|
37
|
+
builder.addLineFlowCode( sourceProperty + ' = ' + sourceSnippet, this );
|
|
38
|
+
|
|
39
|
+
const length = builder.getTypeLength( sourceType );
|
|
40
|
+
const snippetValues = [];
|
|
41
|
+
|
|
42
|
+
let componentIndex = 0;
|
|
43
|
+
|
|
44
|
+
for ( let i = 0; i < length; i ++ ) {
|
|
45
|
+
|
|
46
|
+
const component = vectorComponents[ i ];
|
|
47
|
+
|
|
48
|
+
if ( component === components[ componentIndex ] ) {
|
|
49
|
+
|
|
50
|
+
snippetValues.push( '1.0 - ' + ( sourceProperty + '.' + component ) );
|
|
51
|
+
|
|
52
|
+
componentIndex ++;
|
|
53
|
+
|
|
54
|
+
} else {
|
|
55
|
+
|
|
56
|
+
snippetValues.push( sourceProperty + '.' + component );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return `${ builder.getType( sourceType ) }( ${ snippetValues.join( ', ' ) } )`;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default FlipNode;
|