super-three 0.167.0 → 0.168.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.cjs +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
Mesh,
|
|
4
|
+
NodeMaterial,
|
|
5
|
+
Vector2,
|
|
6
|
+
Vector3
|
|
7
|
+
} from 'three';
|
|
8
|
+
import { vec2, viewportSafeUV, viewportSharedTexture, reflector, pow, float, abs, texture, uniform, TempNode, NodeUpdateType, vec4, Fn, cameraPosition, positionWorld, uv, mix, vec3, normalize, max, dot, viewportUV } from 'three/tsl';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* References:
|
|
12
|
+
* https://alex.vlachos.com/graphics/Vlachos-SIGGRAPH10-WaterFlow.pdf
|
|
13
|
+
* http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
class WaterMesh extends Mesh {
|
|
18
|
+
|
|
19
|
+
constructor( geometry, options = {} ) {
|
|
20
|
+
|
|
21
|
+
const material = new NodeMaterial();
|
|
22
|
+
|
|
23
|
+
super( geometry, material );
|
|
24
|
+
|
|
25
|
+
this.isWater = true;
|
|
26
|
+
|
|
27
|
+
material.fragmentNode = new WaterNode( options, this );
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class WaterNode extends TempNode {
|
|
34
|
+
|
|
35
|
+
constructor( options, waterBody ) {
|
|
36
|
+
|
|
37
|
+
super( 'vec4' );
|
|
38
|
+
|
|
39
|
+
this.waterBody = waterBody;
|
|
40
|
+
|
|
41
|
+
this.normalMap0 = texture( options.normalMap0 );
|
|
42
|
+
this.normalMap1 = texture( options.normalMap1 );
|
|
43
|
+
this.flowMap = texture( options.flowMap !== undefined ? options.flowMap : null );
|
|
44
|
+
|
|
45
|
+
this.color = uniform( options.color !== undefined ? new Color( options.color ) : new Color( 0xffffff ) );
|
|
46
|
+
this.flowDirection = uniform( options.flowDirection !== undefined ? options.flowDirection : new Vector2( 1, 0 ) );
|
|
47
|
+
this.flowSpeed = uniform( options.flowSpeed !== undefined ? options.flowSpeed : 0.03 );
|
|
48
|
+
this.reflectivity = uniform( options.reflectivity !== undefined ? options.reflectivity : 0.02 );
|
|
49
|
+
this.scale = uniform( options.scale !== undefined ? options.scale : 1 );
|
|
50
|
+
this.flowConfig = uniform( new Vector3() );
|
|
51
|
+
|
|
52
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
53
|
+
|
|
54
|
+
this._cycle = 0.15; // a cycle of a flow map phase
|
|
55
|
+
this._halfCycle = this._cycle * 0.5;
|
|
56
|
+
|
|
57
|
+
this._USE_FLOW = options.flowMap !== undefined;
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
updateFlow( delta ) {
|
|
62
|
+
|
|
63
|
+
this.flowConfig.value.x += this.flowSpeed.value * delta; // flowMapOffset0
|
|
64
|
+
this.flowConfig.value.y = this.flowConfig.value.x + this._halfCycle; // flowMapOffset1
|
|
65
|
+
|
|
66
|
+
// Important: The distance between offsets should be always the value of "halfCycle".
|
|
67
|
+
// Moreover, both offsets should be in the range of [ 0, cycle ].
|
|
68
|
+
// This approach ensures a smooth water flow and avoids "reset" effects.
|
|
69
|
+
|
|
70
|
+
if ( this.flowConfig.value.x >= this._cycle ) {
|
|
71
|
+
|
|
72
|
+
this.flowConfig.value.x = 0;
|
|
73
|
+
this.flowConfig.value.y = this._halfCycle;
|
|
74
|
+
|
|
75
|
+
} else if ( this.flowConfig.value.y >= this._cycle ) {
|
|
76
|
+
|
|
77
|
+
this.flowConfig.value.y = this.flowConfig.value.y - this._cycle;
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.flowConfig.value.z = this._halfCycle;
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
updateBefore( frame ) {
|
|
86
|
+
|
|
87
|
+
this.updateFlow( frame.deltaTime );
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setup() {
|
|
92
|
+
|
|
93
|
+
const outputNode = Fn( () => {
|
|
94
|
+
|
|
95
|
+
const flowMapOffset0 = this.flowConfig.x;
|
|
96
|
+
const flowMapOffset1 = this.flowConfig.y;
|
|
97
|
+
const halfCycle = this.flowConfig.z;
|
|
98
|
+
|
|
99
|
+
const toEye = normalize( cameraPosition.sub( positionWorld ) );
|
|
100
|
+
|
|
101
|
+
let flow;
|
|
102
|
+
|
|
103
|
+
if ( this._USE_FLOW === true ) {
|
|
104
|
+
|
|
105
|
+
flow = this.flowMap.rg.mul( 2 ).sub( 1 );
|
|
106
|
+
|
|
107
|
+
} else {
|
|
108
|
+
|
|
109
|
+
flow = vec2( this.flowDirection.x, this.flowDirection.y );
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
flow.x.mulAssign( - 1 );
|
|
114
|
+
|
|
115
|
+
// sample normal maps (distort uvs with flowdata)
|
|
116
|
+
|
|
117
|
+
const uvs = uv();
|
|
118
|
+
|
|
119
|
+
const normalUv0 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset0 ) );
|
|
120
|
+
const normalUv1 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset1 ) );
|
|
121
|
+
|
|
122
|
+
const normalColor0 = this.normalMap0.uv( normalUv0 );
|
|
123
|
+
const normalColor1 = this.normalMap1.uv( normalUv1 );
|
|
124
|
+
|
|
125
|
+
// linear interpolate to get the final normal color
|
|
126
|
+
const flowLerp = abs( halfCycle.sub( flowMapOffset0 ) ).div( halfCycle );
|
|
127
|
+
const normalColor = mix( normalColor0, normalColor1, flowLerp );
|
|
128
|
+
|
|
129
|
+
// calculate normal vector
|
|
130
|
+
const normal = normalize( vec3( normalColor.r.mul( 2 ).sub( 1 ), normalColor.b, normalColor.g.mul( 2 ).sub( 1 ) ) );
|
|
131
|
+
|
|
132
|
+
// calculate the fresnel term to blend reflection and refraction maps
|
|
133
|
+
const theta = max( dot( toEye, normal ), 0 );
|
|
134
|
+
const reflectance = pow( float( 1.0 ).sub( theta ), 5.0 ).mul( float( 1.0 ).sub( this.reflectivity ) ).add( this.reflectivity );
|
|
135
|
+
|
|
136
|
+
// reflector, refractor
|
|
137
|
+
|
|
138
|
+
const offset = normal.xz.mul( 0.05 ).toVar();
|
|
139
|
+
|
|
140
|
+
const reflectionSampler = reflector();
|
|
141
|
+
this.waterBody.add( reflectionSampler.target );
|
|
142
|
+
reflectionSampler.uvNode = reflectionSampler.uvNode.add( offset );
|
|
143
|
+
|
|
144
|
+
const refractorUV = viewportUV.add( offset );
|
|
145
|
+
const refractionSampler = viewportSharedTexture( viewportSafeUV( refractorUV ) );
|
|
146
|
+
|
|
147
|
+
// calculate final uv coords
|
|
148
|
+
|
|
149
|
+
return vec4( this.color, 1.0 ).mul( mix( refractionSampler, reflectionSampler, reflectance ) );
|
|
150
|
+
|
|
151
|
+
} )();
|
|
152
|
+
|
|
153
|
+
return outputNode;
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { WaterMesh };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
Mesh,
|
|
4
|
+
NodeMaterial,
|
|
5
|
+
Vector3
|
|
6
|
+
} from 'three';
|
|
7
|
+
import { add, cameraPosition, div, normalize, positionWorld, sub, timerLocal, Fn, texture, vec2, vec3, vec4, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix } from 'three/tsl';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Work based on :
|
|
11
|
+
* https://github.com/Slayvin: Flat mirror for three.js
|
|
12
|
+
* https://home.adelphi.edu/~stemkoski/ : An implementation of water shader based on the flat mirror
|
|
13
|
+
* http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
class WaterMesh extends Mesh {
|
|
17
|
+
|
|
18
|
+
constructor( geometry, options ) {
|
|
19
|
+
|
|
20
|
+
const material = new NodeMaterial();
|
|
21
|
+
|
|
22
|
+
super( geometry, material );
|
|
23
|
+
|
|
24
|
+
this.isWater = true;
|
|
25
|
+
|
|
26
|
+
this.resolution = options.resolution !== undefined ? options.resolution : 0.5;
|
|
27
|
+
|
|
28
|
+
// uniforms
|
|
29
|
+
|
|
30
|
+
this.waterNormals = texture( options.waterNormals );
|
|
31
|
+
this.alpha = uniform( options.alpha !== undefined ? options.alpha : 1.0 );
|
|
32
|
+
this.size = uniform( options.size !== undefined ? options.size : 1.0 );
|
|
33
|
+
this.sunColor = uniform( new Color( options.sunColor !== undefined ? options.sunColor : 0xffffff ) );
|
|
34
|
+
this.sunDirection = uniform( options.sunDirection !== undefined ? options.sunDirection : new Vector3( 0.70707, 0.70707, 0.0 ) );
|
|
35
|
+
this.waterColor = uniform( new Color( options.waterColor !== undefined ? options.waterColor : 0x7f7f7f ) );
|
|
36
|
+
this.distortionScale = uniform( options.distortionScale !== undefined ? options.distortionScale : 20.0 );
|
|
37
|
+
|
|
38
|
+
// TSL
|
|
39
|
+
|
|
40
|
+
const timeNode = timerLocal();
|
|
41
|
+
|
|
42
|
+
const getNoise = Fn( ( [ uv ] ) => {
|
|
43
|
+
|
|
44
|
+
const uv0 = add( div( uv, 103 ), vec2( div( timeNode, 17 ), div( timeNode, 29 ) ) ).toVar();
|
|
45
|
+
const uv1 = div( uv, 107 ).sub( vec2( div( timeNode, - 19 ), div( timeNode, 31 ) ) ).toVar();
|
|
46
|
+
const uv2 = add( div( uv, vec2( 8907.0, 9803.0 ) ), vec2( div( timeNode, 101 ), div( timeNode, 97 ) ) ).toVar();
|
|
47
|
+
const uv3 = sub( div( uv, vec2( 1091.0, 1027.0 ) ), vec2( div( timeNode, 109 ), div( timeNode, - 113 ) ) ).toVar();
|
|
48
|
+
|
|
49
|
+
const sample0 = this.waterNormals.uv( uv0 );
|
|
50
|
+
const sample1 = this.waterNormals.uv( uv1 );
|
|
51
|
+
const sample2 = this.waterNormals.uv( uv2 );
|
|
52
|
+
const sample3 = this.waterNormals.uv( uv3 );
|
|
53
|
+
|
|
54
|
+
const noise = sample0.add( sample1 ).add( sample2 ).add( sample3 );
|
|
55
|
+
|
|
56
|
+
return noise.mul( 0.5 ).sub( 1 );
|
|
57
|
+
|
|
58
|
+
} );
|
|
59
|
+
|
|
60
|
+
const fragmentNode = Fn( () => {
|
|
61
|
+
|
|
62
|
+
const noise = getNoise( positionWorld.xz.mul( this.size ) );
|
|
63
|
+
const surfaceNormal = normalize( noise.xzy.mul( 1.5, 1.0, 1.5 ) );
|
|
64
|
+
|
|
65
|
+
const diffuseLight = vec3( 0 ).toVar();
|
|
66
|
+
const specularLight = vec3( 0 ).toVar();
|
|
67
|
+
|
|
68
|
+
const worldToEye = cameraPosition.sub( positionWorld );
|
|
69
|
+
const eyeDirection = normalize( worldToEye );
|
|
70
|
+
|
|
71
|
+
const reflection = normalize( reflect( this.sunDirection.negate(), surfaceNormal ) );
|
|
72
|
+
const direction = max( 0.0, dot( eyeDirection, reflection ) );
|
|
73
|
+
specularLight.addAssign( pow( direction, 100 ).mul( this.sunColor ).mul( 2.0 ) );
|
|
74
|
+
diffuseLight.addAssign( max( dot( this.sunDirection, surfaceNormal ), 0.0 ).mul( this.sunColor ).mul( 0.5 ) );
|
|
75
|
+
|
|
76
|
+
const distance = length( worldToEye );
|
|
77
|
+
|
|
78
|
+
const distortion = surfaceNormal.xy.mul( float( 0.001 ).add( float( 1.0 ).div( distance ) ) ).mul( this.distortionScale );
|
|
79
|
+
|
|
80
|
+
const mirrorSampler = reflector();
|
|
81
|
+
mirrorSampler.uvNode = mirrorSampler.uvNode.add( distortion );
|
|
82
|
+
mirrorSampler.resolution = this.resolution;
|
|
83
|
+
|
|
84
|
+
this.add( mirrorSampler.target );
|
|
85
|
+
|
|
86
|
+
const theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
87
|
+
const rf0 = float( 0.3 );
|
|
88
|
+
const reflectance = mul( pow( float( 1.0 ).sub( theta ), 5.0 ), float( 1.0 ).sub( rf0 ) ).add( rf0 );
|
|
89
|
+
const scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ).mul( this.waterColor );
|
|
90
|
+
const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.mul( specularLight ).add( mirrorSampler.rgb.mul( 0.9 ) ).add( vec3( 0.1 ) ), reflectance );
|
|
91
|
+
|
|
92
|
+
return vec4( albedo, this.alpha );
|
|
93
|
+
|
|
94
|
+
} )();
|
|
95
|
+
|
|
96
|
+
material.fragmentNode = fragmentNode;
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { WaterMesh };
|
|
@@ -28,6 +28,26 @@ function getShape( geometry ) {
|
|
|
28
28
|
const radius = parameters.radius !== undefined ? parameters.radius : 1;
|
|
29
29
|
return RAPIER.ColliderDesc.ball( radius );
|
|
30
30
|
|
|
31
|
+
} else if ( geometry.type === 'BufferGeometry' ) {
|
|
32
|
+
|
|
33
|
+
const vertices = [];
|
|
34
|
+
const vertex = new Vector3();
|
|
35
|
+
const position = geometry.getAttribute( 'position' );
|
|
36
|
+
|
|
37
|
+
for ( let i = 0; i < position.count; i ++ ) {
|
|
38
|
+
|
|
39
|
+
vertex.fromBufferAttribute( position, i );
|
|
40
|
+
vertices.push( vertex.x, vertex.y, vertex.z );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// if the buffer is non-indexed, generate an index buffer
|
|
45
|
+
const indices = geometry.getIndex() === null
|
|
46
|
+
? Uint32Array.from( Array( parseInt( vertices.length / 3 ) ).keys() )
|
|
47
|
+
: geometry.getIndex().array;
|
|
48
|
+
|
|
49
|
+
return RAPIER.ColliderDesc.trimesh( vertices, indices );
|
|
50
|
+
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
return null;
|
|
@@ -35,7 +35,7 @@ class OutlinePass extends Pass {
|
|
|
35
35
|
this.pulsePeriod = 0;
|
|
36
36
|
|
|
37
37
|
this._visibilityCache = new Map();
|
|
38
|
-
|
|
38
|
+
this._selectionCache = new Set();
|
|
39
39
|
|
|
40
40
|
this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 );
|
|
41
41
|
|
|
@@ -172,29 +172,18 @@ class OutlinePass extends Pass {
|
|
|
172
172
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
updateSelectionCache() {
|
|
176
176
|
|
|
177
|
-
const cache = this.
|
|
177
|
+
const cache = this._selectionCache;
|
|
178
178
|
|
|
179
179
|
function gatherSelectedMeshesCallBack( object ) {
|
|
180
180
|
|
|
181
|
-
if ( object.isMesh )
|
|
182
|
-
|
|
183
|
-
if ( bVisible === true ) {
|
|
184
|
-
|
|
185
|
-
object.visible = cache.get( object );
|
|
186
|
-
|
|
187
|
-
} else {
|
|
188
|
-
|
|
189
|
-
cache.set( object, object.visible );
|
|
190
|
-
object.visible = bVisible;
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
}
|
|
181
|
+
if ( object.isMesh ) cache.add( object );
|
|
195
182
|
|
|
196
183
|
}
|
|
197
184
|
|
|
185
|
+
cache.clear();
|
|
186
|
+
|
|
198
187
|
for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
|
|
199
188
|
|
|
200
189
|
const selectedObject = this.selectedObjects[ i ];
|
|
@@ -204,56 +193,49 @@ class OutlinePass extends Pass {
|
|
|
204
193
|
|
|
205
194
|
}
|
|
206
195
|
|
|
207
|
-
|
|
196
|
+
changeVisibilityOfSelectedObjects( bVisible ) {
|
|
208
197
|
|
|
209
198
|
const cache = this._visibilityCache;
|
|
210
|
-
const selectedMeshes = [];
|
|
211
|
-
|
|
212
|
-
function gatherSelectedMeshesCallBack( object ) {
|
|
213
|
-
|
|
214
|
-
if ( object.isMesh ) selectedMeshes.push( object );
|
|
215
199
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
for ( let i = 0; i < this.selectedObjects.length; i ++ ) {
|
|
200
|
+
for ( const mesh of this._selectionCache ) {
|
|
219
201
|
|
|
220
|
-
|
|
221
|
-
selectedObject.traverse( gatherSelectedMeshesCallBack );
|
|
202
|
+
if ( bVisible === true ) {
|
|
222
203
|
|
|
223
|
-
|
|
204
|
+
mesh.visible = cache.get( mesh );
|
|
224
205
|
|
|
225
|
-
|
|
206
|
+
} else {
|
|
226
207
|
|
|
227
|
-
|
|
208
|
+
cache.set( mesh, mesh.visible );
|
|
209
|
+
mesh.visible = bVisible;
|
|
228
210
|
|
|
229
|
-
|
|
211
|
+
}
|
|
230
212
|
|
|
231
|
-
|
|
213
|
+
}
|
|
232
214
|
|
|
233
|
-
|
|
215
|
+
}
|
|
234
216
|
|
|
235
|
-
|
|
217
|
+
changeVisibilityOfNonSelectedObjects( bVisible ) {
|
|
236
218
|
|
|
237
|
-
|
|
219
|
+
const visibilityCache = this._visibilityCache;
|
|
220
|
+
const selectionCache = this._selectionCache;
|
|
238
221
|
|
|
239
|
-
|
|
240
|
-
break;
|
|
222
|
+
function VisibilityChangeCallBack( object ) {
|
|
241
223
|
|
|
242
|
-
|
|
224
|
+
if ( object.isMesh || object.isSprite ) {
|
|
243
225
|
|
|
244
|
-
|
|
226
|
+
// only meshes and sprites are supported by OutlinePass
|
|
245
227
|
|
|
246
|
-
if (
|
|
228
|
+
if ( ! selectionCache.has( object ) ) {
|
|
247
229
|
|
|
248
230
|
const visibility = object.visible;
|
|
249
231
|
|
|
250
|
-
if ( bVisible === false ||
|
|
232
|
+
if ( bVisible === false || visibilityCache.get( object ) === true ) {
|
|
251
233
|
|
|
252
234
|
object.visible = bVisible;
|
|
253
235
|
|
|
254
236
|
}
|
|
255
237
|
|
|
256
|
-
|
|
238
|
+
visibilityCache.set( object, visibility );
|
|
257
239
|
|
|
258
240
|
}
|
|
259
241
|
|
|
@@ -264,11 +246,11 @@ class OutlinePass extends Pass {
|
|
|
264
246
|
|
|
265
247
|
if ( bVisible === true ) {
|
|
266
248
|
|
|
267
|
-
object.visible =
|
|
249
|
+
object.visible = visibilityCache.get( object ); // restore
|
|
268
250
|
|
|
269
251
|
} else {
|
|
270
252
|
|
|
271
|
-
|
|
253
|
+
visibilityCache.set( object, object.visible );
|
|
272
254
|
object.visible = bVisible;
|
|
273
255
|
|
|
274
256
|
}
|
|
@@ -306,6 +288,8 @@ class OutlinePass extends Pass {
|
|
|
306
288
|
|
|
307
289
|
renderer.setClearColor( 0xffffff, 1 );
|
|
308
290
|
|
|
291
|
+
this.updateSelectionCache();
|
|
292
|
+
|
|
309
293
|
// Make selected objects invisible
|
|
310
294
|
this.changeVisibilityOfSelectedObjects( false );
|
|
311
295
|
|
|
@@ -337,6 +321,7 @@ class OutlinePass extends Pass {
|
|
|
337
321
|
this.renderScene.overrideMaterial = null;
|
|
338
322
|
this.changeVisibilityOfNonSelectedObjects( true );
|
|
339
323
|
this._visibilityCache.clear();
|
|
324
|
+
this._selectionCache.clear();
|
|
340
325
|
|
|
341
326
|
this.renderScene.background = currentBackground;
|
|
342
327
|
|
|
@@ -462,7 +447,7 @@ class OutlinePass extends Pass {
|
|
|
462
447
|
worldPosition = instanceMatrix * worldPosition;
|
|
463
448
|
|
|
464
449
|
#endif
|
|
465
|
-
|
|
450
|
+
|
|
466
451
|
worldPosition = modelMatrix * worldPosition;
|
|
467
452
|
|
|
468
453
|
projTexCoord = textureMatrix * worldPosition;
|
|
@@ -31,6 +31,8 @@ class SSAARenderPass extends Pass {
|
|
|
31
31
|
this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
|
|
32
32
|
this.unbiased = true;
|
|
33
33
|
|
|
34
|
+
this.stencilBuffer = false;
|
|
35
|
+
|
|
34
36
|
// as we need to clear the buffer in this pass, clearColor must be set to something, defaults to black.
|
|
35
37
|
this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
|
|
36
38
|
this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
|
|
@@ -79,7 +81,7 @@ class SSAARenderPass extends Pass {
|
|
|
79
81
|
|
|
80
82
|
if ( ! this.sampleRenderTarget ) {
|
|
81
83
|
|
|
82
|
-
this.sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType } );
|
|
84
|
+
this.sampleRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, stencilBuffer: this.stencilBuffer } );
|
|
83
85
|
this.sampleRenderTarget.texture.name = 'SSAARenderPass.sample';
|
|
84
86
|
|
|
85
87
|
}
|
|
@@ -38,8 +38,7 @@ const BleachBypassShader = {
|
|
|
38
38
|
|
|
39
39
|
vec4 base = texture2D( tDiffuse, vUv );
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
float lum = dot( lumCoeff, base.rgb );
|
|
41
|
+
float lum = luminance( base.rgb );
|
|
43
42
|
vec3 blend = vec3( lum );
|
|
44
43
|
|
|
45
44
|
float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );
|
|
@@ -322,9 +322,9 @@ class TSLEncoder {
|
|
|
322
322
|
const leftStr = this.emitExpression( node.left );
|
|
323
323
|
const rightStr = this.emitExpression( node.right );
|
|
324
324
|
|
|
325
|
-
this.addImport( '
|
|
325
|
+
this.addImport( 'select' );
|
|
326
326
|
|
|
327
|
-
return `
|
|
327
|
+
return `select( ${ condStr }, ${ leftStr }, ${ rightStr } )`;
|
|
328
328
|
|
|
329
329
|
}
|
|
330
330
|
|
|
@@ -349,7 +349,7 @@ ${ this.tab }} )`;
|
|
|
349
349
|
|
|
350
350
|
const elseCondStr = this.emitExpression( current.elseConditional.cond );
|
|
351
351
|
|
|
352
|
-
ifStr += `.
|
|
352
|
+
ifStr += `.ElseIf( ${ elseCondStr }, () => {
|
|
353
353
|
|
|
354
354
|
${ elseBodyStr }
|
|
355
355
|
|
|
@@ -357,7 +357,7 @@ ${ this.tab }} )`;
|
|
|
357
357
|
|
|
358
358
|
} else {
|
|
359
359
|
|
|
360
|
-
ifStr += `.
|
|
360
|
+
ifStr += `.Else( () => {
|
|
361
361
|
|
|
362
362
|
${ elseBodyStr }
|
|
363
363
|
|
|
@@ -391,13 +391,13 @@ ${ this.tab }} )`;
|
|
|
391
391
|
const conditionParam = condition !== '<' ? `, condition: '${ condition }'` : '';
|
|
392
392
|
const updateParam = update !== '++' ? `, update: '${ update }'` : '';
|
|
393
393
|
|
|
394
|
-
let loopStr = `
|
|
394
|
+
let loopStr = `Loop( { start: ${ start }, end: ${ end + nameParam + typeParam + conditionParam + updateParam } }, ( { ${ name } } ) => {\n\n`;
|
|
395
395
|
|
|
396
396
|
loopStr += this.emitBody( node.body ) + '\n\n';
|
|
397
397
|
|
|
398
398
|
loopStr += this.tab + '} )';
|
|
399
399
|
|
|
400
|
-
this.imports.add( '
|
|
400
|
+
this.imports.add( 'Loop' );
|
|
401
401
|
|
|
402
402
|
return loopStr;
|
|
403
403
|
|
|
@@ -586,7 +586,7 @@ ${ this.tab }} )`;
|
|
|
586
586
|
|
|
587
587
|
const prefix = this.iife === false ? 'export ' : '';
|
|
588
588
|
|
|
589
|
-
let funcStr = `${ prefix }const ${ fnName } = /*#__PURE__*/
|
|
589
|
+
let funcStr = `${ prefix }const ${ fnName } = /*#__PURE__*/ Fn( (${ paramsStr }) => {
|
|
590
590
|
|
|
591
591
|
${ bodyStr }
|
|
592
592
|
|
|
@@ -608,7 +608,7 @@ ${ this.tab }} )`;
|
|
|
608
608
|
|
|
609
609
|
funcStr += ';\n';
|
|
610
610
|
|
|
611
|
-
this.imports.add( '
|
|
611
|
+
this.imports.add( 'Fn' );
|
|
612
612
|
|
|
613
613
|
this.global.add( node.name );
|
|
614
614
|
|
|
@@ -34,7 +34,7 @@ export function decompress( texture, maxTextureSize = Infinity, renderer = null
|
|
|
34
34
|
gl_FragColor = vec4(vUv.xy, 0, 1);
|
|
35
35
|
|
|
36
36
|
#ifdef IS_SRGB
|
|
37
|
-
gl_FragColor =
|
|
37
|
+
gl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );
|
|
38
38
|
#else
|
|
39
39
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
40
40
|
#endif
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "super-three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.168.0",
|
|
4
4
|
"description": "JavaScript 3D library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/three.cjs",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"test-unit-addons": "qunit -r failonlyreporter -f !-webonly test/unit/three.addons.unit.js",
|
|
63
63
|
"test-e2e": "node test/e2e/puppeteer.js",
|
|
64
64
|
"test-e2e-cov": "node test/e2e/check-coverage.js",
|
|
65
|
+
"test-e2e-webgpu": "node test/e2e/puppeteer.js --webgpu",
|
|
65
66
|
"test-treeshake": "rollup -c test/rollup.treeshake.config.js",
|
|
66
67
|
"test-circular-deps": "dpdm --no-warning --no-tree --exit-code circular:1 src/nodes/Nodes.js",
|
|
67
68
|
"make-screenshot": "node test/e2e/puppeteer.js --make"
|
package/src/Three.WebGPU.js
CHANGED
|
@@ -40,6 +40,7 @@ export { DepthTexture } from './textures/DepthTexture.js';
|
|
|
40
40
|
export { Texture } from './textures/Texture.js';
|
|
41
41
|
export * from './geometries/Geometries.js';
|
|
42
42
|
export * from './materials/Materials.js';
|
|
43
|
+
export * from './materials/nodes/NodeMaterials.js';
|
|
43
44
|
export { Material } from './materials/Material.js';
|
|
44
45
|
export { AnimationLoader } from './loaders/AnimationLoader.js';
|
|
45
46
|
export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js';
|
|
@@ -152,6 +153,7 @@ export { Path } from './extras/core/Path.js';
|
|
|
152
153
|
export { ShapePath } from './extras/core/ShapePath.js';
|
|
153
154
|
export { CurvePath } from './extras/core/CurvePath.js';
|
|
154
155
|
export { Curve } from './extras/core/Curve.js';
|
|
156
|
+
export { Controls } from './extras/Controls.js';
|
|
155
157
|
export { DataUtils } from './extras/DataUtils.js';
|
|
156
158
|
export { ImageUtils } from './extras/ImageUtils.js';
|
|
157
159
|
export { ShapeUtils } from './extras/ShapeUtils.js';
|
|
@@ -169,7 +171,11 @@ export { default as StorageTexture } from './renderers/common/StorageTexture.js'
|
|
|
169
171
|
export { default as StorageBufferAttribute } from './renderers/common/StorageBufferAttribute.js';
|
|
170
172
|
export { default as StorageInstancedBufferAttribute } from './renderers/common/StorageInstancedBufferAttribute.js';
|
|
171
173
|
export { default as IESSpotLight } from './lights/webgpu/IESSpotLight.js';
|
|
174
|
+
export { default as NodeLoader } from './loaders/nodes/NodeLoader.js';
|
|
175
|
+
export { default as NodeObjectLoader } from './loaders/nodes/NodeObjectLoader.js';
|
|
176
|
+
export { default as NodeMaterialLoader } from './loaders/nodes/NodeMaterialLoader.js';
|
|
172
177
|
export * from './nodes/Nodes.js';
|
|
178
|
+
export * from './nodes/TSL.js';
|
|
173
179
|
|
|
174
180
|
if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
|
|
175
181
|
|
package/src/Three.js
CHANGED
|
@@ -151,6 +151,7 @@ export { Path } from './extras/core/Path.js';
|
|
|
151
151
|
export { ShapePath } from './extras/core/ShapePath.js';
|
|
152
152
|
export { CurvePath } from './extras/core/CurvePath.js';
|
|
153
153
|
export { Curve } from './extras/core/Curve.js';
|
|
154
|
+
export { Controls } from './extras/Controls.js';
|
|
154
155
|
export { DataUtils } from './extras/DataUtils.js';
|
|
155
156
|
export { ImageUtils } from './extras/ImageUtils.js';
|
|
156
157
|
export { ShapeUtils } from './extras/ShapeUtils.js';
|
package/src/constants.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EventDispatcher } from '../core/EventDispatcher.js';
|
|
2
|
+
|
|
3
|
+
class Controls extends EventDispatcher {
|
|
4
|
+
|
|
5
|
+
constructor( object, domElement ) {
|
|
6
|
+
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.object = object;
|
|
10
|
+
this.domElement = domElement;
|
|
11
|
+
|
|
12
|
+
this.enabled = true;
|
|
13
|
+
|
|
14
|
+
this.state = - 1;
|
|
15
|
+
|
|
16
|
+
this.keys = {};
|
|
17
|
+
this.mouseButtons = { LEFT: null, MIDDLE: null, RIGHT: null };
|
|
18
|
+
this.touches = { ONE: null, TWO: null };
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
connect() {}
|
|
23
|
+
|
|
24
|
+
disconnect() {}
|
|
25
|
+
|
|
26
|
+
dispose() {}
|
|
27
|
+
|
|
28
|
+
update( /* delta */ ) {}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { Controls };
|
|
@@ -851,7 +851,7 @@ class ObjectLoader extends Loader {
|
|
|
851
851
|
case 'DirectionalLight':
|
|
852
852
|
|
|
853
853
|
object = new DirectionalLight( data.color, data.intensity );
|
|
854
|
-
object.target = data.target ||
|
|
854
|
+
object.target = data.target || '';
|
|
855
855
|
|
|
856
856
|
break;
|
|
857
857
|
|
|
@@ -870,7 +870,7 @@ class ObjectLoader extends Loader {
|
|
|
870
870
|
case 'SpotLight':
|
|
871
871
|
|
|
872
872
|
object = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );
|
|
873
|
-
object.target = data.target ||
|
|
873
|
+
object.target = data.target || '';
|
|
874
874
|
|
|
875
875
|
break;
|
|
876
876
|
|
|
@@ -1147,7 +1147,7 @@ class ObjectLoader extends Loader {
|
|
|
1147
1147
|
|
|
1148
1148
|
object.traverse( function ( child ) {
|
|
1149
1149
|
|
|
1150
|
-
if ( child.isDirectionalLight ||
|
|
1150
|
+
if ( child.isDirectionalLight || child.isSpotLight ) {
|
|
1151
1151
|
|
|
1152
1152
|
const uuid = child.target;
|
|
1153
1153
|
|