@gnsx/three 0.185.16 → 0.186.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { RenderObjectRefreshType, DynamicDrawUsage } from '../../../constants.js';
|
|
2
|
+
|
|
1
3
|
const refreshUniforms = [
|
|
2
4
|
'alphaMap',
|
|
3
5
|
'alphaTest',
|
|
@@ -9,28 +11,36 @@ const refreshUniforms = [
|
|
|
9
11
|
'attenuationColor',
|
|
10
12
|
'attenuationDistance',
|
|
11
13
|
'bumpMap',
|
|
14
|
+
'bumpScale',
|
|
12
15
|
'clearcoat',
|
|
13
16
|
'clearcoatMap',
|
|
14
17
|
'clearcoatNormalMap',
|
|
15
18
|
'clearcoatNormalScale',
|
|
16
19
|
'clearcoatRoughness',
|
|
17
20
|
'color',
|
|
21
|
+
'dashOffset',
|
|
22
|
+
'dashSize',
|
|
18
23
|
'dispersion',
|
|
24
|
+
'displacementBias',
|
|
19
25
|
'displacementMap',
|
|
26
|
+
'displacementScale',
|
|
20
27
|
'emissive',
|
|
21
28
|
'emissiveIntensity',
|
|
22
29
|
'emissiveMap',
|
|
23
30
|
'envMap',
|
|
24
31
|
'envMapIntensity',
|
|
25
32
|
'envMapRotation',
|
|
33
|
+
'gapSize',
|
|
26
34
|
'gradientMap',
|
|
27
35
|
'ior',
|
|
28
36
|
'iridescence',
|
|
29
37
|
'iridescenceIOR',
|
|
30
38
|
'iridescenceMap',
|
|
39
|
+
'iridescenceThickness',
|
|
31
40
|
'iridescenceThicknessMap',
|
|
32
41
|
'lightMap',
|
|
33
42
|
'lightMapIntensity',
|
|
43
|
+
'linewidth',
|
|
34
44
|
'map',
|
|
35
45
|
'matcap',
|
|
36
46
|
'metalness',
|
|
@@ -38,19 +48,26 @@ const refreshUniforms = [
|
|
|
38
48
|
'normalMap',
|
|
39
49
|
'normalScale',
|
|
40
50
|
'opacity',
|
|
51
|
+
'reflectivity',
|
|
52
|
+
'retroreflectivity',
|
|
53
|
+
'rotation',
|
|
41
54
|
'roughness',
|
|
42
55
|
'roughnessMap',
|
|
56
|
+
'scale',
|
|
43
57
|
'sheen',
|
|
44
58
|
'sheenColor',
|
|
45
59
|
'sheenColorMap',
|
|
60
|
+
'sheenRoughness',
|
|
46
61
|
'sheenRoughnessMap',
|
|
47
62
|
'shininess',
|
|
63
|
+
'size',
|
|
48
64
|
'specular',
|
|
49
65
|
'specularColor',
|
|
50
66
|
'specularColorMap',
|
|
51
67
|
'specularIntensity',
|
|
52
68
|
'specularIntensityMap',
|
|
53
69
|
'specularMap',
|
|
70
|
+
'steps',
|
|
54
71
|
'thickness',
|
|
55
72
|
'transmission',
|
|
56
73
|
'transmissionMap'
|
|
@@ -82,6 +99,14 @@ const _materialCache = new WeakMap();
|
|
|
82
99
|
*/
|
|
83
100
|
const _geometryCache = new WeakMap();
|
|
84
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Holds the texture data for comparison.
|
|
104
|
+
*
|
|
105
|
+
* @private
|
|
106
|
+
* @type {WeakMap<Texture,Object>}
|
|
107
|
+
*/
|
|
108
|
+
const _textureCache = new WeakMap();
|
|
109
|
+
|
|
85
110
|
/**
|
|
86
111
|
* This class is used by {@link WebGPURenderer} as management component.
|
|
87
112
|
* It's primary purpose is to determine whether render objects require a
|
|
@@ -157,6 +182,20 @@ class NodeMaterialObserver {
|
|
|
157
182
|
|
|
158
183
|
}
|
|
159
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Returns `true` if the given 3D object uses instance buffers with dynamic draw usage.
|
|
187
|
+
* Such buffers must be uploaded once per render so the render object requires a full refresh.
|
|
188
|
+
*
|
|
189
|
+
* @param {Object3D} object - The 3D object.
|
|
190
|
+
* @return {boolean} Whether the given 3D object uses instance buffers with dynamic draw usage or not.
|
|
191
|
+
*/
|
|
192
|
+
hasDynamicInstancing( object ) {
|
|
193
|
+
|
|
194
|
+
return object.isInstancedMesh === true && ( object.instanceMatrix.usage === DynamicDrawUsage ||
|
|
195
|
+
( object.instanceColor !== null && object.instanceColor.usage === DynamicDrawUsage ) );
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
160
199
|
/**
|
|
161
200
|
* Returns `true` if the current rendering produces motion vectors.
|
|
162
201
|
*
|
|
@@ -187,6 +226,8 @@ class NodeMaterialObserver {
|
|
|
187
226
|
|
|
188
227
|
data = {
|
|
189
228
|
geometryId: geometry.id,
|
|
229
|
+
geometryVersion: this.getGeometryData( geometry )._version,
|
|
230
|
+
materialVersion: this.getMaterialData( renderObject.material )._version,
|
|
190
231
|
worldMatrix: object.matrixWorld.clone()
|
|
191
232
|
};
|
|
192
233
|
|
|
@@ -202,6 +243,22 @@ class NodeMaterialObserver {
|
|
|
202
243
|
|
|
203
244
|
}
|
|
204
245
|
|
|
246
|
+
if ( object.isInstancedMesh === true ) {
|
|
247
|
+
|
|
248
|
+
data.instanceMatrixVersion = object.instanceMatrix.version;
|
|
249
|
+
data.instanceColorVersion = object.instanceColor !== null ? object.instanceColor.version : null;
|
|
250
|
+
data.morphTextureVersion = object.morphTexture !== null ? object.morphTexture.version : null;
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if ( object.isBatchedMesh === true ) {
|
|
255
|
+
|
|
256
|
+
data.matricesTextureVersion = object._matricesTexture.version;
|
|
257
|
+
data.colorsTextureVersion = object._colorsTexture !== null ? object._colorsTexture.version : null;
|
|
258
|
+
data.indirectTextureVersion = object._indirectTexture.version;
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
205
262
|
if ( renderObject.bundle !== null ) {
|
|
206
263
|
|
|
207
264
|
data.version = renderObject.bundle.version;
|
|
@@ -222,7 +279,7 @@ class NodeMaterialObserver {
|
|
|
222
279
|
data.environmentIntensity = environmentIntensity;
|
|
223
280
|
data.environmentRotation = environmentRotation.clone();
|
|
224
281
|
|
|
225
|
-
data.lights = this.getLightsData( renderObject.lightsNode.
|
|
282
|
+
data.lights = this.getLightsData( renderObject.lightsNode.getBuiltinLights(), [] );
|
|
226
283
|
|
|
227
284
|
this.renderObjects.set( renderObject, data );
|
|
228
285
|
|
|
@@ -298,7 +355,7 @@ class NodeMaterialObserver {
|
|
|
298
355
|
|
|
299
356
|
data = {
|
|
300
357
|
_renderId: - 1,
|
|
301
|
-
|
|
358
|
+
_version: 0,
|
|
302
359
|
|
|
303
360
|
attributes: this.getAttributesData( geometry.attributes ),
|
|
304
361
|
indexId: geometry.index ? geometry.index.id : null,
|
|
@@ -306,6 +363,14 @@ class NodeMaterialObserver {
|
|
|
306
363
|
drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
|
|
307
364
|
};
|
|
308
365
|
|
|
366
|
+
// force refresh on dispose
|
|
367
|
+
|
|
368
|
+
geometry.addEventListener( 'dispose', () => {
|
|
369
|
+
|
|
370
|
+
data._version ++;
|
|
371
|
+
|
|
372
|
+
} );
|
|
373
|
+
|
|
309
374
|
_geometryCache.set( geometry, data );
|
|
310
375
|
|
|
311
376
|
}
|
|
@@ -314,6 +379,47 @@ class NodeMaterialObserver {
|
|
|
314
379
|
|
|
315
380
|
}
|
|
316
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Returns a texture data structure holding the texture state for
|
|
384
|
+
* monitoring.
|
|
385
|
+
*
|
|
386
|
+
* @param {Texture} texture - The texture.
|
|
387
|
+
* @return {Object} An object for monitoring the texture.
|
|
388
|
+
*/
|
|
389
|
+
getTextureData( texture ) {
|
|
390
|
+
|
|
391
|
+
let data = _textureCache.get( texture );
|
|
392
|
+
|
|
393
|
+
if ( data === undefined ) {
|
|
394
|
+
|
|
395
|
+
data = { _version: 0 };
|
|
396
|
+
|
|
397
|
+
// force refresh on dispose
|
|
398
|
+
|
|
399
|
+
const onDispose = () => {
|
|
400
|
+
|
|
401
|
+
data._version ++;
|
|
402
|
+
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
if ( texture.renderTarget !== null ) {
|
|
406
|
+
|
|
407
|
+
texture.renderTarget.addEventListener( 'dispose', onDispose );
|
|
408
|
+
|
|
409
|
+
} else {
|
|
410
|
+
|
|
411
|
+
texture.addEventListener( 'dispose', onDispose );
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
_textureCache.set( texture, data );
|
|
416
|
+
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return data;
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
|
|
317
423
|
/**
|
|
318
424
|
* Returns a material data structure holding the material property values for
|
|
319
425
|
* monitoring.
|
|
@@ -327,19 +433,23 @@ class NodeMaterialObserver {
|
|
|
327
433
|
|
|
328
434
|
if ( data === undefined ) {
|
|
329
435
|
|
|
330
|
-
data = { _renderId: - 1,
|
|
436
|
+
data = { _renderId: - 1, _version: 0 };
|
|
331
437
|
|
|
332
438
|
for ( const property of this.refreshUniforms ) {
|
|
333
439
|
|
|
334
440
|
const value = material[ property ];
|
|
335
441
|
|
|
336
|
-
if ( value ===
|
|
442
|
+
if ( value === undefined ) continue;
|
|
337
443
|
|
|
338
|
-
if (
|
|
444
|
+
if ( value === null ) {
|
|
445
|
+
|
|
446
|
+
data[ property ] = null; // track unset properties
|
|
447
|
+
|
|
448
|
+
} else if ( typeof value === 'object' && value.clone !== undefined ) {
|
|
339
449
|
|
|
340
450
|
if ( value.isTexture === true ) {
|
|
341
451
|
|
|
342
|
-
data[ property ] = { id: value.id, version: 0 };
|
|
452
|
+
data[ property ] = { id: value.id, version: 0, cacheVersion: this.getTextureData( value )._version };
|
|
343
453
|
|
|
344
454
|
} else {
|
|
345
455
|
|
|
@@ -391,40 +501,71 @@ class NodeMaterialObserver {
|
|
|
391
501
|
|
|
392
502
|
const materialData = this.getMaterialData( renderObject.material );
|
|
393
503
|
|
|
394
|
-
// check the material
|
|
504
|
+
// check the material properties just once per render for all render objects
|
|
395
505
|
|
|
396
506
|
if ( materialData._renderId !== renderId ) {
|
|
397
507
|
|
|
398
508
|
materialData._renderId = renderId;
|
|
399
509
|
|
|
510
|
+
let changed = false;
|
|
511
|
+
|
|
400
512
|
for ( const property in materialData ) {
|
|
401
513
|
|
|
402
514
|
const value = materialData[ property ];
|
|
403
515
|
const mtlValue = material[ property ];
|
|
404
516
|
|
|
405
517
|
if ( property === '_renderId' ) continue;
|
|
406
|
-
if ( property === '
|
|
518
|
+
if ( property === '_version' ) continue;
|
|
519
|
+
|
|
520
|
+
if ( value === null || mtlValue === null || mtlValue === undefined ) {
|
|
521
|
+
|
|
522
|
+
// a property was assigned or removed since the last observation so a new snapshot is required
|
|
523
|
+
|
|
524
|
+
if ( value !== ( mtlValue === undefined ? null : mtlValue ) ) {
|
|
525
|
+
|
|
526
|
+
if ( mtlValue === null || mtlValue === undefined ) {
|
|
527
|
+
|
|
528
|
+
materialData[ property ] = null;
|
|
529
|
+
|
|
530
|
+
} else if ( mtlValue.isTexture === true ) {
|
|
531
|
+
|
|
532
|
+
materialData[ property ] = { id: mtlValue.id, version: mtlValue.version, cacheVersion: this.getTextureData( mtlValue )._version };
|
|
533
|
+
|
|
534
|
+
} else if ( typeof mtlValue === 'object' && mtlValue.clone !== undefined ) {
|
|
535
|
+
|
|
536
|
+
materialData[ property ] = mtlValue.clone();
|
|
537
|
+
|
|
538
|
+
} else {
|
|
539
|
+
|
|
540
|
+
materialData[ property ] = mtlValue;
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
changed = true;
|
|
545
|
+
|
|
546
|
+
}
|
|
407
547
|
|
|
408
|
-
if ( value.equals !== undefined ) {
|
|
548
|
+
} else if ( value.equals !== undefined ) {
|
|
409
549
|
|
|
410
550
|
if ( value.equals( mtlValue ) === false ) {
|
|
411
551
|
|
|
412
552
|
value.copy( mtlValue );
|
|
413
553
|
|
|
414
|
-
|
|
415
|
-
return false;
|
|
554
|
+
changed = true;
|
|
416
555
|
|
|
417
556
|
}
|
|
418
557
|
|
|
419
558
|
} else if ( mtlValue.isTexture === true ) {
|
|
420
559
|
|
|
421
|
-
|
|
560
|
+
const textureData = this.getTextureData( mtlValue );
|
|
561
|
+
|
|
562
|
+
if ( value.id !== mtlValue.id || value.version !== mtlValue.version || value.cacheVersion !== textureData._version ) {
|
|
422
563
|
|
|
423
564
|
value.id = mtlValue.id;
|
|
424
565
|
value.version = mtlValue.version;
|
|
566
|
+
value.cacheVersion = textureData._version;
|
|
425
567
|
|
|
426
|
-
|
|
427
|
-
return false;
|
|
568
|
+
changed = true;
|
|
428
569
|
|
|
429
570
|
}
|
|
430
571
|
|
|
@@ -432,34 +573,38 @@ class NodeMaterialObserver {
|
|
|
432
573
|
|
|
433
574
|
materialData[ property ] = mtlValue;
|
|
434
575
|
|
|
435
|
-
|
|
436
|
-
return false;
|
|
576
|
+
changed = true;
|
|
437
577
|
|
|
438
578
|
}
|
|
439
579
|
|
|
440
580
|
}
|
|
441
581
|
|
|
442
|
-
if (
|
|
582
|
+
if ( changed === true ) materialData._version ++;
|
|
443
583
|
|
|
444
|
-
|
|
584
|
+
}
|
|
445
585
|
|
|
446
|
-
|
|
586
|
+
// a version mismatch means the material has changed since this render object was last refreshed
|
|
447
587
|
|
|
448
|
-
|
|
449
|
-
renderObjectData.bufferHeight = height;
|
|
588
|
+
if ( renderObjectData.materialVersion !== materialData._version ) {
|
|
450
589
|
|
|
451
|
-
|
|
452
|
-
return false;
|
|
590
|
+
renderObjectData.materialVersion = materialData._version;
|
|
453
591
|
|
|
454
|
-
|
|
592
|
+
return false;
|
|
455
593
|
|
|
456
|
-
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if ( materialData.transmission > 0 ) {
|
|
457
597
|
|
|
458
|
-
|
|
598
|
+
const { width, height } = renderObject.context;
|
|
459
599
|
|
|
460
|
-
|
|
600
|
+
if ( renderObjectData.bufferWidth !== width || renderObjectData.bufferHeight !== height ) {
|
|
461
601
|
|
|
462
|
-
|
|
602
|
+
renderObjectData.bufferWidth = width;
|
|
603
|
+
renderObjectData.bufferHeight = height;
|
|
604
|
+
|
|
605
|
+
return false;
|
|
606
|
+
|
|
607
|
+
}
|
|
463
608
|
|
|
464
609
|
}
|
|
465
610
|
|
|
@@ -468,18 +613,22 @@ class NodeMaterialObserver {
|
|
|
468
613
|
if ( renderObjectData.geometryId !== geometry.id ) {
|
|
469
614
|
|
|
470
615
|
renderObjectData.geometryId = geometry.id;
|
|
616
|
+
renderObjectData.geometryVersion = this.getGeometryData( geometry )._version;
|
|
617
|
+
|
|
471
618
|
return false;
|
|
472
619
|
|
|
473
620
|
}
|
|
474
621
|
|
|
475
622
|
const geometryData = this.getGeometryData( renderObject.geometry );
|
|
476
623
|
|
|
477
|
-
// check the
|
|
624
|
+
// check the geometry properties just once per render for all render objects
|
|
478
625
|
|
|
479
626
|
if ( geometryData._renderId !== renderId ) {
|
|
480
627
|
|
|
481
628
|
geometryData._renderId = renderId;
|
|
482
629
|
|
|
630
|
+
let changed = false;
|
|
631
|
+
|
|
483
632
|
// attributes
|
|
484
633
|
|
|
485
634
|
const attributes = geometry.attributes;
|
|
@@ -502,8 +651,8 @@ class NodeMaterialObserver {
|
|
|
502
651
|
// attribute was removed
|
|
503
652
|
delete storedAttributes[ name ];
|
|
504
653
|
|
|
505
|
-
|
|
506
|
-
|
|
654
|
+
changed = true;
|
|
655
|
+
continue;
|
|
507
656
|
|
|
508
657
|
}
|
|
509
658
|
|
|
@@ -515,8 +664,7 @@ class NodeMaterialObserver {
|
|
|
515
664
|
storedAttributeData.id = id;
|
|
516
665
|
storedAttributeData.version = version;
|
|
517
666
|
|
|
518
|
-
|
|
519
|
-
return false;
|
|
667
|
+
changed = true;
|
|
520
668
|
|
|
521
669
|
}
|
|
522
670
|
|
|
@@ -526,26 +674,22 @@ class NodeMaterialObserver {
|
|
|
526
674
|
|
|
527
675
|
geometryData.attributes = this.getAttributesData( attributes );
|
|
528
676
|
|
|
529
|
-
|
|
530
|
-
return false;
|
|
677
|
+
changed = true;
|
|
531
678
|
|
|
532
679
|
}
|
|
533
680
|
|
|
534
681
|
// check index
|
|
535
682
|
|
|
536
683
|
const index = geometry.index;
|
|
537
|
-
const storedIndexId = geometryData.indexId;
|
|
538
|
-
const storedIndexVersion = geometryData.indexVersion;
|
|
539
684
|
const currentIndexId = index ? index.id : null;
|
|
540
685
|
const currentIndexVersion = index ? index.version : null;
|
|
541
686
|
|
|
542
|
-
if (
|
|
687
|
+
if ( geometryData.indexId !== currentIndexId || geometryData.indexVersion !== currentIndexVersion ) {
|
|
543
688
|
|
|
544
689
|
geometryData.indexId = currentIndexId;
|
|
545
690
|
geometryData.indexVersion = currentIndexVersion;
|
|
546
691
|
|
|
547
|
-
|
|
548
|
-
return false;
|
|
692
|
+
changed = true;
|
|
549
693
|
|
|
550
694
|
}
|
|
551
695
|
|
|
@@ -556,16 +700,21 @@ class NodeMaterialObserver {
|
|
|
556
700
|
geometryData.drawRange.start = geometry.drawRange.start;
|
|
557
701
|
geometryData.drawRange.count = geometry.drawRange.count;
|
|
558
702
|
|
|
559
|
-
|
|
560
|
-
return false;
|
|
703
|
+
changed = true;
|
|
561
704
|
|
|
562
705
|
}
|
|
563
706
|
|
|
564
|
-
geometryData.
|
|
707
|
+
if ( changed === true ) geometryData._version ++;
|
|
565
708
|
|
|
566
|
-
}
|
|
709
|
+
}
|
|
567
710
|
|
|
568
|
-
|
|
711
|
+
// a version mismatch means the geometry has changed since this render object was last refreshed
|
|
712
|
+
|
|
713
|
+
if ( renderObjectData.geometryVersion !== geometryData._version ) {
|
|
714
|
+
|
|
715
|
+
renderObjectData.geometryVersion = geometryData._version;
|
|
716
|
+
|
|
717
|
+
return false;
|
|
569
718
|
|
|
570
719
|
}
|
|
571
720
|
|
|
@@ -590,13 +739,63 @@ class NodeMaterialObserver {
|
|
|
590
739
|
|
|
591
740
|
}
|
|
592
741
|
|
|
742
|
+
// instancing
|
|
743
|
+
|
|
744
|
+
if ( object.isInstancedMesh === true ) {
|
|
745
|
+
|
|
746
|
+
const instanceColorVersion = object.instanceColor !== null ? object.instanceColor.version : null;
|
|
747
|
+
const morphTextureVersion = object.morphTexture !== null ? object.morphTexture.version : null;
|
|
748
|
+
|
|
749
|
+
if ( renderObjectData.instanceMatrixVersion !== object.instanceMatrix.version ||
|
|
750
|
+
renderObjectData.instanceColorVersion !== instanceColorVersion ||
|
|
751
|
+
renderObjectData.morphTextureVersion !== morphTextureVersion ) {
|
|
752
|
+
|
|
753
|
+
renderObjectData.instanceMatrixVersion = object.instanceMatrix.version;
|
|
754
|
+
renderObjectData.instanceColorVersion = instanceColorVersion;
|
|
755
|
+
renderObjectData.morphTextureVersion = morphTextureVersion;
|
|
756
|
+
|
|
757
|
+
return false;
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// batching
|
|
764
|
+
|
|
765
|
+
if ( object.isBatchedMesh === true ) {
|
|
766
|
+
|
|
767
|
+
const colorsTextureVersion = object._colorsTexture !== null ? object._colorsTexture.version : null;
|
|
768
|
+
|
|
769
|
+
if ( renderObjectData.matricesTextureVersion !== object._matricesTexture.version ||
|
|
770
|
+
renderObjectData.colorsTextureVersion !== colorsTextureVersion ||
|
|
771
|
+
renderObjectData.indirectTextureVersion !== object._indirectTexture.version ) {
|
|
772
|
+
|
|
773
|
+
renderObjectData.matricesTextureVersion = object._matricesTexture.version;
|
|
774
|
+
renderObjectData.colorsTextureVersion = colorsTextureVersion;
|
|
775
|
+
renderObjectData.indirectTextureVersion = object._indirectTexture.version;
|
|
776
|
+
|
|
777
|
+
return false;
|
|
778
|
+
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
}
|
|
782
|
+
|
|
593
783
|
// lights
|
|
594
784
|
|
|
595
785
|
if ( renderObjectData.lights ) {
|
|
596
786
|
|
|
597
787
|
for ( let i = 0; i < lightsData.length; i ++ ) {
|
|
598
788
|
|
|
599
|
-
|
|
789
|
+
const lightData = renderObjectData.lights[ i ];
|
|
790
|
+
const currentLightData = lightsData[ i ];
|
|
791
|
+
|
|
792
|
+
if ( lightData.map !== currentLightData.map || lightData.cacheVersion !== currentLightData.cacheVersion ||
|
|
793
|
+
lightData.shadowMapWidth !== currentLightData.shadowMapWidth || lightData.shadowMapHeight !== currentLightData.shadowMapHeight ) {
|
|
794
|
+
|
|
795
|
+
lightData.map = currentLightData.map;
|
|
796
|
+
lightData.cacheVersion = currentLightData.cacheVersion;
|
|
797
|
+
lightData.shadowMapWidth = currentLightData.shadowMapWidth;
|
|
798
|
+
lightData.shadowMapHeight = currentLightData.shadowMapHeight;
|
|
600
799
|
|
|
601
800
|
return false;
|
|
602
801
|
|
|
@@ -662,14 +861,30 @@ class NodeMaterialObserver {
|
|
|
662
861
|
|
|
663
862
|
for ( const light of materialLights ) {
|
|
664
863
|
|
|
864
|
+
let data = null;
|
|
865
|
+
|
|
665
866
|
if ( light.isSpotLight === true && light.map !== null ) {
|
|
666
867
|
|
|
667
868
|
// only add lights that have a map
|
|
668
869
|
|
|
669
|
-
|
|
870
|
+
data = { map: light.map.version, cacheVersion: this.getTextureData( light.map )._version };
|
|
670
871
|
|
|
671
872
|
}
|
|
672
873
|
|
|
874
|
+
if ( light.castShadow === true && light.shadow !== undefined ) {
|
|
875
|
+
|
|
876
|
+
// resizing a shadow map recreates its textures so the bindings
|
|
877
|
+
// of all related render objects must be updated
|
|
878
|
+
|
|
879
|
+
if ( data === null ) data = {};
|
|
880
|
+
|
|
881
|
+
data.shadowMapWidth = light.shadow.mapSize.width;
|
|
882
|
+
data.shadowMapHeight = light.shadow.mapSize.height;
|
|
883
|
+
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if ( data !== null ) lights.push( data );
|
|
887
|
+
|
|
673
888
|
}
|
|
674
889
|
|
|
675
890
|
return lights;
|
|
@@ -701,7 +916,7 @@ class NodeMaterialObserver {
|
|
|
701
916
|
}
|
|
702
917
|
|
|
703
918
|
cached.renderId = renderId;
|
|
704
|
-
this.getLightsData( lightsNode.
|
|
919
|
+
this.getLightsData( lightsNode.getBuiltinLights(), cached.lightsData );
|
|
705
920
|
|
|
706
921
|
return cached.lightsData;
|
|
707
922
|
|
|
@@ -712,20 +927,27 @@ class NodeMaterialObserver {
|
|
|
712
927
|
*
|
|
713
928
|
* @param {RenderObject} renderObject - The render object.
|
|
714
929
|
* @param {NodeFrame} nodeFrame - The current node frame.
|
|
715
|
-
* @return {
|
|
930
|
+
* @return {number} The refresh type, see {@link RenderObjectRefreshType}.
|
|
716
931
|
*/
|
|
717
932
|
needsRefresh( renderObject, nodeFrame ) {
|
|
718
933
|
|
|
719
|
-
if ( this.hasNode || this.hasAnimation || this.firstInitialization( renderObject ) || this.needsVelocity( nodeFrame.renderer ) )
|
|
720
|
-
return
|
|
934
|
+
if ( this.hasNode || this.hasAnimation || this.hasDynamicInstancing( renderObject.object ) || this.firstInitialization( renderObject ) || this.needsVelocity( nodeFrame.renderer ) )
|
|
935
|
+
return RenderObjectRefreshType.FULL;
|
|
721
936
|
|
|
722
937
|
const { renderId } = nodeFrame;
|
|
723
938
|
|
|
939
|
+
let refreshType = RenderObjectRefreshType.NONE;
|
|
940
|
+
|
|
941
|
+
// shared UBOs are potentially never updated when objects don't change. Below block
|
|
942
|
+
// make sure these UBOs are updated at least once.
|
|
943
|
+
|
|
724
944
|
if ( this.renderId !== renderId ) {
|
|
725
945
|
|
|
726
946
|
this.renderId = renderId;
|
|
727
947
|
|
|
728
|
-
|
|
948
|
+
// no early out here. instead, use the equals() code path below so the internal cache state gets synched
|
|
949
|
+
|
|
950
|
+
refreshType = RenderObjectRefreshType.SHARED;
|
|
729
951
|
|
|
730
952
|
}
|
|
731
953
|
|
|
@@ -733,12 +955,17 @@ class NodeMaterialObserver {
|
|
|
733
955
|
const isBundle = renderObject.bundle !== null && renderObject.bundle.static === true && this.getRenderObjectData( renderObject ).version === renderObject.bundle.version;
|
|
734
956
|
|
|
735
957
|
if ( isStatic || isBundle )
|
|
736
|
-
return
|
|
958
|
+
return refreshType;
|
|
737
959
|
|
|
738
960
|
const lightsData = this.getLights( renderObject.lightsNode, renderId );
|
|
739
|
-
const notEqual = this.equals( renderObject, lightsData, renderId ) !== true;
|
|
740
961
|
|
|
741
|
-
|
|
962
|
+
if ( this.equals( renderObject, lightsData, renderId ) === false ) {
|
|
963
|
+
|
|
964
|
+
refreshType = RenderObjectRefreshType.FULL;
|
|
965
|
+
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return refreshType;
|
|
742
969
|
|
|
743
970
|
}
|
|
744
971
|
|
package/src/math/Frustum.js
CHANGED
|
@@ -187,6 +187,10 @@ class Frustum {
|
|
|
187
187
|
/**
|
|
188
188
|
* Returns `true` if the given bounding sphere is intersecting this frustum.
|
|
189
189
|
*
|
|
190
|
+
* This is a fast, conservative test that favors performance over precision. It can
|
|
191
|
+
* report false positives for spheres that lie outside the frustum but are not separated
|
|
192
|
+
* by a single frustum plane. It never reports false negatives, so it is safe for culling.
|
|
193
|
+
*
|
|
190
194
|
* @param {Sphere} sphere - The bounding sphere to test.
|
|
191
195
|
* @return {boolean} Whether the bounding sphere is intersecting this frustum or not.
|
|
192
196
|
*/
|
|
@@ -215,6 +219,11 @@ class Frustum {
|
|
|
215
219
|
/**
|
|
216
220
|
* Returns `true` if the given bounding box is intersecting this frustum.
|
|
217
221
|
*
|
|
222
|
+
* This is a fast, conservative test that favors performance over precision. It can
|
|
223
|
+
* report false positives for large boxes that lie outside the frustum but are not
|
|
224
|
+
* separated by a single frustum plane. It never reports false negatives, so it is
|
|
225
|
+
* safe for culling.
|
|
226
|
+
*
|
|
218
227
|
* @param {Box3} box - The bounding box to test.
|
|
219
228
|
* @return {boolean} Whether the bounding box is intersecting this frustum or not.
|
|
220
229
|
*/
|
package/src/math/FrustumArray.js
CHANGED
|
@@ -188,7 +188,7 @@ class FrustumArray {
|
|
|
188
188
|
/**
|
|
189
189
|
* Copies the values of the given frustum array to this instance.
|
|
190
190
|
*
|
|
191
|
-
* @param {FrustumArray}
|
|
191
|
+
* @param {FrustumArray} source - The frustum array to copy.
|
|
192
192
|
* @return {FrustumArray} A reference to this frustum array.
|
|
193
193
|
*/
|
|
194
194
|
copy( source ) {
|
package/src/math/MathUtils.js
CHANGED
|
@@ -280,14 +280,14 @@ function radToDeg( radians ) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
|
-
* Returns `true` if the given
|
|
283
|
+
* Returns `true` if the given integer is a power of two.
|
|
284
284
|
*
|
|
285
285
|
* @param {number} value - The value to check.
|
|
286
|
-
* @return {boolean} Whether the given
|
|
286
|
+
* @return {boolean} Whether the given integer is a power of two or not.
|
|
287
287
|
*/
|
|
288
288
|
function isPowerOfTwo( value ) {
|
|
289
289
|
|
|
290
|
-
return ( value
|
|
290
|
+
return value > 0 && Number.isInteger( value ) && 2 ** Math.round( Math.log2( value ) ) === value;
|
|
291
291
|
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -402,6 +402,7 @@ function denormalize( value, array ) {
|
|
|
402
402
|
return value / 65535.0;
|
|
403
403
|
|
|
404
404
|
case Uint8Array:
|
|
405
|
+
case Uint8ClampedArray:
|
|
405
406
|
|
|
406
407
|
return value / 255.0;
|
|
407
408
|
|
|
@@ -449,6 +450,7 @@ function normalize( value, array ) {
|
|
|
449
450
|
return Math.round( value * 65535.0 );
|
|
450
451
|
|
|
451
452
|
case Uint8Array:
|
|
453
|
+
case Uint8ClampedArray:
|
|
452
454
|
|
|
453
455
|
return Math.round( value * 255.0 );
|
|
454
456
|
|