super-three 0.160.1 → 0.162.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/three.cjs +867 -499
- package/build/three.module.js +867 -496
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +5 -1
- package/examples/jsm/capabilities/WebGPU.js +13 -9
- package/examples/jsm/controls/DragControls.js +91 -30
- package/examples/jsm/controls/OrbitControls.js +130 -15
- package/examples/jsm/controls/TransformControls.js +6 -6
- package/examples/jsm/curves/NURBSUtils.js +59 -4
- package/examples/jsm/curves/NURBSVolume.js +62 -0
- package/examples/jsm/exporters/GLTFExporter.js +11 -1
- package/examples/jsm/exporters/USDZExporter.js +8 -7
- package/examples/jsm/helpers/TextureHelper.js +3 -3
- package/examples/jsm/interactive/InteractiveGroup.js +15 -25
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/tween.module.js +32 -14
- package/examples/jsm/loaders/3DMLoader.js +57 -64
- package/examples/jsm/loaders/DDSLoader.js +1 -0
- package/examples/jsm/loaders/KTX2Loader.js +20 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
- package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
- package/examples/jsm/loaders/LUTImageLoader.js +3 -2
- package/examples/jsm/loaders/MaterialXLoader.js +115 -16
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/VOXLoader.js +9 -2
- package/examples/jsm/loaders/VRMLLoader.js +7 -3
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
- package/examples/jsm/misc/Timer.js +13 -4
- package/examples/jsm/nodes/Nodes.js +24 -11
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
- package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
- package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
- package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
- package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
- package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
- package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +45 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
- package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
- package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
- package/examples/jsm/nodes/code/CodeNode.js +6 -0
- package/examples/jsm/nodes/core/AssignNode.js +68 -12
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +14 -4
- package/examples/jsm/nodes/core/NodeBuilder.js +26 -27
- package/examples/jsm/nodes/core/NodeFrame.js +18 -10
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/constants.js +1 -0
- package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
- package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
- package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
- package/examples/jsm/nodes/display/PassNode.js +3 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
- package/examples/jsm/nodes/display/ViewportNode.js +0 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
- package/examples/jsm/nodes/fog/FogNode.js +2 -1
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
- package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +43 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
- package/examples/jsm/nodes/math/CondNode.js +42 -7
- package/examples/jsm/nodes/math/MathNode.js +32 -2
- package/examples/jsm/nodes/math/MathUtils.js +15 -0
- package/examples/jsm/nodes/math/OperatorNode.js +13 -5
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
- package/examples/jsm/nodes/utils/JoinNode.js +2 -2
- package/examples/jsm/nodes/utils/LoopNode.js +5 -3
- package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
- package/examples/jsm/nodes/utils/RotateNode.js +68 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
- package/examples/jsm/nodes/utils/SplitNode.js +4 -4
- package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
- package/examples/jsm/objects/GroundedSkybox.js +50 -0
- package/examples/jsm/objects/QuadMesh.js +8 -2
- package/examples/jsm/objects/Water2.js +8 -8
- package/examples/jsm/postprocessing/GTAOPass.js +11 -1
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/renderers/common/Backend.js +14 -0
- package/examples/jsm/renderers/common/Background.js +2 -2
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/ClippingContext.js +165 -0
- package/examples/jsm/renderers/common/DataMap.js +1 -1
- package/examples/jsm/renderers/common/Info.js +25 -1
- package/examples/jsm/renderers/common/Pipelines.js +8 -8
- package/examples/jsm/renderers/common/PostProcessing.js +2 -2
- package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
- package/examples/jsm/renderers/common/RenderContext.js +2 -0
- package/examples/jsm/renderers/common/RenderContexts.js +2 -13
- package/examples/jsm/renderers/common/RenderObject.js +46 -1
- package/examples/jsm/renderers/common/RenderObjects.js +3 -1
- package/examples/jsm/renderers/common/Renderer.js +290 -17
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +28 -18
- package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
- package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +5 -2
- package/examples/jsm/renderers/webgl/WebGLBackend.js +653 -272
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +171 -39
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +95 -8
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +424 -11
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +300 -112
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +71 -79
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +87 -14
- package/examples/jsm/shaders/OutputShader.js +4 -0
- package/examples/jsm/transpiler/AST.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
- package/examples/jsm/utils/SkeletonUtils.js +14 -3
- package/examples/jsm/utils/SortUtils.js +2 -0
- package/examples/jsm/webxr/ARButton.js +12 -2
- package/examples/jsm/webxr/VRButton.js +25 -7
- package/examples/jsm/webxr/XRButton.js +12 -3
- package/examples/jsm/webxr/XRControllerModelFactory.js +14 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
- package/package.json +5 -4
- package/src/Three.Legacy.js +20 -0
- package/src/Three.js +0 -1
- package/src/audio/Audio.js +1 -3
- package/src/cameras/PerspectiveCamera.js +35 -0
- package/src/constants.js +2 -6
- package/src/core/BufferAttribute.js +2 -12
- package/src/core/BufferGeometry.js +23 -29
- package/src/core/InterleavedBuffer.js +2 -1
- package/src/core/InterleavedBufferAttribute.js +20 -0
- package/src/core/Object3D.js +11 -0
- package/src/core/Raycaster.js +18 -4
- package/src/core/RenderTarget.js +44 -21
- package/src/extras/PMREMGenerator.js +2 -0
- package/src/extras/curves/EllipseCurve.js +2 -2
- package/src/helpers/SpotLightHelper.js +18 -1
- package/src/loaders/DataTextureLoader.js +0 -4
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +2 -1
- package/src/materials/Material.js +2 -1
- package/src/materials/MeshBasicMaterial.js +3 -0
- package/src/materials/MeshLambertMaterial.js +3 -0
- package/src/materials/MeshPhongMaterial.js +3 -0
- package/src/materials/MeshStandardMaterial.js +3 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Quaternion.js +13 -12
- package/src/math/Triangle.js +0 -30
- package/src/math/Vector3.js +7 -7
- package/src/objects/BatchedMesh.js +6 -7
- package/src/objects/InstancedMesh.js +53 -0
- package/src/objects/Mesh.js +0 -1
- package/src/objects/SkinnedMesh.js +0 -8
- package/src/renderers/WebGLCubeRenderTarget.js +1 -10
- package/src/renderers/WebGLRenderer.js +20 -23
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +38 -7
- package/src/renderers/shaders/ShaderChunk.js +2 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +3 -2
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +4 -1
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/points.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +18 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLMaterials.js +24 -1
- package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
- package/src/renderers/webgl/WebGLProgram.js +42 -4
- package/src/renderers/webgl/WebGLPrograms.js +38 -27
- package/src/renderers/webgl/WebGLState.js +11 -21
- package/src/renderers/webgl/WebGLTextures.js +170 -66
- package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
- package/src/renderers/webxr/WebXRManager.js +46 -0
- package/src/scenes/Scene.js +8 -0
- package/src/textures/Source.js +1 -0
- package/src/textures/Texture.js +1 -29
- package/build/three.js +0 -54519
- package/build/three.min.js +0 -7
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
- package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
export * from './core/constants.js';
|
|
6
6
|
|
|
7
7
|
// core
|
|
8
|
-
export { default as ArrayUniformNode /* @TODO: arrayUniform */ } from './core/ArrayUniformNode.js';
|
|
9
8
|
export { default as AssignNode, assign } from './core/AssignNode.js';
|
|
10
9
|
export { default as AttributeNode, attribute } from './core/AttributeNode.js';
|
|
11
10
|
export { default as BypassNode, bypass } from './core/BypassNode.js';
|
|
@@ -39,11 +38,16 @@ import * as NodeUtils from './core/NodeUtils.js';
|
|
|
39
38
|
export { NodeUtils };
|
|
40
39
|
|
|
41
40
|
// math
|
|
42
|
-
export { default as MathNode, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward } from './math/MathNode.js';
|
|
43
|
-
|
|
41
|
+
export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, all, any, equals } from './math/MathNode.js';
|
|
42
|
+
|
|
43
|
+
export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
|
|
44
44
|
export { default as CondNode, cond } from './math/CondNode.js';
|
|
45
45
|
export { default as HashNode, hash } from './math/HashNode.js';
|
|
46
46
|
|
|
47
|
+
// math utils
|
|
48
|
+
export { parabola, gain, pcurve, sinc } from './math/MathUtils.js';
|
|
49
|
+
export { triNoise3D } from './math/TriNoise3D.js';
|
|
50
|
+
|
|
47
51
|
// utils
|
|
48
52
|
export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
|
|
49
53
|
export { default as ConvertNode } from './utils/ConvertNode.js';
|
|
@@ -51,33 +55,39 @@ export { default as DiscardNode, discard } from './utils/DiscardNode.js';
|
|
|
51
55
|
export { default as EquirectUVNode, equirectUV } from './utils/EquirectUVNode.js';
|
|
52
56
|
export { default as FunctionOverloadingNode, overloadingFn } from './utils/FunctionOverloadingNode.js';
|
|
53
57
|
export { default as JoinNode } from './utils/JoinNode.js';
|
|
54
|
-
export { default as LoopNode, loop } from './utils/LoopNode.js';
|
|
58
|
+
export { default as LoopNode, loop, Continue, Break } from './utils/LoopNode.js';
|
|
55
59
|
export { default as MatcapUVNode, matcapUV } from './utils/MatcapUVNode.js';
|
|
56
60
|
export { default as MaxMipLevelNode, maxMipLevel } from './utils/MaxMipLevelNode.js';
|
|
57
61
|
export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from './utils/OscNode.js';
|
|
58
62
|
export { default as PackingNode, directionToColor, colorToDirection } from './utils/PackingNode.js';
|
|
59
63
|
export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
|
|
60
64
|
export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
|
|
65
|
+
export { default as RotateNode, rotate } from './utils/RotateNode.js';
|
|
61
66
|
export { default as SetNode } from './utils/SetNode.js';
|
|
62
67
|
export { default as SpecularMIPLevelNode, specularMIPLevel } from './utils/SpecularMIPLevelNode.js';
|
|
63
68
|
export { default as SplitNode } from './utils/SplitNode.js';
|
|
64
69
|
export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
|
|
70
|
+
export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
|
|
65
71
|
export { default as TimerNode, timerLocal, timerGlobal, timerDelta, frameId } from './utils/TimerNode.js';
|
|
66
72
|
export { default as TriplanarTexturesNode, triplanarTextures, triplanarTexture } from './utils/TriplanarTexturesNode.js';
|
|
73
|
+
export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
|
|
67
74
|
|
|
68
75
|
// shadernode
|
|
69
76
|
export * from './shadernode/ShaderNode.js';
|
|
70
77
|
|
|
71
78
|
// accessors
|
|
79
|
+
export { TBNViewMatrix, parallaxDirection, parallaxUV } from './accessors/AccessorsUtils.js';
|
|
80
|
+
export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
|
|
72
81
|
export { default as BitangentNode, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, transformedBitangentView, transformedBitangentWorld } from './accessors/BitangentNode.js';
|
|
73
82
|
export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
|
|
74
83
|
export { default as BufferNode, buffer } from './accessors/BufferNode.js';
|
|
75
|
-
export { default as CameraNode, cameraProjectionMatrix, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
|
|
84
|
+
export { default as CameraNode, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraNormalMatrix, cameraWorldMatrix, cameraPosition, cameraNear, cameraFar, cameraLogDepth } from './accessors/CameraNode.js';
|
|
85
|
+
export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
|
|
76
86
|
export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
|
|
77
87
|
export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
|
|
78
88
|
export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecularColor, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth } from './accessors/MaterialNode.js';
|
|
79
89
|
export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
|
|
80
|
-
export { default as MorphNode,
|
|
90
|
+
export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
|
|
81
91
|
export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
|
|
82
92
|
export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale } from './accessors/ModelNode.js';
|
|
83
93
|
export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
|
|
@@ -85,11 +95,11 @@ export { default as NormalNode, normalGeometry, normalLocal, normalView, normalW
|
|
|
85
95
|
export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
|
|
86
96
|
export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
|
|
87
97
|
export { default as PositionNode, positionGeometry, positionLocal, positionWorld, positionWorldDirection, positionView, positionViewDirection } from './accessors/PositionNode.js';
|
|
88
|
-
export { default as ReferenceNode, reference,
|
|
98
|
+
export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
|
|
89
99
|
export { default as ReflectVectorNode, reflectVector } from './accessors/ReflectVectorNode.js';
|
|
90
100
|
export { default as SkinningNode, skinning } from './accessors/SkinningNode.js';
|
|
91
101
|
export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
|
|
92
|
-
export { default as StorageBufferNode, storage } from './accessors/StorageBufferNode.js';
|
|
102
|
+
export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
|
|
93
103
|
export { default as TangentNode, tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView, transformedTangentWorld } from './accessors/TangentNode.js';
|
|
94
104
|
export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
|
|
95
105
|
export { default as TextureStoreNode, textureStore } from './accessors/TextureStoreNode.js';
|
|
@@ -99,10 +109,10 @@ export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
|
|
|
99
109
|
// display
|
|
100
110
|
export { default as BlendModeNode, burn, dodge, overlay, screen } from './display/BlendModeNode.js';
|
|
101
111
|
export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
|
|
102
|
-
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance } from './display/ColorAdjustmentNode.js';
|
|
112
|
+
export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
|
|
103
113
|
export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
|
|
104
114
|
export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
|
|
105
|
-
export { default as NormalMapNode, normalMap
|
|
115
|
+
export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
|
|
106
116
|
export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
|
|
107
117
|
export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
|
|
108
118
|
export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
|
|
@@ -111,6 +121,9 @@ export { default as ViewportSharedTextureNode, viewportSharedTexture } from './d
|
|
|
111
121
|
export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
|
|
112
122
|
export { default as ViewportDepthNode, viewZToOrthographicDepth, orthographicDepthToViewZ, viewZToPerspectiveDepth, perspectiveDepthToViewZ, depth, depthTexture, depthPixel } from './display/ViewportDepthNode.js';
|
|
113
123
|
export { default as GaussianBlurNode, gaussianBlur } from './display/GaussianBlurNode.js';
|
|
124
|
+
export { default as AfterImageNode, afterImage } from './display/AfterImageNode.js';
|
|
125
|
+
export { default as AnamorphicNode, anamorphic } from './display/AnamorphicNode.js';
|
|
126
|
+
|
|
114
127
|
export { default as PassNode, pass, depthPass } from './display/PassNode.js';
|
|
115
128
|
|
|
116
129
|
// code
|
|
@@ -139,7 +152,7 @@ export { default as DirectionalLightNode } from './lighting/DirectionalLightNode
|
|
|
139
152
|
export { default as SpotLightNode } from './lighting/SpotLightNode.js';
|
|
140
153
|
export { default as IESSpotLightNode } from './lighting/IESSpotLightNode.js';
|
|
141
154
|
export { default as AmbientLightNode } from './lighting/AmbientLightNode.js';
|
|
142
|
-
export { default as LightsNode, lights,
|
|
155
|
+
export { default as LightsNode, lights, lightsNode, addLightNode } from './lighting/LightsNode.js';
|
|
143
156
|
export { default as LightingNode /* @TODO: lighting (abstract), light */ } from './lighting/LightingNode.js';
|
|
144
157
|
export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
|
|
145
158
|
export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { bitangentView } from './BitangentNode.js';
|
|
2
|
+
import { normalView } from './NormalNode.js';
|
|
3
|
+
import { tangentView } from './TangentNode.js';
|
|
4
|
+
import { mat3 } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { positionViewDirection } from './PositionNode.js';
|
|
6
|
+
|
|
7
|
+
export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
|
|
8
|
+
|
|
9
|
+
export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
|
|
10
|
+
export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
|
|
@@ -67,12 +67,14 @@ class BufferAttributeNode extends InputNode {
|
|
|
67
67
|
|
|
68
68
|
const nodeType = this.getNodeType( builder );
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
const propertyName = builder.getPropertyName(
|
|
70
|
+
const nodeAttribute = builder.getBufferAttributeFromNode( this, nodeType );
|
|
71
|
+
const propertyName = builder.getPropertyName( nodeAttribute );
|
|
72
72
|
|
|
73
73
|
let output = null;
|
|
74
74
|
|
|
75
|
-
if ( builder.shaderStage === 'vertex' ) {
|
|
75
|
+
if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) {
|
|
76
|
+
|
|
77
|
+
this.name = propertyName;
|
|
76
78
|
|
|
77
79
|
output = propertyName;
|
|
78
80
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Object3DNode from './Object3DNode.js';
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
|
-
import { label } from '../core/ContextNode.js';
|
|
4
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
5
4
|
//import { sharedUniformGroup } from '../core/UniformGroupNode.js';
|
|
6
5
|
import { nodeImmutable } from '../shadernode/ShaderNode.js';
|
|
@@ -23,7 +22,7 @@ class CameraNode extends Object3DNode {
|
|
|
23
22
|
|
|
24
23
|
const scope = this.scope;
|
|
25
24
|
|
|
26
|
-
if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
25
|
+
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
27
26
|
|
|
28
27
|
return 'mat4';
|
|
29
28
|
|
|
@@ -53,6 +52,10 @@ class CameraNode extends Object3DNode {
|
|
|
53
52
|
|
|
54
53
|
uniformNode.value = camera.projectionMatrix;
|
|
55
54
|
|
|
55
|
+
} else if ( scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
56
|
+
|
|
57
|
+
uniformNode.value = camera.projectionMatrixInverse;
|
|
58
|
+
|
|
56
59
|
} else if ( scope === CameraNode.NEAR ) {
|
|
57
60
|
|
|
58
61
|
uniformNode.value = camera.near;
|
|
@@ -79,7 +82,7 @@ class CameraNode extends Object3DNode {
|
|
|
79
82
|
|
|
80
83
|
const scope = this.scope;
|
|
81
84
|
|
|
82
|
-
if ( scope === CameraNode.PROJECTION_MATRIX ) {
|
|
85
|
+
if ( scope === CameraNode.PROJECTION_MATRIX || scope === CameraNode.PROJECTION_MATRIX_INVERSE ) {
|
|
83
86
|
|
|
84
87
|
this._uniformNode.nodeType = 'mat4';
|
|
85
88
|
|
|
@@ -96,13 +99,15 @@ class CameraNode extends Object3DNode {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
|
|
102
|
+
CameraNode.PROJECTION_MATRIX_INVERSE = 'projectionMatrixInverse';
|
|
99
103
|
CameraNode.NEAR = 'near';
|
|
100
104
|
CameraNode.FAR = 'far';
|
|
101
105
|
CameraNode.LOG_DEPTH = 'logDepth';
|
|
102
106
|
|
|
103
107
|
export default CameraNode;
|
|
104
108
|
|
|
105
|
-
export const cameraProjectionMatrix =
|
|
109
|
+
export const cameraProjectionMatrix = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX );
|
|
110
|
+
export const cameraProjectionMatrixInverse = nodeImmutable( CameraNode, CameraNode.PROJECTION_MATRIX_INVERSE );
|
|
106
111
|
export const cameraNear = nodeImmutable( CameraNode, CameraNode.NEAR );
|
|
107
112
|
export const cameraFar = nodeImmutable( CameraNode, CameraNode.FAR );
|
|
108
113
|
export const cameraLogDepth = nodeImmutable( CameraNode, CameraNode.LOG_DEPTH );
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
|
|
2
|
+
import Node from '../core/Node.js';
|
|
3
|
+
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { positionView } from './PositionNode.js';
|
|
5
|
+
import { diffuseColor, property } from '../core/PropertyNode.js';
|
|
6
|
+
import { tslFn } from '../shadernode/ShaderNode.js';
|
|
7
|
+
import { loop } from '../utils/LoopNode.js';
|
|
8
|
+
import { smoothstep } from '../math/MathNode.js';
|
|
9
|
+
import { uniforms } from './UniformsNode.js';
|
|
10
|
+
|
|
11
|
+
class ClippingNode extends Node {
|
|
12
|
+
|
|
13
|
+
constructor( scope = ClippingNode.DEFAULT ) {
|
|
14
|
+
|
|
15
|
+
super();
|
|
16
|
+
|
|
17
|
+
this.scope = scope;
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setup( builder ) {
|
|
22
|
+
|
|
23
|
+
super.setup( builder );
|
|
24
|
+
|
|
25
|
+
const clippingContext = builder.clippingContext;
|
|
26
|
+
const { localClipIntersection, localClippingCount, globalClippingCount } = clippingContext;
|
|
27
|
+
|
|
28
|
+
const numClippingPlanes = globalClippingCount + localClippingCount;
|
|
29
|
+
const numUnionClippingPlanes = localClipIntersection ? numClippingPlanes - localClippingCount : numClippingPlanes;
|
|
30
|
+
|
|
31
|
+
if ( this.scope === ClippingNode.ALPHA_TO_COVERAGE ) {
|
|
32
|
+
|
|
33
|
+
return this.setupAlphaToCoverage( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
|
|
34
|
+
|
|
35
|
+
} else {
|
|
36
|
+
|
|
37
|
+
return this.setupDefault( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
|
|
44
|
+
|
|
45
|
+
return tslFn( () => {
|
|
46
|
+
|
|
47
|
+
const clippingPlanes = uniforms( planes );
|
|
48
|
+
|
|
49
|
+
const distanceToPlane = property( 'float', 'distanceToPlane' );
|
|
50
|
+
const distanceGradient = property( 'float', 'distanceToGradient' );
|
|
51
|
+
|
|
52
|
+
const clipOpacity = property( 'float', 'clipOpacity' );
|
|
53
|
+
|
|
54
|
+
clipOpacity.assign( 1 );
|
|
55
|
+
|
|
56
|
+
let plane;
|
|
57
|
+
|
|
58
|
+
loop( numUnionClippingPlanes, ( { i } ) => {
|
|
59
|
+
|
|
60
|
+
plane = clippingPlanes.element( i );
|
|
61
|
+
|
|
62
|
+
distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
|
|
63
|
+
distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
|
|
64
|
+
|
|
65
|
+
clipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ) );
|
|
66
|
+
|
|
67
|
+
clipOpacity.equal( 0.0 ).discard();
|
|
68
|
+
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
if ( numUnionClippingPlanes < numClippingPlanes ) {
|
|
72
|
+
|
|
73
|
+
const unionClipOpacity = property( 'float', 'unionclipOpacity' );
|
|
74
|
+
|
|
75
|
+
unionClipOpacity.assign( 1 );
|
|
76
|
+
|
|
77
|
+
loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
|
|
78
|
+
|
|
79
|
+
plane = clippingPlanes.element( i );
|
|
80
|
+
|
|
81
|
+
distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
|
|
82
|
+
distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
|
|
83
|
+
|
|
84
|
+
unionClipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ).oneMinus() );
|
|
85
|
+
|
|
86
|
+
} );
|
|
87
|
+
|
|
88
|
+
clipOpacity.mulAssign( unionClipOpacity.oneMinus() );
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
diffuseColor.a.mulAssign( clipOpacity );
|
|
93
|
+
|
|
94
|
+
diffuseColor.a.equal( 0.0 ).discard();
|
|
95
|
+
|
|
96
|
+
} )();
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
|
|
101
|
+
|
|
102
|
+
return tslFn( () => {
|
|
103
|
+
|
|
104
|
+
const clippingPlanes = uniforms( planes );
|
|
105
|
+
|
|
106
|
+
let plane;
|
|
107
|
+
|
|
108
|
+
loop( numUnionClippingPlanes, ( { i } ) => {
|
|
109
|
+
|
|
110
|
+
plane = clippingPlanes.element( i );
|
|
111
|
+
positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
|
|
112
|
+
|
|
113
|
+
} );
|
|
114
|
+
|
|
115
|
+
if ( numUnionClippingPlanes < numClippingPlanes ) {
|
|
116
|
+
|
|
117
|
+
const clipped = property( 'bool', 'clipped' );
|
|
118
|
+
|
|
119
|
+
clipped.assign( true );
|
|
120
|
+
|
|
121
|
+
loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
|
|
122
|
+
|
|
123
|
+
plane = clippingPlanes.element( i );
|
|
124
|
+
clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
|
|
125
|
+
|
|
126
|
+
} );
|
|
127
|
+
|
|
128
|
+
clipped.discard();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
} )();
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ClippingNode.ALPHA_TO_COVERAGE = 'alphaToCoverage';
|
|
138
|
+
ClippingNode.DEFAULT = 'default';
|
|
139
|
+
|
|
140
|
+
export default ClippingNode;
|
|
141
|
+
|
|
142
|
+
export const clipping = () => nodeObject( new ClippingNode() );
|
|
143
|
+
|
|
144
|
+
export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );
|
|
@@ -2,6 +2,7 @@ import TextureNode from './TextureNode.js';
|
|
|
2
2
|
import { reflectVector } from './ReflectVectorNode.js';
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
4
|
import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { WebGPUCoordinateSystem } from 'three';
|
|
5
6
|
|
|
6
7
|
class CubeTextureNode extends TextureNode {
|
|
7
8
|
|
|
@@ -29,7 +30,17 @@ class CubeTextureNode extends TextureNode {
|
|
|
29
30
|
|
|
30
31
|
setupUV( builder, uvNode ) {
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const texture = this.value;
|
|
34
|
+
|
|
35
|
+
if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem || ! texture.isRenderTargetTexture ) {
|
|
36
|
+
|
|
37
|
+
return vec3( uvNode.x.negate(), uvNode.yz );
|
|
38
|
+
|
|
39
|
+
} else {
|
|
40
|
+
|
|
41
|
+
return uvNode;
|
|
42
|
+
|
|
43
|
+
}
|
|
33
44
|
|
|
34
45
|
}
|
|
35
46
|
|
|
@@ -227,11 +227,11 @@ class MaterialNode extends Node {
|
|
|
227
227
|
|
|
228
228
|
} else if ( scope === MaterialNode.IRIDESCENCE_THICKNESS ) {
|
|
229
229
|
|
|
230
|
-
const iridescenceThicknessMaximum = reference( 1, 'float', material.iridescenceThicknessRange );
|
|
230
|
+
const iridescenceThicknessMaximum = reference( '1', 'float', material.iridescenceThicknessRange );
|
|
231
231
|
|
|
232
232
|
if ( material.iridescenceThicknessMap ) {
|
|
233
233
|
|
|
234
|
-
const iridescenceThicknessMinimum = reference( 0, 'float', material.iridescenceThicknessRange );
|
|
234
|
+
const iridescenceThicknessMinimum = reference( '0', 'float', material.iridescenceThicknessRange );
|
|
235
235
|
|
|
236
236
|
node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
|
|
237
237
|
|
|
@@ -24,24 +24,14 @@ class MaterialReferenceNode extends ReferenceNode {
|
|
|
24
24
|
|
|
25
25
|
}*/
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
setReference( state ) {
|
|
28
28
|
|
|
29
|
-
this.reference = this.material !== null ? this.material :
|
|
29
|
+
this.reference = this.material !== null ? this.material : state.material;
|
|
30
30
|
|
|
31
31
|
return this.reference;
|
|
32
32
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
setup( builder ) {
|
|
36
|
-
|
|
37
|
-
const material = this.material !== null ? this.material : builder.material;
|
|
38
|
-
|
|
39
|
-
this.node.value = material[ this.property ];
|
|
40
|
-
|
|
41
|
-
return super.setup( builder );
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
35
|
}
|
|
46
36
|
|
|
47
37
|
export default MaterialReferenceNode;
|
|
@@ -2,13 +2,14 @@ import Node, { addNodeClass } from '../core/Node.js';
|
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
3
|
import { nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
|
|
4
4
|
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import {
|
|
5
|
+
import { reference } from './ReferenceNode.js';
|
|
6
6
|
import { positionLocal } from './PositionNode.js';
|
|
7
7
|
import { normalLocal } from './NormalNode.js';
|
|
8
8
|
import { textureLoad } from './TextureNode.js';
|
|
9
9
|
import { vertexIndex } from '../core/IndexNode.js';
|
|
10
10
|
import { ivec2, int } from '../shadernode/ShaderNode.js';
|
|
11
11
|
import { DataArrayTexture, Vector2, Vector4, FloatType } from 'three';
|
|
12
|
+
import { loop } from '../utils/LoopNode.js';
|
|
12
13
|
|
|
13
14
|
const morphTextures = new WeakMap();
|
|
14
15
|
const morphVec4 = new Vector4();
|
|
@@ -185,10 +186,9 @@ class MorphNode extends Node {
|
|
|
185
186
|
|
|
186
187
|
const width = int( size.width );
|
|
187
188
|
|
|
188
|
-
|
|
189
|
+
loop( morphTargetsCount, ( { i } ) => {
|
|
189
190
|
|
|
190
|
-
const influence =
|
|
191
|
-
const depth = int( i );
|
|
191
|
+
const influence = reference( 'morphTargetInfluences', 'float' ).element( i );
|
|
192
192
|
|
|
193
193
|
if ( hasMorphPosition === true ) {
|
|
194
194
|
|
|
@@ -197,7 +197,7 @@ class MorphNode extends Node {
|
|
|
197
197
|
influence,
|
|
198
198
|
stride,
|
|
199
199
|
width,
|
|
200
|
-
depth,
|
|
200
|
+
depth: i,
|
|
201
201
|
offset: int( 0 )
|
|
202
202
|
} ) );
|
|
203
203
|
|
|
@@ -210,13 +210,13 @@ class MorphNode extends Node {
|
|
|
210
210
|
influence,
|
|
211
211
|
stride,
|
|
212
212
|
width,
|
|
213
|
-
depth,
|
|
213
|
+
depth: i,
|
|
214
214
|
offset: int( 1 )
|
|
215
215
|
} ) );
|
|
216
216
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
}
|
|
219
|
+
} );
|
|
220
220
|
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -240,6 +240,6 @@ class MorphNode extends Node {
|
|
|
240
240
|
|
|
241
241
|
export default MorphNode;
|
|
242
242
|
|
|
243
|
-
export const
|
|
243
|
+
export const morphReference = nodeProxy( MorphNode );
|
|
244
244
|
|
|
245
245
|
addNodeClass( 'MorphNode', MorphNode );
|
|
@@ -2,49 +2,63 @@ import Node, { addNodeClass } from '../core/Node.js';
|
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { texture } from './TextureNode.js';
|
|
5
|
+
import { buffer } from './BufferNode.js';
|
|
5
6
|
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
7
|
+
import { uniforms } from './UniformsNode.js';
|
|
8
|
+
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
6
9
|
|
|
7
|
-
class
|
|
10
|
+
class ReferenceElementNode extends ArrayElementNode {
|
|
8
11
|
|
|
9
|
-
constructor(
|
|
12
|
+
constructor( referenceNode, indexNode ) {
|
|
10
13
|
|
|
11
|
-
super();
|
|
14
|
+
super( referenceNode, indexNode );
|
|
12
15
|
|
|
13
|
-
this.
|
|
14
|
-
this.index = null;
|
|
16
|
+
this.referenceNode = referenceNode;
|
|
15
17
|
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
this.object = object;
|
|
19
|
-
this.reference = null;
|
|
18
|
+
this.isReferenceElementNode = true;
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
}
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
getNodeType() {
|
|
24
23
|
|
|
25
|
-
this.
|
|
24
|
+
return this.referenceNode.uniformType;
|
|
26
25
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
generate( builder ) {
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
const snippet = super.generate( builder );
|
|
31
|
+
const arrayType = this.referenceNode.getNodeType();
|
|
32
|
+
const elementType = this.getNodeType();
|
|
32
33
|
|
|
33
|
-
return
|
|
34
|
+
return builder.format( snippet, arrayType, elementType );
|
|
34
35
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
class ReferenceNode extends Node {
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
constructor( property, uniformType, object = null, count = null ) {
|
|
43
|
+
|
|
44
|
+
super();
|
|
45
|
+
|
|
46
|
+
this.property = property;
|
|
47
|
+
this.uniformType = uniformType;
|
|
48
|
+
this.object = object;
|
|
49
|
+
this.count = count;
|
|
50
|
+
|
|
51
|
+
this.properties = property.split( '.' );
|
|
52
|
+
this.reference = null;
|
|
53
|
+
this.node = null;
|
|
54
|
+
|
|
55
|
+
this.updateType = NodeUpdateType.OBJECT;
|
|
42
56
|
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
|
|
59
|
+
element( indexNode ) {
|
|
46
60
|
|
|
47
|
-
return this
|
|
61
|
+
return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
|
|
48
62
|
|
|
49
63
|
}
|
|
50
64
|
|
|
@@ -52,13 +66,21 @@ class ReferenceNode extends Node {
|
|
|
52
66
|
|
|
53
67
|
let node = null;
|
|
54
68
|
|
|
55
|
-
if (
|
|
69
|
+
if ( this.count !== null ) {
|
|
70
|
+
|
|
71
|
+
node = buffer( null, uniformType, this.count );
|
|
72
|
+
|
|
73
|
+
} else if ( Array.isArray( this.getValueFromReference() ) ) {
|
|
74
|
+
|
|
75
|
+
node = uniforms( null, uniformType );
|
|
76
|
+
|
|
77
|
+
} else if ( uniformType === 'texture' ) {
|
|
56
78
|
|
|
57
79
|
node = texture( null );
|
|
58
80
|
|
|
59
81
|
} else {
|
|
60
82
|
|
|
61
|
-
node = uniform( uniformType );
|
|
83
|
+
node = uniform( null, uniformType );
|
|
62
84
|
|
|
63
85
|
}
|
|
64
86
|
|
|
@@ -72,31 +94,67 @@ class ReferenceNode extends Node {
|
|
|
72
94
|
|
|
73
95
|
}
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
getValueFromReference( object = this.reference ) {
|
|
76
98
|
|
|
77
|
-
|
|
99
|
+
const { properties } = this;
|
|
78
100
|
|
|
79
|
-
|
|
101
|
+
let value = object[ properties[ 0 ] ];
|
|
80
102
|
|
|
81
|
-
|
|
103
|
+
for ( let i = 1; i < properties.length; i ++ ) {
|
|
104
|
+
|
|
105
|
+
value = value[ properties[ i ] ];
|
|
82
106
|
|
|
83
107
|
}
|
|
84
108
|
|
|
85
|
-
|
|
109
|
+
return value;
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setReference( state ) {
|
|
114
|
+
|
|
115
|
+
this.reference = this.object !== null ? this.object : state.object;
|
|
116
|
+
|
|
117
|
+
return this.reference;
|
|
86
118
|
|
|
87
119
|
}
|
|
88
120
|
|
|
89
|
-
setup(
|
|
121
|
+
setup() {
|
|
122
|
+
|
|
123
|
+
this.updateValue();
|
|
90
124
|
|
|
91
125
|
return this.node;
|
|
92
126
|
|
|
93
127
|
}
|
|
94
128
|
|
|
129
|
+
update( /*frame*/ ) {
|
|
130
|
+
|
|
131
|
+
this.updateValue();
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
updateValue() {
|
|
136
|
+
|
|
137
|
+
if ( this.node === null ) this.setNodeType( this.uniformType );
|
|
138
|
+
|
|
139
|
+
const value = this.getValueFromReference();
|
|
140
|
+
|
|
141
|
+
if ( Array.isArray( value ) ) {
|
|
142
|
+
|
|
143
|
+
this.node.array = value;
|
|
144
|
+
|
|
145
|
+
} else {
|
|
146
|
+
|
|
147
|
+
this.node.value = value;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
95
153
|
}
|
|
96
154
|
|
|
97
155
|
export default ReferenceNode;
|
|
98
156
|
|
|
99
157
|
export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
|
|
100
|
-
export const
|
|
158
|
+
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) );
|
|
101
159
|
|
|
102
160
|
addNodeClass( 'ReferenceNode', ReferenceNode );
|