@gnsx/three 0.185.15 → 0.186.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 +10 -82600
- package/build/three.core.js +1303 -728
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -182,6 +182,18 @@ class LightShadow {
|
|
|
182
182
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Used internally by the renderer to get the camera that renders the given viewport.
|
|
187
|
+
*
|
|
188
|
+
* @param {number} [viewportIndex=0] - The viewport index.
|
|
189
|
+
* @return {Camera} The shadow camera.
|
|
190
|
+
*/
|
|
191
|
+
getCamera( /* viewportIndex */ ) {
|
|
192
|
+
|
|
193
|
+
return this.camera;
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
185
197
|
/**
|
|
186
198
|
* Gets the shadow cameras frustum. Used internally by the renderer to cull objects.
|
|
187
199
|
*
|
|
@@ -201,23 +213,41 @@ class LightShadow {
|
|
|
201
213
|
updateMatrices( light ) {
|
|
202
214
|
|
|
203
215
|
const shadowCamera = this.camera;
|
|
204
|
-
const shadowMatrix = this.matrix;
|
|
205
|
-
|
|
206
216
|
_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
|
|
207
217
|
shadowCamera.position.copy( _lightPositionWorld );
|
|
208
218
|
|
|
209
219
|
_lookTarget.setFromMatrixPosition( light.target.matrixWorld );
|
|
210
220
|
shadowCamera.lookAt( _lookTarget );
|
|
211
221
|
shadowCamera.updateMatrixWorld();
|
|
222
|
+
this._updateMatrix( shadowCamera, this.matrix, this._frustum );
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Updates a shadow projection matrix and its corresponding frustum.
|
|
228
|
+
*
|
|
229
|
+
* @private
|
|
230
|
+
* @param {Camera} shadowCamera - The shadow camera.
|
|
231
|
+
* @param {Matrix4} shadowMatrix - The target shadow matrix.
|
|
232
|
+
* @param {Frustum} frustum - The target frustum.
|
|
233
|
+
* @param {Vector4} [viewport] - The viewport within the shadow atlas.
|
|
234
|
+
*/
|
|
235
|
+
_updateMatrix( shadowCamera, shadowMatrix, frustum, viewport ) {
|
|
212
236
|
|
|
213
237
|
_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );
|
|
214
|
-
|
|
238
|
+
frustum.setFromProjectionMatrix( _projScreenMatrix, shadowCamera.coordinateSystem, shadowCamera.reversedDepth );
|
|
239
|
+
|
|
240
|
+
const frameExtents = this._frameExtents;
|
|
241
|
+
const scaleX = viewport ? viewport.z / frameExtents.x : 1;
|
|
242
|
+
const scaleY = viewport ? viewport.w / frameExtents.y : 1;
|
|
243
|
+
const offsetX = viewport ? viewport.x / frameExtents.x : 0;
|
|
244
|
+
const offsetY = viewport ? viewport.y / frameExtents.y : 0;
|
|
215
245
|
|
|
216
246
|
if ( shadowCamera.coordinateSystem === WebGPUCoordinateSystem || shadowCamera.reversedDepth ) {
|
|
217
247
|
|
|
218
248
|
shadowMatrix.set(
|
|
219
|
-
0.5, 0.0, 0.0, 0.5,
|
|
220
|
-
0.0, 0.5, 0.0, 0.5,
|
|
249
|
+
0.5 * scaleX, 0.0, 0.0, 0.5 * scaleX + offsetX,
|
|
250
|
+
0.0, 0.5 * scaleY, 0.0, 0.5 * scaleY + offsetY,
|
|
221
251
|
0.0, 0.0, 1.0, 0.0, // Identity Z (preserving the correct [0, 1] range from the projection matrix)
|
|
222
252
|
0.0, 0.0, 0.0, 1.0
|
|
223
253
|
);
|
|
@@ -225,8 +255,8 @@ class LightShadow {
|
|
|
225
255
|
} else {
|
|
226
256
|
|
|
227
257
|
shadowMatrix.set(
|
|
228
|
-
0.5, 0.0, 0.0, 0.5,
|
|
229
|
-
0.0, 0.5, 0.0, 0.5,
|
|
258
|
+
0.5 * scaleX, 0.0, 0.0, 0.5 * scaleX + offsetX,
|
|
259
|
+
0.0, 0.5 * scaleY, 0.0, 0.5 * scaleY + offsetY,
|
|
230
260
|
0.0, 0.0, 0.5, 0.5,
|
|
231
261
|
0.0, 0.0, 0.0, 1.0
|
|
232
262
|
);
|
|
@@ -329,11 +359,12 @@ class LightShadow {
|
|
|
329
359
|
|
|
330
360
|
const object = {};
|
|
331
361
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
362
|
+
object.intensity = this.intensity;
|
|
363
|
+
object.bias = this.bias;
|
|
364
|
+
object.normalBias = this.normalBias;
|
|
365
|
+
object.radius = this.radius;
|
|
366
|
+
object.blurSamples = this.blurSamples;
|
|
367
|
+
object.mapSize = this.mapSize.toArray();
|
|
337
368
|
|
|
338
369
|
object.camera = this.camera.toJSON( false ).object;
|
|
339
370
|
delete object.camera.matrix;
|
|
@@ -70,11 +70,29 @@ class SpotLightShadow extends LightShadow {
|
|
|
70
70
|
super.copy( source );
|
|
71
71
|
|
|
72
72
|
this.focus = source.focus;
|
|
73
|
+
this.aspect = source.aspect;
|
|
73
74
|
|
|
74
75
|
return this;
|
|
75
76
|
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Serializes the light shadow into JSON.
|
|
81
|
+
*
|
|
82
|
+
* @return {Object} A JSON object representing the serialized light shadow.
|
|
83
|
+
* @see {@link ObjectLoader#parse}
|
|
84
|
+
*/
|
|
85
|
+
toJSON() {
|
|
86
|
+
|
|
87
|
+
const object = super.toJSON();
|
|
88
|
+
|
|
89
|
+
object.focus = this.focus;
|
|
90
|
+
object.aspect = this.aspect;
|
|
91
|
+
|
|
92
|
+
return object;
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
}
|
|
79
97
|
|
|
80
98
|
export { SpotLightShadow };
|
|
@@ -103,6 +103,8 @@ class BufferGeometryLoader extends Loader {
|
|
|
103
103
|
const ib = new InterleavedBuffer( array, interleavedBuffer.stride );
|
|
104
104
|
ib.uuid = interleavedBuffer.uuid;
|
|
105
105
|
|
|
106
|
+
if ( interleavedBuffer.usage !== undefined ) ib.setUsage( interleavedBuffer.usage );
|
|
107
|
+
|
|
106
108
|
interleavedBufferMap[ uuid ] = ib;
|
|
107
109
|
|
|
108
110
|
return ib;
|
|
@@ -157,6 +159,7 @@ class BufferGeometryLoader extends Loader {
|
|
|
157
159
|
|
|
158
160
|
if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
|
|
159
161
|
if ( attribute.usage !== undefined ) bufferAttribute.setUsage( attribute.usage );
|
|
162
|
+
if ( attribute.gpuType !== undefined ) bufferAttribute.gpuType = attribute.gpuType;
|
|
160
163
|
|
|
161
164
|
geometry.setAttribute( key, bufferAttribute );
|
|
162
165
|
|
|
@@ -190,6 +193,8 @@ class BufferGeometryLoader extends Loader {
|
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
|
|
196
|
+
if ( attribute.usage !== undefined ) bufferAttribute.setUsage( attribute.usage );
|
|
197
|
+
if ( attribute.gpuType !== undefined ) bufferAttribute.gpuType = attribute.gpuType;
|
|
193
198
|
array.push( bufferAttribute );
|
|
194
199
|
|
|
195
200
|
}
|
|
@@ -176,7 +176,7 @@ class ImageBitmapLoader extends Loader {
|
|
|
176
176
|
|
|
177
177
|
} ).then( function ( blob ) {
|
|
178
178
|
|
|
179
|
-
return createImageBitmap( blob, Object.assign( scope.options, { colorSpaceConversion: 'none' } ) );
|
|
179
|
+
return createImageBitmap( blob, Object.assign( {}, scope.options, { colorSpaceConversion: 'none' } ) );
|
|
180
180
|
|
|
181
181
|
} ).then( function ( imageBitmap ) {
|
|
182
182
|
|
|
@@ -186,6 +186,8 @@ class ImageBitmapLoader extends Loader {
|
|
|
186
186
|
|
|
187
187
|
scope.manager.itemEnd( url );
|
|
188
188
|
|
|
189
|
+
return imageBitmap; // see #34150
|
|
190
|
+
|
|
189
191
|
} ).catch( function ( e ) {
|
|
190
192
|
|
|
191
193
|
if ( onError ) onError( e );
|
|
@@ -49,7 +49,7 @@ import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
|
|
|
49
49
|
import { Scene } from '../scenes/Scene.js';
|
|
50
50
|
import { CubeTexture } from '../textures/CubeTexture.js';
|
|
51
51
|
import { Texture } from '../textures/Texture.js';
|
|
52
|
-
import {
|
|
52
|
+
import { TextureSource } from '../textures/TextureSource.js';
|
|
53
53
|
import { DataTexture } from '../textures/DataTexture.js';
|
|
54
54
|
import { ImageLoader } from './ImageLoader.js';
|
|
55
55
|
import { LoadingManager } from './LoadingManager.js';
|
|
@@ -548,14 +548,14 @@ class ObjectLoader extends Loader {
|
|
|
548
548
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
images[ image.uuid ] = new
|
|
551
|
+
images[ image.uuid ] = new TextureSource( imageArray );
|
|
552
552
|
|
|
553
553
|
} else {
|
|
554
554
|
|
|
555
555
|
// load single image
|
|
556
556
|
|
|
557
557
|
const deserializedImage = deserializeImage( image.url );
|
|
558
|
-
images[ image.uuid ] = new
|
|
558
|
+
images[ image.uuid ] = new TextureSource( deserializedImage );
|
|
559
559
|
|
|
560
560
|
|
|
561
561
|
}
|
|
@@ -645,14 +645,14 @@ class ObjectLoader extends Loader {
|
|
|
645
645
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
-
images[ image.uuid ] = new
|
|
648
|
+
images[ image.uuid ] = new TextureSource( imageArray );
|
|
649
649
|
|
|
650
650
|
} else {
|
|
651
651
|
|
|
652
652
|
// load single image
|
|
653
653
|
|
|
654
654
|
const deserializedImage = await deserializeImage( image.url );
|
|
655
|
-
images[ image.uuid ] = new
|
|
655
|
+
images[ image.uuid ] = new TextureSource( deserializedImage );
|
|
656
656
|
|
|
657
657
|
}
|
|
658
658
|
|
|
@@ -1166,6 +1166,9 @@ class ObjectLoader extends Loader {
|
|
|
1166
1166
|
if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
|
|
1167
1167
|
if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
|
|
1168
1168
|
if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
|
|
1169
|
+
if ( data.shadow.blurSamples !== undefined ) object.shadow.blurSamples = data.shadow.blurSamples;
|
|
1170
|
+
if ( data.shadow.focus !== undefined ) object.shadow.focus = data.shadow.focus;
|
|
1171
|
+
if ( data.shadow.aspect !== undefined ) object.shadow.aspect = data.shadow.aspect;
|
|
1169
1172
|
if ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize );
|
|
1170
1173
|
if ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera );
|
|
1171
1174
|
|
|
@@ -4,6 +4,7 @@ import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlph
|
|
|
4
4
|
import { generateUUID } from '../math/MathUtils.js';
|
|
5
5
|
import { warn } from '../utils.js';
|
|
6
6
|
import { Vector2 } from '../math/Vector2.js';
|
|
7
|
+
import { Plane } from '../math/Plane.js';
|
|
7
8
|
|
|
8
9
|
let _materialId = 0;
|
|
9
10
|
|
|
@@ -628,10 +629,61 @@ class Material extends EventDispatcher {
|
|
|
628
629
|
};
|
|
629
630
|
|
|
630
631
|
// standard Material serialization
|
|
632
|
+
|
|
631
633
|
data.uuid = this.uuid;
|
|
632
634
|
data.type = this.type;
|
|
633
635
|
|
|
634
|
-
|
|
636
|
+
data.blending = this.blending;
|
|
637
|
+
data.side = this.side;
|
|
638
|
+
data.shadowSide = this.shadowSide;
|
|
639
|
+
data.vertexColors = this.vertexColors;
|
|
640
|
+
|
|
641
|
+
data.opacity = this.opacity;
|
|
642
|
+
data.transparent = this.transparent;
|
|
643
|
+
|
|
644
|
+
data.blendSrc = this.blendSrc;
|
|
645
|
+
data.blendDst = this.blendDst;
|
|
646
|
+
data.blendEquation = this.blendEquation;
|
|
647
|
+
data.blendSrcAlpha = this.blendSrcAlpha;
|
|
648
|
+
data.blendDstAlpha = this.blendDstAlpha;
|
|
649
|
+
data.blendEquationAlpha = this.blendEquationAlpha;
|
|
650
|
+
data.blendColor = this.blendColor.getHex();
|
|
651
|
+
data.blendAlpha = this.blendAlpha;
|
|
652
|
+
|
|
653
|
+
data.depthFunc = this.depthFunc;
|
|
654
|
+
data.depthTest = this.depthTest;
|
|
655
|
+
data.depthWrite = this.depthWrite;
|
|
656
|
+
data.colorWrite = this.colorWrite;
|
|
657
|
+
|
|
658
|
+
data.clipIntersection = this.clipIntersection;
|
|
659
|
+
data.clipShadows = this.clipShadows;
|
|
660
|
+
|
|
661
|
+
data.stencilWriteMask = this.stencilWriteMask;
|
|
662
|
+
data.stencilFunc = this.stencilFunc;
|
|
663
|
+
data.stencilRef = this.stencilRef;
|
|
664
|
+
data.stencilFuncMask = this.stencilFuncMask;
|
|
665
|
+
data.stencilFail = this.stencilFail;
|
|
666
|
+
data.stencilZFail = this.stencilZFail;
|
|
667
|
+
data.stencilZPass = this.stencilZPass;
|
|
668
|
+
data.stencilWrite = this.stencilWrite;
|
|
669
|
+
|
|
670
|
+
data.polygonOffset = this.polygonOffset;
|
|
671
|
+
data.polygonOffsetFactor = this.polygonOffsetFactor;
|
|
672
|
+
data.polygonOffsetUnits = this.polygonOffsetUnits;
|
|
673
|
+
|
|
674
|
+
data.dithering = this.dithering;
|
|
675
|
+
|
|
676
|
+
data.alphaTest = this.alphaTest;
|
|
677
|
+
data.alphaHash = this.alphaHash;
|
|
678
|
+
data.alphaToCoverage = this.alphaToCoverage;
|
|
679
|
+
data.premultipliedAlpha = this.premultipliedAlpha;
|
|
680
|
+
data.forceSinglePass = this.forceSinglePass;
|
|
681
|
+
data.allowOverride = this.allowOverride;
|
|
682
|
+
|
|
683
|
+
data.visible = this.visible;
|
|
684
|
+
data.toneMapped = this.toneMapped;
|
|
685
|
+
|
|
686
|
+
data.name = this.name;
|
|
635
687
|
|
|
636
688
|
if ( this.color && this.color.isColor ) data.color = this.color.getHex();
|
|
637
689
|
|
|
@@ -642,7 +694,7 @@ class Material extends EventDispatcher {
|
|
|
642
694
|
if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
|
|
643
695
|
if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
|
|
644
696
|
if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
|
|
645
|
-
if ( this.emissiveIntensity !== undefined
|
|
697
|
+
if ( this.emissiveIntensity !== undefined ) data.emissiveIntensity = this.emissiveIntensity;
|
|
646
698
|
|
|
647
699
|
if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
|
|
648
700
|
if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
|
|
@@ -683,6 +735,7 @@ class Material extends EventDispatcher {
|
|
|
683
735
|
}
|
|
684
736
|
|
|
685
737
|
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
|
|
738
|
+
if ( this.retroreflectivity !== undefined ) data.retroreflectivity = this.retroreflectivity;
|
|
686
739
|
|
|
687
740
|
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
|
|
688
741
|
if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
|
|
@@ -781,76 +834,39 @@ class Material extends EventDispatcher {
|
|
|
781
834
|
if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
|
|
782
835
|
if ( this.thickness !== undefined ) data.thickness = this.thickness;
|
|
783
836
|
if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
|
|
784
|
-
if ( this.attenuationDistance !== undefined
|
|
837
|
+
if ( this.attenuationDistance !== undefined ) data.attenuationDistance = this.attenuationDistance;
|
|
785
838
|
if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
|
|
786
839
|
|
|
787
840
|
if ( this.size !== undefined ) data.size = this.size;
|
|
788
|
-
if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
|
|
789
841
|
if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;
|
|
790
842
|
|
|
791
|
-
if ( this.
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
if ( this.transparent === true ) data.transparent = true;
|
|
797
|
-
|
|
798
|
-
if ( this.blendSrc !== SrcAlphaFactor ) data.blendSrc = this.blendSrc;
|
|
799
|
-
if ( this.blendDst !== OneMinusSrcAlphaFactor ) data.blendDst = this.blendDst;
|
|
800
|
-
if ( this.blendEquation !== AddEquation ) data.blendEquation = this.blendEquation;
|
|
801
|
-
if ( this.blendSrcAlpha !== null ) data.blendSrcAlpha = this.blendSrcAlpha;
|
|
802
|
-
if ( this.blendDstAlpha !== null ) data.blendDstAlpha = this.blendDstAlpha;
|
|
803
|
-
if ( this.blendEquationAlpha !== null ) data.blendEquationAlpha = this.blendEquationAlpha;
|
|
804
|
-
if ( this.blendColor && this.blendColor.isColor ) data.blendColor = this.blendColor.getHex();
|
|
805
|
-
if ( this.blendAlpha !== 0 ) data.blendAlpha = this.blendAlpha;
|
|
806
|
-
|
|
807
|
-
if ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc;
|
|
808
|
-
if ( this.depthTest === false ) data.depthTest = this.depthTest;
|
|
809
|
-
if ( this.depthWrite === false ) data.depthWrite = this.depthWrite;
|
|
810
|
-
if ( this.colorWrite === false ) data.colorWrite = this.colorWrite;
|
|
811
|
-
|
|
812
|
-
if ( this.stencilWriteMask !== 0xff ) data.stencilWriteMask = this.stencilWriteMask;
|
|
813
|
-
if ( this.stencilFunc !== AlwaysStencilFunc ) data.stencilFunc = this.stencilFunc;
|
|
814
|
-
if ( this.stencilRef !== 0 ) data.stencilRef = this.stencilRef;
|
|
815
|
-
if ( this.stencilFuncMask !== 0xff ) data.stencilFuncMask = this.stencilFuncMask;
|
|
816
|
-
if ( this.stencilFail !== KeepStencilOp ) data.stencilFail = this.stencilFail;
|
|
817
|
-
if ( this.stencilZFail !== KeepStencilOp ) data.stencilZFail = this.stencilZFail;
|
|
818
|
-
if ( this.stencilZPass !== KeepStencilOp ) data.stencilZPass = this.stencilZPass;
|
|
819
|
-
if ( this.stencilWrite === true ) data.stencilWrite = this.stencilWrite;
|
|
843
|
+
if ( Array.isArray( this.clippingPlanes ) && this.clippingPlanes.length > 0 ) {
|
|
844
|
+
|
|
845
|
+
data.clippingPlanes = this.clippingPlanes.map( plane => plane.toJSON() );
|
|
846
|
+
|
|
847
|
+
}
|
|
820
848
|
|
|
821
849
|
// rotation (SpriteMaterial)
|
|
822
|
-
if ( this.rotation !== undefined
|
|
850
|
+
if ( this.rotation !== undefined ) data.rotation = this.rotation;
|
|
823
851
|
|
|
824
|
-
|
|
825
|
-
if ( this.
|
|
826
|
-
if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
|
|
852
|
+
// depthPacking (MeshDepthMaterial)
|
|
853
|
+
if ( this.depthPacking !== undefined ) data.depthPacking = this.depthPacking;
|
|
827
854
|
|
|
828
|
-
if ( this.linewidth !== undefined
|
|
855
|
+
if ( this.linewidth !== undefined ) data.linewidth = this.linewidth;
|
|
856
|
+
if ( this.linecap !== undefined ) data.linecap = this.linecap;
|
|
857
|
+
if ( this.linejoin !== undefined ) data.linejoin = this.linejoin;
|
|
829
858
|
if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
|
|
830
859
|
if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
|
|
831
860
|
if ( this.scale !== undefined ) data.scale = this.scale;
|
|
832
861
|
|
|
833
|
-
if ( this.
|
|
834
|
-
|
|
835
|
-
if ( this.
|
|
836
|
-
if ( this.
|
|
837
|
-
if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
|
|
838
|
-
if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
|
|
839
|
-
if ( this.forceSinglePass === true ) data.forceSinglePass = true;
|
|
840
|
-
if ( this.allowOverride === false ) data.allowOverride = false;
|
|
841
|
-
|
|
842
|
-
if ( this.wireframe === true ) data.wireframe = true;
|
|
843
|
-
if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
|
|
844
|
-
if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
|
|
845
|
-
if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
|
|
846
|
-
|
|
847
|
-
if ( this.flatShading === true ) data.flatShading = true;
|
|
848
|
-
|
|
849
|
-
if ( this.visible === false ) data.visible = false;
|
|
862
|
+
if ( this.wireframe !== undefined ) data.wireframe = this.wireframe;
|
|
863
|
+
if ( this.wireframeLinewidth !== undefined ) data.wireframeLinewidth = this.wireframeLinewidth;
|
|
864
|
+
if ( this.wireframeLinecap !== undefined ) data.wireframeLinecap = this.wireframeLinecap;
|
|
865
|
+
if ( this.wireframeLinejoin !== undefined ) data.wireframeLinejoin = this.wireframeLinejoin;
|
|
850
866
|
|
|
851
|
-
if ( this.
|
|
867
|
+
if ( this.flatShading !== undefined ) data.flatShading = this.flatShading;
|
|
852
868
|
|
|
853
|
-
if ( this.fog
|
|
869
|
+
if ( this.fog !== undefined ) data.fog = this.fog;
|
|
854
870
|
|
|
855
871
|
if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
|
|
856
872
|
|
|
@@ -911,6 +927,7 @@ class Material extends EventDispatcher {
|
|
|
911
927
|
if ( json.clearcoat !== undefined ) this.clearcoat = json.clearcoat;
|
|
912
928
|
if ( json.clearcoatRoughness !== undefined ) this.clearcoatRoughness = json.clearcoatRoughness;
|
|
913
929
|
if ( json.dispersion !== undefined ) this.dispersion = json.dispersion;
|
|
930
|
+
if ( json.retroreflectivity !== undefined ) this.retroreflectivity = json.retroreflectivity;
|
|
914
931
|
if ( json.iridescence !== undefined ) this.iridescence = json.iridescence;
|
|
915
932
|
if ( json.iridescenceIOR !== undefined ) this.iridescenceIOR = json.iridescenceIOR;
|
|
916
933
|
if ( json.iridescenceThicknessRange !== undefined ) this.iridescenceThicknessRange = json.iridescenceThicknessRange;
|
|
@@ -934,6 +951,10 @@ class Material extends EventDispatcher {
|
|
|
934
951
|
if ( json.depthTest !== undefined ) this.depthTest = json.depthTest;
|
|
935
952
|
if ( json.depthWrite !== undefined ) this.depthWrite = json.depthWrite;
|
|
936
953
|
if ( json.colorWrite !== undefined ) this.colorWrite = json.colorWrite;
|
|
954
|
+
if ( json.clippingPlanes !== undefined ) this.clippingPlanes = json.clippingPlanes.map( plane => new Plane().fromJSON( plane ) );
|
|
955
|
+
if ( json.clipIntersection !== undefined ) this.clipIntersection = json.clipIntersection;
|
|
956
|
+
if ( json.clipShadows !== undefined ) this.clipShadows = json.clipShadows;
|
|
957
|
+
if ( json.depthPacking !== undefined ) this.depthPacking = json.depthPacking;
|
|
937
958
|
if ( json.blendSrc !== undefined ) this.blendSrc = json.blendSrc;
|
|
938
959
|
if ( json.blendDst !== undefined ) this.blendDst = json.blendDst;
|
|
939
960
|
if ( json.blendEquation !== undefined ) this.blendEquation = json.blendEquation;
|
|
@@ -959,6 +980,8 @@ class Material extends EventDispatcher {
|
|
|
959
980
|
if ( json.rotation !== undefined ) this.rotation = json.rotation;
|
|
960
981
|
|
|
961
982
|
if ( json.linewidth !== undefined ) this.linewidth = json.linewidth;
|
|
983
|
+
if ( json.linecap !== undefined ) this.linecap = json.linecap;
|
|
984
|
+
if ( json.linejoin !== undefined ) this.linejoin = json.linejoin;
|
|
962
985
|
if ( json.dashSize !== undefined ) this.dashSize = json.dashSize;
|
|
963
986
|
if ( json.gapSize !== undefined ) this.gapSize = json.gapSize;
|
|
964
987
|
if ( json.scale !== undefined ) this.scale = json.scale;
|
|
@@ -19,6 +19,8 @@ import { clamp } from '../math/MathUtils.js';
|
|
|
19
19
|
* transparent materials are less reflective. Physically-based transmission provides a more
|
|
20
20
|
* realistic option for thin, transparent surfaces like glass.
|
|
21
21
|
* - Advanced reflectivity: More flexible reflectivity for non-metallic materials.
|
|
22
|
+
* - Retroreflection: Redirects specular light back toward the light source for
|
|
23
|
+
* safety materials like road markings and reflective tape.
|
|
22
24
|
* - Sheen: Can be used for representing cloth and fabric materials.
|
|
23
25
|
*
|
|
24
26
|
* As a result of these complex shading features, `MeshPhysicalMaterial` has a
|
|
@@ -354,6 +356,7 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
354
356
|
this._clearcoat = 0;
|
|
355
357
|
this._dispersion = 0;
|
|
356
358
|
this._iridescence = 0;
|
|
359
|
+
this._retroreflectivity = 0;
|
|
357
360
|
this._sheen = 0.0;
|
|
358
361
|
this._transmission = 0;
|
|
359
362
|
|
|
@@ -461,6 +464,33 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
461
464
|
|
|
462
465
|
}
|
|
463
466
|
|
|
467
|
+
/**
|
|
468
|
+
* The strength of retroreflection, from `0.0` to `1.0`. A value of `1.0`
|
|
469
|
+
* evaluates the material's microfacet reflection with the view direction
|
|
470
|
+
* reflected about the surface normal, redirecting the specular lobe back
|
|
471
|
+
* toward the light source.
|
|
472
|
+
*
|
|
473
|
+
* @type {number}
|
|
474
|
+
* @default 0
|
|
475
|
+
*/
|
|
476
|
+
get retroreflectivity() {
|
|
477
|
+
|
|
478
|
+
return this._retroreflectivity;
|
|
479
|
+
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
set retroreflectivity( value ) {
|
|
483
|
+
|
|
484
|
+
if ( this._retroreflectivity > 0 !== value > 0 ) {
|
|
485
|
+
|
|
486
|
+
this.version ++;
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
this._retroreflectivity = value;
|
|
491
|
+
|
|
492
|
+
}
|
|
493
|
+
|
|
464
494
|
/**
|
|
465
495
|
* The intensity of the sheen layer, from `0.0` to `1.0`.
|
|
466
496
|
*
|
|
@@ -546,6 +576,8 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
|
|
|
546
576
|
this.iridescenceThicknessRange = [ ...source.iridescenceThicknessRange ];
|
|
547
577
|
this.iridescenceThicknessMap = source.iridescenceThicknessMap;
|
|
548
578
|
|
|
579
|
+
this.retroreflectivity = source.retroreflectivity;
|
|
580
|
+
|
|
549
581
|
this.sheen = source.sheen;
|
|
550
582
|
this.sheenColor.copy( source.sheenColor );
|
|
551
583
|
this.sheenColorMap = source.sheenColorMap;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import NodeMaterial from './NodeMaterial.js';
|
|
2
2
|
import { dashSize, diffuseColor, gapSize, varyingProperty } from '../../nodes/core/PropertyNode.js';
|
|
3
3
|
import { attribute } from '../../nodes/core/AttributeNode.js';
|
|
4
|
-
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
4
|
+
import { cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraWorldMatrix } from '../../nodes/accessors/Camera.js';
|
|
5
5
|
import { materialLineScale, materialLineDashSize, materialLineGapSize, materialLineDashOffset, materialLineWidth } from '../../nodes/accessors/MaterialNode.js';
|
|
6
|
-
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
7
|
-
import { positionGeometry } from '../../nodes/accessors/Position.js';
|
|
6
|
+
import { modelViewMatrix, modelWorldMatrixInverse } from '../../nodes/accessors/ModelNode.js';
|
|
7
|
+
import { positionGeometry, positionLocal, positionPrevious } from '../../nodes/accessors/Position.js';
|
|
8
8
|
import { mix, smoothstep } from '../../nodes/math/MathNode.js';
|
|
9
9
|
import { Fn, float, vec2, vec3, vec4, If } from '../../nodes/tsl/TSLBase.js';
|
|
10
10
|
import { uv } from '../../nodes/accessors/UV.js';
|
|
@@ -518,15 +518,24 @@ class Line2NodeMaterial extends NodeMaterial {
|
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
/**
|
|
521
|
-
* Setups the position
|
|
522
|
-
* Overrides the default model-view-projection to return the expanded fat line vertex coordinates.
|
|
521
|
+
* Setups the position of the expanded fat line vertex in local space.
|
|
523
522
|
*
|
|
524
523
|
* @param {NodeBuilder} builder - The current node builder.
|
|
525
|
-
* @return {Node<
|
|
524
|
+
* @return {Node<vec3>} The position of the fat line vertex in local space.
|
|
526
525
|
*/
|
|
527
|
-
|
|
526
|
+
setupPosition( builder ) {
|
|
528
527
|
|
|
529
|
-
|
|
528
|
+
const localPosition = modelWorldMatrixInverse.mul( cameraWorldMatrix ).mul( cameraProjectionMatrixInverse ).mul( mvpLine );
|
|
529
|
+
|
|
530
|
+
positionLocal.assign( localPosition.xyz.div( localPosition.w ) );
|
|
531
|
+
|
|
532
|
+
if ( builder.needsPreviousData() ) {
|
|
533
|
+
|
|
534
|
+
positionPrevious.assign( positionLocal );
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return super.setupPosition( builder );
|
|
530
539
|
|
|
531
540
|
}
|
|
532
541
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularColorBlended, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor, dispersion } from '../../nodes/core/PropertyNode.js';
|
|
2
|
-
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor, materialDispersion } from '../../nodes/accessors/MaterialNode.js';
|
|
1
|
+
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularColorBlended, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor, dispersion, retroreflectivity } from '../../nodes/core/PropertyNode.js';
|
|
2
|
+
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor, materialDispersion, materialRetroreflectivity } from '../../nodes/accessors/MaterialNode.js';
|
|
3
3
|
import { float, vec2, vec3, If } from '../../nodes/tsl/TSLBase.js';
|
|
4
4
|
import getRoughness from '../../nodes/functions/material/getRoughness.js';
|
|
5
5
|
import { TBNViewMatrix } from '../../nodes/accessors/AccessorsUtils.js';
|
|
@@ -251,6 +251,19 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
251
251
|
*/
|
|
252
252
|
this.dispersionNode = null;
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* The retroreflective strength of physical materials is by default inferred from the
|
|
256
|
+
* `retroreflectivity` property. This node property allows to overwrite the default
|
|
257
|
+
* and define the retroreflective strength with a node instead.
|
|
258
|
+
*
|
|
259
|
+
* If you don't want to overwrite the retroreflective strength but modify the existing
|
|
260
|
+
* value instead, use {@link materialRetroreflectivity}.
|
|
261
|
+
*
|
|
262
|
+
* @type {?Node<float>}
|
|
263
|
+
* @default null
|
|
264
|
+
*/
|
|
265
|
+
this.retroreflectivityNode = null;
|
|
266
|
+
|
|
254
267
|
/**
|
|
255
268
|
* The anisotropy of physical materials is by default inferred from the
|
|
256
269
|
* `anisotropy` property. This node property allows to overwrite the default
|
|
@@ -342,17 +355,31 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
342
355
|
|
|
343
356
|
}
|
|
344
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Whether the lighting model should use retroreflection or not.
|
|
360
|
+
*
|
|
361
|
+
* @type {boolean}
|
|
362
|
+
* @default true
|
|
363
|
+
*/
|
|
364
|
+
get useRetroreflection() {
|
|
365
|
+
|
|
366
|
+
return this.retroreflectivity > 0 || this.retroreflectivityNode !== null;
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
345
370
|
/**
|
|
346
371
|
* Setups the specular related node variables.
|
|
347
372
|
*/
|
|
348
373
|
setupSpecular() {
|
|
349
374
|
|
|
350
375
|
const iorNode = this.iorNode ? float( this.iorNode ) : materialIOR;
|
|
376
|
+
const specularColorNode = this.specularColorNode ? vec3( this.specularColorNode ) : materialSpecularColor;
|
|
377
|
+
const specularIntensityNode = this.specularIntensityNode ? float( this.specularIntensityNode ) : materialSpecularIntensity;
|
|
351
378
|
|
|
352
379
|
ior.assign( iorNode );
|
|
353
|
-
specularColor.assign( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul(
|
|
380
|
+
specularColor.assign( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul( specularColorNode ), vec3( 1.0 ) ).mul( specularIntensityNode ) );
|
|
354
381
|
specularColorBlended.assign( mix( specularColor, diffuseColor.rgb, metalness ) );
|
|
355
|
-
specularF90.assign( mix(
|
|
382
|
+
specularF90.assign( mix( specularIntensityNode, 1.0, metalness ) );
|
|
356
383
|
|
|
357
384
|
}
|
|
358
385
|
|
|
@@ -363,7 +390,7 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
363
390
|
*/
|
|
364
391
|
setupLightingModel( /*builder*/ ) {
|
|
365
392
|
|
|
366
|
-
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission, this.useDispersion );
|
|
393
|
+
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission, this.useDispersion, this.useRetroreflection );
|
|
367
394
|
|
|
368
395
|
}
|
|
369
396
|
|
|
@@ -400,6 +427,16 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
400
427
|
|
|
401
428
|
}
|
|
402
429
|
|
|
430
|
+
// RETROREFLECTION
|
|
431
|
+
|
|
432
|
+
if ( this.useRetroreflection ) {
|
|
433
|
+
|
|
434
|
+
const retroreflectivityNode = this.retroreflectivityNode ? float( this.retroreflectivityNode ) : materialRetroreflectivity;
|
|
435
|
+
|
|
436
|
+
retroreflectivity.assign( retroreflectivityNode );
|
|
437
|
+
|
|
438
|
+
}
|
|
439
|
+
|
|
403
440
|
// IRIDESCENCE
|
|
404
441
|
|
|
405
442
|
if ( this.useIridescence ) {
|