@plastic-software/three 0.180.0 → 0.181.2
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 +944 -487
- package/build/three.core.js +506 -327
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +436 -164
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +8 -2
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3753 -1177
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3752 -1176
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/DragControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +1 -1
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -2
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +3 -3
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +2 -2
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +5 -3
- package/examples/jsm/loaders/KTX2Loader.js +28 -21
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +7 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -1
- package/examples/jsm/tsl/display/BloomNode.js +4 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +7 -0
- package/examples/jsm/tsl/display/GTAONode.js +45 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +5 -3
- package/examples/jsm/tsl/display/OutlineNode.js +11 -0
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +2 -0
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +123 -6
- package/examples/jsm/tsl/display/boxBlur.js +1 -0
- package/examples/jsm/tsl/display/hashBlur.js +1 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +3 -2
- package/src/Three.TSL.js +7 -1
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +3 -2
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +8 -8
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +7 -7
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +4 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +2 -1
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +2 -2
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +1 -1
- package/src/nodes/TSL.js +1 -1
- package/src/nodes/accessors/CubeTextureNode.js +3 -2
- package/src/nodes/accessors/InstanceNode.js +22 -4
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceNode.js +2 -1
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +61 -27
- package/src/nodes/code/FunctionCallNode.js +5 -4
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +5 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +137 -12
- package/src/nodes/core/NodeBuilder.js +135 -21
- package/src/nodes/core/NodeFrame.js +20 -20
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUtils.js +17 -90
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +16 -14
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +70 -12
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +51 -10
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +25 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +2 -3
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/ConditionalNode.js +6 -5
- package/src/nodes/math/MathNode.js +22 -4
- package/src/nodes/math/OperatorNode.js +3 -2
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +36 -15
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +3 -2
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +2 -1
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +12 -2
- package/src/nodes/utils/ReflectorNode.js +10 -3
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +2 -1
- package/src/renderers/WebGLRenderer.js +49 -33
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Backend.js +93 -30
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +56 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +3 -1
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +436 -228
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +8 -0
- package/src/renderers/common/Sampler.js +37 -11
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +89 -35
- package/src/renderers/common/TimestampQueryPool.js +63 -1
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +7 -3
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeLibrary.js +4 -2
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +11 -10
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +2 -1
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +18 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +74 -11
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +6 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +117 -16
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +42 -12
- package/src/renderers/webgpu/WebGPUBackend.js +134 -108
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +21 -19
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +5 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +44 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +146 -74
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +29 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +3 -2
- package/src/textures/Source.js +2 -1
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -0
- package/src/utils.js +67 -3
|
@@ -4,6 +4,7 @@ import { modelNormalMatrix, modelWorldMatrix } from './ModelNode.js';
|
|
|
4
4
|
import { mat3, vec3, Fn } from '../tsl/TSLBase.js';
|
|
5
5
|
import { positionView } from './Position.js';
|
|
6
6
|
import { directionToFaceDirection } from '../display/FrontFacingNode.js';
|
|
7
|
+
import { warn } from '../../utils.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* TSL object that represents the normal attribute of the current rendered object in local space.
|
|
@@ -23,7 +24,7 @@ export const normalLocal = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
23
24
|
|
|
24
25
|
if ( builder.geometry.hasAttribute( 'normal' ) === false ) {
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
warn( 'TSL: Vertex attribute "normal" not found on geometry.' );
|
|
27
28
|
|
|
28
29
|
return vec3( 0, 1, 0 );
|
|
29
30
|
|
|
@@ -208,7 +209,7 @@ export const transformNormalToView = /*@__PURE__*/ Fn( ( [ normal ], builder ) =
|
|
|
208
209
|
*/
|
|
209
210
|
export const transformedNormalView = ( Fn( () => { // @deprecated, r177
|
|
210
211
|
|
|
211
|
-
|
|
212
|
+
warn( 'TSL: "transformedNormalView" is deprecated. Use "normalView" instead.' );
|
|
212
213
|
return normalView;
|
|
213
214
|
|
|
214
215
|
} ).once( [ 'NORMAL', 'VERTEX' ] ) )();
|
|
@@ -222,7 +223,7 @@ export const transformedNormalView = ( Fn( () => { // @deprecated, r177
|
|
|
222
223
|
*/
|
|
223
224
|
export const transformedNormalWorld = ( Fn( () => { // @deprecated, r177
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
warn( 'TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.' );
|
|
226
227
|
return normalWorld;
|
|
227
228
|
|
|
228
229
|
} ).once( [ 'NORMAL', 'VERTEX' ] ) )();
|
|
@@ -236,7 +237,7 @@ export const transformedNormalWorld = ( Fn( () => { // @deprecated, r177
|
|
|
236
237
|
*/
|
|
237
238
|
export const transformedClearcoatNormalView = ( Fn( () => { // @deprecated, r177
|
|
238
239
|
|
|
239
|
-
|
|
240
|
+
warn( 'TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.' );
|
|
240
241
|
return clearcoatNormalView;
|
|
241
242
|
|
|
242
243
|
} ).once( [ 'NORMAL', 'VERTEX' ] ) )();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attribute } from '../core/AttributeNode.js';
|
|
2
|
-
import { Fn } from '../tsl/TSLCore.js';
|
|
2
|
+
import { Fn, vec3 } from '../tsl/TSLCore.js';
|
|
3
3
|
import { modelWorldMatrix } from './ModelNode.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -71,4 +71,20 @@ export const positionView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
71
71
|
* @tsl
|
|
72
72
|
* @type {VaryingNode<vec3>}
|
|
73
73
|
*/
|
|
74
|
-
export const positionViewDirection = /*@__PURE__*/
|
|
74
|
+
export const positionViewDirection = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
75
|
+
|
|
76
|
+
let output;
|
|
77
|
+
|
|
78
|
+
if ( builder.camera.isOrthographicCamera ) {
|
|
79
|
+
|
|
80
|
+
output = vec3( 0, 0, 1 );
|
|
81
|
+
|
|
82
|
+
} else {
|
|
83
|
+
|
|
84
|
+
output = positionView.negate().toVarying( 'v_positionViewDirection' ).normalize();
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return output.toVar( 'positionViewDirection' );
|
|
89
|
+
|
|
90
|
+
}, 'vec3' ).once( [ 'POSITION' ] ) )();
|
|
@@ -7,6 +7,7 @@ import { buffer } from './BufferNode.js';
|
|
|
7
7
|
import { nodeObject } from '../tsl/TSLBase.js';
|
|
8
8
|
import { uniformArray } from './UniformArrayNode.js';
|
|
9
9
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
10
|
+
import { warn } from '../../utils.js';
|
|
10
11
|
|
|
11
12
|
// TODO: Avoid duplicated code and ues only ReferenceBaseNode or ReferenceNode
|
|
12
13
|
|
|
@@ -238,7 +239,7 @@ class ReferenceNode extends Node {
|
|
|
238
239
|
*/
|
|
239
240
|
label( name ) {
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
242
243
|
|
|
243
244
|
return this.setName( name );
|
|
244
245
|
|
|
@@ -5,6 +5,7 @@ import Node from '../core/Node.js';
|
|
|
5
5
|
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
6
6
|
import { nodeImmutable, uniform } from '../tsl/TSLBase.js';
|
|
7
7
|
import { reference } from './ReferenceNode.js';
|
|
8
|
+
import { error } from '../../utils.js';
|
|
8
9
|
|
|
9
10
|
const _e1 = /*@__PURE__*/ new Euler();
|
|
10
11
|
const _m1 = /*@__PURE__*/ new Matrix4();
|
|
@@ -103,7 +104,7 @@ class SceneNode extends Node {
|
|
|
103
104
|
|
|
104
105
|
} else {
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
error( 'SceneNode: Unknown scope:', scope );
|
|
107
108
|
|
|
108
109
|
}
|
|
109
110
|
|
|
@@ -4,6 +4,7 @@ import { nodeObject, varying } from '../tsl/TSLBase.js';
|
|
|
4
4
|
import { storageElement } from '../utils/StorageArrayElementNode.js';
|
|
5
5
|
import { NodeAccess } from '../core/constants.js';
|
|
6
6
|
import { getTypeFromLength } from '../core/NodeUtils.js';
|
|
7
|
+
import { warn } from '../../utils.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* This node is used in context of compute shaders and allows to define a
|
|
@@ -408,7 +409,7 @@ export const storage = ( value, type = null, count = 0 ) => nodeObject( new Stor
|
|
|
408
409
|
*/
|
|
409
410
|
export const storageObject = ( value, type, count ) => { // @deprecated, r171
|
|
410
411
|
|
|
411
|
-
|
|
412
|
+
warn( 'TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.' );
|
|
412
413
|
|
|
413
414
|
return storage( value, type, count ).setPBO( true );
|
|
414
415
|
|
|
@@ -60,6 +60,14 @@ class StorageTextureNode extends TextureNode {
|
|
|
60
60
|
*/
|
|
61
61
|
this.storeNode = storeNode;
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* The mip level to write to for storage textures.
|
|
65
|
+
*
|
|
66
|
+
* @type {number}
|
|
67
|
+
* @default 0
|
|
68
|
+
*/
|
|
69
|
+
this.mipLevel = 0;
|
|
70
|
+
|
|
63
71
|
/**
|
|
64
72
|
* This flag can be used for type testing.
|
|
65
73
|
*
|
|
@@ -115,6 +123,19 @@ class StorageTextureNode extends TextureNode {
|
|
|
115
123
|
|
|
116
124
|
}
|
|
117
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Sets the mip level to write to.
|
|
128
|
+
*
|
|
129
|
+
* @param {number} level - The mip level.
|
|
130
|
+
* @return {StorageTextureNode} A reference to this node.
|
|
131
|
+
*/
|
|
132
|
+
setMipLevel( level ) {
|
|
133
|
+
|
|
134
|
+
this.mipLevel = level;
|
|
135
|
+
return this;
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
118
139
|
/**
|
|
119
140
|
* Generates the code snippet of the storage node. If no `storeNode`
|
|
120
141
|
* is defined, the texture node is generated as normal texture.
|
|
@@ -200,6 +221,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
200
221
|
|
|
201
222
|
const newNode = super.clone();
|
|
202
223
|
newNode.storeNode = this.storeNode;
|
|
224
|
+
newNode.mipLevel = this.mipLevel;
|
|
203
225
|
return newNode;
|
|
204
226
|
|
|
205
227
|
}
|
|
@@ -4,12 +4,13 @@ import { textureSize } from './TextureSizeNode.js';
|
|
|
4
4
|
import { colorSpaceToWorking } from '../display/ColorSpaceNode.js';
|
|
5
5
|
import { expression } from '../code/ExpressionNode.js';
|
|
6
6
|
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
7
|
-
import { nodeProxy, vec3, nodeObject, int } from '../tsl/TSLBase.js';
|
|
7
|
+
import { nodeProxy, vec3, nodeObject, int, Fn } from '../tsl/TSLBase.js';
|
|
8
8
|
import { NodeUpdateType } from '../core/constants.js';
|
|
9
9
|
|
|
10
10
|
import { IntType, NearestFilter, UnsignedIntType } from '../../constants.js';
|
|
11
11
|
|
|
12
12
|
import { Texture } from '../../textures/Texture.js';
|
|
13
|
+
import { warn } from '../../utils.js';
|
|
13
14
|
|
|
14
15
|
const EmptyTexture = /*@__PURE__*/ new Texture();
|
|
15
16
|
|
|
@@ -123,9 +124,9 @@ class TextureNode extends UniformNode {
|
|
|
123
124
|
this.updateMatrix = false;
|
|
124
125
|
|
|
125
126
|
/**
|
|
126
|
-
* By default the `update()` method is not executed.
|
|
127
|
-
*
|
|
128
|
-
*
|
|
127
|
+
* By default the `update()` method is not executed. Depending on
|
|
128
|
+
* whether a uv transformation matrix and/or flipY is applied, `update()`
|
|
129
|
+
* is executed per object.
|
|
129
130
|
*
|
|
130
131
|
* @type {string}
|
|
131
132
|
* @default 'none'
|
|
@@ -153,9 +154,19 @@ class TextureNode extends UniformNode {
|
|
|
153
154
|
*
|
|
154
155
|
* @private
|
|
155
156
|
* @type {?UniformNode<mat3>}
|
|
157
|
+
* @default null
|
|
156
158
|
*/
|
|
157
159
|
this._matrixUniform = null;
|
|
158
160
|
|
|
161
|
+
/**
|
|
162
|
+
* The uniform node that represents the y-flip. Only required for WebGL.
|
|
163
|
+
*
|
|
164
|
+
* @private
|
|
165
|
+
* @type {?UniformNode<bool>}
|
|
166
|
+
* @default null
|
|
167
|
+
*/
|
|
168
|
+
this._flipYUniform = null;
|
|
169
|
+
|
|
159
170
|
this.setUpdateMatrix( uvNode === null );
|
|
160
171
|
|
|
161
172
|
}
|
|
@@ -279,7 +290,6 @@ class TextureNode extends UniformNode {
|
|
|
279
290
|
setUpdateMatrix( value ) {
|
|
280
291
|
|
|
281
292
|
this.updateMatrix = value;
|
|
282
|
-
this.updateType = value ? NodeUpdateType.OBJECT : NodeUpdateType.NONE;
|
|
283
293
|
|
|
284
294
|
return this;
|
|
285
295
|
|
|
@@ -295,17 +305,19 @@ class TextureNode extends UniformNode {
|
|
|
295
305
|
*/
|
|
296
306
|
setupUV( builder, uvNode ) {
|
|
297
307
|
|
|
298
|
-
|
|
308
|
+
if ( builder.isFlipY() ) {
|
|
299
309
|
|
|
300
|
-
|
|
310
|
+
if ( this._flipYUniform === null ) this._flipYUniform = uniform( false );
|
|
311
|
+
|
|
312
|
+
uvNode = uvNode.toVar();
|
|
301
313
|
|
|
302
314
|
if ( this.sampler ) {
|
|
303
315
|
|
|
304
|
-
uvNode = uvNode.flipY();
|
|
316
|
+
uvNode = this._flipYUniform.select( uvNode.flipY(), uvNode );
|
|
305
317
|
|
|
306
318
|
} else {
|
|
307
319
|
|
|
308
|
-
uvNode = uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) );
|
|
320
|
+
uvNode = this._flipYUniform.select( uvNode.setY( int( textureSize( this, this.levelNode ).y ).sub( uvNode.y ).sub( 1 ) ), uvNode );
|
|
309
321
|
|
|
310
322
|
}
|
|
311
323
|
|
|
@@ -337,23 +349,35 @@ class TextureNode extends UniformNode {
|
|
|
337
349
|
|
|
338
350
|
//
|
|
339
351
|
|
|
340
|
-
|
|
352
|
+
const uvNode = Fn( () => {
|
|
341
353
|
|
|
342
|
-
|
|
354
|
+
let uvNode = this.uvNode;
|
|
343
355
|
|
|
344
|
-
uvNode
|
|
356
|
+
if ( ( uvNode === null || builder.context.forceUVContext === true ) && builder.context.getUV ) {
|
|
345
357
|
|
|
346
|
-
|
|
358
|
+
uvNode = builder.context.getUV( this, builder );
|
|
347
359
|
|
|
348
|
-
|
|
360
|
+
}
|
|
349
361
|
|
|
350
|
-
|
|
362
|
+
if ( ! uvNode ) uvNode = this.getDefaultUV();
|
|
351
363
|
|
|
352
|
-
|
|
364
|
+
if ( this.updateMatrix === true ) {
|
|
353
365
|
|
|
354
|
-
|
|
366
|
+
uvNode = this.getTransformedUV( uvNode );
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
uvNode = this.setupUV( builder, uvNode );
|
|
371
|
+
|
|
372
|
+
//
|
|
355
373
|
|
|
356
|
-
|
|
374
|
+
this.updateType = ( this._matrixUniform !== null || this._flipYUniform !== null ) ? NodeUpdateType.OBJECT : NodeUpdateType.NONE;
|
|
375
|
+
|
|
376
|
+
//
|
|
377
|
+
|
|
378
|
+
return uvNode;
|
|
379
|
+
|
|
380
|
+
} )();
|
|
357
381
|
|
|
358
382
|
//
|
|
359
383
|
|
|
@@ -423,11 +447,7 @@ class TextureNode extends UniformNode {
|
|
|
423
447
|
|
|
424
448
|
let snippet;
|
|
425
449
|
|
|
426
|
-
if (
|
|
427
|
-
|
|
428
|
-
snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
429
|
-
|
|
430
|
-
} else if ( biasSnippet ) {
|
|
450
|
+
if ( biasSnippet ) {
|
|
431
451
|
|
|
432
452
|
snippet = builder.generateTextureBias( texture, textureProperty, uvSnippet, biasSnippet, depthSnippet, offsetSnippet );
|
|
433
453
|
|
|
@@ -441,7 +461,11 @@ class TextureNode extends UniformNode {
|
|
|
441
461
|
|
|
442
462
|
} else if ( this.sampler === false ) {
|
|
443
463
|
|
|
444
|
-
snippet = builder.generateTextureLoad( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet );
|
|
464
|
+
snippet = builder.generateTextureLoad( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
465
|
+
|
|
466
|
+
} else if ( levelSnippet ) {
|
|
467
|
+
|
|
468
|
+
snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet, offsetSnippet );
|
|
445
469
|
|
|
446
470
|
} else {
|
|
447
471
|
|
|
@@ -557,7 +581,7 @@ class TextureNode extends UniformNode {
|
|
|
557
581
|
*/
|
|
558
582
|
uv( uvNode ) { // @deprecated, r172
|
|
559
583
|
|
|
560
|
-
|
|
584
|
+
warn( 'TextureNode: .uv() has been renamed. Use .sample() instead.' );
|
|
561
585
|
|
|
562
586
|
return this.sample( uvNode );
|
|
563
587
|
|
|
@@ -607,7 +631,7 @@ class TextureNode extends UniformNode {
|
|
|
607
631
|
|
|
608
632
|
if ( textureNode.generateMipmaps === false && ( map && map.generateMipmaps === false || map.minFilter === NearestFilter || map.magFilter === NearestFilter ) ) {
|
|
609
633
|
|
|
610
|
-
|
|
634
|
+
warn( 'TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.' );
|
|
611
635
|
|
|
612
636
|
textureNode.biasNode = null;
|
|
613
637
|
|
|
@@ -776,6 +800,16 @@ class TextureNode extends UniformNode {
|
|
|
776
800
|
|
|
777
801
|
}
|
|
778
802
|
|
|
803
|
+
//
|
|
804
|
+
|
|
805
|
+
const flipYUniform = this._flipYUniform;
|
|
806
|
+
|
|
807
|
+
if ( flipYUniform !== null ) {
|
|
808
|
+
|
|
809
|
+
flipYUniform.value = ( ( texture.image instanceof ImageBitmap && texture.flipY === true ) || texture.isRenderTargetTexture === true || texture.isFramebufferTexture === true || texture.isDepthTexture === true );
|
|
810
|
+
|
|
811
|
+
}
|
|
812
|
+
|
|
779
813
|
}
|
|
780
814
|
|
|
781
815
|
/**
|
|
@@ -870,7 +904,7 @@ export const uniformTexture = ( value = EmptyTexture ) => texture( value );
|
|
|
870
904
|
*/
|
|
871
905
|
export const textureLoad = ( ...params ) => texture( ...params ).setSampler( false );
|
|
872
906
|
|
|
873
|
-
|
|
907
|
+
export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level );
|
|
874
908
|
|
|
875
909
|
/**
|
|
876
910
|
* Converts a texture or texture node to a sampler.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { addMethodChaining, nodeArray, nodeObject, nodeObjects, float } from '../tsl/TSLCore.js';
|
|
3
|
+
import { error } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This module represents the call of a {@link FunctionNode}. Developers are usually not confronted
|
|
@@ -121,13 +122,13 @@ class FunctionCallNode extends TempNode {
|
|
|
121
122
|
|
|
122
123
|
if ( parameters.length > inputs.length ) {
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
error( 'TSL: The number of provided parameters exceeds the expected number of inputs in \'Fn()\'.' );
|
|
125
126
|
|
|
126
127
|
parameters.length = inputs.length;
|
|
127
128
|
|
|
128
129
|
} else if ( parameters.length < inputs.length ) {
|
|
129
130
|
|
|
130
|
-
|
|
131
|
+
error( 'TSL: The number of provided parameters is less than the expected number of inputs in \'Fn()\'.' );
|
|
131
132
|
|
|
132
133
|
while ( parameters.length < inputs.length ) {
|
|
133
134
|
|
|
@@ -155,7 +156,7 @@ class FunctionCallNode extends TempNode {
|
|
|
155
156
|
|
|
156
157
|
} else {
|
|
157
158
|
|
|
158
|
-
|
|
159
|
+
error( `TSL: Input '${ inputNode.name }' not found in \'Fn()\'.` );
|
|
159
160
|
|
|
160
161
|
params.push( generateInput( float( 0 ), inputNode ) );
|
|
161
162
|
|
|
@@ -179,7 +180,7 @@ export const call = ( func, ...params ) => {
|
|
|
179
180
|
|
|
180
181
|
params = params.length > 1 || ( params[ 0 ] && params[ 0 ].isNode === true ) ? nodeArray( params ) : nodeObjects( params[ 0 ] );
|
|
181
182
|
|
|
182
|
-
return
|
|
183
|
+
return new FunctionCallNode( nodeObject( func ), params );
|
|
183
184
|
|
|
184
185
|
};
|
|
185
186
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { nodeObject, varying } from '../tsl/TSLBase.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Base class for representing shader attributes as nodes.
|
|
@@ -125,7 +126,7 @@ class AttributeNode extends Node {
|
|
|
125
126
|
|
|
126
127
|
} else {
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
warn( `AttributeNode: Vertex attribute "${ attributeName }" not found on geometry.` );
|
|
129
130
|
|
|
130
131
|
return builder.generateConst( nodeType );
|
|
131
132
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This node can be used as a context management component for another node.
|
|
@@ -93,9 +94,7 @@ class ContextNode extends Node {
|
|
|
93
94
|
|
|
94
95
|
analyze( builder ) {
|
|
95
96
|
|
|
96
|
-
const previousContext = builder.
|
|
97
|
-
|
|
98
|
-
builder.setContext( { ...builder.context, ...this.value } );
|
|
97
|
+
const previousContext = builder.addContext( this.value );
|
|
99
98
|
|
|
100
99
|
this.node.build( builder );
|
|
101
100
|
|
|
@@ -105,9 +104,7 @@ class ContextNode extends Node {
|
|
|
105
104
|
|
|
106
105
|
setup( builder ) {
|
|
107
106
|
|
|
108
|
-
const previousContext = builder.
|
|
109
|
-
|
|
110
|
-
builder.setContext( { ...builder.context, ...this.value } );
|
|
107
|
+
const previousContext = builder.addContext( this.value );
|
|
111
108
|
|
|
112
109
|
this.node.build( builder );
|
|
113
110
|
|
|
@@ -117,9 +114,7 @@ class ContextNode extends Node {
|
|
|
117
114
|
|
|
118
115
|
generate( builder, output ) {
|
|
119
116
|
|
|
120
|
-
const previousContext = builder.
|
|
121
|
-
|
|
122
|
-
builder.setContext( { ...builder.context, ...this.value } );
|
|
117
|
+
const previousContext = builder.addContext( this.value );
|
|
123
118
|
|
|
124
119
|
const snippet = this.node.build( builder, output );
|
|
125
120
|
|
|
@@ -177,7 +172,7 @@ export const setName = ( node, name ) => context( node, { nodeName: name } );
|
|
|
177
172
|
*/
|
|
178
173
|
export function label( node, name ) {
|
|
179
174
|
|
|
180
|
-
|
|
175
|
+
warn( 'TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
181
176
|
|
|
182
177
|
return setName( node, name );
|
|
183
178
|
|
|
@@ -10,7 +10,7 @@ import { nodeImmutable, varying } from '../tsl/TSLBase.js';
|
|
|
10
10
|
* - `drawIndex`: The index of a draw call.
|
|
11
11
|
* - `invocationLocalIndex`: The index of a compute invocation within the scope of a workgroup load.
|
|
12
12
|
* - `invocationSubgroupIndex`: The index of a compute invocation within the scope of a subgroup.
|
|
13
|
-
* - `subgroupIndex`: The index of
|
|
13
|
+
* - `subgroupIndex`: The index of a compute invocation's subgroup within its workgroup.
|
|
14
14
|
*
|
|
15
15
|
* @augments Node
|
|
16
16
|
*/
|
|
@@ -25,7 +25,7 @@ class IndexNode extends Node {
|
|
|
25
25
|
/**
|
|
26
26
|
* Constructs a new index node.
|
|
27
27
|
*
|
|
28
|
-
* @param {('vertex'|'instance'|'subgroup'|'invocationLocal'|'invocationSubgroup'|'draw')} scope - The scope of the index node.
|
|
28
|
+
* @param {('vertex'|'instance'|'subgroup'|'invocationLocal'|'invocationGlobal'|'invocationSubgroup'|'draw')} scope - The scope of the index node.
|
|
29
29
|
*/
|
|
30
30
|
constructor( scope ) {
|
|
31
31
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
2
|
import { getValueType, getValueFromType, arrayBufferToBase64 } from './NodeUtils.js';
|
|
3
|
+
import { warn } from '../../utils.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Base class for representing data input nodes.
|
|
@@ -126,7 +127,7 @@ class InputNode extends Node {
|
|
|
126
127
|
|
|
127
128
|
generate( /*builder, output*/ ) {
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
warn( 'Abstract function.' );
|
|
130
131
|
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import Node from './Node.js';
|
|
2
|
+
import InspectorBase from '../../renderers/common/InspectorBase.js';
|
|
3
|
+
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
4
|
+
import { NodeUpdateType } from './constants.js';
|
|
5
|
+
import { warnOnce } from '../../utils.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* InspectorNode is a wrapper node that allows inspection of node values during rendering.
|
|
9
|
+
* It can be used to debug or analyze node outputs in the rendering pipeline.
|
|
10
|
+
*
|
|
11
|
+
* @augments Node
|
|
12
|
+
*/
|
|
13
|
+
class InspectorNode extends Node {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the type of the node.
|
|
17
|
+
*
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
static get type() {
|
|
21
|
+
|
|
22
|
+
return 'InspectorNode';
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an InspectorNode.
|
|
28
|
+
*
|
|
29
|
+
* @param {Node} node - The node to inspect.
|
|
30
|
+
* @param {string} [name=''] - Optional name for the inspector node.
|
|
31
|
+
* @param {Function|null} [callback=null] - Optional callback to modify the node during setup.
|
|
32
|
+
*/
|
|
33
|
+
constructor( node, name = '', callback = null ) {
|
|
34
|
+
|
|
35
|
+
super();
|
|
36
|
+
|
|
37
|
+
this.node = node;
|
|
38
|
+
this.name = name;
|
|
39
|
+
this.callback = callback;
|
|
40
|
+
|
|
41
|
+
this.updateType = NodeUpdateType.FRAME;
|
|
42
|
+
|
|
43
|
+
this.isInspectorNode = true;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns the name of the inspector node.
|
|
49
|
+
*
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
getName() {
|
|
53
|
+
|
|
54
|
+
return this.name || this.node.name;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Updates the inspector node, allowing inspection of the wrapped node.
|
|
60
|
+
*
|
|
61
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
62
|
+
*/
|
|
63
|
+
update( frame ) {
|
|
64
|
+
|
|
65
|
+
frame.renderer.inspector.inspect( this );
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Returns the type of the wrapped node.
|
|
71
|
+
*
|
|
72
|
+
* @param {NodeBuilder} builder - The node builder.
|
|
73
|
+
* @returns {string}
|
|
74
|
+
*/
|
|
75
|
+
getNodeType( builder ) {
|
|
76
|
+
|
|
77
|
+
return this.node.getNodeType( builder );
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Sets up the inspector node.
|
|
83
|
+
*
|
|
84
|
+
* @param {NodeBuilder} builder - The node builder.
|
|
85
|
+
* @returns {Node} The setup node.
|
|
86
|
+
*/
|
|
87
|
+
setup( builder ) {
|
|
88
|
+
|
|
89
|
+
let node = this.node;
|
|
90
|
+
|
|
91
|
+
if ( builder.context.inspector === true && this.callback !== null ) {
|
|
92
|
+
|
|
93
|
+
node = this.callback( node );
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if ( builder.renderer.backend.isWebGPUBackend !== true && builder.renderer.inspector.constructor !== InspectorBase ) {
|
|
98
|
+
|
|
99
|
+
warnOnce( 'TSL: ".toInspector()" is only available with WebGPU.' );
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return node;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default InspectorNode;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Creates an inspector node to wrap around a given node for inspection purposes.
|
|
113
|
+
*
|
|
114
|
+
* @tsl
|
|
115
|
+
* @param {Node} node - The node to inspect.
|
|
116
|
+
* @param {string} [name=''] - Optional name for the inspector node.
|
|
117
|
+
* @param {Function|null} [callback=null] - Optional callback to modify the node during setup.
|
|
118
|
+
* @returns {Node} The inspector node.
|
|
119
|
+
*/
|
|
120
|
+
export function inspector( node, name = '', callback = null ) {
|
|
121
|
+
|
|
122
|
+
node = nodeObject( node );
|
|
123
|
+
|
|
124
|
+
return node.before( new InspectorNode( node, name, callback ) );
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
addMethodChaining( 'toInspector', inspector );
|