@plastic-software/three 0.182.0 → 0.183.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/LICENSE +1 -1
- package/build/three.cjs +11521 -10878
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +510 -263
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +4 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -5,12 +5,15 @@ import { colorSpaceToWorking } from '../display/ColorSpaceNode.js';
|
|
|
5
5
|
import { expression } from '../code/ExpressionNode.js';
|
|
6
6
|
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
7
7
|
import { nodeProxy, vec3, nodeObject, int, Fn } from '../tsl/TSLBase.js';
|
|
8
|
+
import { step } from '../math/MathNode.js';
|
|
8
9
|
import { NodeUpdateType } from '../core/constants.js';
|
|
9
10
|
|
|
10
|
-
import { IntType, NearestFilter, UnsignedIntType } from '../../constants.js';
|
|
11
|
+
import { Compatibility, GreaterCompare, GreaterEqualCompare, IntType, LessCompare, LessEqualCompare, NearestFilter, UnsignedIntType } from '../../constants.js';
|
|
11
12
|
|
|
12
13
|
import { Texture } from '../../textures/Texture.js';
|
|
13
|
-
import { warn } from '../../utils.js';
|
|
14
|
+
import { warn, warnOnce } from '../../utils.js';
|
|
15
|
+
|
|
16
|
+
import NodeError from '../core/NodeError.js';
|
|
14
17
|
|
|
15
18
|
const EmptyTexture = /*@__PURE__*/ new Texture();
|
|
16
19
|
|
|
@@ -343,7 +346,7 @@ class TextureNode extends UniformNode {
|
|
|
343
346
|
|
|
344
347
|
if ( ! texture || texture.isTexture !== true ) {
|
|
345
348
|
|
|
346
|
-
throw new
|
|
349
|
+
throw new NodeError( 'THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().', this.stackTrace );
|
|
347
350
|
|
|
348
351
|
}
|
|
349
352
|
|
|
@@ -391,10 +394,40 @@ class TextureNode extends UniformNode {
|
|
|
391
394
|
|
|
392
395
|
//
|
|
393
396
|
|
|
397
|
+
let compareNode = null;
|
|
398
|
+
let compareStepNode = null;
|
|
399
|
+
|
|
400
|
+
if ( this.compareNode !== null ) {
|
|
401
|
+
|
|
402
|
+
if ( builder.renderer.hasCompatibility( Compatibility.TEXTURE_COMPARE ) ) {
|
|
403
|
+
|
|
404
|
+
compareNode = this.compareNode;
|
|
405
|
+
|
|
406
|
+
} else {
|
|
407
|
+
|
|
408
|
+
const compareFunction = texture.compareFunction;
|
|
409
|
+
|
|
410
|
+
if ( compareFunction === null || compareFunction === LessCompare || compareFunction === LessEqualCompare || compareFunction === GreaterCompare || compareFunction === GreaterEqualCompare ) {
|
|
411
|
+
|
|
412
|
+
compareStepNode = this.compareNode;
|
|
413
|
+
|
|
414
|
+
} else {
|
|
415
|
+
|
|
416
|
+
compareNode = this.compareNode;
|
|
417
|
+
|
|
418
|
+
warnOnce( 'TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.' );
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
}
|
|
425
|
+
|
|
394
426
|
properties.uvNode = uvNode;
|
|
395
427
|
properties.levelNode = levelNode;
|
|
396
428
|
properties.biasNode = this.biasNode;
|
|
397
|
-
properties.compareNode =
|
|
429
|
+
properties.compareNode = compareNode;
|
|
430
|
+
properties.compareStepNode = compareStepNode;
|
|
398
431
|
properties.gradNode = this.gradNode;
|
|
399
432
|
properties.depthNode = this.depthNode;
|
|
400
433
|
properties.offsetNode = this.offsetNode;
|
|
@@ -503,17 +536,20 @@ class TextureNode extends UniformNode {
|
|
|
503
536
|
|
|
504
537
|
const nodeData = builder.getDataFromNode( this );
|
|
505
538
|
|
|
539
|
+
const nodeType = this.getNodeType( builder );
|
|
540
|
+
|
|
506
541
|
let propertyName = nodeData.propertyName;
|
|
507
542
|
|
|
508
543
|
if ( propertyName === undefined ) {
|
|
509
544
|
|
|
510
|
-
const { uvNode, levelNode, biasNode, compareNode, depthNode, gradNode, offsetNode } = properties;
|
|
545
|
+
const { uvNode, levelNode, biasNode, compareNode, compareStepNode, depthNode, gradNode, offsetNode } = properties;
|
|
511
546
|
|
|
512
547
|
const uvSnippet = this.generateUV( builder, uvNode );
|
|
513
548
|
const levelSnippet = levelNode ? levelNode.build( builder, 'float' ) : null;
|
|
514
549
|
const biasSnippet = biasNode ? biasNode.build( builder, 'float' ) : null;
|
|
515
550
|
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
|
|
516
551
|
const compareSnippet = compareNode ? compareNode.build( builder, 'float' ) : null;
|
|
552
|
+
const compareStepSnippet = compareStepNode ? compareStepNode.build( builder, 'float' ) : null;
|
|
517
553
|
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
|
|
518
554
|
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;
|
|
519
555
|
|
|
@@ -521,7 +557,23 @@ class TextureNode extends UniformNode {
|
|
|
521
557
|
|
|
522
558
|
propertyName = builder.getPropertyName( nodeVar );
|
|
523
559
|
|
|
524
|
-
|
|
560
|
+
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet );
|
|
561
|
+
|
|
562
|
+
if ( compareStepSnippet !== null ) {
|
|
563
|
+
|
|
564
|
+
const compareFunction = texture.compareFunction;
|
|
565
|
+
|
|
566
|
+
if ( compareFunction === GreaterCompare || compareFunction === GreaterEqualCompare ) {
|
|
567
|
+
|
|
568
|
+
snippet = step( expression( snippet, nodeType ), expression( compareStepSnippet, 'float' ) ).build( builder, nodeType );
|
|
569
|
+
|
|
570
|
+
} else {
|
|
571
|
+
|
|
572
|
+
snippet = step( expression( compareStepSnippet, 'float' ), expression( snippet, nodeType ) ).build( builder, nodeType );
|
|
573
|
+
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
}
|
|
525
577
|
|
|
526
578
|
builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
|
|
527
579
|
|
|
@@ -531,7 +583,6 @@ class TextureNode extends UniformNode {
|
|
|
531
583
|
}
|
|
532
584
|
|
|
533
585
|
let snippet = propertyName;
|
|
534
|
-
const nodeType = this.getNodeType( builder );
|
|
535
586
|
|
|
536
587
|
if ( builder.needsToWorkingColorSpace( texture ) ) {
|
|
537
588
|
|
|
@@ -572,21 +623,6 @@ class TextureNode extends UniformNode {
|
|
|
572
623
|
|
|
573
624
|
// @TODO: Move to TSL
|
|
574
625
|
|
|
575
|
-
/**
|
|
576
|
-
* @function
|
|
577
|
-
* @deprecated since r172. Use {@link TextureNode#sample} instead.
|
|
578
|
-
*
|
|
579
|
-
* @param {Node} uvNode - The uv node.
|
|
580
|
-
* @return {TextureNode} A texture node representing the texture sample.
|
|
581
|
-
*/
|
|
582
|
-
uv( uvNode ) { // @deprecated, r172
|
|
583
|
-
|
|
584
|
-
warn( 'TextureNode: .uv() has been renamed. Use .sample() instead.' );
|
|
585
|
-
|
|
586
|
-
return this.sample( uvNode );
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
626
|
/**
|
|
591
627
|
* Samples the texture with the given uv node.
|
|
592
628
|
*
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import OutputStructNode from './OutputStructNode.js';
|
|
2
2
|
import { nodeProxy, vec4 } from '../tsl/TSLBase.js';
|
|
3
|
+
import { MaterialBlending, NoBlending } from '../../constants.js';
|
|
4
|
+
import BlendMode from '../../renderers/common/BlendMode.js';
|
|
5
|
+
|
|
6
|
+
// Predefined blend modes for MRT nodes.
|
|
7
|
+
const _noBlending = /**@__PURE__*/ new BlendMode( NoBlending );
|
|
8
|
+
const _materialBlending = /**@__PURE__*/ new BlendMode( MaterialBlending );
|
|
3
9
|
|
|
4
10
|
/**
|
|
5
11
|
* Returns the MRT texture index for the given name.
|
|
@@ -31,7 +37,7 @@ export function getTextureIndex( textures, name ) {
|
|
|
31
37
|
* const mrtNode = mrt( {
|
|
32
38
|
* output: output,
|
|
33
39
|
* normal: normalView
|
|
34
|
-
* } )
|
|
40
|
+
* } ) ;
|
|
35
41
|
* ```
|
|
36
42
|
* The MRT output is defined as a dictionary.
|
|
37
43
|
*
|
|
@@ -63,6 +69,15 @@ class MRTNode extends OutputStructNode {
|
|
|
63
69
|
*/
|
|
64
70
|
this.outputNodes = outputNodes;
|
|
65
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A dictionary storing the blend modes for each output.
|
|
74
|
+
*
|
|
75
|
+
* @type {Object<string, BlendMode>}
|
|
76
|
+
*/
|
|
77
|
+
this.blendModes = {
|
|
78
|
+
output: _materialBlending
|
|
79
|
+
};
|
|
80
|
+
|
|
66
81
|
/**
|
|
67
82
|
* This flag can be used for type testing.
|
|
68
83
|
*
|
|
@@ -74,6 +89,33 @@ class MRTNode extends OutputStructNode {
|
|
|
74
89
|
|
|
75
90
|
}
|
|
76
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Sets the blend mode for the given output name.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} name - The name of the output.
|
|
96
|
+
* @param {BlendMode} blend - The blending mode.
|
|
97
|
+
* @return {MRTNode} The current MRT node.
|
|
98
|
+
*/
|
|
99
|
+
setBlendMode( name, blend ) {
|
|
100
|
+
|
|
101
|
+
this.blendModes[ name ] = blend;
|
|
102
|
+
|
|
103
|
+
return this;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Returns the blend mode for the given output name.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} name - The name of the output.
|
|
111
|
+
* @return {BlendMode} The blend mode.
|
|
112
|
+
*/
|
|
113
|
+
getBlendMode( name ) {
|
|
114
|
+
|
|
115
|
+
return this.blendModes[ name ] || _noBlending;
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
77
119
|
/**
|
|
78
120
|
* Returns `true` if the MRT node has an output with the given name.
|
|
79
121
|
*
|
|
@@ -107,8 +149,12 @@ class MRTNode extends OutputStructNode {
|
|
|
107
149
|
merge( mrtNode ) {
|
|
108
150
|
|
|
109
151
|
const outputs = { ...this.outputNodes, ...mrtNode.outputNodes };
|
|
152
|
+
const blendings = { ...this.blendModes, ...mrtNode.blendModes };
|
|
153
|
+
|
|
154
|
+
const mrtTarget = mrt( outputs );
|
|
155
|
+
mrtTarget.blendings = blendings;
|
|
110
156
|
|
|
111
|
-
return
|
|
157
|
+
return mrtTarget;
|
|
112
158
|
|
|
113
159
|
}
|
|
114
160
|
|
package/src/nodes/core/Node.js
CHANGED
|
@@ -5,6 +5,8 @@ import { EventDispatcher } from '../../core/EventDispatcher.js';
|
|
|
5
5
|
import { MathUtils } from '../../math/MathUtils.js';
|
|
6
6
|
import { warn, error } from '../../utils.js';
|
|
7
7
|
|
|
8
|
+
import StackTrace from './StackTrace.js';
|
|
9
|
+
|
|
8
10
|
const _parentBuildStage = {
|
|
9
11
|
analyze: 'setup',
|
|
10
12
|
generate: 'analyze'
|
|
@@ -132,7 +134,7 @@ class Node extends EventDispatcher {
|
|
|
132
134
|
this._cacheKey = null;
|
|
133
135
|
|
|
134
136
|
/**
|
|
135
|
-
* The cache key
|
|
137
|
+
* The cache key's version.
|
|
136
138
|
*
|
|
137
139
|
* @private
|
|
138
140
|
* @type {number}
|
|
@@ -142,6 +144,20 @@ class Node extends EventDispatcher {
|
|
|
142
144
|
|
|
143
145
|
Object.defineProperty( this, 'id', { value: _nodeId ++ } );
|
|
144
146
|
|
|
147
|
+
/**
|
|
148
|
+
* The stack trace of the node for debugging purposes.
|
|
149
|
+
*
|
|
150
|
+
* @type {?string}
|
|
151
|
+
* @default null
|
|
152
|
+
*/
|
|
153
|
+
this.stackTrace = null;
|
|
154
|
+
|
|
155
|
+
if ( Node.captureStackTrace === true ) {
|
|
156
|
+
|
|
157
|
+
this.stackTrace = new StackTrace();
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
145
161
|
}
|
|
146
162
|
|
|
147
163
|
/**
|
|
@@ -770,7 +786,6 @@ class Node extends EventDispatcher {
|
|
|
770
786
|
|
|
771
787
|
//
|
|
772
788
|
|
|
773
|
-
builder.addNode( this );
|
|
774
789
|
builder.addChain( this );
|
|
775
790
|
|
|
776
791
|
/* Build stages expected results:
|
|
@@ -784,6 +799,8 @@ class Node extends EventDispatcher {
|
|
|
784
799
|
|
|
785
800
|
if ( buildStage === 'setup' ) {
|
|
786
801
|
|
|
802
|
+
builder.addNode( this );
|
|
803
|
+
|
|
787
804
|
this.updateReference( builder );
|
|
788
805
|
|
|
789
806
|
const properties = builder.getNodeProperties( this );
|
|
@@ -820,6 +837,8 @@ class Node extends EventDispatcher {
|
|
|
820
837
|
|
|
821
838
|
}
|
|
822
839
|
|
|
840
|
+
builder.addSequentialNode( this );
|
|
841
|
+
|
|
823
842
|
}
|
|
824
843
|
|
|
825
844
|
result = properties.outputNode;
|
|
@@ -889,7 +908,6 @@ class Node extends EventDispatcher {
|
|
|
889
908
|
}
|
|
890
909
|
|
|
891
910
|
builder.removeChain( this );
|
|
892
|
-
builder.addSequentialNode( this );
|
|
893
911
|
|
|
894
912
|
return result;
|
|
895
913
|
|
|
@@ -1080,4 +1098,12 @@ class Node extends EventDispatcher {
|
|
|
1080
1098
|
|
|
1081
1099
|
}
|
|
1082
1100
|
|
|
1101
|
+
/**
|
|
1102
|
+
* Enables or disables the automatic capturing of stack traces for nodes.
|
|
1103
|
+
*
|
|
1104
|
+
* @type {boolean}
|
|
1105
|
+
* @default false
|
|
1106
|
+
*/
|
|
1107
|
+
Node.captureStackTrace = false;
|
|
1108
|
+
|
|
1083
1109
|
export default Node;
|
|
@@ -8,7 +8,7 @@ import ParameterNode from './ParameterNode.js';
|
|
|
8
8
|
import StructType from './StructType.js';
|
|
9
9
|
import FunctionNode from '../code/FunctionNode.js';
|
|
10
10
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
11
|
-
import { getTypeFromLength } from './NodeUtils.js';
|
|
11
|
+
import { getDataFromObject, getTypeFromLength, hashString } from './NodeUtils.js';
|
|
12
12
|
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
13
13
|
|
|
14
14
|
import {
|
|
@@ -20,7 +20,6 @@ import { stack } from './StackNode.js';
|
|
|
20
20
|
import { getCurrentStack, setCurrentStack } from '../tsl/TSLBase.js';
|
|
21
21
|
|
|
22
22
|
import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
23
|
-
import ChainMap from '../../renderers/common/ChainMap.js';
|
|
24
23
|
|
|
25
24
|
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
26
25
|
|
|
@@ -35,9 +34,9 @@ import { warn, error } from '../../utils.js';
|
|
|
35
34
|
|
|
36
35
|
let _id = 0;
|
|
37
36
|
|
|
38
|
-
const
|
|
37
|
+
const _bindingGroupsCache = new WeakMap();
|
|
39
38
|
|
|
40
|
-
const
|
|
39
|
+
const sharedNodeData = new WeakMap();
|
|
41
40
|
|
|
42
41
|
const typeFromArray = new Map( [
|
|
43
42
|
[ Int8Array, 'int' ],
|
|
@@ -140,7 +139,10 @@ class NodeBuilder {
|
|
|
140
139
|
this.nodes = [];
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
|
-
* A list of all sequential
|
|
142
|
+
* A list of all nodes the builder is processing in sequential order.
|
|
143
|
+
*
|
|
144
|
+
* This is used to determine the update order of nodes, which is important for
|
|
145
|
+
* {@link NodeUpdateType#UPDATE_BEFORE} and {@link NodeUpdateType#UPDATE_AFTER}.
|
|
144
146
|
*
|
|
145
147
|
* @type {Array<Node>}
|
|
146
148
|
*/
|
|
@@ -468,36 +470,26 @@ class NodeBuilder {
|
|
|
468
470
|
}
|
|
469
471
|
|
|
470
472
|
/**
|
|
471
|
-
* Whether the material is
|
|
473
|
+
* Whether the material is using flat shading or not.
|
|
472
474
|
*
|
|
473
|
-
* @
|
|
475
|
+
* @returns {boolean} Whether the material is using flat shading or not.
|
|
474
476
|
*/
|
|
475
|
-
|
|
477
|
+
isFlatShading() {
|
|
476
478
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
return material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false;
|
|
479
|
+
return this.material.flatShading === true || this.geometry.hasAttribute( 'normal' ) === false;
|
|
480
480
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/**
|
|
484
|
-
*
|
|
484
|
+
* Whether the material is opaque or not.
|
|
485
485
|
*
|
|
486
|
-
* @return {
|
|
486
|
+
* @return {boolean} Whether the material is opaque or not.
|
|
487
487
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
let bindGroupsCache = rendererCache.get( this.renderer );
|
|
491
|
-
|
|
492
|
-
if ( bindGroupsCache === undefined ) {
|
|
493
|
-
|
|
494
|
-
bindGroupsCache = new ChainMap();
|
|
495
|
-
|
|
496
|
-
rendererCache.set( this.renderer, bindGroupsCache );
|
|
488
|
+
isOpaque() {
|
|
497
489
|
|
|
498
|
-
|
|
490
|
+
const material = this.material;
|
|
499
491
|
|
|
500
|
-
return
|
|
492
|
+
return material.transparent === false && material.blending === NormalBlending && material.alphaToCoverage === false;
|
|
501
493
|
|
|
502
494
|
}
|
|
503
495
|
|
|
@@ -561,19 +553,21 @@ class NodeBuilder {
|
|
|
561
553
|
*/
|
|
562
554
|
_getBindGroup( groupName, bindings ) {
|
|
563
555
|
|
|
564
|
-
const
|
|
556
|
+
const groupNode = bindings[ 0 ].groupNode;
|
|
565
557
|
|
|
566
|
-
|
|
558
|
+
let sharedGroup = groupNode.shared;
|
|
567
559
|
|
|
568
|
-
|
|
560
|
+
if ( sharedGroup ) {
|
|
569
561
|
|
|
570
|
-
|
|
562
|
+
for ( let i = 1; i < bindings.length; i ++ ) {
|
|
571
563
|
|
|
572
|
-
|
|
564
|
+
if ( groupNode !== bindings[ i ].groupNode ) {
|
|
573
565
|
|
|
574
|
-
|
|
566
|
+
sharedGroup = false;
|
|
575
567
|
|
|
576
|
-
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
}
|
|
577
571
|
|
|
578
572
|
}
|
|
579
573
|
|
|
@@ -583,19 +577,59 @@ class NodeBuilder {
|
|
|
583
577
|
|
|
584
578
|
if ( sharedGroup ) {
|
|
585
579
|
|
|
586
|
-
|
|
580
|
+
let cacheKeyString = '';
|
|
581
|
+
|
|
582
|
+
for ( const binding of bindings ) {
|
|
583
|
+
|
|
584
|
+
if ( binding.isNodeUniformsGroup ) {
|
|
585
|
+
|
|
586
|
+
binding.uniforms.sort( ( a, b ) => a.nodeUniform.node.id - b.nodeUniform.node.id );
|
|
587
|
+
|
|
588
|
+
for ( const uniform of binding.uniforms ) {
|
|
589
|
+
|
|
590
|
+
cacheKeyString += uniform.nodeUniform.node.id;
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
} else {
|
|
595
|
+
|
|
596
|
+
cacheKeyString += binding.nodeUniform.id;
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// TODO: Remove this hack ._currentRenderContext
|
|
603
|
+
|
|
604
|
+
const currentContext = this.renderer._currentRenderContext || this.renderer; // use renderer as fallback until we have a compute context
|
|
605
|
+
|
|
606
|
+
let bindingGroupsCache = _bindingGroupsCache.get( currentContext );
|
|
607
|
+
|
|
608
|
+
if ( bindingGroupsCache === undefined ) {
|
|
609
|
+
|
|
610
|
+
bindingGroupsCache = new Map();
|
|
611
|
+
|
|
612
|
+
_bindingGroupsCache.set( currentContext, bindingGroupsCache );
|
|
613
|
+
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//
|
|
617
|
+
|
|
618
|
+
const cacheKey = hashString( cacheKeyString );
|
|
619
|
+
|
|
620
|
+
bindGroup = bindingGroupsCache.get( cacheKey );
|
|
587
621
|
|
|
588
622
|
if ( bindGroup === undefined ) {
|
|
589
623
|
|
|
590
|
-
bindGroup = new BindGroup( groupName,
|
|
624
|
+
bindGroup = new BindGroup( groupName, bindings, this.bindingsIndexes[ groupName ].group );
|
|
591
625
|
|
|
592
|
-
|
|
626
|
+
bindingGroupsCache.set( cacheKey, bindGroup );
|
|
593
627
|
|
|
594
628
|
}
|
|
595
629
|
|
|
596
630
|
} else {
|
|
597
631
|
|
|
598
|
-
bindGroup = new BindGroup( groupName,
|
|
632
|
+
bindGroup = new BindGroup( groupName, bindings, this.bindingsIndexes[ groupName ].group );
|
|
599
633
|
|
|
600
634
|
}
|
|
601
635
|
|
|
@@ -653,7 +687,16 @@ class NodeBuilder {
|
|
|
653
687
|
const uniforms = bindings[ shaderStage ][ groupName ];
|
|
654
688
|
|
|
655
689
|
const groupUniforms = groups[ groupName ] || ( groups[ groupName ] = [] );
|
|
656
|
-
|
|
690
|
+
|
|
691
|
+
for ( const uniform of uniforms ) {
|
|
692
|
+
|
|
693
|
+
if ( groupUniforms.includes( uniform ) === false ) {
|
|
694
|
+
|
|
695
|
+
groupUniforms.push( uniform );
|
|
696
|
+
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
}
|
|
657
700
|
|
|
658
701
|
}
|
|
659
702
|
|
|
@@ -738,9 +781,16 @@ class NodeBuilder {
|
|
|
738
781
|
*/
|
|
739
782
|
addSequentialNode( node ) {
|
|
740
783
|
|
|
741
|
-
|
|
784
|
+
const updateBeforeType = node.getUpdateBeforeType();
|
|
785
|
+
const updateAfterType = node.getUpdateAfterType();
|
|
786
|
+
|
|
787
|
+
if ( updateBeforeType !== NodeUpdateType.NONE || updateAfterType !== NodeUpdateType.NONE ) {
|
|
742
788
|
|
|
743
|
-
this.sequentialNodes.
|
|
789
|
+
if ( this.sequentialNodes.includes( node ) === false ) {
|
|
790
|
+
|
|
791
|
+
this.sequentialNodes.push( node );
|
|
792
|
+
|
|
793
|
+
}
|
|
744
794
|
|
|
745
795
|
}
|
|
746
796
|
|
|
@@ -809,6 +859,17 @@ class NodeBuilder {
|
|
|
809
859
|
|
|
810
860
|
}
|
|
811
861
|
|
|
862
|
+
/**
|
|
863
|
+
* Returns the maximum number of bytes available for uniform buffers.
|
|
864
|
+
*
|
|
865
|
+
* @return {number} The maximum number of bytes available for uniform buffers.
|
|
866
|
+
*/
|
|
867
|
+
getUniformBufferLimit() {
|
|
868
|
+
|
|
869
|
+
return 16384;
|
|
870
|
+
|
|
871
|
+
}
|
|
872
|
+
|
|
812
873
|
/**
|
|
813
874
|
* Adds the given node to the internal node chain.
|
|
814
875
|
* This is used to check recursive calls in node-graph.
|
|
@@ -2916,9 +2977,9 @@ class NodeBuilder {
|
|
|
2916
2977
|
|
|
2917
2978
|
this.setBuildStage( buildStage );
|
|
2918
2979
|
|
|
2919
|
-
if ( this.context.
|
|
2980
|
+
if ( this.context.position && this.context.position.isNode ) {
|
|
2920
2981
|
|
|
2921
|
-
this.flowNodeFromShaderStage( 'vertex', this.context.
|
|
2982
|
+
this.flowNodeFromShaderStage( 'vertex', this.context.position );
|
|
2922
2983
|
|
|
2923
2984
|
}
|
|
2924
2985
|
|
|
@@ -3118,6 +3179,20 @@ class NodeBuilder {
|
|
|
3118
3179
|
|
|
3119
3180
|
}
|
|
3120
3181
|
|
|
3182
|
+
/**
|
|
3183
|
+
* Returns `true` if data from the previous frame are required. Relevant
|
|
3184
|
+
* when computing motion vectors with {@link VelocityNode}.
|
|
3185
|
+
*
|
|
3186
|
+
* @return {boolean} Whether data from the previous frame are required or not.
|
|
3187
|
+
*/
|
|
3188
|
+
needsPreviousData() {
|
|
3189
|
+
|
|
3190
|
+
const mrt = this.renderer.getMRT();
|
|
3191
|
+
|
|
3192
|
+
return ( mrt && mrt.has( 'velocity' ) ) || getDataFromObject( this.object ).useVelocity === true;
|
|
3193
|
+
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3121
3196
|
}
|
|
3122
3197
|
|
|
3123
3198
|
export default NodeBuilder;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error class for node-related errors, including stack trace information.
|
|
3
|
+
*/
|
|
4
|
+
class NodeError extends Error {
|
|
5
|
+
|
|
6
|
+
constructor( message, stackTrace = null ) {
|
|
7
|
+
|
|
8
|
+
super( message );
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The name of the error.
|
|
12
|
+
*
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
this.name = 'NodeError';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The stack trace associated with the error.
|
|
19
|
+
*
|
|
20
|
+
* @type {?StackTrace}
|
|
21
|
+
*/
|
|
22
|
+
this.stackTrace = stackTrace;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default NodeError;
|
|
@@ -5,7 +5,9 @@ import { Matrix4 } from '../../math/Matrix4.js';
|
|
|
5
5
|
import { Vector2 } from '../../math/Vector2.js';
|
|
6
6
|
import { Vector3 } from '../../math/Vector3.js';
|
|
7
7
|
import { Vector4 } from '../../math/Vector4.js';
|
|
8
|
+
|
|
8
9
|
import { error } from '../../utils.js';
|
|
10
|
+
import StackTrace from '../core/StackTrace.js';
|
|
9
11
|
|
|
10
12
|
// cyrb53 (c) 2018 bryc (github.com/bryc). License: Public domain. Attribution appreciated.
|
|
11
13
|
// A fast and simple 64-bit (or 53-bit) string hash function with decent collision resistance.
|
|
@@ -154,7 +156,7 @@ export function getLengthFromType( type ) {
|
|
|
154
156
|
if ( /mat3/.test( type ) ) return 9;
|
|
155
157
|
if ( /mat4/.test( type ) ) return 16;
|
|
156
158
|
|
|
157
|
-
error(
|
|
159
|
+
error( `TSL: Unsupported type: ${ type }`, new StackTrace() );
|
|
158
160
|
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -176,7 +178,7 @@ export function getMemoryLengthFromType( type ) {
|
|
|
176
178
|
if ( /mat3/.test( type ) ) return 12;
|
|
177
179
|
if ( /mat4/.test( type ) ) return 16;
|
|
178
180
|
|
|
179
|
-
error(
|
|
181
|
+
error( `TSL: Unsupported type: ${ type }`, new StackTrace() );
|
|
180
182
|
|
|
181
183
|
}
|
|
182
184
|
|
|
@@ -198,7 +200,7 @@ export function getAlignmentFromType( type ) {
|
|
|
198
200
|
if ( /mat3/.test( type ) ) return 16;
|
|
199
201
|
if ( /mat4/.test( type ) ) return 16;
|
|
200
202
|
|
|
201
|
-
error(
|
|
203
|
+
error( `TSL: Unsupported type: ${ type }`, new StackTrace() );
|
|
202
204
|
|
|
203
205
|
}
|
|
204
206
|
|
|
@@ -42,11 +42,17 @@ class OutputStructNode extends Node {
|
|
|
42
42
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
getNodeType( builder ) {
|
|
45
|
+
getNodeType( /*builder*/ ) {
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
return 'OutputType';
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
generate( builder ) {
|
|
52
|
+
|
|
53
|
+
const nodeData = builder.getDataFromNode( this );
|
|
54
|
+
|
|
55
|
+
if ( nodeData.membersLayout === undefined ) {
|
|
50
56
|
|
|
51
57
|
const members = this.members;
|
|
52
58
|
const membersLayout = [];
|
|
@@ -60,16 +66,12 @@ class OutputStructNode extends Node {
|
|
|
60
66
|
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
nodeData.membersLayout = membersLayout;
|
|
70
|
+
nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
|
|
65
71
|
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
generate( builder ) {
|
|
74
|
+
//
|
|
73
75
|
|
|
74
76
|
const propertyName = builder.getOutputStructName();
|
|
75
77
|
const members = this.members;
|