super-three 0.181.0 → 0.184.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +13152 -11354
- package/build/three.core.js +12319 -11539
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1808 -781
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +27 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +10523 -6263
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +10484 -6262
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +11 -3
- package/examples/jsm/animation/CCDIKSolver.js +7 -3
- package/examples/jsm/controls/ArcballControls.js +7 -4
- package/examples/jsm/controls/DragControls.js +2 -2
- package/examples/jsm/controls/FirstPersonControls.js +58 -54
- package/examples/jsm/controls/FlyControls.js +4 -0
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +111 -8
- package/examples/jsm/controls/TrackballControls.js +8 -8
- package/examples/jsm/controls/TransformControls.js +34 -2
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/csm/CSMShadowNode.js +6 -2
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +152 -9
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +18 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +221 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Extension.js +13 -0
- package/examples/jsm/inspector/Inspector.js +203 -88
- package/examples/jsm/inspector/RendererInspector.js +14 -4
- package/examples/jsm/inspector/extensions/extensions.json +6 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +916 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +281 -0
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Memory.js +128 -0
- package/examples/jsm/inspector/tabs/Parameters.js +51 -3
- package/examples/jsm/inspector/tabs/Performance.js +4 -4
- package/examples/jsm/inspector/tabs/Settings.js +264 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1611 -0
- package/examples/jsm/inspector/tabs/Viewer.js +107 -5
- package/examples/jsm/inspector/ui/Graph.js +2 -2
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +1936 -34
- package/examples/jsm/inspector/ui/Style.js +1044 -31
- package/examples/jsm/inspector/ui/Tab.js +222 -3
- package/examples/jsm/inspector/ui/Values.js +55 -2
- package/examples/jsm/inspector/ui/utils.js +13 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +9 -8
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightProbeGrid.js +651 -0
- package/examples/jsm/lines/LineMaterial.js +7 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +687 -48
- package/examples/jsm/loaders/FBXLoader.js +235 -37
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +146 -178
- package/examples/jsm/loaders/HDRLoader.js +1 -2
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +27 -5
- package/examples/jsm/loaders/LDrawLoader.js +41 -50
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +42 -25
- package/examples/jsm/loaders/collada/ColladaComposer.js +3044 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/usd/USDAParser.js +450 -363
- package/examples/jsm/loaders/usd/USDCParser.js +1867 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4594 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/GPUComputationRenderer.js +2 -0
- package/examples/jsm/misc/RollerCoaster.js +42 -4
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/modifiers/TessellateModifier.js +1 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Reflector.js +73 -25
- package/examples/jsm/objects/Sky.js +90 -6
- package/examples/jsm/objects/SkyMesh.js +150 -16
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +246 -28
- package/examples/jsm/renderers/SVGRenderer.js +174 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +63 -6
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/WebGLNodesHandler.js +605 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +11 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +12 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +374 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +3 -36
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FSR1Node.js +477 -0
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +6 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +21 -2
- package/examples/jsm/tsl/display/GodraysNode.js +615 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +69 -19
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -24
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SharpenNode.js +283 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TAAUNode.js +835 -0
- package/examples/jsm/tsl/display/TRAANode.js +315 -126
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +300 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +61 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +111 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +99 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +134 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +161 -0
- package/examples/jsm/tsl/math/Bayer.js +53 -3
- package/examples/jsm/utils/BufferGeometryUtils.js +2 -3
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/SkeletonUtils.js +14 -8
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +36 -10
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -1
- package/package.json +24 -30
- package/src/Three.Core.js +3 -1
- package/src/Three.TSL.js +25 -11
- package/src/Three.WebGPU.Nodes.js +5 -0
- package/src/Three.WebGPU.js +9 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +12 -2
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioContext.js +2 -2
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferAttribute.js +13 -1
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +52 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +4 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/extras/curves/CatmullRomCurve3.js +3 -2
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/AudioLoader.js +11 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/DataTextureLoader.js +6 -4
- package/src/loaders/FileLoader.js +2 -3
- package/src/loaders/ImageBitmapLoader.js +12 -9
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +46 -6
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/loaders/nodes/NodeObjectLoader.js +18 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +34 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +45 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +191 -86
- package/src/math/Line3.js +6 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix2.js +13 -9
- package/src/math/Matrix3.js +13 -9
- package/src/math/Matrix4.js +87 -74
- package/src/math/Plane.js +4 -3
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Triangle.js +1 -1
- package/src/math/Vector2.js +11 -7
- package/src/math/Vector3.js +15 -13
- package/src/math/Vector4.js +13 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +86 -68
- package/src/nodes/TSL.js +7 -7
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +107 -15
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +27 -2
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialProperties.js +2 -5
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +6 -6
- package/src/nodes/accessors/ReferenceNode.js +8 -8
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +14 -25
- package/src/nodes/accessors/StorageTextureNode.js +40 -9
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +67 -23
- package/src/nodes/accessors/UniformArrayNode.js +6 -4
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionCallNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +2 -3
- package/src/nodes/core/ArrayNode.js +21 -2
- package/src/nodes/core/AssignNode.js +3 -3
- package/src/nodes/core/AttributeNode.js +3 -3
- package/src/nodes/core/BypassNode.js +1 -1
- package/src/nodes/core/ContextNode.js +104 -5
- package/src/nodes/core/IndexNode.js +2 -1
- package/src/nodes/core/InputNode.js +1 -1
- package/src/nodes/core/InspectorNode.js +1 -1
- package/src/nodes/core/IsolateNode.js +1 -1
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +112 -15
- package/src/nodes/core/NodeBuilder.js +284 -66
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +11 -9
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +66 -17
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +17 -3
- package/src/nodes/core/StructTypeNode.js +12 -18
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +36 -6
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +48 -23
- package/src/nodes/core/VaryingNode.js +2 -19
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +125 -16
- package/src/nodes/display/RenderOutputNode.js +7 -7
- package/src/nodes/display/ScreenNode.js +4 -2
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportDepthTextureNode.js +11 -15
- package/src/nodes/display/ViewportTextureNode.js +39 -11
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +5 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/BarrierNode.js +9 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -3
- package/src/nodes/gpgpu/ComputeNode.js +74 -48
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +2 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +7 -28
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +120 -42
- package/src/nodes/math/BitcastNode.js +1 -1
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +76 -41
- package/src/nodes/math/OperatorNode.js +3 -2
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLBase.js +1 -1
- package/src/nodes/tsl/TSLCore.js +38 -17
- package/src/nodes/utils/ArrayElementNode.js +14 -1
- package/src/nodes/utils/ConvertNode.js +1 -1
- package/src/nodes/utils/DebugNode.js +12 -12
- package/src/nodes/utils/EventNode.js +31 -2
- package/src/nodes/utils/FlipNode.js +1 -1
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/JoinNode.js +3 -3
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +2 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SetNode.js +1 -1
- package/src/nodes/utils/SplitNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +44 -16
- package/src/objects/InstancedMesh.js +30 -3
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/objects/SkinnedMesh.js +26 -9
- package/src/renderers/WebGLRenderer.js +329 -145
- package/src/renderers/common/Animation.js +3 -3
- package/src/renderers/common/Attributes.js +15 -1
- package/src/renderers/common/Backend.js +29 -8
- package/src/renderers/common/Background.js +26 -13
- package/src/renderers/common/BindGroup.js +1 -16
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +29 -14
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/ComputePipeline.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +51 -7
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Info.js +333 -4
- package/src/renderers/common/InspectorBase.js +6 -1
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +40 -7
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +3 -1
- package/src/renderers/common/RenderBundles.js +7 -3
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +17 -5
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +21 -5
- package/src/renderers/common/RenderPipeline.js +232 -17
- package/src/renderers/common/Renderer.js +481 -117
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +89 -4
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +62 -1
- package/src/renderers/common/XRManager.js +37 -29
- package/src/renderers/common/extras/PMREMGenerator.js +25 -23
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +242 -99
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +8 -12
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +13 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +2 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -53
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +12 -2
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +5 -3
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -6
- package/src/renderers/shaders/UniformsLib.js +7 -5
- package/src/renderers/shaders/UniformsUtils.js +27 -5
- package/src/renderers/webgl/WebGLAnimation.js +2 -1
- package/src/renderers/webgl/WebGLBackground.js +15 -15
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLCapabilities.js +9 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +0 -32
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +24 -13
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +270 -0
- package/src/renderers/webgl/WebGLProgram.js +49 -109
- package/src/renderers/webgl/WebGLPrograms.js +63 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLRenderStates.js +13 -2
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +75 -37
- package/src/renderers/webgl/WebGLTextures.js +215 -54
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +19 -0
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +253 -82
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +0 -41
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +173 -74
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +53 -19
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +25 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +223 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +68 -53
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +10 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +260 -140
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +366 -90
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +107 -34
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +48 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +10 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +156 -59
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +33 -11
- package/src/renderers/webxr/WebXRController.js +12 -0
- package/src/renderers/webxr/WebXRManager.js +4 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +16 -5
- package/src/utils.js +280 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/RemapNode.js +0 -125
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -25,6 +25,16 @@ import {
|
|
|
25
25
|
* sky.scale.setScalar( 10000 );
|
|
26
26
|
* scene.add( sky );
|
|
27
27
|
* ```
|
|
28
|
+
*
|
|
29
|
+
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* // disable before rendering environment map
|
|
33
|
+
* sky.material.uniforms.showSunDisc.value = false;
|
|
34
|
+
* // ...
|
|
35
|
+
* // re-enable before scene sky box rendering
|
|
36
|
+
* sky.material.uniforms.showSunDisc.value = true;
|
|
37
|
+
* ```
|
|
28
38
|
*
|
|
29
39
|
* @augments Mesh
|
|
30
40
|
* @three_import import { Sky } from 'three/addons/objects/Sky.js';
|
|
@@ -72,7 +82,14 @@ Sky.SkyShader = {
|
|
|
72
82
|
'mieCoefficient': { value: 0.005 },
|
|
73
83
|
'mieDirectionalG': { value: 0.8 },
|
|
74
84
|
'sunPosition': { value: new Vector3() },
|
|
75
|
-
'up': { value: new Vector3( 0, 1, 0 ) }
|
|
85
|
+
'up': { value: new Vector3( 0, 1, 0 ) },
|
|
86
|
+
'cloudScale': { value: 0.0002 },
|
|
87
|
+
'cloudSpeed': { value: 0.0001 },
|
|
88
|
+
'cloudCoverage': { value: 0.4 },
|
|
89
|
+
'cloudDensity': { value: 0.4 },
|
|
90
|
+
'cloudElevation': { value: 0.5 },
|
|
91
|
+
'showSunDisc': { value: 1 },
|
|
92
|
+
'time': { value: 0.0 }
|
|
76
93
|
},
|
|
77
94
|
|
|
78
95
|
vertexShader: /* glsl */`
|
|
@@ -150,13 +167,46 @@ Sky.SkyShader = {
|
|
|
150
167
|
fragmentShader: /* glsl */`
|
|
151
168
|
varying vec3 vWorldPosition;
|
|
152
169
|
varying vec3 vSunDirection;
|
|
153
|
-
varying float vSunfade;
|
|
154
170
|
varying vec3 vBetaR;
|
|
155
171
|
varying vec3 vBetaM;
|
|
156
172
|
varying float vSunE;
|
|
157
173
|
|
|
158
174
|
uniform float mieDirectionalG;
|
|
159
175
|
uniform vec3 up;
|
|
176
|
+
uniform float cloudScale;
|
|
177
|
+
uniform float cloudSpeed;
|
|
178
|
+
uniform float cloudCoverage;
|
|
179
|
+
uniform float cloudDensity;
|
|
180
|
+
uniform float cloudElevation;
|
|
181
|
+
uniform float showSunDisc;
|
|
182
|
+
uniform float time;
|
|
183
|
+
|
|
184
|
+
// Cloud noise functions
|
|
185
|
+
float hash( vec2 p ) {
|
|
186
|
+
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
float noise( vec2 p ) {
|
|
190
|
+
vec2 i = floor( p );
|
|
191
|
+
vec2 f = fract( p );
|
|
192
|
+
f = f * f * ( 3.0 - 2.0 * f );
|
|
193
|
+
float a = hash( i );
|
|
194
|
+
float b = hash( i + vec2( 1.0, 0.0 ) );
|
|
195
|
+
float c = hash( i + vec2( 0.0, 1.0 ) );
|
|
196
|
+
float d = hash( i + vec2( 1.0, 1.0 ) );
|
|
197
|
+
return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y );
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
float fbm( vec2 p ) {
|
|
201
|
+
float value = 0.0;
|
|
202
|
+
float amplitude = 0.5;
|
|
203
|
+
for ( int i = 0; i < 5; i ++ ) {
|
|
204
|
+
value += amplitude * noise( p );
|
|
205
|
+
p *= 2.0;
|
|
206
|
+
amplitude *= 0.5;
|
|
207
|
+
}
|
|
208
|
+
return value;
|
|
209
|
+
}
|
|
160
210
|
|
|
161
211
|
// constants for atmospheric scattering
|
|
162
212
|
const float pi = 3.141592653589793238462643383279502884197169;
|
|
@@ -218,14 +268,48 @@ Sky.SkyShader = {
|
|
|
218
268
|
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
219
269
|
|
|
220
270
|
// composition + solar disc
|
|
221
|
-
float
|
|
222
|
-
L0 += ( vSunE * 19000.0 * Fex ) *
|
|
271
|
+
float sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ) * showSunDisc;
|
|
272
|
+
L0 += ( vSunE * 19000.0 * Fex ) * sundisc;
|
|
223
273
|
|
|
224
274
|
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
225
275
|
|
|
226
|
-
|
|
276
|
+
// Clouds
|
|
277
|
+
if ( direction.y > 0.0 && cloudCoverage > 0.0 ) {
|
|
278
|
+
|
|
279
|
+
// Project to cloud plane (higher elevation = clouds appear lower/closer)
|
|
280
|
+
float elevation = mix( 1.0, 0.1, cloudElevation );
|
|
281
|
+
vec2 cloudUV = direction.xz / ( direction.y * elevation );
|
|
282
|
+
cloudUV *= cloudScale;
|
|
283
|
+
cloudUV += time * cloudSpeed;
|
|
284
|
+
|
|
285
|
+
// Multi-octave noise for fluffy clouds
|
|
286
|
+
float cloudNoise = fbm( cloudUV * 1000.0 );
|
|
287
|
+
cloudNoise += 0.5 * fbm( cloudUV * 2000.0 + 3.7 );
|
|
288
|
+
cloudNoise = cloudNoise * 0.5 + 0.5;
|
|
289
|
+
|
|
290
|
+
// Apply coverage threshold
|
|
291
|
+
float cloudMask = smoothstep( 1.0 - cloudCoverage, 1.0 - cloudCoverage + 0.3, cloudNoise );
|
|
292
|
+
|
|
293
|
+
// Fade clouds near horizon (adjusted by elevation)
|
|
294
|
+
float horizonFade = smoothstep( 0.0, 0.1 + 0.2 * cloudElevation, direction.y );
|
|
295
|
+
cloudMask *= horizonFade;
|
|
296
|
+
|
|
297
|
+
// Cloud lighting based on sun position
|
|
298
|
+
float sunInfluence = dot( direction, vSunDirection ) * 0.5 + 0.5;
|
|
299
|
+
float daylight = max( 0.0, vSunDirection.y * 2.0 );
|
|
300
|
+
|
|
301
|
+
// Base cloud color affected by atmosphere
|
|
302
|
+
vec3 atmosphereColor = Lin * 0.04;
|
|
303
|
+
vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight );
|
|
304
|
+
cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 );
|
|
305
|
+
cloudColor *= vSunE * 0.00002;
|
|
306
|
+
|
|
307
|
+
// Blend clouds with sky
|
|
308
|
+
texColor = mix( texColor, cloudColor, cloudMask * cloudDensity );
|
|
309
|
+
|
|
310
|
+
}
|
|
227
311
|
|
|
228
|
-
gl_FragColor = vec4(
|
|
312
|
+
gl_FragColor = vec4( texColor, 1.0 );
|
|
229
313
|
|
|
230
314
|
#include <tonemapping_fragment>
|
|
231
315
|
#include <colorspace_fragment>
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
NodeMaterial
|
|
7
7
|
} from 'three/webgpu';
|
|
8
8
|
|
|
9
|
-
import { Fn, float, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition } from 'three/tsl';
|
|
9
|
+
import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition, fract, floor, sin, time, Loop, If } from 'three/tsl';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a skydome for scene backgrounds. Based on [A Practical Analytic Model for Daylight](https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight)
|
|
13
13
|
* aka The Preetham Model, the de facto standard for analytical skydomes.
|
|
14
14
|
*
|
|
15
|
-
* Note that this class can only be used with {@link
|
|
16
|
-
* When using {@link
|
|
15
|
+
* Note that this class can only be used with {@link WebGPURenderer}.
|
|
16
|
+
* When using {@link WebGLRenderer}, use {@link Sky}.
|
|
17
17
|
*
|
|
18
18
|
* More references:
|
|
19
19
|
*
|
|
@@ -26,6 +26,16 @@ import { Fn, float, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelV
|
|
|
26
26
|
* scene.add( sky );
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
+
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* // disable before rendering environment map
|
|
33
|
+
* sky.showSunDisc.value = false;
|
|
34
|
+
* // ...
|
|
35
|
+
* // re-enable before scene sky box rendering
|
|
36
|
+
* sky.showSunDisc.value = true;
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
29
39
|
* @augments Mesh
|
|
30
40
|
* @three_import import { SkyMesh } from 'three/addons/objects/SkyMesh.js';
|
|
31
41
|
*/
|
|
@@ -82,6 +92,58 @@ class SkyMesh extends Mesh {
|
|
|
82
92
|
*/
|
|
83
93
|
this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
|
|
84
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The cloud scale uniform.
|
|
97
|
+
*
|
|
98
|
+
* @type {UniformNode<float>}
|
|
99
|
+
*/
|
|
100
|
+
this.cloudScale = uniform( 0.0002 );
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The cloud speed uniform.
|
|
104
|
+
*
|
|
105
|
+
* @type {UniformNode<float>}
|
|
106
|
+
*/
|
|
107
|
+
this.cloudSpeed = uniform( 0.0001 );
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The cloud coverage uniform.
|
|
111
|
+
*
|
|
112
|
+
* @type {UniformNode<float>}
|
|
113
|
+
*/
|
|
114
|
+
this.cloudCoverage = uniform( 0.4 );
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The cloud density uniform.
|
|
118
|
+
*
|
|
119
|
+
* @type {UniformNode<float>}
|
|
120
|
+
*/
|
|
121
|
+
this.cloudDensity = uniform( 0.4 );
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The cloud elevation uniform.
|
|
125
|
+
*
|
|
126
|
+
* @type {UniformNode<float>}
|
|
127
|
+
*/
|
|
128
|
+
this.cloudElevation = uniform( 0.5 );
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Whether to render the solar disc.
|
|
132
|
+
*
|
|
133
|
+
* @type {UniformNode<float>}
|
|
134
|
+
*/
|
|
135
|
+
this.showSunDisc = uniform( 1 );
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* This flag can be used for type testing.
|
|
139
|
+
*
|
|
140
|
+
* @type {boolean}
|
|
141
|
+
* @readonly
|
|
142
|
+
* @default true
|
|
143
|
+
* @deprecated Use isSkyMesh instead.
|
|
144
|
+
*/
|
|
145
|
+
this.isSky = true; // @deprecated, r182
|
|
146
|
+
|
|
85
147
|
/**
|
|
86
148
|
* This flag can be used for type testing.
|
|
87
149
|
*
|
|
@@ -89,21 +151,20 @@ class SkyMesh extends Mesh {
|
|
|
89
151
|
* @readonly
|
|
90
152
|
* @default true
|
|
91
153
|
*/
|
|
92
|
-
this.
|
|
154
|
+
this.isSkyMesh = true;
|
|
93
155
|
|
|
94
156
|
// Varyings
|
|
95
157
|
|
|
96
158
|
const vSunDirection = varyingProperty( 'vec3' );
|
|
97
159
|
const vSunE = varyingProperty( 'float' );
|
|
98
|
-
const vSunfade = varyingProperty( 'float' );
|
|
99
160
|
const vBetaR = varyingProperty( 'vec3' );
|
|
100
161
|
const vBetaM = varyingProperty( 'vec3' );
|
|
101
162
|
|
|
102
163
|
const vertexNode = /*@__PURE__*/ Fn( () => {
|
|
103
164
|
|
|
104
165
|
// constants for atmospheric scattering
|
|
105
|
-
const e = float( 2.
|
|
106
|
-
// const pi = float( 3.
|
|
166
|
+
const e = float( 2.718281828459045 );
|
|
167
|
+
// const pi = float( 3.141592653589793 );
|
|
107
168
|
|
|
108
169
|
// wavelength of used primaries, according to preetham
|
|
109
170
|
// const lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
@@ -136,10 +197,9 @@ class SkyMesh extends Mesh {
|
|
|
136
197
|
const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
|
|
137
198
|
vSunE.assign( sunIntensity );
|
|
138
199
|
|
|
139
|
-
//
|
|
200
|
+
// sun fade
|
|
140
201
|
|
|
141
202
|
const sunfade = float( 1.0 ).sub( clamp( float( 1.0 ).sub( exp( this.sunPosition.y.div( 450000.0 ) ) ), 0, 1 ) );
|
|
142
|
-
vSunfade.assign( sunfade );
|
|
143
203
|
|
|
144
204
|
// varying vBetaR
|
|
145
205
|
|
|
@@ -168,13 +228,13 @@ class SkyMesh extends Mesh {
|
|
|
168
228
|
const colorNode = /*@__PURE__*/ Fn( () => {
|
|
169
229
|
|
|
170
230
|
// constants for atmospheric scattering
|
|
171
|
-
const pi = float( 3.
|
|
231
|
+
const pi = float( 3.141592653589793 );
|
|
172
232
|
|
|
173
233
|
// optical length at zenith for molecules
|
|
174
234
|
const rayleighZenithLength = float( 8.4E3 );
|
|
175
235
|
const mieZenithLength = float( 1.25E3 );
|
|
176
236
|
// 66 arc seconds -> degrees, and the cosine of that
|
|
177
|
-
const sunAngularDiameterCos = float( 0.
|
|
237
|
+
const sunAngularDiameterCos = float( 0.9999566769464484 );
|
|
178
238
|
|
|
179
239
|
// 3.0 / ( 16.0 * pi )
|
|
180
240
|
const THREE_OVER_SIXTEENPI = float( 0.05968310365946075 );
|
|
@@ -219,14 +279,88 @@ class SkyMesh extends Mesh {
|
|
|
219
279
|
const L0 = vec3( 0.1 ).mul( Fex );
|
|
220
280
|
|
|
221
281
|
// composition + solar disc
|
|
222
|
-
const
|
|
223
|
-
L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul(
|
|
282
|
+
const sundisc = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta ).mul( this.showSunDisc );
|
|
283
|
+
L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisc ) );
|
|
284
|
+
|
|
285
|
+
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
|
|
286
|
+
|
|
287
|
+
// Cloud noise functions
|
|
288
|
+
const hash = Fn( ( [ p ] ) => {
|
|
289
|
+
|
|
290
|
+
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ).mul( 43758.5453123 ) );
|
|
291
|
+
|
|
292
|
+
} );
|
|
293
|
+
|
|
294
|
+
const noise = Fn( ( [ p_immutable ] ) => {
|
|
295
|
+
|
|
296
|
+
const p = vec2( p_immutable ).toVar();
|
|
297
|
+
const i = floor( p );
|
|
298
|
+
const f = fract( p );
|
|
299
|
+
const ff = f.mul( f ).mul( sub( 3.0, f.mul( 2.0 ) ) );
|
|
300
|
+
|
|
301
|
+
const a = hash( i );
|
|
302
|
+
const b = hash( add( i, vec2( 1.0, 0.0 ) ) );
|
|
303
|
+
const c = hash( add( i, vec2( 0.0, 1.0 ) ) );
|
|
304
|
+
const d = hash( add( i, vec2( 1.0, 1.0 ) ) );
|
|
305
|
+
|
|
306
|
+
return mix( mix( a, b, ff.x ), mix( c, d, ff.x ), ff.y );
|
|
307
|
+
|
|
308
|
+
} );
|
|
309
|
+
|
|
310
|
+
const fbm = Fn( ( [ p_immutable ] ) => {
|
|
311
|
+
|
|
312
|
+
const p = vec2( p_immutable ).toVar();
|
|
313
|
+
const value = float( 0.0 ).toVar();
|
|
314
|
+
const amplitude = float( 0.5 ).toVar();
|
|
315
|
+
|
|
316
|
+
Loop( 5, () => {
|
|
317
|
+
|
|
318
|
+
value.addAssign( amplitude.mul( noise( p ) ) );
|
|
319
|
+
p.mulAssign( 2.0 );
|
|
320
|
+
amplitude.mulAssign( 0.5 );
|
|
321
|
+
|
|
322
|
+
} );
|
|
323
|
+
|
|
324
|
+
return value;
|
|
325
|
+
|
|
326
|
+
} );
|
|
327
|
+
|
|
328
|
+
// Clouds
|
|
329
|
+
If( direction.y.greaterThan( 0.0 ).and( this.cloudCoverage.greaterThan( 0.0 ) ), () => {
|
|
330
|
+
|
|
331
|
+
// Project to cloud plane (higher elevation = clouds appear lower/closer)
|
|
332
|
+
const elevation = mix( 1.0, 0.1, this.cloudElevation );
|
|
333
|
+
const cloudUV = direction.xz.div( direction.y.mul( elevation ) ).toVar();
|
|
334
|
+
cloudUV.mulAssign( this.cloudScale );
|
|
335
|
+
cloudUV.addAssign( time.mul( this.cloudSpeed ) );
|
|
336
|
+
|
|
337
|
+
// Multi-octave noise for fluffy clouds
|
|
338
|
+
const cloudNoise = fbm( cloudUV.mul( 1000.0 ) ).add( fbm( cloudUV.mul( 2000.0 ).add( 3.7 ) ).mul( 0.5 ) ).toVar();
|
|
339
|
+
cloudNoise.assign( cloudNoise.mul( 0.5 ).add( 0.5 ) );
|
|
340
|
+
|
|
341
|
+
// Apply coverage threshold
|
|
342
|
+
const cloudMask = smoothstep( sub( 1.0, this.cloudCoverage ), sub( 1.0, this.cloudCoverage ).add( 0.3 ), cloudNoise ).toVar();
|
|
343
|
+
|
|
344
|
+
// Fade clouds near horizon (adjusted by elevation)
|
|
345
|
+
const horizonFade = smoothstep( 0.0, add( 0.1, mul( 0.2, this.cloudElevation ) ), direction.y );
|
|
346
|
+
cloudMask.mulAssign( horizonFade );
|
|
347
|
+
|
|
348
|
+
// Cloud lighting based on sun position
|
|
349
|
+
const sunInfluence = dot( direction, vSunDirection ).mul( 0.5 ).add( 0.5 );
|
|
350
|
+
const daylight = max( 0.0, vSunDirection.y.mul( 2.0 ) );
|
|
351
|
+
|
|
352
|
+
// Base cloud color affected by atmosphere
|
|
353
|
+
const atmosphereColor = Lin.mul( 0.04 );
|
|
354
|
+
const cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight ).toVar();
|
|
355
|
+
cloudColor.assign( mix( cloudColor, atmosphereColor.add( vec3( 1.0 ) ), sunInfluence.mul( 0.5 ) ) );
|
|
356
|
+
cloudColor.mulAssign( vSunE.mul( 0.00002 ) );
|
|
224
357
|
|
|
225
|
-
|
|
358
|
+
// Blend clouds with sky
|
|
359
|
+
texColor.assign( mix( texColor, cloudColor, cloudMask.mul( this.cloudDensity ) ) );
|
|
226
360
|
|
|
227
|
-
|
|
361
|
+
} );
|
|
228
362
|
|
|
229
|
-
return vec4(
|
|
363
|
+
return vec4( texColor, 1.0 );
|
|
230
364
|
|
|
231
365
|
} )();
|
|
232
366
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Color,
|
|
3
3
|
FrontSide,
|
|
4
|
+
HalfFloatType,
|
|
4
5
|
Matrix4,
|
|
5
6
|
Mesh,
|
|
6
7
|
PerspectiveCamera,
|
|
@@ -84,7 +85,7 @@ class Water extends Mesh {
|
|
|
84
85
|
|
|
85
86
|
const mirrorCamera = new PerspectiveCamera();
|
|
86
87
|
|
|
87
|
-
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
|
|
88
|
+
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { type: HalfFloatType } );
|
|
88
89
|
|
|
89
90
|
const mirrorShader = {
|
|
90
91
|
|
|
@@ -196,10 +197,10 @@ class Water extends Mesh {
|
|
|
196
197
|
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
197
198
|
|
|
198
199
|
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
199
|
-
float rf0 = 0.
|
|
200
|
+
float rf0 = 0.02;
|
|
200
201
|
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
201
202
|
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
202
|
-
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(),
|
|
203
|
+
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), reflectionSample + specularLight, reflectance );
|
|
203
204
|
vec3 outgoingLight = albedo;
|
|
204
205
|
gl_FragColor = vec4( outgoingLight, alpha );
|
|
205
206
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Timer,
|
|
3
3
|
Color,
|
|
4
4
|
Matrix4,
|
|
5
5
|
Mesh,
|
|
@@ -74,7 +74,7 @@ class Water extends Mesh {
|
|
|
74
74
|
const cycle = 0.15; // a cycle of a flow map phase
|
|
75
75
|
const halfCycle = cycle * 0.5;
|
|
76
76
|
const textureMatrix = new Matrix4();
|
|
77
|
-
const
|
|
77
|
+
const timer = new Timer();
|
|
78
78
|
|
|
79
79
|
// internal components
|
|
80
80
|
|
|
@@ -180,7 +180,7 @@ class Water extends Mesh {
|
|
|
180
180
|
|
|
181
181
|
function updateFlow() {
|
|
182
182
|
|
|
183
|
-
const delta =
|
|
183
|
+
const delta = timer.getDelta();
|
|
184
184
|
const config = scope.material.uniforms[ 'config' ];
|
|
185
185
|
|
|
186
186
|
config.value.x += flowSpeed * delta; // flowMapOffset0
|
|
@@ -207,6 +207,8 @@ class Water extends Mesh {
|
|
|
207
207
|
|
|
208
208
|
this.onBeforeRender = function ( renderer, scene, camera ) {
|
|
209
209
|
|
|
210
|
+
timer.update();
|
|
211
|
+
|
|
210
212
|
updateTextureMatrix( camera );
|
|
211
213
|
updateFlow();
|
|
212
214
|
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
Color,
|
|
3
3
|
Mesh,
|
|
4
4
|
Vector3,
|
|
5
|
-
|
|
5
|
+
NodeMaterial
|
|
6
6
|
} from 'three/webgpu';
|
|
7
7
|
|
|
8
|
-
import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2,
|
|
8
|
+
import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix } from 'three/tsl';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A basic flat, reflective water effect.
|
|
@@ -32,7 +32,7 @@ class WaterMesh extends Mesh {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor( geometry, options ) {
|
|
34
34
|
|
|
35
|
-
const material = new
|
|
35
|
+
const material = new NodeMaterial();
|
|
36
36
|
|
|
37
37
|
super( geometry, material );
|
|
38
38
|
|
|
@@ -155,8 +155,6 @@ class WaterMesh extends Mesh {
|
|
|
155
155
|
|
|
156
156
|
material.receivedShadowPositionNode = positionWorld.add( distortion );
|
|
157
157
|
|
|
158
|
-
material.setupOutgoingLight = () => diffuseColor.rgb; // backwards compatibility
|
|
159
|
-
|
|
160
158
|
material.colorNode = Fn( () => {
|
|
161
159
|
|
|
162
160
|
const mirrorSampler = reflector();
|
|
@@ -166,10 +164,10 @@ class WaterMesh extends Mesh {
|
|
|
166
164
|
this.add( mirrorSampler.target );
|
|
167
165
|
|
|
168
166
|
const theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
169
|
-
const rf0 = float( 0.
|
|
167
|
+
const rf0 = float( 0.02 );
|
|
170
168
|
const reflectance = mul( pow( float( 1.0 ).sub( theta ), 5.0 ), float( 1.0 ).sub( rf0 ) ).add( rf0 );
|
|
171
169
|
const scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ).mul( this.waterColor );
|
|
172
|
-
const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.
|
|
170
|
+
const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.add( specularLight ), reflectance );
|
|
173
171
|
|
|
174
172
|
return albedo;
|
|
175
173
|
|
|
@@ -23,7 +23,7 @@ async function AmmoPhysics() {
|
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const AmmoLib = await Ammo();
|
|
26
|
+
const AmmoLib = await Ammo();
|
|
27
27
|
|
|
28
28
|
const frameRate = 60;
|
|
29
29
|
|
|
@@ -66,6 +66,8 @@ async function AmmoPhysics() {
|
|
|
66
66
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
console.error( 'AmmoPhysics: Unsupported geometry type:', geometry.type );
|
|
70
|
+
|
|
69
71
|
return null;
|
|
70
72
|
|
|
71
73
|
}
|
|
@@ -83,7 +85,7 @@ async function AmmoPhysics() {
|
|
|
83
85
|
|
|
84
86
|
if ( physics ) {
|
|
85
87
|
|
|
86
|
-
addMesh( child, physics.mass );
|
|
88
|
+
addMesh( child, physics.mass, physics.restitution );
|
|
87
89
|
|
|
88
90
|
}
|
|
89
91
|
|
|
@@ -93,7 +95,7 @@ async function AmmoPhysics() {
|
|
|
93
95
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
function addMesh( mesh, mass = 0 ) {
|
|
98
|
+
function addMesh( mesh, mass = 0, restitution = 0 ) {
|
|
97
99
|
|
|
98
100
|
const shape = getShape( mesh.geometry );
|
|
99
101
|
|
|
@@ -101,11 +103,11 @@ async function AmmoPhysics() {
|
|
|
101
103
|
|
|
102
104
|
if ( mesh.isInstancedMesh ) {
|
|
103
105
|
|
|
104
|
-
handleInstancedMesh( mesh, mass,
|
|
106
|
+
handleInstancedMesh( mesh, shape, mass, restitution );
|
|
105
107
|
|
|
106
108
|
} else if ( mesh.isMesh ) {
|
|
107
109
|
|
|
108
|
-
handleMesh( mesh, mass,
|
|
110
|
+
handleMesh( mesh, shape, mass, restitution );
|
|
109
111
|
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -113,7 +115,7 @@ async function AmmoPhysics() {
|
|
|
113
115
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
function handleMesh( mesh, mass,
|
|
118
|
+
function handleMesh( mesh, shape, mass, restitution ) {
|
|
117
119
|
|
|
118
120
|
const position = mesh.position;
|
|
119
121
|
const quaternion = mesh.quaternion;
|
|
@@ -129,6 +131,7 @@ async function AmmoPhysics() {
|
|
|
129
131
|
shape.calculateLocalInertia( mass, localInertia );
|
|
130
132
|
|
|
131
133
|
const rbInfo = new AmmoLib.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia );
|
|
134
|
+
rbInfo.set_m_restitution( restitution );
|
|
132
135
|
|
|
133
136
|
const body = new AmmoLib.btRigidBody( rbInfo );
|
|
134
137
|
// body.setFriction( 4 );
|
|
@@ -144,7 +147,7 @@ async function AmmoPhysics() {
|
|
|
144
147
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
function handleInstancedMesh( mesh, mass,
|
|
150
|
+
function handleInstancedMesh( mesh, shape, mass, restitution ) {
|
|
148
151
|
|
|
149
152
|
const array = mesh.instanceMatrix.array;
|
|
150
153
|
|
|
@@ -163,6 +166,7 @@ async function AmmoPhysics() {
|
|
|
163
166
|
shape.calculateLocalInertia( mass, localInertia );
|
|
164
167
|
|
|
165
168
|
const rbInfo = new AmmoLib.btRigidBodyConstructionInfo( mass, motionState, shape, localInertia );
|
|
169
|
+
rbInfo.set_m_restitution( restitution );
|
|
166
170
|
|
|
167
171
|
const body = new AmmoLib.btRigidBody( rbInfo );
|
|
168
172
|
world.addRigidBody( body );
|
|
@@ -302,6 +306,7 @@ async function AmmoPhysics() {
|
|
|
302
306
|
* @name AmmoPhysics#addMesh
|
|
303
307
|
* @param {Mesh} mesh The mesh to add.
|
|
304
308
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
309
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
305
310
|
*/
|
|
306
311
|
addMesh: addMesh,
|
|
307
312
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
|
|
2
2
|
|
|
3
|
-
const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@0.
|
|
3
|
+
const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@1.0.0/dist/jolt-physics.wasm-compat.js';
|
|
4
4
|
|
|
5
5
|
const frameRate = 60;
|
|
6
6
|
|
|
@@ -28,6 +28,8 @@ function getShape( geometry ) {
|
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
console.error( 'JoltPhysics: Unsupported geometry type:', geometry.type );
|
|
32
|
+
|
|
31
33
|
return null;
|
|
32
34
|
|
|
33
35
|
}
|
|
@@ -75,7 +77,7 @@ async function JoltPhysics() {
|
|
|
75
77
|
|
|
76
78
|
if ( Jolt === null ) {
|
|
77
79
|
|
|
78
|
-
const { default: initJolt } = await import(
|
|
80
|
+
const { default: initJolt } = await import( JOLT_PATH /* @vite-ignore */ );
|
|
79
81
|
Jolt = await initJolt();
|
|
80
82
|
|
|
81
83
|
}
|
|
@@ -220,11 +222,13 @@ async function JoltPhysics() {
|
|
|
220
222
|
|
|
221
223
|
//
|
|
222
224
|
|
|
223
|
-
const
|
|
225
|
+
const timer = new Timer();
|
|
224
226
|
|
|
225
227
|
function step() {
|
|
226
228
|
|
|
227
|
-
|
|
229
|
+
timer.update();
|
|
230
|
+
|
|
231
|
+
let deltaTime = timer.getDelta();
|
|
228
232
|
|
|
229
233
|
// Don't go below 30 Hz to prevent spiral of death
|
|
230
234
|
deltaTime = Math.min( deltaTime, 1.0 / 30.0 );
|
|
@@ -305,7 +309,7 @@ async function JoltPhysics() {
|
|
|
305
309
|
* @name JoltPhysics#addMesh
|
|
306
310
|
* @param {Mesh} mesh The mesh to add.
|
|
307
311
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
308
|
-
* @param {number} [restitution=0] The restitution
|
|
312
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
309
313
|
*/
|
|
310
314
|
addMesh: addMesh,
|
|
311
315
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
|
|
2
2
|
|
|
3
3
|
const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.17.3';
|
|
4
4
|
|
|
@@ -73,6 +73,8 @@ function getShape( geometry ) {
|
|
|
73
73
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
console.error( 'RapierPhysics: Unsupported geometry type:', geometry.type );
|
|
77
|
+
|
|
76
78
|
return null;
|
|
77
79
|
|
|
78
80
|
}
|
|
@@ -95,7 +97,7 @@ async function RapierPhysics() {
|
|
|
95
97
|
|
|
96
98
|
if ( RAPIER === null ) {
|
|
97
99
|
|
|
98
|
-
RAPIER = await import(
|
|
100
|
+
RAPIER = await import( RAPIER_PATH /* @vite-ignore */ );
|
|
99
101
|
await RAPIER.init();
|
|
100
102
|
|
|
101
103
|
}
|
|
@@ -299,11 +301,13 @@ async function RapierPhysics() {
|
|
|
299
301
|
|
|
300
302
|
//
|
|
301
303
|
|
|
302
|
-
const
|
|
304
|
+
const timer = new Timer();
|
|
303
305
|
|
|
304
306
|
function step() {
|
|
305
307
|
|
|
306
|
-
|
|
308
|
+
timer.update();
|
|
309
|
+
|
|
310
|
+
world.timestep = timer.getDelta();
|
|
307
311
|
world.step();
|
|
308
312
|
|
|
309
313
|
//
|
|
@@ -372,7 +376,7 @@ async function RapierPhysics() {
|
|
|
372
376
|
* @name RapierPhysics#addMesh
|
|
373
377
|
* @param {Mesh} mesh The mesh to add.
|
|
374
378
|
* @param {number} [mass=0] The mass in kg of the mesh.
|
|
375
|
-
* @param {number} [restitution=0] The restitution
|
|
379
|
+
* @param {number} [restitution=0] The restitution of the mesh, usually from 0 to 1. Represents how "bouncy" objects are when they collide with each other.
|
|
376
380
|
*/
|
|
377
381
|
addMesh: addMesh,
|
|
378
382
|
|