super-three 0.152.0 → 0.154.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +778 -557
- package/build/three.js +778 -557
- package/build/three.min.js +1 -1
- package/build/three.module.js +769 -539
- package/build/three.module.min.js +1 -1
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +15 -1
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +5 -1
- package/examples/jsm/csm/CSM.js +1 -3
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/exporters/GLTFExporter.js +74 -2
- package/examples/jsm/exporters/USDZExporter.js +170 -129
- package/examples/jsm/helpers/ViewHelper.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/DRACOLoader.js +2 -0
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/GLTFLoader.js +230 -94
- package/examples/jsm/loaders/KTX2Loader.js +106 -47
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/MMDLoader.js +40 -13
- package/examples/jsm/loaders/PCDLoader.js +25 -10
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +30 -8
- package/examples/jsm/loaders/STLLoader.js +8 -3
- package/examples/jsm/loaders/VRMLLoader.js +55 -7
- package/examples/jsm/loaders/VTKLoader.js +12 -4
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +82 -37
- package/examples/jsm/misc/GPUComputationRenderer.js +1 -0
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/nodes/Nodes.js +22 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +99 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +29 -12
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +4 -9
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/ReferenceNode.js +2 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +2 -2
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +13 -16
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +86 -8
- package/examples/jsm/nodes/core/NodeUtils.js +10 -0
- package/examples/jsm/nodes/core/PropertyNode.js +6 -2
- package/examples/jsm/nodes/core/StackNode.js +8 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +24 -15
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +7 -6
- package/examples/jsm/nodes/display/ViewportTextureNode.js +33 -19
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +132 -19
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +33 -51
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +6 -3
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +107 -62
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +119 -29
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +60 -33
- package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -3
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +4 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/physics/RapierPhysics.js +93 -133
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -0
- package/examples/jsm/postprocessing/BloomPass.js +7 -2
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +4 -1
- package/examples/jsm/postprocessing/FilmPass.js +1 -0
- package/examples/jsm/postprocessing/OutlinePass.js +8 -9
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -2
- package/examples/jsm/postprocessing/SMAAPass.js +5 -2
- package/examples/jsm/postprocessing/SSAARenderPass.js +5 -13
- package/examples/jsm/postprocessing/SSAOPass.js +4 -2
- package/examples/jsm/postprocessing/SSRPass.js +3 -1
- package/examples/jsm/postprocessing/SavePass.js +5 -2
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +17 -4
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +13 -13
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +2 -2
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +162 -0
- package/examples/jsm/renderers/common/Background.js +134 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/{webgpu/WebGPUWeakMap.js → common/ChainMap.js} +11 -5
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/{webgpu/WebGPUGeometries.js → common/Geometries.js} +38 -37
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +321 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +2 -39
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +113 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderTarget.js → common/RenderTarget.js} +2 -2
- package/examples/jsm/renderers/common/Renderer.js +864 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodes.js → common/nodes/NodeRender.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +847 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -1131
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +75 -45
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +255 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +6 -7
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +154 -247
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +3 -25
- package/examples/jsm/renderers/webgpu/{WebGPUTextures.js → utils/WebGPUTextureUtils.js} +392 -505
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +92 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +4 -2
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +2 -0
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +17 -1
- package/examples/jsm/utils/TextureUtils.js +86 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +3 -1
- package/src/Three.Legacy.js +0 -228
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +13 -1
- package/src/core/BufferAttribute.js +3 -25
- package/src/core/BufferGeometry.js +1 -8
- package/src/core/Object3D.js +1 -1
- package/src/extras/core/Curve.js +1 -1
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +5 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +13 -1
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/math/Color.js +16 -11
- package/src/math/Frustum.js +16 -2
- package/src/math/MathUtils.js +16 -0
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/objects/InstancedMesh.js +3 -0
- package/src/objects/Mesh.js +14 -10
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +36 -8
- package/src/renderers/WebGLRenderer.js +126 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -2
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +10 -5
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +7 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +6 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +12 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib.js +4 -1
- package/src/renderers/shaders/UniformsLib.js +2 -0
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLMaterials.js +18 -0
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +43 -5
- package/src/renderers/webgl/WebGLPrograms.js +19 -7
- package/src/renderers/webgl/WebGLTextures.js +19 -1
- package/src/renderers/webvr/WebVRManager.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +39 -99
- package/src/scenes/Scene.js +0 -14
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +1 -1
- package/examples/jsm/exporters/ColladaExporter.js +0 -725
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -26
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -361
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -197
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -190
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -270
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -44
- package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +0 -50
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -274
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -54
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -75
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -88
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { add, mul, div } from '../math/OperatorNode.js';
|
|
4
|
+
import { floor, ceil, fract, pow } from '../math/MathNode.js';
|
|
5
|
+
import { nodeProxy, addNodeElement, float, vec2, vec4, int } from '../shadernode/ShaderNode.js';
|
|
6
|
+
|
|
7
|
+
// Mipped Bicubic Texture Filtering by N8
|
|
8
|
+
// https://www.shadertoy.com/view/Dl2SDW
|
|
9
|
+
|
|
10
|
+
const bC = 1.0 / 6.0;
|
|
11
|
+
|
|
12
|
+
const w0 = ( a ) => mul( bC, mul( a, mul( a, a.negate().add( 3.0 ) ).sub( 3.0 ) ).add( 1.0 ) );
|
|
13
|
+
|
|
14
|
+
const w1 = ( a ) => mul( bC, mul( a, mul( a, mul( 3.0, a ).sub( 6.0 ) ) ).add( 4.0 ) );
|
|
15
|
+
|
|
16
|
+
const w2 = ( a ) => mul( bC, mul( a, mul( a, mul( - 3.0, a ).add( 3.0 ) ).add( 3.0 ) ).add( 1.0 ) );
|
|
17
|
+
|
|
18
|
+
const w3 = ( a ) => mul( bC, pow( a, 3 ) );
|
|
19
|
+
|
|
20
|
+
const g0 = ( a ) => w0( a ).add( w1( a ) );
|
|
21
|
+
|
|
22
|
+
const g1 = ( a ) => w2( a ).add( w3( a ) );
|
|
23
|
+
|
|
24
|
+
// h0 and h1 are the two offset functions
|
|
25
|
+
const h0 = ( a ) => add( - 1.0, w1( a ).div( w0( a ).add( w1( a ) ) ) );
|
|
26
|
+
|
|
27
|
+
const h1 = ( a ) => add( 1.0, w3( a ).div( w2( a ).add( w3( a ) ) ) );
|
|
28
|
+
|
|
29
|
+
const bicubic = ( textureNode, texelSize, lod ) => {
|
|
30
|
+
|
|
31
|
+
const uv = textureNode.uvNode;
|
|
32
|
+
const uvScaled = mul( uv, texelSize.zw ).add( 0.5 );
|
|
33
|
+
|
|
34
|
+
const iuv = floor( uvScaled );
|
|
35
|
+
const fuv = fract( uvScaled );
|
|
36
|
+
|
|
37
|
+
const g0x = g0( fuv.x );
|
|
38
|
+
const g1x = g1( fuv.x );
|
|
39
|
+
const h0x = h0( fuv.x );
|
|
40
|
+
const h1x = h1( fuv.x );
|
|
41
|
+
const h0y = h0( fuv.y );
|
|
42
|
+
const h1y = h1( fuv.y );
|
|
43
|
+
|
|
44
|
+
const p0 = vec2( iuv.x.add( h0x ), iuv.y.add( h0y ) ).sub( 0.5 ).mul( texelSize.xy );
|
|
45
|
+
const p1 = vec2( iuv.x.add( h1x ), iuv.y.add( h0y ) ).sub( 0.5 ).mul( texelSize.xy );
|
|
46
|
+
const p2 = vec2( iuv.x.add( h0x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
|
|
47
|
+
const p3 = vec2( iuv.x.add( h1x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
|
|
48
|
+
|
|
49
|
+
const a = g0( fuv.y ).mul( add( g0x.mul( textureNode.uv( p0 ).level( lod ) ), g1x.mul( textureNode.uv( p1 ).level( lod ) ) ) );
|
|
50
|
+
const b = g1( fuv.y ).mul( add( g0x.mul( textureNode.uv( p2 ).level( lod ) ), g1x.mul( textureNode.uv( p3 ).level( lod ) ) ) );
|
|
51
|
+
|
|
52
|
+
return a.add( b );
|
|
53
|
+
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const textureBicubicMethod = ( textureNode, lodNode ) => {
|
|
57
|
+
|
|
58
|
+
const fLodSize = vec2( textureNode.size( int( lodNode ) ) );
|
|
59
|
+
const cLodSize = vec2( textureNode.size( int( lodNode.add( 1.0 ) ) ) );
|
|
60
|
+
const fLodSizeInv = div( 1.0, fLodSize );
|
|
61
|
+
const cLodSizeInv = div( 1.0, cLodSize );
|
|
62
|
+
const fSample = bicubic( textureNode, vec4( fLodSizeInv, fLodSize ), floor( lodNode ) );
|
|
63
|
+
const cSample = bicubic( textureNode, vec4( cLodSizeInv, cLodSize ), ceil( lodNode ) );
|
|
64
|
+
|
|
65
|
+
return fract( lodNode ).mix( fSample, cSample );
|
|
66
|
+
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
class TextureBicubicNode extends TempNode {
|
|
70
|
+
|
|
71
|
+
constructor( textureNode, blurNode = float( 3 ) ) {
|
|
72
|
+
|
|
73
|
+
super( 'vec4' );
|
|
74
|
+
|
|
75
|
+
this.textureNode = textureNode;
|
|
76
|
+
this.blurNode = blurNode;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
construct() {
|
|
81
|
+
|
|
82
|
+
return textureBicubicMethod( this.textureNode, this.blurNode );
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default TextureBicubicNode;
|
|
89
|
+
|
|
90
|
+
export const textureBicubic = nodeProxy( TextureBicubicNode );
|
|
91
|
+
|
|
92
|
+
addNodeElement( 'bicubic', textureBicubic );
|
|
93
|
+
|
|
94
|
+
addNodeClass( TextureBicubicNode );
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import UniformNode from '../core/UniformNode.js';
|
|
1
|
+
import UniformNode, { uniform } from '../core/UniformNode.js';
|
|
2
2
|
import { uv } from './UVNode.js';
|
|
3
|
+
import { textureSize } from './TextureSizeNode.js';
|
|
4
|
+
import { colorSpaceToLinear } from '../display/ColorSpaceNode.js';
|
|
5
|
+
import { context } from '../core/ContextNode.js';
|
|
6
|
+
import { expression } from '../code/ExpressionNode.js';
|
|
3
7
|
import { addNodeClass } from '../core/Node.js';
|
|
4
|
-
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
5
|
-
|
|
6
|
-
let defaultUV;
|
|
8
|
+
import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
9
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
7
10
|
|
|
8
11
|
class TextureNode extends UniformNode {
|
|
9
12
|
|
|
@@ -16,6 +19,8 @@ class TextureNode extends UniformNode {
|
|
|
16
19
|
this.uvNode = uvNode;
|
|
17
20
|
this.levelNode = levelNode;
|
|
18
21
|
|
|
22
|
+
this.updateType = NodeUpdateType.FRAME;
|
|
23
|
+
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
getUniformHash( /*builder*/ ) {
|
|
@@ -40,7 +45,9 @@ class TextureNode extends UniformNode {
|
|
|
40
45
|
|
|
41
46
|
getDefaultUV() {
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
const texture = this.value;
|
|
49
|
+
|
|
50
|
+
return uniform( texture.matrix ).mul( vec3( uv( texture.channel ), 1 ) );
|
|
44
51
|
|
|
45
52
|
}
|
|
46
53
|
|
|
@@ -134,12 +141,46 @@ class TextureNode extends UniformNode {
|
|
|
134
141
|
|
|
135
142
|
}
|
|
136
143
|
|
|
137
|
-
|
|
144
|
+
let snippet = propertyName;
|
|
145
|
+
|
|
146
|
+
if ( builder.needsColorSpaceToLinear( this.value ) ) {
|
|
147
|
+
|
|
148
|
+
snippet = colorSpaceToLinear( expression( snippet, nodeType ), this.value.colorSpace ).construct( builder ).build( builder, nodeType );
|
|
149
|
+
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return builder.format( snippet, nodeType, output );
|
|
138
153
|
|
|
139
154
|
}
|
|
140
155
|
|
|
141
156
|
}
|
|
142
157
|
|
|
158
|
+
uv( uvNode ) {
|
|
159
|
+
|
|
160
|
+
const textureNode = this.clone();
|
|
161
|
+
textureNode.uvNode = uvNode;
|
|
162
|
+
|
|
163
|
+
return textureNode;
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
level( levelNode ) {
|
|
168
|
+
|
|
169
|
+
const textureNode = this.clone();
|
|
170
|
+
textureNode.levelNode = levelNode;
|
|
171
|
+
|
|
172
|
+
return context( textureNode, {
|
|
173
|
+
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => levelNode
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
size( levelNode ) {
|
|
179
|
+
|
|
180
|
+
return textureSize( this, levelNode );
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
143
184
|
serialize( data ) {
|
|
144
185
|
|
|
145
186
|
super.serialize( data );
|
|
@@ -156,13 +197,34 @@ class TextureNode extends UniformNode {
|
|
|
156
197
|
|
|
157
198
|
}
|
|
158
199
|
|
|
200
|
+
update() {
|
|
201
|
+
|
|
202
|
+
const texture = this.value;
|
|
203
|
+
|
|
204
|
+
if ( texture.matrixAutoUpdate === true ) {
|
|
205
|
+
|
|
206
|
+
texture.updateMatrix();
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
clone() {
|
|
213
|
+
|
|
214
|
+
return new this.constructor( this.value, this.uvNode, this.levelNode );
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
159
218
|
}
|
|
160
219
|
|
|
161
220
|
export default TextureNode;
|
|
162
221
|
|
|
163
222
|
export const texture = nodeProxy( TextureNode );
|
|
223
|
+
//export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level );
|
|
224
|
+
|
|
164
225
|
export const sampler = ( aTexture ) => ( aTexture.isNode === true ? aTexture : texture( aTexture ) ).convert( 'sampler' );
|
|
165
226
|
|
|
166
227
|
addNodeElement( 'texture', texture );
|
|
228
|
+
//addNodeElement( 'textureLevel', textureLevel );
|
|
167
229
|
|
|
168
230
|
addNodeClass( TextureNode );
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class TextureSizeNode extends Node {
|
|
6
|
+
|
|
7
|
+
constructor( textureNode, levelNode = null ) {
|
|
8
|
+
|
|
9
|
+
super( 'uvec2' );
|
|
10
|
+
|
|
11
|
+
this.isTextureSizeNode = true;
|
|
12
|
+
|
|
13
|
+
this.textureNode = textureNode;
|
|
14
|
+
this.levelNode = levelNode;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
generate( builder, output ) {
|
|
19
|
+
|
|
20
|
+
const textureProperty = this.textureNode.build( builder, 'property' );
|
|
21
|
+
const levelNode = this.levelNode.build( builder, 'int' );
|
|
22
|
+
|
|
23
|
+
return builder.format( `textureDimensions( ${textureProperty}, ${levelNode} )`, this.getNodeType( builder ), output );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default TextureSizeNode;
|
|
30
|
+
|
|
31
|
+
export const textureSize = nodeProxy( TextureSizeNode );
|
|
32
|
+
|
|
33
|
+
addNodeElement( 'textureSize', textureSize );
|
|
34
|
+
|
|
35
|
+
addNodeClass( TextureSizeNode );
|
|
@@ -70,6 +70,9 @@ class CodeNode extends Node {
|
|
|
70
70
|
export default CodeNode;
|
|
71
71
|
|
|
72
72
|
export const code = nodeProxy( CodeNode );
|
|
73
|
+
|
|
73
74
|
export const js = ( src, includes ) => code( src, includes, 'js' );
|
|
75
|
+
export const wgsl = ( src, includes ) => code( src, includes, 'wgsl' );
|
|
76
|
+
export const glsl = ( src, includes ) => code( src, includes, 'glsl' );
|
|
74
77
|
|
|
75
78
|
addNodeClass( CodeNode );
|
|
@@ -4,9 +4,9 @@ import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
|
4
4
|
|
|
5
5
|
class FunctionNode extends CodeNode {
|
|
6
6
|
|
|
7
|
-
constructor( code = '', includes = [] ) {
|
|
7
|
+
constructor( code = '', includes = [], language = '' ) {
|
|
8
8
|
|
|
9
|
-
super( code, includes );
|
|
9
|
+
super( code, includes, language );
|
|
10
10
|
|
|
11
11
|
this.keywords = {};
|
|
12
12
|
|
|
@@ -99,8 +99,29 @@ class FunctionNode extends CodeNode {
|
|
|
99
99
|
|
|
100
100
|
export default FunctionNode;
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
const nativeFn = ( code, includes, language = '' ) => {
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
let functionNode = null;
|
|
105
|
+
|
|
106
|
+
return ( ...params ) => {
|
|
107
|
+
|
|
108
|
+
if ( functionNode === null ) functionNode = nodeObject( new FunctionNode( code, includes, language ) );
|
|
109
|
+
|
|
110
|
+
return functionNode.call( ...params );
|
|
111
|
+
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const glslFn = ( code, includes ) => nativeFn( code, includes, 'glsl' );
|
|
117
|
+
export const wgslFn = ( code, includes ) => nativeFn( code, includes, 'wgsl' );
|
|
118
|
+
|
|
119
|
+
export const func = ( code, includes ) => { // @deprecated, r154
|
|
120
|
+
|
|
121
|
+
console.warn( 'TSL: func() is deprecated. Use nativeFn(), wgslFn() or glslFn() instead.' );
|
|
122
|
+
|
|
123
|
+
return nodeObject( new FunctionNode( code, includes ) );
|
|
124
|
+
|
|
125
|
+
};
|
|
105
126
|
|
|
106
127
|
addNodeClass( FunctionNode );
|
|
@@ -71,7 +71,7 @@ class AttributeNode extends Node {
|
|
|
71
71
|
|
|
72
72
|
const nodeAttribute = builder.getAttribute( attributeName, attributeType );
|
|
73
73
|
|
|
74
|
-
if ( builder.
|
|
74
|
+
if ( builder.shaderStage === 'vertex' ) {
|
|
75
75
|
|
|
76
76
|
return builder.format( nodeAttribute.name, attributeType, nodeType );
|
|
77
77
|
|
|
@@ -20,7 +20,7 @@ class BypassNode extends Node {
|
|
|
20
20
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
generate( builder
|
|
23
|
+
generate( builder ) {
|
|
24
24
|
|
|
25
25
|
const snippet = this.callNode.build( builder, 'void' );
|
|
26
26
|
|
|
@@ -30,7 +30,7 @@ class BypassNode extends Node {
|
|
|
30
30
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
return this.outputNode.build( builder
|
|
33
|
+
return this.outputNode.build( builder );
|
|
34
34
|
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -53,7 +53,9 @@ class ContextNode extends Node {
|
|
|
53
53
|
export default ContextNode;
|
|
54
54
|
|
|
55
55
|
export const context = nodeProxy( ContextNode );
|
|
56
|
+
export const label = ( node, name ) => context( node, { label: name } );
|
|
56
57
|
|
|
57
58
|
addNodeElement( 'context', context );
|
|
59
|
+
addNodeElement( 'label', label );
|
|
58
60
|
|
|
59
61
|
addNodeClass( ContextNode );
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Node, { addNodeClass } from './Node.js';
|
|
2
|
+
import { varying } from './VaryingNode.js';
|
|
3
|
+
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class IndexNode extends Node {
|
|
6
|
+
|
|
7
|
+
constructor( scope ) {
|
|
8
|
+
|
|
9
|
+
super( 'uint' );
|
|
10
|
+
|
|
11
|
+
this.scope = scope;
|
|
12
|
+
|
|
13
|
+
this.isInstanceIndexNode = true;
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
generate( builder ) {
|
|
18
|
+
|
|
19
|
+
const nodeType = this.getNodeType( builder );
|
|
20
|
+
const scope = this.scope;
|
|
21
|
+
|
|
22
|
+
let propertyName;
|
|
23
|
+
|
|
24
|
+
if ( scope === IndexNode.VERTEX ) {
|
|
25
|
+
|
|
26
|
+
propertyName = builder.getVertexIndex();
|
|
27
|
+
|
|
28
|
+
} else if ( scope === IndexNode.INSTANCE ) {
|
|
29
|
+
|
|
30
|
+
propertyName = builder.getInstanceIndex();
|
|
31
|
+
|
|
32
|
+
} else {
|
|
33
|
+
|
|
34
|
+
throw new Error( 'THREE.IndexNode: Unknown scope: ' + scope );
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let output;
|
|
39
|
+
|
|
40
|
+
if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) {
|
|
41
|
+
|
|
42
|
+
output = propertyName;
|
|
43
|
+
|
|
44
|
+
} else {
|
|
45
|
+
|
|
46
|
+
const nodeVarying = varying( this );
|
|
47
|
+
|
|
48
|
+
output = nodeVarying.build( builder, nodeType );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return output;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
IndexNode.VERTEX = 'vertex';
|
|
59
|
+
IndexNode.INSTANCE = 'instance';
|
|
60
|
+
|
|
61
|
+
export default IndexNode;
|
|
62
|
+
|
|
63
|
+
export const vertexIndex = nodeImmutable( IndexNode, IndexNode.VERTEX );
|
|
64
|
+
export const instanceIndex = nodeImmutable( IndexNode, IndexNode.INSTANCE );
|
|
65
|
+
|
|
66
|
+
addNodeClass( IndexNode );
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
class LightingModel {
|
|
2
2
|
|
|
3
|
-
constructor( direct = null, indirectDiffuse = null, indirectSpecular = null, ambientOcclusion = null ) {
|
|
3
|
+
constructor( init = null, direct = null, indirectDiffuse = null, indirectSpecular = null, ambientOcclusion = null ) {
|
|
4
4
|
|
|
5
|
+
this.init = init;
|
|
5
6
|
this.direct = direct;
|
|
6
7
|
this.indirectDiffuse = indirectDiffuse;
|
|
7
8
|
this.indirectSpecular = indirectSpecular;
|
|
@@ -41,23 +41,12 @@ class Node {
|
|
|
41
41
|
|
|
42
42
|
for ( const { property, index, childNode } of getNodeChildren( this ) ) {
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
yield { childNode, replaceNode( node ) {
|
|
47
|
-
|
|
48
|
-
self[ property ][ index ] = node;
|
|
49
|
-
|
|
50
|
-
} };
|
|
51
|
-
|
|
52
|
-
} else {
|
|
53
|
-
|
|
54
|
-
yield { childNode, replaceNode( node ) {
|
|
44
|
+
yield { childNode, replaceNode( node ) {
|
|
55
45
|
|
|
56
|
-
|
|
46
|
+
if ( index === undefined ) self[ property ] = node;
|
|
47
|
+
else self[ property ][ index ] = node;
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
49
|
+
} };
|
|
61
50
|
|
|
62
51
|
}
|
|
63
52
|
|
|
@@ -206,9 +195,17 @@ class Node {
|
|
|
206
195
|
|
|
207
196
|
if ( properties.initialized !== true || builder.context.tempRead === false ) {
|
|
208
197
|
|
|
198
|
+
const stackNodesBeforeConstruct = builder.stack.nodes.length;
|
|
199
|
+
|
|
209
200
|
properties.initialized = true;
|
|
210
201
|
properties.outputNode = this.construct( builder );
|
|
211
202
|
|
|
203
|
+
if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeConstruct ) {
|
|
204
|
+
|
|
205
|
+
properties.outputNode = builder.stack;
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
212
209
|
for ( const childNode of Object.values( properties ) ) {
|
|
213
210
|
|
|
214
211
|
if ( childNode && childNode.isNode === true ) {
|
|
@@ -374,7 +371,7 @@ class Node {
|
|
|
374
371
|
type,
|
|
375
372
|
meta,
|
|
376
373
|
metadata: {
|
|
377
|
-
version: 4.
|
|
374
|
+
version: 4.6,
|
|
378
375
|
type: 'Node',
|
|
379
376
|
generator: 'Node.toJSON'
|
|
380
377
|
}
|
|
@@ -5,6 +5,7 @@ import NodeVar from './NodeVar.js';
|
|
|
5
5
|
import NodeCode from './NodeCode.js';
|
|
6
6
|
import NodeKeywords from './NodeKeywords.js';
|
|
7
7
|
import NodeCache from './NodeCache.js';
|
|
8
|
+
import { createNodeMaterialFromType } from '../materials/NodeMaterial.js';
|
|
8
9
|
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
9
10
|
|
|
10
11
|
import { REVISION, NoColorSpace, LinearEncoding, sRGBEncoding, SRGBColorSpace, Color, Vector2, Vector3, Vector4, Float16BufferAttribute } from 'three';
|
|
@@ -42,13 +43,14 @@ const toFloat = ( value ) => {
|
|
|
42
43
|
|
|
43
44
|
class NodeBuilder {
|
|
44
45
|
|
|
45
|
-
constructor( object, renderer, parser ) {
|
|
46
|
+
constructor( object, renderer, parser, scene = null ) {
|
|
46
47
|
|
|
47
48
|
this.object = object;
|
|
48
|
-
this.material = object &&
|
|
49
|
-
this.geometry = object &&
|
|
49
|
+
this.material = ( object && object.material ) || null;
|
|
50
|
+
this.geometry = ( object && object.geometry ) || null;
|
|
50
51
|
this.renderer = renderer;
|
|
51
52
|
this.parser = parser;
|
|
53
|
+
this.scene = scene;
|
|
52
54
|
|
|
53
55
|
this.nodes = [];
|
|
54
56
|
this.updateNodes = [];
|
|
@@ -68,7 +70,11 @@ class NodeBuilder {
|
|
|
68
70
|
this.flowCode = { vertex: '', fragment: '', compute: [] };
|
|
69
71
|
this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };
|
|
70
72
|
this.codes = { vertex: [], fragment: [], compute: [] };
|
|
73
|
+
this.bindings = { vertex: [], fragment: [], compute: [] };
|
|
74
|
+
this.bindingsOffset = { vertex: 0, fragment: 0, compute: 0 };
|
|
75
|
+
this.bindingsArray = null;
|
|
71
76
|
this.attributes = [];
|
|
77
|
+
this.bufferAttributes = [];
|
|
72
78
|
this.varyings = [];
|
|
73
79
|
this.vars = { vertex: [], fragment: [], compute: [] };
|
|
74
80
|
this.flow = { code: '' };
|
|
@@ -92,6 +98,28 @@ class NodeBuilder {
|
|
|
92
98
|
|
|
93
99
|
}
|
|
94
100
|
|
|
101
|
+
includes( node ) {
|
|
102
|
+
|
|
103
|
+
return this.nodes.includes( node );
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getBindings() {
|
|
108
|
+
|
|
109
|
+
let bindingsArray = this.bindingsArray;
|
|
110
|
+
|
|
111
|
+
if ( bindingsArray === null ) {
|
|
112
|
+
|
|
113
|
+
const bindings = this.bindings;
|
|
114
|
+
|
|
115
|
+
this.bindingsArray = bindingsArray = ( this.material !== null ) ? [ ...bindings.vertex, ...bindings.fragment ] : bindings.compute;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return bindingsArray;
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
95
123
|
setHashNode( node, hash ) {
|
|
96
124
|
|
|
97
125
|
this.hashNodes[ hash ] = node;
|
|
@@ -207,6 +235,12 @@ class NodeBuilder {
|
|
|
207
235
|
|
|
208
236
|
}
|
|
209
237
|
|
|
238
|
+
getVertexIndex() {
|
|
239
|
+
|
|
240
|
+
console.warn( 'Abstract function.' );
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
210
244
|
getInstanceIndex() {
|
|
211
245
|
|
|
212
246
|
console.warn( 'Abstract function.' );
|
|
@@ -281,6 +315,10 @@ class NodeBuilder {
|
|
|
281
315
|
|
|
282
316
|
return `${ this.getType( type ) }( ${ getConst( value.x ) }, ${ getConst( value.y ) }, ${ getConst( value.z ) }, ${ getConst( value.w ) } )`;
|
|
283
317
|
|
|
318
|
+
} else if ( typeLength > 4 && value && ( value.isMatrix3 || value.isMatrix4 ) ) {
|
|
319
|
+
|
|
320
|
+
return `${ this.getType( type ) }( ${ value.elements.map( getConst ).join( ', ' ) } )`;
|
|
321
|
+
|
|
284
322
|
} else if ( typeLength > 4 ) {
|
|
285
323
|
|
|
286
324
|
return `${ this.getType( type ) }()`;
|
|
@@ -359,9 +397,9 @@ class NodeBuilder {
|
|
|
359
397
|
|
|
360
398
|
}
|
|
361
399
|
|
|
362
|
-
|
|
400
|
+
needsColorSpaceToLinear( /*texture*/ ) {
|
|
363
401
|
|
|
364
|
-
return
|
|
402
|
+
return false;
|
|
365
403
|
|
|
366
404
|
}
|
|
367
405
|
|
|
@@ -541,7 +579,29 @@ class NodeBuilder {
|
|
|
541
579
|
|
|
542
580
|
}
|
|
543
581
|
|
|
544
|
-
|
|
582
|
+
getBufferAttributeFromNode( node, type ) {
|
|
583
|
+
|
|
584
|
+
const nodeData = this.getDataFromNode( node );
|
|
585
|
+
|
|
586
|
+
let bufferAttribute = nodeData.bufferAttribute;
|
|
587
|
+
|
|
588
|
+
if ( bufferAttribute === undefined ) {
|
|
589
|
+
|
|
590
|
+
const index = this.uniforms.index ++;
|
|
591
|
+
|
|
592
|
+
bufferAttribute = new NodeAttribute( 'nodeAttribute' + index, type, node );
|
|
593
|
+
|
|
594
|
+
this.bufferAttributes.push( bufferAttribute );
|
|
595
|
+
|
|
596
|
+
nodeData.bufferAttribute = bufferAttribute;
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return bufferAttribute;
|
|
601
|
+
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
getUniformFromNode( node, type, shaderStage = this.shaderStage, name = null ) {
|
|
545
605
|
|
|
546
606
|
const nodeData = this.getDataFromNode( node, shaderStage );
|
|
547
607
|
|
|
@@ -551,7 +611,7 @@ class NodeBuilder {
|
|
|
551
611
|
|
|
552
612
|
const index = this.uniforms.index ++;
|
|
553
613
|
|
|
554
|
-
nodeUniform = new NodeUniform( 'nodeUniform' + index, type, node );
|
|
614
|
+
nodeUniform = new NodeUniform( name || ( 'nodeUniform' + index ), type, node );
|
|
555
615
|
|
|
556
616
|
this.uniforms[ shaderStage ].push( nodeUniform );
|
|
557
617
|
|
|
@@ -732,6 +792,12 @@ class NodeBuilder {
|
|
|
732
792
|
|
|
733
793
|
}
|
|
734
794
|
|
|
795
|
+
getAttributesArray() {
|
|
796
|
+
|
|
797
|
+
return this.attributes.concat( this.bufferAttributes );
|
|
798
|
+
|
|
799
|
+
}
|
|
800
|
+
|
|
735
801
|
getAttributes( /*shaderStage*/ ) {
|
|
736
802
|
|
|
737
803
|
console.warn( 'Abstract function.' );
|
|
@@ -744,6 +810,12 @@ class NodeBuilder {
|
|
|
744
810
|
|
|
745
811
|
}
|
|
746
812
|
|
|
813
|
+
getVar( type, name ) {
|
|
814
|
+
|
|
815
|
+
return `${type} ${name}`;
|
|
816
|
+
|
|
817
|
+
}
|
|
818
|
+
|
|
747
819
|
getVars( shaderStage ) {
|
|
748
820
|
|
|
749
821
|
let snippet = '';
|
|
@@ -752,7 +824,7 @@ class NodeBuilder {
|
|
|
752
824
|
|
|
753
825
|
for ( const variable of vars ) {
|
|
754
826
|
|
|
755
|
-
snippet += `${variable.type
|
|
827
|
+
snippet += `${ this.getVar( variable.type, variable.name ) }; `;
|
|
756
828
|
|
|
757
829
|
}
|
|
758
830
|
|
|
@@ -869,6 +941,12 @@ class NodeBuilder {
|
|
|
869
941
|
|
|
870
942
|
}
|
|
871
943
|
|
|
944
|
+
createNodeMaterial( type ) {
|
|
945
|
+
|
|
946
|
+
return createNodeMaterialFromType( type );
|
|
947
|
+
|
|
948
|
+
}
|
|
949
|
+
|
|
872
950
|
format( snippet, fromType, toType ) {
|
|
873
951
|
|
|
874
952
|
fromType = this.getVectorType( fromType );
|