super-three 0.133.5 → 0.135.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.js +617 -536
- package/build/three.min.js +1 -1
- package/build/three.module.js +760 -613
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +9 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
- package/examples/js/controls/ArcballControls.js +68 -27
- package/examples/js/controls/DragControls.js +7 -0
- package/examples/js/controls/OrbitControls.js +5 -36
- package/examples/js/controls/TrackballControls.js +3 -2
- package/examples/js/csm/CSM.js +2 -2
- package/examples/js/csm/CSMFrustum.js +133 -0
- package/examples/js/exporters/GLTFExporter.js +147 -63
- package/examples/js/exporters/USDZExporter.js +45 -26
- package/examples/js/lines/LineMaterial.js +58 -20
- package/examples/js/lines/LineSegments2.js +29 -24
- package/examples/js/loaders/3DMLoader.js +24 -11
- package/examples/js/loaders/3MFLoader.js +2 -2
- package/examples/js/loaders/ColladaLoader.js +61 -3
- package/examples/js/loaders/FBXLoader.js +1 -1
- package/examples/js/loaders/GLTFLoader.js +94 -31
- package/examples/js/loaders/KTX2Loader.js +12 -0
- package/examples/js/loaders/LWOLoader.js +8 -6
- package/examples/js/loaders/LogLuvLoader.js +766 -0
- package/examples/js/loaders/PLYLoader.js +32 -7
- package/examples/js/loaders/RGBELoader.js +2 -1
- package/examples/js/loaders/SVGLoader.js +7 -3
- package/examples/js/loaders/TDSLoader.js +237 -271
- package/examples/js/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/js/loaders/lwo/LWO3Parser.js +4 -2
- package/examples/js/objects/MarchingCubes.js +42 -128
- package/examples/js/renderers/CSS2DRenderer.js +4 -4
- package/examples/js/renderers/CSS3DRenderer.js +4 -4
- package/examples/js/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/controls/ArcballControls.js +61 -29
- package/examples/jsm/controls/DragControls.js +7 -0
- package/examples/jsm/controls/OrbitControls.js +9 -51
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/csm/CSM.js +3 -3
- package/examples/jsm/csm/{Frustum.js → CSMFrustum.js} +3 -3
- package/examples/jsm/exporters/GLTFExporter.js +160 -74
- package/examples/jsm/exporters/USDZExporter.js +47 -26
- package/examples/jsm/libs/flow.module.js +3218 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lines/LineMaterial.js +59 -23
- package/examples/jsm/lines/LineSegments2.js +22 -18
- package/examples/jsm/loaders/3DMLoader.js +18 -12
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +61 -3
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +99 -35
- package/examples/jsm/loaders/KTX2Loader.js +19 -0
- package/examples/jsm/loaders/LWOLoader.js +8 -6
- package/examples/jsm/loaders/LogLuvLoader.js +606 -0
- package/examples/jsm/loaders/PLYLoader.js +33 -7
- package/examples/jsm/loaders/SVGLoader.js +7 -4
- package/examples/jsm/loaders/TDSLoader.js +225 -285
- package/examples/jsm/loaders/lwo/LWO2Parser.js +1 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +2 -2
- package/examples/jsm/node-editor/NodeEditor.js +455 -0
- package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/UVEditor.js +26 -0
- package/examples/jsm/node-editor/display/BlendEditor.js +43 -0
- package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
- package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
- package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
- package/examples/jsm/node-editor/examples/rim.json +1 -0
- package/examples/jsm/node-editor/inputs/ColorEditor.js +91 -0
- package/examples/jsm/node-editor/inputs/FloatEditor.js +24 -0
- package/examples/jsm/node-editor/inputs/SliderEditor.js +68 -0
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +69 -0
- package/examples/jsm/node-editor/math/DotEditor.js +36 -0
- package/examples/jsm/node-editor/math/InvertEditor.js +38 -0
- package/examples/jsm/node-editor/math/LimiterEditor.js +48 -0
- package/examples/jsm/node-editor/math/NormalizeEditor.js +26 -0
- package/examples/jsm/node-editor/math/OperatorEditor.js +50 -0
- package/examples/jsm/node-editor/math/PowerEditor.js +34 -0
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +39 -0
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +26 -0
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +42 -0
- package/examples/jsm/node-editor/utils/TimerEditor.js +57 -0
- package/examples/jsm/nodes/materials/StandardNodeMaterial.js +1 -1
- package/examples/jsm/nodes/materials/nodes/StandardNode.js +6 -6
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -49
- package/examples/jsm/objects/MarchingCubes.js +46 -152
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +1 -1
- package/examples/jsm/postprocessing/BloomPass.js +1 -1
- package/examples/jsm/postprocessing/BokehPass.js +1 -1
- package/examples/jsm/postprocessing/ClearPass.js +1 -1
- package/examples/jsm/postprocessing/CubeTexturePass.js +1 -1
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -1
- package/examples/jsm/postprocessing/EffectComposer.js +3 -3
- package/examples/jsm/postprocessing/FilmPass.js +1 -1
- package/examples/jsm/postprocessing/GlitchPass.js +1 -1
- package/examples/jsm/postprocessing/HalftonePass.js +1 -1
- package/examples/jsm/postprocessing/MaskPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SMAAPass.js +1 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +1 -1
- package/examples/jsm/postprocessing/SSRrPass.js +1 -1
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/ShaderPass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/TexturePass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +1 -1
- package/examples/jsm/renderers/CSS2DRenderer.js +5 -4
- package/examples/jsm/renderers/CSS3DRenderer.js +5 -4
- package/examples/jsm/renderers/nodes/Nodes.js +14 -13
- package/examples/jsm/renderers/nodes/ShaderNode.js +193 -41
- package/examples/jsm/renderers/nodes/accessors/MaterialNode.js +6 -6
- package/examples/jsm/renderers/nodes/accessors/ModelViewProjectionNode.js +5 -5
- package/examples/jsm/renderers/nodes/accessors/NormalNode.js +14 -3
- package/examples/jsm/renderers/nodes/accessors/PointUVNode.js +3 -3
- package/examples/jsm/renderers/nodes/accessors/PositionNode.js +15 -5
- package/examples/jsm/renderers/nodes/accessors/SkinningNode.js +107 -0
- package/examples/jsm/renderers/nodes/accessors/UVNode.js +7 -5
- package/examples/jsm/renderers/nodes/core/ArrayInputNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/AttributeNode.js +6 -0
- package/examples/jsm/renderers/nodes/core/BypassNode.js +38 -0
- package/examples/jsm/renderers/nodes/core/CodeNode.js +3 -3
- package/examples/jsm/renderers/nodes/core/ContextNode.js +4 -19
- package/examples/jsm/renderers/nodes/core/ExpressionNode.js +13 -2
- package/examples/jsm/renderers/nodes/core/FunctionNode.js +19 -132
- package/examples/jsm/renderers/nodes/core/InputNode.js +13 -3
- package/examples/jsm/renderers/nodes/core/Node.js +32 -10
- package/examples/jsm/renderers/nodes/core/NodeBuilder.js +146 -128
- package/examples/jsm/renderers/nodes/core/NodeFunction.js +22 -0
- package/examples/jsm/renderers/nodes/core/NodeFunctionInput.js +4 -4
- package/examples/jsm/renderers/nodes/core/NodeKeywords.js +18 -179
- package/examples/jsm/renderers/nodes/core/NodeParser.js +11 -0
- package/examples/jsm/renderers/nodes/core/NodeVar.js +2 -2
- package/examples/jsm/renderers/nodes/core/PropertyNode.js +14 -2
- package/examples/jsm/renderers/nodes/core/TempNode.js +10 -13
- package/examples/jsm/renderers/nodes/core/VarNode.js +12 -7
- package/examples/jsm/renderers/nodes/core/VaryNode.js +23 -8
- package/examples/jsm/renderers/nodes/core/constants.js +2 -0
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +47 -25
- package/examples/jsm/renderers/nodes/display/NormalMapNode.js +21 -22
- package/examples/jsm/renderers/nodes/functions/BSDFs.js +64 -101
- package/examples/jsm/renderers/nodes/inputs/BufferNode.js +25 -0
- package/examples/jsm/renderers/nodes/inputs/IntNode.js +17 -0
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +10 -2
- package/examples/jsm/renderers/nodes/lights/LightContextNode.js +20 -14
- package/examples/jsm/renderers/nodes/lights/LightNode.js +32 -36
- package/examples/jsm/renderers/nodes/math/CondNode.js +60 -0
- package/examples/jsm/renderers/nodes/math/MathNode.js +87 -36
- package/examples/jsm/renderers/nodes/math/OperatorNode.js +124 -31
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeFunction.js +137 -0
- package/examples/jsm/renderers/nodes/parsers/GLSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeFunction.js +89 -0
- package/examples/jsm/renderers/nodes/parsers/WGSLNodeParser.js +14 -0
- package/examples/jsm/renderers/nodes/procedural/CheckerNode.js +7 -9
- package/examples/jsm/renderers/nodes/utils/ArrayElementNode.js +31 -0
- package/examples/jsm/renderers/nodes/utils/ConvertNode.js +33 -0
- package/examples/jsm/renderers/nodes/utils/JoinNode.js +7 -7
- package/examples/jsm/renderers/nodes/utils/OscNode.js +58 -0
- package/examples/jsm/renderers/nodes/utils/SplitNode.js +18 -8
- package/examples/jsm/renderers/nodes/utils/SpriteSheetUVNode.js +7 -7
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +22 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +191 -94
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +2 -2
- package/examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +3 -3
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +2 -4
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +15 -23
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +11 -27
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +62 -28
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +34 -27
- package/examples/jsm/renderers/webgpu/constants.js +2 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +430 -98
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +1 -1
- package/examples/jsm/utils/RoughnessMipmapper.js +1 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +6 -6
- package/package.json +10 -10
- package/src/Three.Legacy.js +6 -0
- package/src/Three.js +0 -1
- package/src/cameras/StereoCamera.js +8 -7
- package/src/constants.js +1 -2
- package/src/core/Layers.js +7 -1
- package/src/core/Object3D.js +2 -0
- package/src/extras/PMREMGenerator.js +11 -6
- package/src/loaders/FileLoader.js +89 -152
- package/src/loaders/ImageLoader.js +9 -4
- package/src/loaders/LoaderUtils.js +26 -0
- package/src/loaders/MaterialLoader.js +7 -4
- package/src/loaders/ObjectLoader.js +2 -0
- package/src/materials/Material.js +4 -4
- package/src/materials/MeshPhysicalMaterial.js +20 -14
- package/src/math/MathUtils.js +5 -16
- package/src/renderers/WebGLMultisampleRenderTarget.js +7 -1
- package/src/renderers/WebGLRenderer.js +83 -117
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -27
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +19 -6
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +13 -5
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib.js +6 -4
- package/src/renderers/shaders/UniformsLib.js +1 -2
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLMaterials.js +27 -15
- package/src/renderers/webgl/WebGLProgram.js +10 -6
- package/src/renderers/webgl/WebGLPrograms.js +17 -12
- package/src/renderers/webgl/WebGLShadowMap.js +14 -5
- package/src/renderers/webgl/WebGLState.js +31 -17
- package/src/renderers/webgl/WebGLTextures.js +188 -51
- package/src/renderers/webgl/WebGLUniforms.js +45 -1
- package/src/renderers/webxr/WebXRManager.js +68 -107
- package/src/textures/Texture.js +6 -0
- package/src/utils.js +37 -1
- package/examples/js/controls/DeviceOrientationControls.js +0 -147
- package/examples/js/libs/dat.gui.min.js +0 -14
- package/examples/jsm/controls/DeviceOrientationControls.js +0 -153
- package/examples/jsm/libs/dat.gui.module.js +0 -3575
- package/examples/jsm/libs/glslang.js +0 -78
- package/examples/jsm/libs/glslang.wasm +0 -0
- package/examples/jsm/renderers/nodes/consts/MathConsts.js +0 -7
- package/examples/jsm/renderers/nodes/core/ConstNode.js +0 -39
- package/examples/jsm/renderers/nodes/core/NodeSlot.js +0 -13
- package/examples/jsm/renderers/nodes/core/StructNode.js +0 -80
- package/examples/jsm/renderers/nodes/core/StructVarNode.js +0 -75
- package/examples/jsm/renderers/nodes/functions/EncodingFunctions.js +0 -99
- package/examples/jsm/renderers/nodes/functions/MathFunctions.js +0 -47
- package/examples/jsm/renderers/webgpu/nodes/ShaderLib.js +0 -152
- package/src/extras/objects/ImmediateRenderObject.js +0 -31
|
@@ -5,10 +5,10 @@ import ModelNode from '../accessors/ModelNode.js';
|
|
|
5
5
|
import CameraNode from '../accessors/CameraNode.js';
|
|
6
6
|
import OperatorNode from '../math/OperatorNode.js';
|
|
7
7
|
import MathNode from '../math/MathNode.js';
|
|
8
|
-
import { inverseTransformDirection } from '../functions/MathFunctions.js';
|
|
9
8
|
|
|
10
9
|
class NormalNode extends Node {
|
|
11
10
|
|
|
11
|
+
static GEOMETRY = 'geometry';
|
|
12
12
|
static LOCAL = 'local';
|
|
13
13
|
static WORLD = 'world';
|
|
14
14
|
static VIEW = 'view';
|
|
@@ -21,16 +21,26 @@ class NormalNode extends Node {
|
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
getHash( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return `normal-${this.scope}`;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
generate( builder ) {
|
|
25
31
|
|
|
26
32
|
const scope = this.scope;
|
|
27
33
|
|
|
28
34
|
let outputNode = null;
|
|
29
35
|
|
|
30
|
-
if ( scope === NormalNode.
|
|
36
|
+
if ( scope === NormalNode.GEOMETRY ) {
|
|
31
37
|
|
|
32
38
|
outputNode = new AttributeNode( 'normal', 'vec3' );
|
|
33
39
|
|
|
40
|
+
} else if ( scope === NormalNode.LOCAL ) {
|
|
41
|
+
|
|
42
|
+
outputNode = new VaryNode( new NormalNode( NormalNode.GEOMETRY ) );
|
|
43
|
+
|
|
34
44
|
} else if ( scope === NormalNode.VIEW ) {
|
|
35
45
|
|
|
36
46
|
const vertexNormalNode = new OperatorNode( '*', new ModelNode( ModelNode.NORMAL_MATRIX ), new NormalNode( NormalNode.LOCAL ) );
|
|
@@ -38,7 +48,8 @@ class NormalNode extends Node {
|
|
|
38
48
|
|
|
39
49
|
} else if ( scope === NormalNode.WORLD ) {
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
// To use INVERSE_TRANSFORM_DIRECTION only inverse the param order like this: MathNode( ..., Vector, Matrix );
|
|
52
|
+
const vertexNormalNode = new MathNode( MathNode.TRANSFORM_DIRECTION, new NormalNode( NormalNode.VIEW ), new CameraNode( CameraNode.VIEW_MATRIX ) );
|
|
42
53
|
outputNode = new MathNode( MathNode.NORMALIZE, new VaryNode( vertexNormalNode ) );
|
|
43
54
|
|
|
44
55
|
}
|
|
@@ -6,11 +6,9 @@ class PointUVNode extends Node {
|
|
|
6
6
|
|
|
7
7
|
super( 'vec2' );
|
|
8
8
|
|
|
9
|
-
Object.defineProperty( this, 'isPointUVNode', { value: true } );
|
|
10
|
-
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
generate( builder ) {
|
|
11
|
+
generate( /*builder*/ ) {
|
|
14
12
|
|
|
15
13
|
return 'vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )';
|
|
16
14
|
|
|
@@ -18,4 +16,6 @@ class PointUVNode extends Node {
|
|
|
18
16
|
|
|
19
17
|
}
|
|
20
18
|
|
|
19
|
+
PointUVNode.prototype.isPointUVNode = true;
|
|
20
|
+
|
|
21
21
|
export default PointUVNode;
|
|
@@ -4,10 +4,10 @@ import VaryNode from '../core/VaryNode.js';
|
|
|
4
4
|
import ModelNode from '../accessors/ModelNode.js';
|
|
5
5
|
import MathNode from '../math/MathNode.js';
|
|
6
6
|
import OperatorNode from '../math/OperatorNode.js';
|
|
7
|
-
import { transformDirection } from '../functions/MathFunctions.js';
|
|
8
7
|
|
|
9
8
|
class PositionNode extends Node {
|
|
10
9
|
|
|
10
|
+
static GEOMETRY = 'geometry';
|
|
11
11
|
static LOCAL = 'local';
|
|
12
12
|
static WORLD = 'world';
|
|
13
13
|
static VIEW = 'view';
|
|
@@ -21,19 +21,29 @@ class PositionNode extends Node {
|
|
|
21
21
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
getHash( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return `position-${this.scope}`;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
generate( builder ) {
|
|
25
31
|
|
|
26
32
|
const scope = this.scope;
|
|
27
33
|
|
|
28
34
|
let outputNode = null;
|
|
29
35
|
|
|
30
|
-
if ( scope === PositionNode.
|
|
31
|
-
|
|
36
|
+
if ( scope === PositionNode.GEOMETRY ) {
|
|
37
|
+
|
|
32
38
|
outputNode = new AttributeNode( 'position', 'vec3' );
|
|
33
|
-
|
|
39
|
+
|
|
40
|
+
} else if ( scope === PositionNode.LOCAL ) {
|
|
41
|
+
|
|
42
|
+
outputNode = new VaryNode( new PositionNode( PositionNode.GEOMETRY ) );
|
|
43
|
+
|
|
34
44
|
} else if ( scope === PositionNode.WORLD ) {
|
|
35
45
|
|
|
36
|
-
const vertexPositionNode =
|
|
46
|
+
const vertexPositionNode = new MathNode( MathNode.TRANSFORM_DIRECTION, new ModelNode( ModelNode.WORLD_MATRIX ), new PositionNode( PositionNode.LOCAL ) );
|
|
37
47
|
outputNode = new VaryNode( vertexPositionNode );
|
|
38
48
|
|
|
39
49
|
} else if ( scope === PositionNode.VIEW ) {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import AttributeNode from '../core/AttributeNode.js';
|
|
3
|
+
import PositionNode from '../accessors/PositionNode.js';
|
|
4
|
+
import NormalNode from '../accessors/NormalNode.js';
|
|
5
|
+
import Matrix4Node from '../inputs/Matrix4Node.js';
|
|
6
|
+
import BufferNode from '../inputs/BufferNode.js';
|
|
7
|
+
|
|
8
|
+
import { ShaderNode, assign, element, add, mul, transformDirection } from '../ShaderNode.js';
|
|
9
|
+
|
|
10
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
11
|
+
|
|
12
|
+
const Skinning = new ShaderNode( ( inputs, builder ) => {
|
|
13
|
+
|
|
14
|
+
const { position, normal, index, weight, bindMatrix, bindMatrixInverse, boneMatrices } = inputs;
|
|
15
|
+
|
|
16
|
+
const boneMatX = element( boneMatrices, index.x );
|
|
17
|
+
const boneMatY = element( boneMatrices, index.y );
|
|
18
|
+
const boneMatZ = element( boneMatrices, index.z );
|
|
19
|
+
const boneMatW = element( boneMatrices, index.w );
|
|
20
|
+
|
|
21
|
+
// POSITION
|
|
22
|
+
|
|
23
|
+
const skinVertex = mul( bindMatrix, position );
|
|
24
|
+
|
|
25
|
+
const skinned = add(
|
|
26
|
+
mul( mul( boneMatX, skinVertex ), weight.x ),
|
|
27
|
+
mul( mul( boneMatY, skinVertex ), weight.y ),
|
|
28
|
+
mul( mul( boneMatZ, skinVertex ), weight.z ),
|
|
29
|
+
mul( mul( boneMatW, skinVertex ), weight.w )
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const skinPosition = mul( bindMatrixInverse, skinned ).xyz;
|
|
33
|
+
|
|
34
|
+
// NORMAL
|
|
35
|
+
|
|
36
|
+
let skinMatrix = add(
|
|
37
|
+
mul( weight.x, boneMatX ),
|
|
38
|
+
mul( weight.y, boneMatY ),
|
|
39
|
+
mul( weight.z, boneMatZ ),
|
|
40
|
+
mul( weight.w, boneMatW )
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
skinMatrix = mul( mul( bindMatrixInverse, skinMatrix ), bindMatrix );
|
|
44
|
+
|
|
45
|
+
const skinNormal = transformDirection( skinMatrix, normal ).xyz;
|
|
46
|
+
|
|
47
|
+
// ASSIGNS
|
|
48
|
+
|
|
49
|
+
assign( position, skinPosition ).build( builder );
|
|
50
|
+
assign( normal, skinNormal ).build( builder );
|
|
51
|
+
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
class SkinningNode extends Node {
|
|
55
|
+
|
|
56
|
+
constructor( skinnedMesh ) {
|
|
57
|
+
|
|
58
|
+
super( 'void' );
|
|
59
|
+
|
|
60
|
+
this.skinnedMesh = skinnedMesh;
|
|
61
|
+
|
|
62
|
+
this.updateType = NodeUpdateType.Object;
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
|
|
66
|
+
this.skinIndexNode = new AttributeNode( 'skinIndex', 'uvec4' );
|
|
67
|
+
this.skinWeightNode = new AttributeNode( 'skinWeight', 'vec4' );
|
|
68
|
+
|
|
69
|
+
this.bindMatrixNode = new Matrix4Node( skinnedMesh.bindMatrix );
|
|
70
|
+
this.bindMatrixInverseNode = new Matrix4Node( skinnedMesh.bindMatrixInverse );
|
|
71
|
+
this.boneMatricesNode = new BufferNode( skinnedMesh.skeleton.boneMatrices, 'mat4', skinnedMesh.skeleton.bones.length );
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
generate( builder ) {
|
|
76
|
+
|
|
77
|
+
// inout nodes
|
|
78
|
+
const position = new PositionNode( PositionNode.LOCAL );
|
|
79
|
+
const normal = new NormalNode( NormalNode.LOCAL );
|
|
80
|
+
|
|
81
|
+
const index = this.skinIndexNode;
|
|
82
|
+
const weight = this.skinWeightNode;
|
|
83
|
+
const bindMatrix = this.bindMatrixNode;
|
|
84
|
+
const bindMatrixInverse = this.bindMatrixInverseNode;
|
|
85
|
+
const boneMatrices = this.boneMatricesNode;
|
|
86
|
+
|
|
87
|
+
Skinning( {
|
|
88
|
+
position,
|
|
89
|
+
normal,
|
|
90
|
+
index,
|
|
91
|
+
weight,
|
|
92
|
+
bindMatrix,
|
|
93
|
+
bindMatrixInverse,
|
|
94
|
+
boneMatrices
|
|
95
|
+
}, builder );
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
update() {
|
|
100
|
+
|
|
101
|
+
this.skinnedMesh.skeleton.update();
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default SkinningNode;
|
|
@@ -2,22 +2,24 @@ import AttributeNode from '../core/AttributeNode.js';
|
|
|
2
2
|
|
|
3
3
|
class UVNode extends AttributeNode {
|
|
4
4
|
|
|
5
|
-
constructor(
|
|
5
|
+
constructor( value = 0 ) {
|
|
6
6
|
|
|
7
7
|
super( null, 'vec2' );
|
|
8
8
|
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
Object.defineProperty( this, 'isUVNode', { value: true } );
|
|
9
|
+
this.value = value;
|
|
12
10
|
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
getAttributeName( /*builder*/ ) {
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
const value = this.value;
|
|
16
|
+
|
|
17
|
+
return 'uv' + ( value > 0 ? value + 1 : '' );
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
UVNode.prototype.isUVNode = true;
|
|
24
|
+
|
|
23
25
|
export default UVNode;
|
|
@@ -2,17 +2,17 @@ import InputNode from './InputNode.js';
|
|
|
2
2
|
|
|
3
3
|
class ArrayInputNode extends InputNode {
|
|
4
4
|
|
|
5
|
-
constructor(
|
|
5
|
+
constructor( nodes = [] ) {
|
|
6
6
|
|
|
7
7
|
super();
|
|
8
8
|
|
|
9
|
-
this.
|
|
9
|
+
this.nodes = nodes;
|
|
10
10
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
getNodeType( builder ) {
|
|
14
14
|
|
|
15
|
-
return this.
|
|
15
|
+
return this.nodes[ 0 ].getNodeType( builder );
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Node from './Node.js';
|
|
2
|
+
|
|
3
|
+
class BypassNode extends Node {
|
|
4
|
+
|
|
5
|
+
constructor( returnNode, callNode ) {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.outputNode = returnNode;
|
|
10
|
+
this.callNode = callNode;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getNodeType( builder ) {
|
|
15
|
+
|
|
16
|
+
return this.outputNode.getNodeType( builder );
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
generate( builder, output ) {
|
|
21
|
+
|
|
22
|
+
const snippet = this.callNode.build( builder, 'void' );
|
|
23
|
+
|
|
24
|
+
if ( snippet !== '' ) {
|
|
25
|
+
|
|
26
|
+
builder.addFlowCode( snippet );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return this.outputNode.build( builder, output );
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
BypassNode.prototype.isBypassNode = true;
|
|
37
|
+
|
|
38
|
+
export default BypassNode;
|
|
@@ -12,8 +12,6 @@ class CodeNode extends Node {
|
|
|
12
12
|
|
|
13
13
|
this._includes = [];
|
|
14
14
|
|
|
15
|
-
Object.defineProperty( this, 'isCodeNode', { value: true } );
|
|
16
|
-
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
setIncludes( includes ) {
|
|
@@ -34,7 +32,7 @@ class CodeNode extends Node {
|
|
|
34
32
|
|
|
35
33
|
if ( this.useKeywords === true ) {
|
|
36
34
|
|
|
37
|
-
const contextKeywords = builder.
|
|
35
|
+
const contextKeywords = builder.context.keywords;
|
|
38
36
|
|
|
39
37
|
if ( contextKeywords !== undefined ) {
|
|
40
38
|
|
|
@@ -75,4 +73,6 @@ class CodeNode extends Node {
|
|
|
75
73
|
|
|
76
74
|
}
|
|
77
75
|
|
|
76
|
+
CodeNode.prototype.isCodeNode = true;
|
|
77
|
+
|
|
78
78
|
export default CodeNode;
|
|
@@ -2,30 +2,13 @@ import Node from './Node.js';
|
|
|
2
2
|
|
|
3
3
|
class ContextNode extends Node {
|
|
4
4
|
|
|
5
|
-
constructor( node,
|
|
5
|
+
constructor( node, context = {} ) {
|
|
6
6
|
|
|
7
|
-
super(
|
|
7
|
+
super();
|
|
8
8
|
|
|
9
9
|
this.node = node;
|
|
10
|
-
|
|
11
10
|
this.context = context;
|
|
12
11
|
|
|
13
|
-
Object.defineProperty( this, 'isContextNode', { value: true } );
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setContextValue( name, value ) {
|
|
18
|
-
|
|
19
|
-
this.context[ name ] = value;
|
|
20
|
-
|
|
21
|
-
return this;
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getContextValue( name ) {
|
|
26
|
-
|
|
27
|
-
return this.context[ name ];
|
|
28
|
-
|
|
29
12
|
}
|
|
30
13
|
|
|
31
14
|
getNodeType( builder ) {
|
|
@@ -50,4 +33,6 @@ class ContextNode extends Node {
|
|
|
50
33
|
|
|
51
34
|
}
|
|
52
35
|
|
|
36
|
+
ContextNode.prototype.isContextNode = true;
|
|
37
|
+
|
|
53
38
|
export default ContextNode;
|
|
@@ -2,7 +2,7 @@ import TempNode from './TempNode.js';
|
|
|
2
2
|
|
|
3
3
|
class ExpressionNode extends TempNode {
|
|
4
4
|
|
|
5
|
-
constructor( snipped = '', nodeType =
|
|
5
|
+
constructor( snipped = '', nodeType = 'void' ) {
|
|
6
6
|
|
|
7
7
|
super( nodeType );
|
|
8
8
|
|
|
@@ -12,7 +12,18 @@ class ExpressionNode extends TempNode {
|
|
|
12
12
|
|
|
13
13
|
generate( builder ) {
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const type = this.getNodeType( builder );
|
|
16
|
+
const snipped = this.snipped;
|
|
17
|
+
|
|
18
|
+
if ( type === 'void' ) {
|
|
19
|
+
|
|
20
|
+
builder.addFlowCode( snipped );
|
|
21
|
+
|
|
22
|
+
} else {
|
|
23
|
+
|
|
24
|
+
return `( ${ snipped } )`;
|
|
25
|
+
|
|
26
|
+
}
|
|
16
27
|
|
|
17
28
|
}
|
|
18
29
|
|
|
@@ -1,143 +1,43 @@
|
|
|
1
1
|
import CodeNode from './CodeNode.js';
|
|
2
|
-
import NodeFunctionInput from './NodeFunctionInput.js';
|
|
3
2
|
import FunctionCallNode from './FunctionCallNode.js';
|
|
4
3
|
|
|
5
|
-
const declarationRegexp = /^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\((.*?)\)/i;
|
|
6
|
-
const propertiesRegexp = /[a-z_0-9]+/ig;
|
|
7
|
-
|
|
8
|
-
const pragmaMain = '#pragma main';
|
|
9
|
-
|
|
10
4
|
class FunctionNode extends CodeNode {
|
|
11
5
|
|
|
12
6
|
constructor( code = '' ) {
|
|
13
7
|
|
|
14
8
|
super( code );
|
|
15
9
|
|
|
16
|
-
this.inputs = [];
|
|
17
|
-
|
|
18
|
-
this.name = '';
|
|
19
|
-
this.needsUpdate = true;
|
|
20
|
-
|
|
21
10
|
this.useKeywords = true;
|
|
22
11
|
|
|
23
|
-
this.presicion = '';
|
|
24
|
-
|
|
25
|
-
this._includeCode = '';
|
|
26
|
-
this._internalCode = '';
|
|
27
|
-
|
|
28
12
|
}
|
|
29
13
|
|
|
30
14
|
getNodeType( builder ) {
|
|
31
15
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.parse();
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return super.getNodeType( builder );
|
|
16
|
+
return this.getNodeFunction( builder ).type;
|
|
39
17
|
|
|
40
18
|
}
|
|
41
19
|
|
|
42
|
-
getInputs(
|
|
43
|
-
|
|
44
|
-
if ( this.needsUpdate === true ) {
|
|
45
|
-
|
|
46
|
-
this.parse();
|
|
20
|
+
getInputs( builder ) {
|
|
47
21
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return this.inputs;
|
|
22
|
+
return this.getNodeFunction( builder ).inputs;
|
|
51
23
|
|
|
52
24
|
}
|
|
53
25
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const code = this.code;
|
|
57
|
-
|
|
58
|
-
const pragmaMainIndex = code.indexOf( pragmaMain );
|
|
59
|
-
|
|
60
|
-
const mainCode = pragmaMainIndex !== - 1 ? code.substr( pragmaMainIndex + pragmaMain.length ) : code;
|
|
61
|
-
|
|
62
|
-
const declaration = mainCode.match( declarationRegexp );
|
|
63
|
-
|
|
64
|
-
if ( declaration !== null && declaration.length === 5 ) {
|
|
65
|
-
|
|
66
|
-
// tokenizer
|
|
67
|
-
|
|
68
|
-
const paramsCode = declaration[ 4 ];
|
|
69
|
-
const propsMatches = [];
|
|
70
|
-
|
|
71
|
-
let nameMatch = null;
|
|
72
|
-
|
|
73
|
-
while ( ( nameMatch = propertiesRegexp.exec( paramsCode ) ) !== null ) {
|
|
74
|
-
|
|
75
|
-
propsMatches.push( nameMatch );
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// parser
|
|
80
|
-
|
|
81
|
-
const inputs = [];
|
|
82
|
-
|
|
83
|
-
let i = 0;
|
|
84
|
-
|
|
85
|
-
while ( i < propsMatches.length ) {
|
|
86
|
-
|
|
87
|
-
const isConst = propsMatches[ i ][ 0 ] === 'const';
|
|
88
|
-
|
|
89
|
-
if ( isConst === true ) {
|
|
26
|
+
getNodeFunction( builder ) {
|
|
90
27
|
|
|
91
|
-
|
|
28
|
+
const nodeData = builder.getDataFromNode( this );
|
|
92
29
|
|
|
93
|
-
|
|
30
|
+
let nodeFunction = nodeData.nodeFunction;
|
|
94
31
|
|
|
95
|
-
|
|
32
|
+
if ( nodeFunction === undefined ) {
|
|
96
33
|
|
|
97
|
-
|
|
34
|
+
nodeFunction = builder.parser.parseFunction( this.code );
|
|
98
35
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
|
|
103
|
-
qualifier = '';
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const type = propsMatches[ i ++ ][ 0 ];
|
|
108
|
-
|
|
109
|
-
let count = Number.parseInt( propsMatches[ i ][ 0 ] );
|
|
110
|
-
|
|
111
|
-
if ( Number.isNaN( count ) === false ) i ++;
|
|
112
|
-
else count = 0;
|
|
113
|
-
|
|
114
|
-
const name = propsMatches[ i ++ ][ 0 ];
|
|
115
|
-
|
|
116
|
-
inputs.push( new NodeFunctionInput( type, name, qualifier, isConst, count ) );
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const blockCode = mainCode.substring( declaration[ 0 ].length );
|
|
121
|
-
|
|
122
|
-
this.name = declaration[ 3 ] !== undefined ? declaration[ 3 ] : '';
|
|
123
|
-
this.nodeType = declaration[ 2 ];
|
|
124
|
-
|
|
125
|
-
this.presicion = declaration[ 1 ] !== undefined ? declaration[ 1 ] : '';
|
|
126
|
-
|
|
127
|
-
this.inputs = inputs;
|
|
128
|
-
|
|
129
|
-
this._includeCode = pragmaMainIndex !== - 1 ? code.substr( 0, pragmaMainIndex ) : '';
|
|
130
|
-
this._internalCode = `( ${paramsCode} ) ${blockCode}`;
|
|
131
|
-
|
|
132
|
-
} else {
|
|
133
|
-
|
|
134
|
-
throw new Error( 'FunctionNode: Function is not a GLSL code.' );
|
|
36
|
+
nodeData.nodeFunction = nodeFunction;
|
|
135
37
|
|
|
136
38
|
}
|
|
137
39
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.needsUpdate = false;
|
|
40
|
+
return nodeFunction;
|
|
141
41
|
|
|
142
42
|
}
|
|
143
43
|
|
|
@@ -151,37 +51,24 @@ class FunctionNode extends CodeNode {
|
|
|
151
51
|
|
|
152
52
|
super.generate( builder );
|
|
153
53
|
|
|
154
|
-
const
|
|
54
|
+
const nodeFunction = this.getNodeFunction( builder );
|
|
55
|
+
|
|
56
|
+
const name = nodeFunction.name;
|
|
57
|
+
const type = nodeFunction.type;
|
|
58
|
+
|
|
155
59
|
const nodeCode = builder.getCodeFromNode( this, type );
|
|
156
60
|
|
|
157
|
-
if (
|
|
61
|
+
if ( name !== '' ) {
|
|
158
62
|
|
|
159
63
|
// use a custom property name
|
|
160
64
|
|
|
161
|
-
nodeCode.name =
|
|
65
|
+
nodeCode.name = name;
|
|
162
66
|
|
|
163
67
|
}
|
|
164
68
|
|
|
165
69
|
const propertyName = builder.getPropertyName( nodeCode );
|
|
166
70
|
|
|
167
|
-
|
|
168
|
-
const includeCode = this._includeCode;
|
|
169
|
-
|
|
170
|
-
let code = `${type} ${propertyName} ${this._internalCode}`;
|
|
171
|
-
|
|
172
|
-
if ( presicion !== '' ) {
|
|
173
|
-
|
|
174
|
-
code = `${presicion} ${code}`;
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if ( includeCode !== '' ) {
|
|
179
|
-
|
|
180
|
-
code = `${includeCode} ${code}`;
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
nodeCode.code = code;
|
|
71
|
+
nodeCode.code = this.getNodeFunction( builder ).getCode( propertyName );
|
|
185
72
|
|
|
186
73
|
if ( output === 'property' ) {
|
|
187
74
|
|
|
@@ -189,7 +76,7 @@ class FunctionNode extends CodeNode {
|
|
|
189
76
|
|
|
190
77
|
} else {
|
|
191
78
|
|
|
192
|
-
return builder.format( `${propertyName}()`, type, output );
|
|
79
|
+
return builder.format( `${ propertyName }()`, type, output );
|
|
193
80
|
|
|
194
81
|
}
|
|
195
82
|
|
|
@@ -2,9 +2,11 @@ import Node from './Node.js';
|
|
|
2
2
|
|
|
3
3
|
class InputNode extends Node {
|
|
4
4
|
|
|
5
|
-
constructor(
|
|
5
|
+
constructor( inputType ) {
|
|
6
6
|
|
|
7
|
-
super(
|
|
7
|
+
super( inputType );
|
|
8
|
+
|
|
9
|
+
this.inputType = inputType;
|
|
8
10
|
|
|
9
11
|
this.constant = false;
|
|
10
12
|
|
|
@@ -24,6 +26,12 @@ class InputNode extends Node {
|
|
|
24
26
|
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
getInputType( builder ) {
|
|
30
|
+
|
|
31
|
+
return this.inputType;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
generateConst( builder ) {
|
|
28
36
|
|
|
29
37
|
return builder.getConst( this.getNodeType( builder ), this.value );
|
|
@@ -40,7 +48,9 @@ class InputNode extends Node {
|
|
|
40
48
|
|
|
41
49
|
} else {
|
|
42
50
|
|
|
43
|
-
const
|
|
51
|
+
const inputType = this.getInputType( builder );
|
|
52
|
+
|
|
53
|
+
const nodeUniform = builder.getUniformFromNode( this, builder.shaderStage, inputType );
|
|
44
54
|
const propertyName = builder.getPropertyName( nodeUniform );
|
|
45
55
|
|
|
46
56
|
return builder.format( propertyName, type, output );
|