rhodonite 0.26.0 → 0.27.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/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +14 -0
- package/dist/esm/foundation/components/Light/LightComponent.js +1 -1
- package/dist/esm/foundation/components/Mesh/MeshComponent.js +1 -1
- package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +28 -0
- package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
- package/dist/esm/foundation/components/Physics/PhysicsComponent.js +1 -1
- package/dist/esm/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +1 -1
- package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.js +1 -1
- package/dist/esm/foundation/components/Shape/ShapeComponent.js +1 -1
- package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +1 -1
- package/dist/esm/foundation/components/Skeletal/SkeletalComponent.js +1 -1
- package/dist/esm/foundation/components/Transform/TransformComponent.js +1 -1
- package/dist/esm/foundation/constraints/VrmRollConstraint.js +1 -1
- package/dist/esm/foundation/core/Component.js +1 -1
- package/dist/esm/foundation/core/Config.d.ts +15 -0
- package/dist/esm/foundation/core/Config.js +1 -1
- package/dist/esm/foundation/core/GlobalDataRepository.js +1 -1
- package/dist/esm/foundation/core/MemoryManager.d.ts +19 -0
- package/dist/esm/foundation/core/MemoryManager.js +2 -2
- package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +1 -0
- package/dist/esm/foundation/definitions/ShaderSemantics.js +2 -2
- package/dist/esm/foundation/definitions/ShaderSemanticsInfo.d.ts +1 -0
- package/dist/esm/foundation/definitions/ShaderSemanticsInfo.js +1 -1
- package/dist/esm/foundation/definitions/VertexAttribute.js +1 -1
- package/dist/esm/foundation/exporter/Gltf2Exporter.d.ts +6 -0
- package/dist/esm/foundation/exporter/Gltf2Exporter.js +1 -1
- package/dist/esm/foundation/geometry/Frustum.js +1 -1
- package/dist/esm/foundation/geometry/Mesh.d.ts +15 -0
- package/dist/esm/foundation/geometry/Mesh.js +1 -1
- package/dist/esm/foundation/geometry/Primitive.js +1 -1
- package/dist/esm/foundation/geometry/shapes/Cylinder.js +1 -1
- package/dist/esm/foundation/geometry/shapes/Joint.js +1 -1
- package/dist/esm/foundation/gizmos/AABBGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/CapsuleColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/Gizmo.js +1 -1
- package/dist/esm/foundation/gizmos/JointGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LightGizmo.d.ts +108 -10
- package/dist/esm/foundation/gizmos/LightGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/LocatorGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/ShapeGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
- package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
- package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
- package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
- package/dist/esm/foundation/helpers/MaterialHelper.d.ts +2 -0
- package/dist/esm/foundation/helpers/MaterialHelper.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
- package/dist/esm/foundation/helpers/materials/createClassicUberMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.d.ts +21 -0
- package/dist/esm/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.js +1 -0
- package/dist/esm/foundation/helpers/materials/createGaussianBlurForEncodedDepthMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/createGaussianBlurMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +1 -1
- package/dist/esm/foundation/helpers/materials/createPbrUberMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.js +1 -1
- package/dist/esm/foundation/helpers/materials/index.d.ts +1 -0
- package/dist/esm/foundation/helpers/materials/index.js +1 -1
- package/dist/esm/foundation/helpers/materials/nodeBasedMaterialCommon.js +1 -1
- package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
- package/dist/esm/foundation/importer/Gltf2Importer.d.ts +2 -1
- package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
- package/dist/esm/foundation/importer/GltfImporter.js +1 -1
- package/dist/esm/foundation/importer/ModelConverter.d.ts +19 -0
- package/dist/esm/foundation/importer/ModelConverter.js +1 -1
- package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
- package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
- package/dist/esm/foundation/importer/VrmImporter.js +1 -1
- package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/DepthEncodeMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/EntityUIDOutputMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/FurnaceTestMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +18 -18
- package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
- package/dist/esm/foundation/materials/contents/MatCapMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/SynthesizeHdrMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
- package/dist/esm/foundation/materials/core/AbstractShaderNode.js +2 -2
- package/dist/esm/foundation/materials/core/Material.d.ts +7 -2
- package/dist/esm/foundation/materials/core/Material.js +1 -1
- package/dist/esm/foundation/materials/core/MaterialRepository.js +1 -1
- package/dist/esm/foundation/materials/core/ShaderGraphResolver.js +4 -4
- package/dist/esm/foundation/materials/core/ShaderHandler.js +3 -3
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
- package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
- package/dist/esm/foundation/materials/nodes/AbsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AcosShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AddShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AlphaTestShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AndShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Atan2ShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributePositionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeTexcoordShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/BlockBeginShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/BlockEndShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/BranchShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/CalcBitangentShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ClampShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ClassicShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ConstantVariableShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/CosShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/DotProductShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/EqualShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/FlatShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/GreaterOrEqualShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/GreaterShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/GreaterThanShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/LengthShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/LessOrEqualShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/LessThanShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/MinShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/MultiplyShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/NormalizeShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/NotEqualShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/OrShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrNormalPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrShaderShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrSheenPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PbrVolumePropsShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ProcessGeometryShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/RemapShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/SinShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/SmoothStepShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/StepShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/TanShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/Texture2DShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/TimeShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/TransformShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/UniformDataShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/WireframeMaterialNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendXYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendXZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendYXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendYZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendZXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/BendZYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/TwistXShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/TwistYShaderNode.js +1 -1
- package/dist/esm/foundation/materials/nodes/raymarching/TwistZShaderNode.js +1 -1
- package/dist/esm/foundation/math/IdentityMatrix33.js +2 -2
- package/dist/esm/foundation/math/IdentityMatrix44.js +2 -2
- package/dist/esm/foundation/math/MathClassUtil.js +1 -1
- package/dist/esm/foundation/math/Quaternion.js +1 -1
- package/dist/esm/foundation/math/Transform3D.js +1 -1
- package/dist/esm/foundation/memory/Accessor.js +6 -6
- package/dist/esm/foundation/memory/Buffer.js +3 -3
- package/dist/esm/foundation/memory/BufferView.js +1 -1
- package/dist/esm/foundation/misc/Logger.js +1 -1
- package/dist/esm/foundation/misc/PngDecoder.d.ts +18 -0
- package/dist/esm/foundation/misc/PngDecoder.js +1 -0
- package/dist/esm/foundation/misc/Time.js +1 -1
- package/dist/esm/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +1 -1
- package/dist/esm/foundation/physics/Rapier/RapierPhysicsStrategy.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/CapsuleCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/SphereCollider.js +1 -1
- package/dist/esm/foundation/physics/VRMSpring/VRMSpringBone.js +1 -1
- package/dist/esm/foundation/renderer/Frame.js +1 -1
- package/dist/esm/foundation/renderer/FrameBuffer.js +1 -1
- package/dist/esm/foundation/renderer/RenderPass.d.ts +7 -0
- package/dist/esm/foundation/renderer/RenderPass.js +1 -1
- package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +1 -1
- package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -1
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +12 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.js +1 -1
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystemStub.js +1 -1
- package/dist/esm/foundation/renderer/pipelines/DeferredRenderPipeline.js +1 -1
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +84 -10
- package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
- package/dist/esm/foundation/system/Engine.d.ts +2 -16
- package/dist/esm/foundation/system/Engine.js +1 -1
- package/dist/esm/foundation/system/EngineState.d.ts +6 -0
- package/dist/esm/foundation/system/GpuDriverWorkarounds.d.ts +50 -0
- package/dist/esm/foundation/system/GpuDriverWorkarounds.js +1 -0
- package/dist/esm/foundation/system/ModuleManager.js +1 -1
- package/dist/esm/foundation/system/index.d.ts +1 -0
- package/dist/esm/foundation/system/index.js +1 -1
- package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
- package/dist/esm/foundation/textures/CubeTexture.d.ts +11 -2
- package/dist/esm/foundation/textures/CubeTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
- package/dist/esm/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
- package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
- package/dist/esm/foundation/textures/Texture.js +1 -1
- package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
- package/dist/esm/foundation/textures/VideoTexture.js +1 -1
- package/dist/esm/types/glTF2.d.ts +9 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/webgl/InstanceSidTable.js +1 -1
- package/dist/esm/webgl/MultiDraw.js +1 -1
- package/dist/esm/webgl/MultiDrawRepository.js +1 -1
- package/dist/esm/webgl/WebGLResourceRepository.d.ts +5 -0
- package/dist/esm/webgl/WebGLResourceRepository.js +4 -4
- package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
- package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +19 -14
- package/dist/esm/webgl/WebGLStrategyWebGL2.js +67 -67
- package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +17 -8
- package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +5 -5
- package/dist/esm/webgl/shaderity_shaders/ColorGradingUsingLUTsShader/ColorGradingUsingLUTsShader.vert.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/DepthEncodeSingleShader/DepthEncodeSingleShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/DepthMomentEncodeShader/DepthMomentEncodeShader.vert.js +3 -3
- package/dist/esm/webgl/shaderity_shaders/DetectHighLuminanceAndCorrectShader/DetectHighLuminanceAndCorrectShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/EntityUIDOutputSingleShader/EntityUIDOutputSingleShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.js +84 -0
- package/dist/esm/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.js +34 -0
- package/dist/esm/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +5 -5
- package/dist/esm/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +7 -7
- package/dist/esm/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.vert.js +4 -4
- package/dist/esm/webgl/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +8 -4
- package/dist/esm/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +43 -39
- package/dist/esm/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js +4 -4
- package/dist/esm/webgl/shaderity_shaders/MatCapShader/MatCapShader.vert.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +3 -3
- package/dist/esm/webgl/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.glsl.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.glsl.js +4 -4
- package/dist/esm/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +125 -111
- package/dist/esm/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.vert.js +6 -6
- package/dist/esm/webgl/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.js +5 -5
- package/dist/esm/webgl/shaderity_shaders/ShadowMapDecodeClassicSingleShader/ShadowMapDecodeClassicSingleShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/SummedAreaTableShader/SummedAreaTableShader.frag.js +3 -3
- package/dist/esm/webgl/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.js +1 -1
- package/dist/esm/webgl/shaderity_shaders/VarianceShadowMapDecodeClassicShader/VarianceShadowMapDecodeClassicShader.vert.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/common/iblDefinition.glsl.js +64 -5
- package/dist/esm/webgl/shaderity_shaders/common/morphVariables.glsl.js +2 -2
- package/dist/esm/webgl/shaderity_shaders/common/opticalDefinition.glsl.js +4 -1
- package/dist/esm/webgl/shaderity_shaders/common/prerequisites.glsl.js +3 -3
- package/dist/esm/webgl/shaderity_shaders/nodes/ClassicShader.glsl.js +10 -1
- package/dist/esm/webgl/shaderity_shaders/nodes/PbrShader.glsl.js +12 -0
- package/dist/esm/webgl/shaders/RaymarchingShaderPart.js +23 -11
- package/dist/esm/webgl/shaders/nodes/BlockBeginShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/BlockEndShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
- package/dist/esm/webgl/shaders/nodes/DiscardShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/EndShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/RaymarchObjectIdUniform.js +3 -3
- package/dist/esm/webgl/shaders/nodes/SdApplyTransform.js +5 -5
- package/dist/esm/webgl/shaders/nodes/SdApplyWorldMatrix.js +3 -3
- package/dist/esm/webgl/shaders/nodes/Texture2DShader.js +14 -14
- package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +13 -13
- package/dist/esm/webgl/textureLoader/KTX2TextureLoader.js +1 -1
- package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
- package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
- package/dist/esm/webgpu/RangeAllocator.js +1 -1
- package/dist/esm/webgpu/WebGpuBufferArena.js +1 -1
- package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -1
- package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +6 -0
- package/dist/esm/webgpu/WebGpuResourceRepository.js +5 -5
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +1 -0
- package/dist/esm/webgpu/WebGpuStrategyBasic.js +54 -54
- package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
- package/dist/esm/webgpu/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +15 -8
- package/dist/esm/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.wgsl.js +84 -0
- package/dist/esm/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.wgsl.js +19 -0
- package/dist/esm/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +6 -6
- package/dist/esm/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +3 -3
- package/dist/esm/webgpu/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +5 -5
- package/dist/esm/webgpu/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +3 -3
- package/dist/esm/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +9 -5
- package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +44 -40
- package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js +2 -2
- package/dist/esm/webgpu/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.wgsl.js +1 -1
- package/dist/esm/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.wgsl.js +2 -2
- package/dist/esm/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.wgsl.js +3 -3
- package/dist/esm/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +125 -113
- package/dist/esm/webgpu/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.wgsl.js +5 -5
- package/dist/esm/webgpu/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.wgsl.js +1 -1
- package/dist/esm/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +65 -5
- package/dist/esm/webgpu/shaderity_shaders/common/opticalDefinition.wgsl.js +4 -1
- package/dist/esm/webgpu/shaderity_shaders/nodes/ClassicShader.wgsl.js +7 -0
- package/dist/esm/webgpu/shaderity_shaders/nodes/PbrShader.wgsl.js +13 -2
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +14 -0
- package/dist/esmdev/foundation/components/Light/LightComponent.js +38 -11
- package/dist/esmdev/foundation/components/Mesh/MeshComponent.js +47 -44
- package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +28 -0
- package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +142 -92
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.js +65 -65
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingComponent.js +54 -54
- package/dist/esmdev/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +250 -250
- package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.js +335 -335
- package/dist/esmdev/foundation/components/Shape/ShapeComponent.js +31 -31
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +5 -5
- package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +9 -9
- package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.js +222 -222
- package/dist/esmdev/foundation/components/Transform/TransformComponent.js +66 -66
- package/dist/esmdev/foundation/components/Trigger/TriggerComponent.js +61 -61
- package/dist/esmdev/foundation/components/Vrm/VrmComponent.js +44 -44
- package/dist/esmdev/foundation/constraints/VrmAimConstraint.js +11 -11
- package/dist/esmdev/foundation/constraints/VrmRollConstraint.js +16 -16
- package/dist/esmdev/foundation/constraints/VrmRotationConstraint.js +10 -10
- package/dist/esmdev/foundation/core/Component.js +32 -32
- package/dist/esmdev/foundation/core/ComponentMemoryRegistry.js +41 -41
- package/dist/esmdev/foundation/core/ComponentRepository.js +37 -37
- package/dist/esmdev/foundation/core/Config.d.ts +15 -0
- package/dist/esmdev/foundation/core/Config.js +27 -10
- package/dist/esmdev/foundation/core/Entity.js +9 -9
- package/dist/esmdev/foundation/core/EntityRepository.js +19 -19
- package/dist/esmdev/foundation/core/GlobalDataRepository.js +31 -18
- package/dist/esmdev/foundation/core/MemoryManager.d.ts +19 -0
- package/dist/esmdev/foundation/core/MemoryManager.js +52 -27
- package/dist/esmdev/foundation/core/RnObject.js +37 -37
- package/dist/esmdev/foundation/definitions/Blend.js +3 -3
- package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
- package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
- package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
- package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +1 -0
- package/dist/esmdev/foundation/definitions/ShaderSemantics.js +12 -7
- package/dist/esmdev/foundation/definitions/ShaderSemanticsInfo.d.ts +1 -0
- package/dist/esmdev/foundation/definitions/ShaderSemanticsInfo.js +1 -1
- package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
- package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
- package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
- package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
- package/dist/esmdev/foundation/exporter/Gltf2Exporter.d.ts +6 -0
- package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +140 -110
- package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +24 -24
- package/dist/esmdev/foundation/geometry/Frustum.js +41 -41
- package/dist/esmdev/foundation/geometry/Mesh.d.ts +15 -0
- package/dist/esmdev/foundation/geometry/Mesh.js +245 -215
- package/dist/esmdev/foundation/geometry/Primitive.js +141 -135
- package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
- package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
- package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
- package/dist/esmdev/foundation/gizmos/AABBGizmo.js +16 -16
- package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +23 -23
- package/dist/esmdev/foundation/gizmos/Gizmo.js +23 -23
- package/dist/esmdev/foundation/gizmos/JointGizmo.js +37 -37
- package/dist/esmdev/foundation/gizmos/LightGizmo.d.ts +108 -10
- package/dist/esmdev/foundation/gizmos/LightGizmo.js +248 -49
- package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +25 -25
- package/dist/esmdev/foundation/gizmos/RotationGizmo.js +211 -211
- package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +130 -130
- package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +43 -43
- package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +24 -24
- package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +129 -129
- package/dist/esmdev/foundation/helpers/BloomHelper.js +42 -38
- package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
- package/dist/esmdev/foundation/helpers/MaterialHelper.d.ts +2 -0
- package/dist/esmdev/foundation/helpers/MaterialHelper.js +3 -1
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
- package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +119 -119
- package/dist/esmdev/foundation/helpers/materials/createClassicUberMaterial.js +13 -5
- package/dist/esmdev/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.d.ts +21 -0
- package/dist/esmdev/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.js +32 -0
- package/dist/esmdev/foundation/helpers/materials/createGaussianBlurForEncodedDepthMaterial.js +12 -4
- package/dist/esmdev/foundation/helpers/materials/createGaussianBlurMaterial.js +13 -5
- package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.js +7 -3
- package/dist/esmdev/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +49 -17
- package/dist/esmdev/foundation/helpers/materials/createPbrUberMaterial.js +13 -5
- package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.js +22 -8
- package/dist/esmdev/foundation/helpers/materials/index.d.ts +1 -0
- package/dist/esmdev/foundation/helpers/materials/index.js +3 -1
- package/dist/esmdev/foundation/helpers/materials/nodeBasedMaterialCommon.js +32 -10
- package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
- package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
- package/dist/esmdev/foundation/importer/Gltf2Importer.d.ts +2 -1
- package/dist/esmdev/foundation/importer/Gltf2Importer.js +21 -17
- package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
- package/dist/esmdev/foundation/importer/ModelConverter.d.ts +19 -0
- package/dist/esmdev/foundation/importer/ModelConverter.js +183 -132
- package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
- package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
- package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
- package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +37 -28
- package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +15 -9
- package/dist/esmdev/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +3 -2
- package/dist/esmdev/foundation/materials/contents/EntityUIDOutputMaterialContent.js +5 -3
- package/dist/esmdev/foundation/materials/contents/FurnaceTestMaterialContent.js +16 -8
- package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +205 -170
- package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +28 -20
- package/dist/esmdev/foundation/materials/contents/MatCapMaterialContent.js +7 -4
- package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +33 -19
- package/dist/esmdev/foundation/materials/contents/SynthesizeHdrMaterialContent.js +3 -1
- package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +41 -24
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +51 -51
- package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +26 -26
- package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
- package/dist/esmdev/foundation/materials/core/Material.d.ts +7 -2
- package/dist/esmdev/foundation/materials/core/Material.js +132 -118
- package/dist/esmdev/foundation/materials/core/MaterialRepository.js +65 -65
- package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
- package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +26 -20
- package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +29 -23
- package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
- package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
- package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
- package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
- package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
- package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
- package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
- package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
- package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
- package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
- package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
- package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
- package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
- package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
- package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
- package/dist/esmdev/foundation/math/AABB.js +132 -132
- package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
- package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
- package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
- package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
- package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
- package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
- package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
- package/dist/esmdev/foundation/math/Quaternion.js +20 -20
- package/dist/esmdev/foundation/math/Transform3D.js +74 -74
- package/dist/esmdev/foundation/math/shapes/MathSphere.js +7 -7
- package/dist/esmdev/foundation/memory/Accessor.js +369 -369
- package/dist/esmdev/foundation/memory/Buffer.js +40 -40
- package/dist/esmdev/foundation/memory/BufferView.js +33 -33
- package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
- package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
- package/dist/esmdev/foundation/misc/Logger.js +14 -14
- package/dist/esmdev/foundation/misc/PngDecoder.d.ts +18 -0
- package/dist/esmdev/foundation/misc/PngDecoder.js +113 -0
- package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
- package/dist/esmdev/foundation/misc/Time.js +27 -27
- package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
- package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
- package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
- package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +10 -10
- package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +193 -193
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +241 -241
- package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
- package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +42 -42
- package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +27 -27
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +10 -10
- package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +56 -56
- package/dist/esmdev/foundation/renderer/Expression.js +6 -6
- package/dist/esmdev/foundation/renderer/Frame.js +12 -12
- package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
- package/dist/esmdev/foundation/renderer/RenderPass.d.ts +7 -0
- package/dist/esmdev/foundation/renderer/RenderPass.js +109 -101
- package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +10 -10
- package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +78 -78
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +12 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +193 -155
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
- package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +6 -6
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +84 -10
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +585 -461
- package/dist/esmdev/foundation/system/Engine.d.ts +2 -16
- package/dist/esmdev/foundation/system/Engine.js +239 -238
- package/dist/esmdev/foundation/system/EngineState.d.ts +6 -0
- package/dist/esmdev/foundation/system/EngineState.js +1 -1
- package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
- package/dist/esmdev/foundation/system/GpuDriverWorkarounds.d.ts +50 -0
- package/dist/esmdev/foundation/system/GpuDriverWorkarounds.js +93 -0
- package/dist/esmdev/foundation/system/InputManager.js +56 -56
- package/dist/esmdev/foundation/system/ModuleManager.js +6 -6
- package/dist/esmdev/foundation/system/index.d.ts +1 -0
- package/dist/esmdev/foundation/system/index.js +2 -1
- package/dist/esmdev/foundation/textures/AbstractTexture.js +49 -49
- package/dist/esmdev/foundation/textures/CubeTexture.d.ts +11 -2
- package/dist/esmdev/foundation/textures/CubeTexture.js +47 -36
- package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
- package/dist/esmdev/foundation/textures/RenderTargetTexture.js +24 -24
- package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +35 -35
- package/dist/esmdev/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
- package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +25 -19
- package/dist/esmdev/foundation/textures/Sampler.js +24 -24
- package/dist/esmdev/foundation/textures/Texture.js +83 -83
- package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
- package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
- package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
- package/dist/esmdev/types/glTF2.d.ts +9 -0
- package/dist/esmdev/types/glTF2.js +1 -1
- package/dist/esmdev/version.js +2 -2
- package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
- package/dist/esmdev/webgl/MultiDraw.js +2 -2
- package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
- package/dist/esmdev/webgl/WebGLContextWrapper.js +164 -164
- package/dist/esmdev/webgl/WebGLGpuTimer.js +32 -32
- package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +5 -0
- package/dist/esmdev/webgl/WebGLResourceRepository.js +379 -314
- package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +19 -14
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +320 -299
- package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
- package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ColorGradingUsingLUTsShader/ColorGradingUsingLUTsShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/DepthEncodeSingleShader/DepthEncodeSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/DepthMomentEncodeShader/DepthMomentEncodeShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/DetectHighLuminanceAndCorrectShader/DetectHighLuminanceAndCorrectShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/EntityUIDOutputSingleShader/EntityUIDOutputSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.js +12 -0
- package/dist/esmdev/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MatCapShader/MatCapShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ShadowMapDecodeClassicSingleShader/ShadowMapDecodeClassicSingleShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/SummedAreaTableShader/SummedAreaTableShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/VarianceShadowMapDecodeClassicShader/VarianceShadowMapDecodeClassicShader.vert.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/common/iblDefinition.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/common/morphVariables.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/common/opticalDefinition.glsl.js +5 -2
- package/dist/esmdev/webgl/shaderity_shaders/common/prerequisites.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/nodes/ClassicShader.glsl.js +2 -2
- package/dist/esmdev/webgl/shaderity_shaders/nodes/PbrShader.glsl.js +2 -2
- package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +25 -13
- package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
- package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
- package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
- package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/EndShader.js +3 -3
- package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
- package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
- package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
- package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
- package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
- package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +27 -27
- package/dist/esmdev/webgpu/GpuCullingRegistry.js +94 -94
- package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
- package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
- package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
- package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
- package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
- package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +37 -37
- package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +6 -0
- package/dist/esmdev/webgpu/WebGpuResourceRepository.js +661 -599
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +1 -0
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +129 -125
- package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
- package/dist/esmdev/webgpu/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.wgsl.js +12 -0
- package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/common/opticalDefinition.wgsl.js +5 -2
- package/dist/esmdev/webgpu/shaderity_shaders/nodes/ClassicShader.wgsl.js +2 -2
- package/dist/esmdev/webgpu/shaderity_shaders/nodes/PbrShader.wgsl.js +2 -2
- package/dist/esmdev/xr/WebARSystem.js +69 -69
- package/dist/esmdev/xr/WebXRSystem.js +153 -153
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CameraComponent as h}from"../../components/Camera/CameraComponent.js";import{TextureFormat as n}from"../../definitions/TextureFormat.js";import{TextureParameter as s}from"../../definitions/TextureParameter.js";import{createMotionVectorMaterial as d}from"../../helpers/materials/createMotionVectorMaterial.js";import{createTemporalAAResolveMaterial as x}from"../../helpers/materials/createTemporalAAResolveMaterial.js";import{RenderableHelper as p}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as C}from"../../helpers/RenderPassHelper.js";import{MutableMatrix44 as f}from"../../math/MutableMatrix44.js";import{Vector2 as u}from"../../math/Vector2.js";import{Vector4 as v}from"../../math/Vector4.js";import{Sampler as l}from"../../textures/Sampler.js";import{Expression as F}from"../Expression.js";import{RenderPass as R}from"../RenderPass.js";import{PreviousFrameDataTracker as P}from"./PreviousFrameDataTracker.js";var y=8,g=1024;function c(o,e){let t=0,i=1/e,a=o;for(;a>0;)t+=i*(a%e),a=Math.floor(a/e),i/=e;return t}function A(o,e,t){let i=o%y+1,a=c(i,2)-.5,r=c(i,3)-.5;return u.fromCopy2(a*2/e,r*2/t)}var T=class{constructor(e,t,i,a){this.
|
|
1
|
+
import{CameraComponent as h}from"../../components/Camera/CameraComponent.js";import{TextureFormat as n}from"../../definitions/TextureFormat.js";import{TextureParameter as s}from"../../definitions/TextureParameter.js";import{createMotionVectorMaterial as d}from"../../helpers/materials/createMotionVectorMaterial.js";import{createTemporalAAResolveMaterial as x}from"../../helpers/materials/createTemporalAAResolveMaterial.js";import{RenderableHelper as p}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as C}from"../../helpers/RenderPassHelper.js";import{MutableMatrix44 as f}from"../../math/MutableMatrix44.js";import{Vector2 as u}from"../../math/Vector2.js";import{Vector4 as v}from"../../math/Vector4.js";import{Sampler as l}from"../../textures/Sampler.js";import{Expression as F}from"../Expression.js";import{RenderPass as R}from"../RenderPass.js";import{PreviousFrameDataTracker as P}from"./PreviousFrameDataTracker.js";var y=8,g=1024;function c(o,e){let t=0,i=1/e,a=o;for(;a>0;)t+=i*(a%e),a=Math.floor(a/e),i/=e;return t}function A(o,e,t){let i=o%y+1,a=c(i,2)-.5,r=c(i,3)-.5;return u.fromCopy2(a*2/e,r*2/t)}var T=class{constructor(e,t,i,a){this.am=0;this.TT=0;this.lT=new P;this.cT=0;this.oT=!1;this.pT=0;this.dT=f.identity();this.i=e,e._enablePreviousMorphWeights(),this.am=t,this.TT=i,this.iT=p.createFrameBuffer(e,{width:t,height:i,textureNum:1,textureFormats:[n.RGBA16F],mipLevelCount:1,createDepthBuffer:!0,depthTextureFormat:n.Depth32F}),this.iT.tryToSetUniqueName("TemporalAAMotionVector",!0),this.aT=p.createFrameBuffer(e,{width:t,height:i,textureNum:1,textureFormats:[n.RGBA16F],mipLevelCount:1,createDepthBuffer:!1}),this.aT.tryToSetUniqueName("TemporalAAOutput",!0),this.sT=p.createFrameBuffer(e,{width:t,height:i,textureNum:1,textureFormats:[n.RGBA16F],mipLevelCount:1,createDepthBuffer:!1}),this.sT.tryToSetUniqueName("TemporalAAHistory",!0),this.hT=new l(e,{magFilter:s.Linear,minFilter:s.Linear,wrapS:s.ClampToEdge,wrapT:s.ClampToEdge}),this.hT.create(),this.nT=new l(e,{magFilter:s.Nearest,minFilter:s.Nearest,wrapS:s.ClampToEdge,wrapT:s.ClampToEdge}),this.nT.create(),this.mT=d(e);let r=new R(e);r.tryToSetUniqueName("TemporalAAMotionVector",!0),r.clearColor=v.fromCopy4(0,0,1,0),r.toClearColorBuffer=!0,r.toClearDepthBuffer=!0,r.isVrRendering=!1,r.isOutputForVr=!1,r.setToRenderOpaquePrimitives(!0),r.setToRenderBlendWithZWritePrimitives(!0),r.setToRenderBlendWithoutZWritePrimitives(!1),r.setToRenderTranslucentPrimitives(!1),r.setFramebuffer(this.iT),r.setMaterial(this.mT),this.fT=r,this.tT=x(e),this.tT.setParameter("framebufferSize",u.fromCopy2(t,i)),this.tT.setTextureParameter("historyTexture",this.sT.getColorAttachedRenderTargetTexture(0),this.hT),this.tT.setTextureParameter("velocityTexture",this.iT.getColorAttachedRenderTargetTexture(0),this.nT);let m=C.createScreenDrawRenderPassWithBaseColorTexture(e,this.tT,a,this.nT);m.tryToSetUniqueName("TemporalAAResolve",!0),m.isVrRendering=!1,m.isOutputForVr=!1,m.setFramebuffer(this.aT),m.setResolveFramebuffer2(this.sT),this.xT=m,this.uT=new F,this.uT.tryToSetUniqueName("TemporalAA",!0),this.uT.addRenderPasses([r,m])}get expression(){return this.uT}get outputTexture(){return this.aT.getColorAttachedRenderTargetTexture(0)}get motionVectorTexture(){return this.iT.getColorAttachedRenderTargetTexture(0)}set currentFrameWeight(e){this.tT.setParameter("currentFrameWeight",e)}get currentFrameWeight(){return this.tT.getParameter("currentFrameWeight")._v[0]}set staticFrameWeight(e){this.tT.setParameter("staticFrameWeight",e)}get staticFrameWeight(){return this.tT.getParameter("staticFrameWeight")._v[0]}set varianceClipGamma(e){this.tT.setParameter("varianceClipGamma",e)}get frameIndex(){return this.cT}setEntities(e){this.fT.clearEntities(),this.fT.addEntities(e),this.lT.setEntities(e)}resetHistory(){this.oT=!1}prepareFrame(e){if(e==null)return;e!==this.rT&&(this.rT!=null&&(this.rT.jitterOffset=u.zero()),this.rT=e,this.oT=!1),f.multiplyTo(e.projectionMatrixWithoutJitter,e.viewMatrix,this.dT),this.mT.setParameter("previousViewProjectionMatrix",this.dT);let t=A(this.cT,this.am,this.TT);e.jitterOffset=t,this.mT.setParameter("currentJitter",t),this.tT.setParameter("currentJitter",t),this.cT++,this.lT.update()&&this.i._markGpuInstanceDataDirty(),this.oT||(this.pT=0),this.tT.setParameter("isHistoryValid",this.oT),this.tT.setParameter("historyFrameCount",this.pT),this.oT=!0,this.pT=Math.min(this.pT+1,g)}get historyFrameCount(){return this.tT.getParameter("historyFrameCount")._v[0]}destroy3DAPIResources(){this.rT!=null&&(this.rT.jitterOffset=u.zero(),this.rT=void 0),this.iT.destroy3DAPIResources(),this.aT.destroy3DAPIResources(),this.sT.destroy3DAPIResources(),this.lT.clear()}};function H(o,e){for(let t of e)if(t.cameraComponent!=null)return t.cameraComponent;return o.componentRepository.getComponent(h,h.getCurrent(o))}export{T as TemporalAASystem,H as _getTemporalAACamera,A as getTemporalAAJitter,c as halton};
|
|
@@ -28,6 +28,8 @@ export type LightClusterGpuBuildParams = {
|
|
|
28
28
|
*
|
|
29
29
|
* - Every enabled light is written to the all-light list of the `clusteredLightData` global property
|
|
30
30
|
* (lights that can not be culled first, then the local lights, each sorted by the component SID).
|
|
31
|
+
* Ambient lights are the exception: their (color * intensity) is summed into the `ambientLightIntensity`
|
|
32
|
+
* global property, which the shaders add once per fragment.
|
|
31
33
|
* - For each camera used by the render passes of the frame (up to `Config.clusteredForwardMaxViewNumber`),
|
|
32
34
|
* a view region with the cluster grid is built when there are local lights, and the camera's
|
|
33
35
|
* `lightClusterViewInfo` points to it. Other cameras use the all-light list.
|
|
@@ -54,6 +56,10 @@ export declare class LightClusterSystem {
|
|
|
54
56
|
private __dataVersion;
|
|
55
57
|
private __globalData?;
|
|
56
58
|
private __globalDataVec4Base;
|
|
59
|
+
/** The `ambientLightIntensity` global property: the sum of (color * intensity) of the enabled ambient lights. */
|
|
60
|
+
private __ambientData?;
|
|
61
|
+
/** The ambient sum of the current frame, collected by __collectLights(). */
|
|
62
|
+
private __ambientSum;
|
|
57
63
|
private __capacity;
|
|
58
64
|
private __layout?;
|
|
59
65
|
private __scratch?;
|
|
@@ -153,6 +159,12 @@ export declare class LightClusterSystem {
|
|
|
153
159
|
* @returns true if the lists changed since the previous frame
|
|
154
160
|
*/
|
|
155
161
|
private __collectLights;
|
|
162
|
+
/**
|
|
163
|
+
* Writes the sum of the ambient lights (collected by __collectLights) into the `ambientLightIntensity` global
|
|
164
|
+
* property.
|
|
165
|
+
* @returns true if the value changed
|
|
166
|
+
*/
|
|
167
|
+
private __writeAmbientData;
|
|
156
168
|
/**
|
|
157
169
|
* Writes the all-light list into the `clusteredLightData` global property.
|
|
158
170
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CameraComponent as V}from"../../components/Camera/CameraComponent.js";import{LightComponent as D}from"../../components/Light/LightComponent.js";import{BufferUse as
|
|
1
|
+
import{CameraComponent as V}from"../../components/Camera/CameraComponent.js";import{LightComponent as D}from"../../components/Light/LightComponent.js";import{BufferUse as M}from"../../definitions/BufferUse.js";import{ProcessApproach as O}from"../../definitions/ProcessApproach.js";import{Logger as G}from"../../misc/Logger.js";import{buildLightClustersOnCpu as R,computeLightBoundingSphere as P,createLightClusterBuildScratch as N,writeLightClusterViewHeader as k}from"./LightClusterBuilder.js";import{getLightClusterViewLayout as U,getLightListCapacity as T,LightClusterLayout as L,packLightEntry as z}from"./LightClusterLayout.js";var H=254,E=class{constructor(e){this.Rb=0;this.Qb=-1;this.Hb=new Float64Array(3);this.F0=0;this.X0=new Float64Array(0);this.$0=new Float64Array(0);this.j0=new Float64Array(0);this.q0=new Float64Array(0);this.J0=new Float64Array(0);this.K0=0;this.Zb=0;this._0=0;this.jb=0;this.Wb=-1;this.Yb=-1;this.hw=-1;this.I0=[];this.A0=[];this.N0=[];this.Xb=new Float32Array(0);this.W0=new Set;this.$b=!1;this.qb=!1;this.tw=[];this.Jb=new Float64Array(0);this.Q0=new Float64Array(0);this.wb=new Float64Array(0);this.Kb=new Uint32Array(0);this.Lb=new Float32Array(0);this.U0=0;this.H0=[];this.Fb=[];this.Gb=[];this.Db=[];this.ew=new Float32Array(L.viewHeaderVec4Count*4+4);this.i=e}get dataVersion(){return this.Rb}get isGpuBuild(){return this.i.config.clusteredForwardBuildMode==="auto"&&this.i.engineState.currentProcessApproach===O.WebGPU}_getGpuBuildParams(){if(!(!this.isGpuBuild||this.H0.length===0||this.V0==null))return{views:this.H0,data:this.Lb,dataStride:this.U0,localCapacity:this.F0,layout:this.V0}}_getExcludedByteRanges(){return this.Gb}_takeDirtyByteRanges(){let e=this.Db;return this.Db=[],e}_getViewUniformData(e){let s=this.ew,o=L.viewHeaderVec4Count*4,u=e>=0?this.A0.indexOf(e):-1,r=u>=0?this.I0[u]:void 0;return r==null||!this.W0.has(e)?(s.fill(0),s[o]=-1,s):(s.set(r.array.subarray(0,o)),s[o]=r.vec4Base,s)}update(e){if(!this.iw())return;let s=this.rw(),o=s,u=this.sw(),r=this.i.config,f=this.isGpuBuild,h=Math.max(0,Math.floor(r.clusteredForwardMaxViewNumber)),n=Math.max(1,Math.floor(r.clusteredForwardMinLocalLightNumber)),m=r.isClusteredForwardEnabled&&this.jb>=n&&h>0&&!this.$b?this.nw(e):[];o&&(this.aw(),s=!0),this.H0.length=0,s=this.ow(m,h,o,f)||s,(s||u)&&this.Rb++}iw(){if(this.Z0!=null)return!0;let e=this.i,s=e.globalDataRepository.getValue("clusteredLightData",0);if(s==null)return!1;let o=e.globalDataRepository.getValue("ambientLightIntensity",0);if(o==null)return!1;this.Z0=s._v,this.Pb=o._v,this.Qb=e.globalDataRepository.getLocationOffsetOfProperty("clusteredLightData");let u=e.config;this.F0=Math.min(T(u.maxLightListLength),(this.Z0.length/4-L.globalHeaderVec4Count)*4),this.X0=new Float64Array(this.F0),this.$0=new Float64Array(this.F0),this.j0=new Float64Array(this.F0*4),this.q0=new Float64Array(this.F0*4),this.J0=new Float64Array(this.F0),this.V0=U(u.clusteredForwardGridSize,u.clusteredForwardLightCapacityPerCluster),this.Jb=new Float64Array(this.F0),this.Q0=new Float64Array(this.F0*4),this.wb=new Float64Array(this.F0),this.Kb=new Uint32Array(this.V0.gridZ*2);let r=Math.max(0,Math.floor(u.clusteredForwardMaxViewNumber));return this.U0=this.F0*5+this.V0.gridZ*2,this.Lb=new Float32Array(r*this.U0),this.A0=new Array(r).fill(-1),this.N0=new Array(r).fill(!1),this.Fb=new Array(r).fill(0),this.Xb=new Float32Array(r*32),this.I0=new Array(r).fill(void 0),!0}rw(){let e=this.i.componentRepository._getComponents(D),s=this.F0,o=this.X0,u=this.j0,r=this.J0,f=Math.min(this.i.config.maxLightNumber-1,H),h=0,n=0,m=0,d=!1,i=this.Hb;if(i[0]=0,i[1]=0,i[2]=0,e!=null)for(let a=0;a<e.length;a++){let p=e[a];if(p==null||!p._isAlive)continue;let v=p._lightPropertyForGpu._v,g=v[0];if(g<-.5)continue;if(g>2.5){let t=p._lightIntensityForGpu._v;i[0]+=t[0],i[1]+=t[1],i[2]+=t[2];continue}if(h+n>=s||p.componentSID>=L.entryRadix){d=!0;continue}let b=p._shadowSlot,w=z(p.componentSID,b>=0&&b<=f?b:-1);if(P(g,p._lightPositionForGpu._v,p._lightDirectionForGpu._v,v[1],v[3],u,n*4)<0)o[h++]=w;else{r[n++]=w;let t=p._lightIntensityForGpu._v;(t[0]>0||t[1]>0||t[2]>0)&&m++}}d&&!this.qb&&(G.default.warn(`LightClusterSystem: The number of enabled lights exceeds Config.maxLightListLength (${s}). The other lights are ignored.`),this.qb=!0),o.set(r.subarray(0,n),h);let l=h+n;this.K0=l,this.Zb=h,this._0=n,this.jb=m;let c=l!==this.Wb||h!==this.Yb;if(!c){for(let a=0;a<l;a++)if(o[a]!==this.$0[a]){c=!0;break}}if(!c){for(let a=0;a<n*4;a++)if(u[a]!==this.q0[a]){c=!0;break}}return c&&(this.$0.set(o.subarray(0,l)),this.q0.set(u.subarray(0,n*4)),this.Wb=l,this.Yb=h),c}sw(){let e=this.Pb,s=this.Hb,o=Math.fround(s[0]),u=Math.fround(s[1]),r=Math.fround(s[2]);return e[0]===o&&e[1]===u&&e[2]===r?!1:(e[0]=o,e[1]=u,e[2]=r,!0)}aw(){let e=this.Z0;e[0]=this.K0,e[1]=this.Zb,e[2]=this._0,e[3]=-1;let s=L.globalHeaderVec4Count*4;e.set(this.X0.subarray(0,this.K0),s)}nw(e){let s=this.i,o=s._webXRSystemIfEnabled,u=[],r=f=>{f>=0&&!u.includes(f)&&u.push(f)};for(let f of e)for(let h of f.renderPasses){if(h.isBufferLessRenderingMode()||h.material!=null)continue;if(o!=null&&o.isWebXRMode&&h.isVrRendering){o.isMultiView()||(r(o._getCameraComponentSIDAt(0)),r(o._getCameraComponentSIDAt(1)));continue}let n=h.cameraComponent;n==null&&(n=s.componentRepository.getComponent(V,V.getCurrent(s))),!(n==null||n.isSyncToLight)&&r(n.componentSID)}return u}ow(e,s,o,u){var m,d;let r=this.i,f=this.V0,h=!1,n=new Array(s).fill(-1);for(let i of e){let l=this.A0.indexOf(i);l>=0&&(n[l]=i)}for(let i of e){if(n.includes(i))continue;let l=n.indexOf(-1);if(l<0)break;n[l]=i}for(let i of Array.from(this.W0))if(!n.includes(i)){let l=r.componentRepository.getComponent(V,i);l!=null&&l._lightClusterViewInfoForGpu._v[0]!==-1&&(l._lightClusterViewInfoForGpu._v[0]=-1,h=!0),this.W0.delete(i)}for(let i=0;i<s;i++){let l=n[i];if(l!==this.A0[i]&&(this.A0[i]=l,this.N0[i]=!1),l<0)continue;let c=r.componentRepository.getComponent(V,l);if(c==null){this.A0[i]=-1;continue}let a=this.I0[i];if(a==null){if(a=this.lw(f.viewVec4Count),a==null){this.A0[i]=-1;continue}this.I0[i]=a;let t=(a.vec4Base+L.viewHeaderVec4Count)*16;this.Gb.push([t,(a.vec4Base+f.viewVec4Count)*16]),this.Gb.sort((y,x)=>y[0]-x[0])}let p=c.viewMatrix._v,v=c._projectionMatrixForGpu._v,g=this.Xb,b=i*32,w=!1;for(let t=0;t<16;t++)if(g[b+t]!==p[t]||g[b+16+t]!==v[t]){w=!0;break}if(o||w||!this.N0[i]){if(g.set(p,b),g.set(v,b+16),k(a.array,0,p,v,this.j0,this._0,f,c.zNear,c.zFar),this.uw(a.array,i,u,f),this.Fb[i]=this._0,!u){(d=this[m="Y0"])!=null||(this[m]=N(f)),R(a.array,0,f,this.Q0,this.wb,this._0,this.Y0);let t=(a.vec4Base+L.viewHeaderVec4Count)*16,y=f.tableVec4Count+this.Y0.usedIndexVec4Count;this.Db.push([t,t+y*16])}this.N0[i]=!0,h=!0}let F=c._lightClusterViewInfoForGpu._v;F[0]!==a.vec4Base&&(F[0]=a.vec4Base,h=!0),this.W0.add(l)}if(this.H0.length=0,u)for(let i=0;i<s;i++){let l=this.I0[i];this.N0[i]&&l!=null&&this.A0[i]>=0&&this.H0.push({viewVec4Base:l.vec4Base,localCount:this.Fb[i],dataOffset:i*this.U0})}return h}uw(e,s,o,u){let r=this._0,f=u.clusterLightCapacity,h=u.gridZ,n=this.j0,m=this.J0,d=this.Q0,i=this.wb,l=this.Kb;if(r<=f){d.set(n.subarray(0,r*4)),i.set(m.subarray(0,r));for(let c=0;c<h;c++)l[c*2]=0,l[c*2+1]=r}else{let c=this.Jb,a=this.tw;a.length=r;let p=e[12],v=e[13],g=e[14],b=e[15];for(let t=0;t<r;t++)c[t]=p*n[t*4]+v*n[t*4+1]+g*n[t*4+2]+b,a[t]=t;a.sort((t,y)=>c[t]-c[y]);for(let t=0;t<r;t++){let y=a[t];d[t*4]=n[y*4],d[t*4+1]=n[y*4+1],d[t*4+2]=n[y*4+2],d[t*4+3]=n[y*4+3],i[t]=m[y]}let w=e[20],F=e[21];for(let t=0;t<h;t++){let y=t===0?Number.NEGATIVE_INFINITY:Math.exp((t-F)/w),x=t===h-1?Number.POSITIVE_INFINITY:Math.exp((t+1-F)/w),A=r,B=0;for(let C=0;C<r;C++){let _=a[C],S=c[_],I=n[_*4+3];S+I>=y&&S-I<=x&&(C<A&&(A=C),C+1>B&&(B=C+1))}A>=B&&(A=0,B=0),l[t*2]=A,l[t*2+1]=B}}if(o){let c=s*this.U0,a=this.F0,p=this.Lb;p.set(d.subarray(0,r*4),c),p.set(i.subarray(0,r),c+a*4);let v=c+a*5;for(let g=0;g<h*2;g++)p[v+g]=l[g]}}lw(e){let s=this.i.memoryManager,o=e*16,u=this.i.config.bufferSizeDivisionRatiosForGPUInstanceDataUsage.length;for(let r=0;r<u;r++){let f=s.createOrGetBuffer(M.GPUInstanceData,r);if(f.byteLength-f.takenSizeInByte<o)continue;let h=f.takeBufferView({byteLengthToNeed:o,byteStride:0});if(h.isErr())continue;let n=h.get(),m=s.getByteOffsetOfExistingBuffers(M.GPUInstanceData,f.indexOfTheBufferUsage)+n.byteOffsetInBuffer,d=new Float32Array(f.getArrayBuffer(),n.byteOffsetInRawArrayBufferOfBuffer,e*4);return d.fill(0),{array:d,vec4Base:m/16}}G.default.warn("LightClusterSystem: Failed to allocate the light cluster data. All lights are evaluated."),this.$b=!0}};export{E as LightClusterSystem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LightClusterLayout as e}from"./LightClusterLayout.js";var r=class{constructor(){this.
|
|
1
|
+
import{LightClusterLayout as e}from"./LightClusterLayout.js";var r=class{constructor(){this.ew=new Float32Array(e.viewHeaderVec4Count*4+4);this.ew[e.viewHeaderVec4Count*4]=-1}get dataVersion(){return 0}get isGpuBuild(){return!1}update(t){}_getGpuBuildParams(){}_getExcludedByteRanges(){return[]}_takeDirtyByteRanges(){return[]}_getViewUniformData(t){return this.ew}};export{r as LightClusterSystemStub};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RnObject as i}from"../../core/RnObject.js";var t=class extends i{constructor(){super(...arguments);this.
|
|
1
|
+
import{RnObject as i}from"../../core/RnObject.js";var t=class extends i{constructor(){super(...arguments);this.am=0;this.TT=0;this.hp=[]}async setup(s,p){this.am=s,this.TT=p}setExpressions(s){this.hp=s}};export{t as DeferredRenderPipeline};
|
|
@@ -69,6 +69,16 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
69
69
|
private __frameBufferResolve?;
|
|
70
70
|
private __frameBufferResolveForReference?;
|
|
71
71
|
private __initialExpression?;
|
|
72
|
+
/**
|
|
73
|
+
* The WebXR multiview mode the render targets were built for (`Config.multiViewForWebVR`).
|
|
74
|
+
* The targets and the compiled shaders depend on it, so a change during a session rebuilds
|
|
75
|
+
* them (see `__updateRenderTargetsForMultiViewModeChange`).
|
|
76
|
+
*/
|
|
77
|
+
private __lastMultiViewMode;
|
|
78
|
+
/** Screen-space background material and its buffer-less full-screen pass. */
|
|
79
|
+
private __backgroundMaterial?;
|
|
80
|
+
private __backgroundExpression?;
|
|
81
|
+
private __backgroundRenderPass?;
|
|
72
82
|
/** main expressions */
|
|
73
83
|
private __expressions;
|
|
74
84
|
private __gizmoExpression;
|
|
@@ -168,6 +178,20 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
168
178
|
isTemporalAA?: boolean | undefined;
|
|
169
179
|
shadowMapSize?: number | undefined;
|
|
170
180
|
}): Promise<Err<unknown, undefined> | Ok<unknown, unknown>>;
|
|
181
|
+
/**
|
|
182
|
+
* Whether WebXR is rendering with multiview (one multiview draw writes both eye layers).
|
|
183
|
+
*/
|
|
184
|
+
private __isMultiViewMode;
|
|
185
|
+
/**
|
|
186
|
+
* Rebuilds the render targets and invalidates the shaders when the WebXR multiview mode
|
|
187
|
+
* changes during a session.
|
|
188
|
+
*
|
|
189
|
+
* The pipeline picks the multiview targets and the `WEBGL2_MULTI_VIEW` shader definitions
|
|
190
|
+
* when it is set up. Without this rebuild, flipping `Config.multiViewForWebVR` while a
|
|
191
|
+
* session is running keeps the single-display camera path: the scene is drawn once with
|
|
192
|
+
* one eye's camera and both eyes show the same image.
|
|
193
|
+
*/
|
|
194
|
+
private __updateRenderTargetsForMultiViewModeChange;
|
|
171
195
|
/**
|
|
172
196
|
* Gets the main frame buffer used for back buffer operations.
|
|
173
197
|
*
|
|
@@ -353,7 +377,8 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
353
377
|
* The diffuse texture provides ambient lighting, while the specular texture provides
|
|
354
378
|
* reflections and specular highlights.
|
|
355
379
|
*
|
|
356
|
-
* The sheen texture is optional and used for materials with fabric-like properties.
|
|
380
|
+
* The sheen texture is optional and used for materials with fabric-like properties. Omitting it clears
|
|
381
|
+
* a previously set sheen texture, so switching to an IBL without sheen falls back to the specular cube.
|
|
357
382
|
*
|
|
358
383
|
* @example
|
|
359
384
|
* ```typescript
|
|
@@ -380,6 +405,40 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
380
405
|
* clearing of color and depth buffers before main rendering begins.
|
|
381
406
|
*/
|
|
382
407
|
getInitialExpression(): Expression | undefined;
|
|
408
|
+
/**
|
|
409
|
+
* Sets the material used to draw the screen-space background.
|
|
410
|
+
*
|
|
411
|
+
* The material is rendered by a buffer-less full-screen pass (typically created with
|
|
412
|
+
* `createEnvConstantScreenSpaceMaterial`) before the shadow, raymarching and opaque
|
|
413
|
+
* expressions. The pass has depth test and depth write disabled, so the background
|
|
414
|
+
* never occludes scene objects and does not depend on the camera's near / far planes,
|
|
415
|
+
* frustum culling or any mesh scale.
|
|
416
|
+
*
|
|
417
|
+
* The material can be set before or after `setup()`. Call {@link removeBackgroundMaterial}
|
|
418
|
+
* to stop drawing the background.
|
|
419
|
+
*
|
|
420
|
+
* @param material - The background material
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* const backgroundMaterial = Rn.MaterialHelper.createEnvConstantScreenSpaceMaterial(engine);
|
|
425
|
+
* backgroundMaterial.setTextureParameter('colorEnvTexture', environmentCubeTexture, sampler);
|
|
426
|
+
* pipeline.setBackgroundMaterial(backgroundMaterial);
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
setBackgroundMaterial(material: Material): void;
|
|
430
|
+
/**
|
|
431
|
+
* Gets the material used to draw the screen-space background.
|
|
432
|
+
*
|
|
433
|
+
* @returns The background material, or undefined when no background is drawn
|
|
434
|
+
*/
|
|
435
|
+
getBackgroundMaterial(): Material | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* Stops drawing the screen-space background.
|
|
438
|
+
*
|
|
439
|
+
* The material itself is not destroyed; the caller keeps ownership of it.
|
|
440
|
+
*/
|
|
441
|
+
removeBackgroundMaterial(): void;
|
|
383
442
|
/**
|
|
384
443
|
* Gets the tone mapping expression used for HDR to LDR conversion.
|
|
385
444
|
*
|
|
@@ -610,6 +669,20 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
610
669
|
*/
|
|
611
670
|
setToneMappingType(type: ToneMappingTypeEnum): void;
|
|
612
671
|
private __setupRaymarchingExpression;
|
|
672
|
+
/**
|
|
673
|
+
* Creates the screen-space background expression.
|
|
674
|
+
*
|
|
675
|
+
* The background is drawn by a buffer-less full-screen pass before the shadow,
|
|
676
|
+
* raymarching and opaque expressions, with depth test and depth write disabled.
|
|
677
|
+
* It therefore has no depth: scene geometry and SDFs always composite over it,
|
|
678
|
+
* regardless of their distance from the camera.
|
|
679
|
+
*/
|
|
680
|
+
private __setupBackgroundExpression;
|
|
681
|
+
/**
|
|
682
|
+
* Points a buffer-less full-screen pass at the pipeline's main render targets, including
|
|
683
|
+
* the MSAA resolve targets the transmission pass and mipmap generation read.
|
|
684
|
+
*/
|
|
685
|
+
private __configureMainFrameBufferPassTargets;
|
|
613
686
|
/**
|
|
614
687
|
* Points a buffer-less raymarching pass at the pipeline's render targets, including
|
|
615
688
|
* the MSAA resolve targets the transmission pass and mipmap generation read.
|
|
@@ -823,15 +896,16 @@ export declare class ForwardRenderPipeline extends RnObject {
|
|
|
823
896
|
* This method is called automatically during the render loop to configure
|
|
824
897
|
* the frame with all necessary expressions in the correct order:
|
|
825
898
|
* 1. Initial expression (buffer clearing)
|
|
826
|
-
* 2.
|
|
827
|
-
* 3.
|
|
828
|
-
* 4.
|
|
829
|
-
* 5.
|
|
830
|
-
* 6.
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
* 8.
|
|
834
|
-
* 9.
|
|
899
|
+
* 2. Background expression (screen-space environment, no depth)
|
|
900
|
+
* 3. Shadow expressions
|
|
901
|
+
* 4. Main expressions (opaque rendering)
|
|
902
|
+
* 5. Mipmap generation
|
|
903
|
+
* 6. Multi-view blitting
|
|
904
|
+
* 7. Raymarching expression for transmission materials (samples the scene color;
|
|
905
|
+
* without transmission the raymarching expression is drawn before step 4)
|
|
906
|
+
* 8. Transparent expressions
|
|
907
|
+
* 9. Bloom effect
|
|
908
|
+
* 10. Tone mapping
|
|
835
909
|
*
|
|
836
910
|
* @internal
|
|
837
911
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CameraComponent as q}from"../../components/Camera/CameraComponent.js";import{RaymarchingComponent as C}from"../../components/Raymarching/RaymarchingComponent.js";import{RnObject as H}from"../../core/RnObject.js";import{ComponentType as z,CompositionType as G,PixelFormat as $,ToneMappingType as v}from"../../definitions/index.js";import{ShaderSemantics as I}from"../../definitions/ShaderSemantics.js";import{TextureFormat as R}from"../../definitions/TextureFormat.js";import{TextureParameter as w}from"../../definitions/TextureParameter.js";import{Bloom as Z}from"../../helpers/BloomHelper.js";import{collectRrnJson as J,createNodeBasedRaymarchingComponentShadowMaterial as V,createNodeBasedRaymarchingShadowMaterial as O,RAYMARCHING_COMPONENT_WORLD_MATRIX_SEMANTIC as U}from"../../helpers/materials/createNodeBasedRaymarchingMaterials.js";import{createToneMappingMaterial as K}from"../../helpers/materials/createToneMappingMaterial.js";import{RenderableHelper as F}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as X}from"../../helpers/RenderPassHelper.js";import{ShadowSystem as Q}from"../../helpers/Shadow/ShadowSystem.js";import{Scalar as A}from"../../math/Scalar.js";import{Vector2 as ee}from"../../math/Vector2.js";import{Vector3 as S}from"../../math/Vector3.js";import{Vector4 as N}from"../../math/Vector4.js";import{MiscUtil as k}from"../../misc/index.js";import{Is as g}from"../../misc/Is.js";import{Logger as te}from"../../misc/Logger.js";import{Err as L,Ok as W}from"../../misc/Result.js";import{Sampler as re}from"../../textures/Sampler.js";import{Expression as M}from"../Expression.js";import{Frame as ie}from"../Frame.js";import{RenderPass as P}from"../RenderPass.js";import{_getTemporalAACamera as se,TemporalAASystem as ne}from"../TemporalAA/TemporalAASystem.js";var _=Object.freeze(S.fromCopy3(-1e20,-1e20,-1e20)),D=Object.freeze(S.fromCopy3(1e20,1e20,1e20)),j=class extends H{constructor(e){super();this.sm=0;this.TT=0;this.jR=!1;this.gT=!1;this.Xx=!1;this.wR=!1;this.HR=1024;this.hp=[];this.WT=new M;this.BT=[];this.OR=0;this.kR=1;this.LR=1;this.YR=new Map;this.Zx=new Map;this.wT=new Map;this.qR=-1;this.HT=new Map;this.KR=v.GT_ToneMap;this.$R=[];this.QR=[];this.GT=new Map;this.VT=!1;this.FT=new Map;this.OT=new Map;this.i=e,this.zR=new Z(e)}Lb(){this.yT!=null&&(this.yT.destroy3DAPIResources(),this.yT=void 0),this.IT!=null&&(this.IT.destroy3DAPIResources(),this.IT=void 0),this.PT!=null&&(this.PT.destroy3DAPIResources(),this.PT=void 0),this.MT!=null&&(this.MT.destroy3DAPIResources(),this.MT=void 0),this.RT!=null&&(this.RT.destroy3DAPIResources(),this.RT=void 0),this.zR.destroy3DAPIResources(),this.Yx!=null&&(this.Yx.destroy3DAPIResources(),this.Yx=void 0),this.bT=void 0,this.YT=void 0,this.qT=void 0,this.zT=void 0,this.kT=void 0,this.AT=void 0,this.DT=void 0,this.vT=void 0,this.GT.clear(),this.VT=!1,this.FT.clear(),this.OT.clear(),this.wT.clear(),this.HT.clear(),this.YR.clear()}async setup(e,t,{isShadow:r=!1,isBloom:i=!1,shadowMapSize:s=1024,isSimple:n=!1,isTemporalAA:a=!1}={}){if(this.sm=e,this.TT=t,this.gT=i,this.jR=r,this.Xx=n,this.wR=a,this.HR=s,this.bT!=null)return new L({message:"Already setup",error:void 0});let o=new ie;if(this.bT=o,!this.Xx){let l=new re(this.i,{wrapS:w.Repeat,wrapT:w.Repeat,minFilter:w.LinearMipmapLinear,magFilter:w.Linear});l.create(),this.jT=l,this.Wb(e,t),r&&(this.ST=new Q(this.i,s)),this.RT!=null&&!k.isMobile()&&(this.YT=this.Yb(this.RT)),this.yT!=null&&(this.VR=this.qb(this.yT),this.qT=this.zb(this.yT));let T=this.$b(),h=T.getColorAttachedRenderTargetTexture(0);if(this.db()&&(this.Yx=new ne(this.i,e,t,T.getColorAttachedRenderTargetTexture(0)),h=this.Yx.outputTexture),i){let c=h,{bloomExpression:m,bloomedRenderTarget:p}=this.zR.createBloomExpression({textureToBloom:c,parameters:{}});this.zT=m,h=p}let d=this.Xb(h);this.kT=d}this.DR=this.jb(),this.hp.length>0&&this.setExpressions(this.hp);let[u,f]=this.Hb();return this.AT=u,this._T=f,this.CT(),new W}XR(){return this.yT!=null?this.UT:this.RT}$b(){return this.yT!=null?this.IT:this.MT}LT(){var e;return this.yT!=null?this.yT:(e=this.PT)!=null?e:this.MT}db(){var e;return!this.wR||this.Xx?!1:!((e=this.i._webXRSystemIfEnabled)!=null&&e.isWebXRMode)}setExpressions(e,t={isTransmission:!0}){let r=e.map(i=>i.clone());if(this.Zb(e,{isTransmission:t.isTransmission}),t.isTransmission&&this.Jb(r),this.ST!=null){let i=this.hp.flatMap(s=>s.renderPasses.flatMap(n=>n.entities));this.$R=this.ST.getExpressions(i,this.Rb(),this.Pb())}this.CT()}setGizmoExpression(e){this.WT=e}startRenderLoop(e){return this.bT==null?new L({message:"not initialized.",error:void 0}):(this.JR=e,this.CT(),this.i.startRenderLoop(()=>{let t=this.ST;if(t!=null){let r=this.QR,i=this.Rb();t.isLightChanged()&&(this.$R=t.getExpressions(r,i,this.Pb()),this.CT()),t.setDepthBiasPV(r,i)}this.Kb(),this.Fb(),e(this.bT)}),new W)}draw(){this.Fb(),this.JR(this.bT)}get isTemporalAA(){return this.Yx!=null}resetTemporalAAHistory(){var e;(e=this.Yx)==null||e.resetHistory()}set temporalAACurrentFrameWeight(e){this.Yx!=null&&(this.Yx.currentFrameWeight=e)}get temporalAACurrentFrameWeight(){var e,t;return(t=(e=this.Yx)==null?void 0:e.currentFrameWeight)!=null?t:.1}set temporalAAStaticFrameWeight(e){this.Yx!=null&&(this.Yx.staticFrameWeight=e)}get temporalAAStaticFrameWeight(){var e,t;return(t=(e=this.Yx)==null?void 0:e.staticFrameWeight)!=null?t:.04}_setTemporalAAVarianceClipGamma(e){this.Yx!=null&&(this.Yx.varianceClipGamma=e)}Fb(){if(this.Yx==null)return;let e=this.hp.flatMap(t=>t.renderPasses);this.Yx.prepareFrame(se(this.i,e))}setNeedsShadowMapRefresh(){var e;(e=this.ST)==null||e.setNeedsRefresh()}resize(e,t){if(this.bT==null)return new L({message:"not initialized.",error:void 0});let r=this.i._webXRSystemIfEnabled;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&(e=r.getCanvasWidthForVr(),t=r.getCanvasHeightForVr()),e<=0||t<=0){let s=this.sm,n=this.TT;if(s<=0||n<=0){let[a,o]=this.i.getCanvasSize();s=a,n=o}(s<=0||n<=0)&&(s=1,n=1),te.default.warn(`ForwardRenderPipeline.resize received non-positive dimensions (${e}x${t}). Falling back to ${s}x${n}.`),e=s,t=n}let i=this.getRaymarchingMaterial();return this.i.resizeCanvas(e,t),this.Lb(),this.setup(e,t,{isShadow:this.jR,isBloom:this.gT,shadowMapSize:this.HR,isSimple:this.Xx,isTemporalAA:this.wR}),i!=null&&this.setRaymarchingMaterial(i),new W}setIBLTextures(e,t,r){this.$T=e,this.XT=t,g.exist(r)&&(this.ET=r),this.wb(),this.Db(),this.NT(),this.CT()}getInitialExpression(){return this.DR}getToneMappingExpression(){return this.kT}setDiffuseIBLContribution(e){this.kR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}for(let t of this.BT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}}setSpecularIBLContribution(e){this.LR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}for(let t of this.BT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}}setIBLRotation(e){this.OR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.rotationOfCubeMap=e)}}Zb(e,t={isTransmission:!0}){for(let r of e)for(let i of r.renderPasses)if(i.setToRenderOpaquePrimitives(!0),i.setToRenderBlendWithZWritePrimitives(!0),i.setToRenderBlendWithoutZWritePrimitives(!0),t.isTransmission?i.setToRenderTranslucentPrimitives(!1):i.setToRenderTranslucentPrimitives(!0),i.toClearDepthBuffer=!1,!this.Xx){let s=this.LT();s!=null&&(i.setFramebuffer(s),this.PT!=null?(i.setResolveFramebuffer(this.MT),i.setResolveFramebuffer2(this.RT)):this.yT==null&&(i.setResolveFramebuffer(void 0),i.setResolveFramebuffer2(this.RT)))}this.hp=e,this.wb()}Jb(e){for(let t of e){t.tryToSetUniqueName("modelTransparentForTransmission",!0);for(let r of t.renderPasses)if(r.setToRenderOpaquePrimitives(!1),r.setToRenderTranslucentPrimitives(!0),r.setToRenderBlendWithZWritePrimitives(!1),r.setToRenderBlendWithoutZWritePrimitives(!1),r.toClearDepthBuffer=!1,r.toClearColorBuffer=!1,!this.Xx){r.setFramebuffer(this.LT()),this.PT!=null?r.setResolveFramebuffer(this.MT):r.setResolveFramebuffer(void 0);for(let i of r.entities){let s=i.tryToGetMesh();if(g.exist(s)){let n=s.mesh;if(g.exist(n))for(let a=0;a<n.getPrimitiveNumber();a++)n.getPrimitiveAt(a).material.setTextureParameter("backBufferTexture",this.XR().getColorAttachedRenderTargetTexture(0),this.jT)}}}}this.BT=e,this.Db()}refreshBackBufferTextureOnTransparentMaterials(){var r;if(this.Xx)return;let e=(r=this.XR())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.jT;if(!(e==null||t==null))for(let i of this.BT)for(let s of i.renderPasses)for(let n of s.entities){let a=n.tryToGetMesh();if(g.exist(a)){let o=a.mesh;if(g.exist(o))for(let u=0;u<o.getPrimitiveNumber();u++)o.getPrimitiveAt(u).material.setTextureParameter("backBufferTexture",e,t)}}}jb(){let e=new M;e.tryToSetUniqueName("Initial",!0);let t=new P(this.i);if(t.clearColor=N.fromCopyArray4([0,0,0,0]),t.toClearColorBuffer=!0,t.toClearDepthBuffer=!0,t.isOutputForVr=!0,t.tryToSetUniqueName("InitialRenderPass",!0),e.addRenderPasses([t]),!this.Xx){let r=new P(this.i);r.clearColor=N.fromCopyArray4([0,0,0,0]),r.toClearColorBuffer=!0,r.toClearDepthBuffer=!0,r.setFramebuffer(this.LT()),r.tryToSetUniqueName("InitialRenderPassForFrameBuffer",!0),e.addRenderPasses([r])}return e}Wb(e,t){let r=this.i._webXRSystemIfEnabled,i=this.i.cgApiResourceRepository;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&i.isSupportMultiViewVRRendering(this.i)){let s=F.createFrameBufferTextureArrayForMultiView(this.i,{width:e/2,height:t,arrayLength:2,level:0,internalFormat:this.gT?R.R11F_G11F_B10F:R.RGBA8,format:this.gT?$.RGB:$.RGBA,type:this.gT?z.Float:z.UnsignedByte});s.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiView",!0);let n=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});n.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlit",!0);let a=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlitBackBuffer",!0),this.yT=s,this.IT=n,this.UT=a,this.PT=void 0,this.MT=void 0,this.RT=void 0}else{console.log(`canvasWidth: ${e}, canvasHeight: ${t}`);let s;this.db()||(s=F.createFrameBufferMSAA(this.i,{width:e,height:t,colorBufferNum:1,colorFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],sampleCountMSAA:4,depthBufferFormat:R.Depth32F}),s.tryToSetUniqueName("FramebufferTargetOfToneMappingMsaa",!0));let n=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!0,depthTextureFormat:R.Depth32F});n.tryToSetUniqueName("FramebufferTargetOfToneMappingResolve",!0);let a=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingResolveForReference",!0),this.yT=void 0,this.IT=void 0,this.UT=void 0,this.PT=s,this.MT=n,this.RT=a}}Yb(e){let t=new M;t.tryToSetUniqueName("GenerateMipmaps",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("GenerateMipmaps",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(function(){e.getColorAttachedRenderTargetTexture(0).generateMipmaps()}),t}qb(e){let t=new M;t.tryToSetUniqueName("MultiViewBlitBackBuffer",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlitBackBuffer",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.UT!=null&&!k.isMobile()){let i=this.UT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i),i.generateMipmaps()}}),t}zb(e){let t=new M;t.tryToSetUniqueName("MultiViewBlit",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlit",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.IT!=null){let i=this.IT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i)}}),t}Xb(e){let t=new M,r=K(this.i);this.ZR=r,this.setToneMappingType(this.KR);let i=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);i.tryToSetUniqueName("renderPassToneMapping",!0),i.toClearColorBuffer=!1,i.toClearDepthBuffer=!1,i.isDepthTest=!1,i.clearColor=N.fromCopyArray4([0,0,0,0]),i.isVrRendering=!1,i.isOutputForVr=!1;let s=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);return s.tryToSetUniqueName("renderPassToneMappingVr",!0),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!1,s.clearColor=N.fromCopyArray4([0,0,0,0]),s.isVrRendering=!1,s.isOutputForVr=!0,t.addRenderPasses([i,s]),t}mM(e){return F.createFrameBuffer(this.i,{width:e,height:e,textureNum:1,textureFormats:[R.RG32F],createDepthBuffer:!0,depthTextureFormat:R.Depth32F})}wb(){for(let e of this.hp)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.$T,this.XT,this.ET)}}Db(){for(let e of this.BT)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.$T,this.XT,this.ET)}}setToneMappingType(e){let t=this.ZR;t!=null&&(this.KR=e,t.removeShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"),t.removeShaderDefine("RN_USE_REINHARD"),t.removeShaderDefine("RN_USE_GT_TONEMAP"),t.removeShaderDefine("RN_USE_ACES_NARKOWICZ"),t.removeShaderDefine("RN_USE_ACES_HILL"),t.removeShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"),e===v.KhronosPbrNeutral?t.addShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"):e===v.Reinhard?t.addShaderDefine("RN_USE_REINHARD"):e===v.GT_ToneMap?t.addShaderDefine("RN_USE_GT_TONEMAP"):e===v.ACES_Narkowicz?t.addShaderDefine("RN_USE_ACES_NARKOWICZ"):e===v.ACES_Hill?t.addShaderDefine("RN_USE_ACES_HILL"):e===v.ACES_Hill_Exposure_Boost&&t.addShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"))}Hb(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=new P(this.i);return t.toClearDepthBuffer=!1,t.isDepthTest=!0,this.Gb(t),t.setPreRenderFunction(()=>this.Qb(t)),e.addRenderPasses([t]),t.tryToSetUniqueName("Raymarching",!0),[e,t]}Gb(e){var r;let t=this.LT();e.setFramebuffer(t),t!=null&&this.PT!=null?(e.setResolveFramebuffer(this.MT),e.setResolveFramebuffer2((r=this.RT)!=null?r:void 0)):(e.setResolveFramebuffer(void 0),e.setResolveFramebuffer2(t!=null?this.RT:void 0))}Qb(e){this.NT(),this.ZT();let t=e.material;if(t==null)return;let r=this.i.componentRepository.getComponentsWithType(C),i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,f=r.length>0;for(let l of r){let T=l.entity.tryToGetSceneGraph();T!=null&&(t.setParameter(`worldMatrix_${l.componentSID}`,T.matrixInner),t.setParameter(`raymarchObjectId_${l.componentSID}`,A.fromCopyNumber(l.componentSID)));let h=this.JT(l);if(h==null){f=!1;continue}i=Math.min(i,h.min.x),s=Math.min(s,h.min.y),n=Math.min(n,h.min.z),a=Math.max(a,h.max.x),o=Math.max(o,h.max.y),u=Math.max(u,h.max.z)}f?(t.setParameter("raymarchAabbMin",S.fromCopy3(i,s,n)),t.setParameter("raymarchAabbMax",S.fromCopy3(a,o,u))):(t.setParameter("raymarchAabbMin",_),t.setParameter("raymarchAabbMax",D))}setRaymarchingComponentMaterial(e,t){var r;this.Zx.set(e.componentSID,t),this.NT(),this.ZT(),(r=this.ST)==null||r.applyShadowParametersToMaterials([t]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}getRaymarchingComponentMaterial(e){return this.Zx.get(e.componentSID)}removeRaymarchingComponentMaterial(e){this.Zx.delete(e.componentSID)&&(this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT())}setRaymarchingMaterial(e){var t,r;(t=this._T)==null||t.setBufferLessFullScreenRendering(e),this.NT(),this.ZT(),(r=this.ST)==null||r.applyShadowParametersToMaterials([e]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}eM(){let e=[],t=new Set;if(this.qR=-1,this.Zx.size>0)for(let r of this.KT()){let i=r.componentSID,s=this.Zx.get(i);if(s==null)continue;t.add(i);let n=this.wT.get(i);n==null&&(n=new P(this.i),n.toClearDepthBuffer=!1,n.isDepthTest=!0,n.setPreRenderFunction(()=>this.tM(i)),n.tryToSetUniqueName(`Raymarching_${i}`,!0),this.wT.set(i,n)),n.setBufferLessFullScreenRendering(s),this.Gb(n),e.length===0&&(this.qR=i),e.push(n)}for(let r of[...this.wT.keys()])t.has(r)||this.wT.delete(r);for(let r of[...this.Zx.keys()])!t.has(r)&&this.i.componentRepository.getComponent(C,r)==null&&this.Zx.delete(r);return e}tM(e){var n,a,o;e===this.qR&&(this.NT(),this.ZT());let t=this.Zx.get(e),r=this.i.componentRepository.getComponent(C,e),i=r==null?void 0:r.entity.tryToGetSceneGraph();if(t==null||r==null||i==null)return;t.setParameter(U,i.matrixInner);let s=this.JT(r);t.setParameter("raymarchAabbMin",(n=s==null?void 0:s.min)!=null?n:_),t.setParameter("raymarchAabbMax",(a=s==null?void 0:s.max)!=null?a:D),(o=this.wT.get(e))==null||o.setScissorRect(this.rM(s))}JT(e){let t=e.entity.tryToGetSceneGraph();if(t==null)return null;let r=t.matrixInner,i=[r.m00,r.m01,r.m02,r.m03,r.m10,r.m11,r.m12,r.m13,r.m20,r.m21,r.m22,r.m23,r.m30,r.m31,r.m32,r.m33],s=C.getAABBVersion(this.i),n=e.componentSID,a=this.HT.get(n);if(a!=null&&a.aabbVersion===s&&a.matrix.length===i.length&&a.matrix.every((f,l)=>f===i[l]))return a.aabb;let o=e.calcWorldAABB();if(o==null)return this.HT.delete(n),null;let u={min:S.fromCopy3(o.minPoint.x,o.minPoint.y,o.minPoint.z),max:S.fromCopy3(o.maxPoint.x,o.maxPoint.y,o.maxPoint.z)};return this.HT.set(n,{aabbVersion:s,matrix:i,aabb:u}),u}rM(e){if(e==null||this.sm<=0||this.TT<=0)return;let t=this.i.componentRepository.getComponent(q,q.getCurrent(this.i));if(t==null)return;let r=t.viewProjectionMatrix,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let c=0;c<8;c++){let m=(c&1)===0?e.min.x:e.max.x,p=(c&2)===0?e.min.y:e.max.y,x=(c&4)===0?e.min.z:e.max.z,y=r.multiplyVector(N.fromCopy4(m,p,x,1));if(y.w<=0)return;let E=y.x/y.w,B=y.y/y.w,b=(E*.5+.5)*this.sm,Y=(-B*.5+.5)*this.TT;i=Math.min(i,b),s=Math.min(s,Y),n=Math.max(n,b),a=Math.max(a,Y)}let o=2,u=Math.max(0,Math.floor(i)-o),f=Math.max(0,Math.floor(s)-o),l=Math.min(this.sm,Math.ceil(n)+o),T=Math.min(this.TT,Math.ceil(a)+o),h=l-u,d=T-f;if(h<=0||d<=0)return{x:0,y:0,width:1,height:1};if(!(u===0&&f===0&&h===this.sm&&d===this.TT))return{x:u,y:f,width:h,height:d}}QT(){let e=[];for(let r of this.Zx.values())e.push(r);let t=this.getRaymarchingMaterial();return t!=null&&e.push(t),e}iM(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=this.eM();return t.length>0?e.addRenderPasses(t):this._T!=null&&this._T.material!=null&&e.addRenderPasses([this._T]),e}refreshRaymarchingShadowMaterial(){let e=this.vT,t=new Map(this.FT);if(this.DT=void 0,this.vT=void 0,this.GT.clear(),this.FT.clear(),this.OT.clear(),this.VT=this.Zx.size>0,!(this.ST==null||this.i.config.maxLightNumber<=0)){if(this.VT)for(let r of this.KT()){let i=r.componentSID;if(!r.castShadow||!this.Zx.has(i))continue;let s=V(this.i,r,"regular",t.get(i));s!=null&&this.FT.set(i,s)}else{let r=J(this.i,{castShadowOnly:!0});if(r.nodes.length>0){let i=r;this.DT=i,this.vT=O(this.i,i,"regular",e)}}this.ST.invalidateShadowVolumeFitting(),this.ST.setNeedsRefresh()}}KT(){let e=this.i.componentRepository.getComponentsWithType(C).slice();return e.sort((t,r)=>t.componentSID-r.componentSID),e}getRaymarchingShadowMaterial(){return this.vT}getRaymarchingComponentShadowMaterial(e){return this.FT.get(e.componentSID)}Pb(){return{hasCaster:()=>this.VT?this.FT.size>0:this.DT!=null&&this.vT!=null,createPasses:e=>this.sM(e),updatePointLightFarPlane:(e,t)=>this.nM(e,t)}}aM(e,t,r){let i=this.GT.get(e);if(i==null){let n=this.DT;if(n==null)return;let a=O(this.i,n,"paraboloidFront"),o=O(this.i,n,"paraboloidBack");if(a==null||o==null)return;i={front:a,back:o},this.GT.set(e,i)}let s=A.fromCopyNumber(t);return i.front.setParameter("lightIndex",s),i.back.setParameter("lightIndex",s),this.NR(i,r),i}NR(e,t){let r=A.fromCopyNumber(t);e.front.setParameter("shadowFarPlane",r),e.back.setParameter("shadowFarPlane",r)}oM(e,t,r,i){let s=this.OT.get(e);s==null&&(s=new Map,this.OT.set(e,s));let n=s.get(i.componentSID);if(n==null){let o=V(this.i,i,"paraboloidFront"),u=V(this.i,i,"paraboloidBack");if(o==null||u==null)return;n={front:o,back:u},s.set(i.componentSID,n)}let a=A.fromCopyNumber(t);return n.front.setParameter("lightIndex",a),n.back.setParameter("lightIndex",a),this.NR(n,r),n}nM(e,t){let r=this.GT.get(e);r!=null&&this.NR(r,t);let i=this.OT.get(e);if(i!=null)for(let s of i.values())this.NR(s,t)}sM(e){let{lightComponent:t,kind:r,shadowSlot:i,farPlane:s}=e;if(this.VT){let a=[];for(let o of this.KT()){let u=o.componentSID;if(!o.castShadow||!this.Zx.has(u))continue;let f;if(r==="regular")f=this.FT.get(u);else{let l=this.oM(i,t.componentSID,s!=null?s:1e3,o);f=r==="paraboloidFront"?l==null?void 0:l.front:l==null?void 0:l.back}f!=null&&a.push(this.Ub(f,e))}return a}let n;if(r==="regular")n=this.vT;else{let a=this.aM(i,t.componentSID,s!=null?s:1e3);n=r==="paraboloidFront"?a==null?void 0:a.front:a==null?void 0:a.back}return n==null?[]:[this.Ub(n,e)]}Ub(e,{lightEntity:t,framebuffer:r,kind:i}){let s=new P(this.i);return s.isVrRendering=!1,s.setBufferLessFullScreenRendering(e),s.setFramebuffer(r),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!0,s.depthWriteMask=!0,i==="regular"&&(s.cameraComponent=t.getCamera()),s.tryToSetUniqueName(`RaymarchingShadow_${i}`,!0),s}Kb(){if(this.VT){this.hM();return}if(this.DT==null)return;let e=[];this.vT!=null&&e.push(this.vT);for(let m of this.GT.values())e.push(m.front,m.back);let t=this.Zx,r=this.getRaymarchingMaterial(),i=t.size>0?t.values().next().value:r,s=(m,p,x)=>{if(i!=null)if(G.isTexture(x.compositionType)){let y=i.getTextureParameter(p);y!=null&&m.setTextureParameter(p,y[1],y[2])}else{let y=i.getParameter(p);y!=null&&m.setParameter(p,y)}},n=this.i.componentRepository.getComponentsWithType(C),a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,h=!1;for(let m of n){if(!m.castShadow)continue;h=!0;let p=this.JT(m);if(p==null){h=!1;break}a=Math.min(a,p.min.x),o=Math.min(o,p.min.y),u=Math.min(u,p.min.z),f=Math.max(f,p.max.x),l=Math.max(l,p.max.y),T=Math.max(T,p.max.z)}let d=h?S.fromCopy3(a,o,u):_,c=h?S.fromCopy3(f,l,T):D;for(let m of e){m.setParameter("raymarchAabbMin",d),m.setParameter("raymarchAabbMax",c);for(let p of m.fieldsInfoArray){let x=p.semantic;if(x.startsWith("worldMatrix_")||x.startsWith("raymarchObjectId_")||x==="raymarchAabbMin"||x==="raymarchAabbMax"||x==="lightIndex"||x==="shadowFarPlane")continue;let y=/^(.*)_(\d+)$/.exec(x),E=y!=null?t.get(Number(y[2])):void 0;if(E!=null){let B=y[1];if(G.isTexture(p.compositionType)){let b=E.getTextureParameter(B);b!=null&&m.setTextureParameter(x,b[1],b[2])}else{let b=E.getParameter(B);b!=null&&m.setParameter(x,b)}}else s(m,x,p)}for(let p of n){if(!p.castShadow)continue;let x=p.entity.tryToGetSceneGraph();x!=null&&m.setParameter(`worldMatrix_${p.componentSID}`,x.matrixInner),m.setParameter(`raymarchObjectId_${p.componentSID}`,A.fromCopyNumber(p.componentSID))}}}hM(){var e,t;for(let r of this.KT()){let i=r.componentSID;if(!r.castShadow)continue;let s=this.Zx.get(i);if(s==null)continue;let n=[],a=this.FT.get(i);a!=null&&n.push(a);for(let h of this.OT.values()){let d=h.get(i);d!=null&&n.push(d.front,d.back)}if(n.length===0)continue;let o=r.entity.tryToGetSceneGraph(),u=o==null?void 0:o.matrixInner,f=this.JT(r),l=(e=f==null?void 0:f.min)!=null?e:_,T=(t=f==null?void 0:f.max)!=null?t:D;for(let h of n){u!=null&&h.setParameter(U,u),h.setParameter("raymarchAabbMin",l),h.setParameter("raymarchAabbMax",T);for(let d of h.fieldsInfoArray){let c=d.semantic;if(!(c===U||c==="raymarchAabbMin"||c==="raymarchAabbMax"||c==="lightIndex"||c==="shadowFarPlane"))if(G.isTexture(d.compositionType)){let m=s.getTextureParameter(c);m!=null&&h.setTextureParameter(c,m[1],m[2])}else{let m=s.getParameter(c);m!=null&&h.setParameter(c,m)}}}}}Rb(){return this.QT()}getRaymarchingMaterial(){var e;return(e=this._T)==null?void 0:e.material}NT(){for(let e of this.QT())this.uM(e)}uM(e){var u,f,l,T,h,d;let t=e.getTextureParameter(I.DiffuseEnvTexture.str),r=e.getTextureParameter(I.SpecularEnvTexture.str);if(t==null||r==null)return;let i=e.getTextureParameter(I.SheenEnvTexture.str),s=this.$T,n=this.XT;if(s==null||n==null)return;let a=`${s.objectUID}:${s.isTextureReady}:${n.objectUID}:${n.isTextureReady}:${(f=(u=this.ET)==null?void 0:u.objectUID)!=null?f:-1}:${(T=(l=this.ET)==null?void 0:l.isTextureReady)!=null?T:!1}:${this.OR}:${this.kR}:${this.LR}`;if(a===this.YR.get(e.objectUID))return;this.YR.set(e.objectUID,a);let o=t[2];if(s.isTextureReady&&e.setTextureParameter(I.DiffuseEnvTexture.str,s,o),n.isTextureReady&&(e.setTextureParameter(I.SpecularEnvTexture.str,n,o),i!=null)){let c=(h=this.ET)!=null&&h.isTextureReady?this.ET:n,m=(d=i[2])!=null?d:o;e.setTextureParameter(I.SheenEnvTexture.str,c,m)}e.setParameter("iblParameter",N.fromCopy4(n.mipmapLevelNumber,this.kR,this.LR,this.OR)),e.setParameter("hdriFormat",ee.fromCopy2(s.hdriFormat.index,n.hdriFormat.index))}fM(){return this.QT().some(e=>e.isShaderDefine("RN_USE_TRANSMISSION"))}ZT(){var r;if(this.Xx)return;let e=(r=this.XR())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.jT;if(!(e==null||t==null))for(let i of this.QT())i.setTextureParameter(I.BackBufferTexture.str,e,t)}CT(){let e=this.bT;if(e==null){console.log("Frame is not set.");return}if(e.clearExpressions(),e.addExpression(this.DR),this.AT=this.iM(),!this.Xx)for(let i of this.$R)e.addExpression(i);let t=this.fM();!t&&this.AT!=null&&e.addExpression(this.AT);for(let i of this.hp)this.Xx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);!this.Xx&&this.YT!=null&&!k.isMobile()&&e.addExpression(this.YT),!this.Xx&&this.VR!=null&&e.addExpression(this.VR),t&&this.AT!=null&&e.addExpression(this.AT);for(let i of this.BT)this.Xx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);if(this.WT.renderPasses.length>0){if(!this.Xx){let i=this.LT();if(i!=null)for(let s of this.WT.renderPasses)s.setFramebuffer(i),this.PT!=null&&s.setResolveFramebuffer(this.MT)}e.addExpression(this.WT)}let r=this.hp.flatMap(i=>i.renderPasses.flatMap(s=>s.entities));this.QR=r,this.Yx!=null&&(this.Yx.setEntities(r),e.addExpression(this.Yx.expression)),!this.Xx&&this.qT!=null&&e.addExpression(this.qT),!this.Xx&&this.gT&&this.zT!=null&&e.addExpression(this.zT),!this.Xx&&this.kT!=null&&e.addExpression(this.kT)}};export{j as ForwardRenderPipeline};
|
|
1
|
+
import{CameraComponent as Y}from"../../components/Camera/CameraComponent.js";import{RaymarchingComponent as C}from"../../components/Raymarching/RaymarchingComponent.js";import{RnObject as H}from"../../core/RnObject.js";import{ComponentType as z,CompositionType as V,PixelFormat as $,ToneMappingType as v}from"../../definitions/index.js";import{ShaderSemantics as F}from"../../definitions/ShaderSemantics.js";import{TextureFormat as y}from"../../definitions/TextureFormat.js";import{TextureParameter as w}from"../../definitions/TextureParameter.js";import{Bloom as Z}from"../../helpers/BloomHelper.js";import{collectRrnJson as J,createNodeBasedRaymarchingComponentShadowMaterial as G,createNodeBasedRaymarchingShadowMaterial as O,RAYMARCHING_COMPONENT_WORLD_MATRIX_SEMANTIC as U}from"../../helpers/materials/createNodeBasedRaymarchingMaterials.js";import{createToneMappingMaterial as K}from"../../helpers/materials/createToneMappingMaterial.js";import{RenderableHelper as I}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as X}from"../../helpers/RenderPassHelper.js";import{ShadowSystem as Q}from"../../helpers/Shadow/ShadowSystem.js";import{Scalar as E}from"../../math/Scalar.js";import{Vector2 as ee}from"../../math/Vector2.js";import{Vector3 as P}from"../../math/Vector3.js";import{Vector4 as N}from"../../math/Vector4.js";import{MiscUtil as k}from"../../misc/index.js";import{Is as R}from"../../misc/Is.js";import{Logger as te}from"../../misc/Logger.js";import{Err as L,Ok as W}from"../../misc/Result.js";import{Sampler as re}from"../../textures/Sampler.js";import{Expression as M}from"../Expression.js";import{Frame as ie}from"../Frame.js";import{RenderPass as S}from"../RenderPass.js";import{_getTemporalAACamera as se,TemporalAASystem as ne}from"../TemporalAA/TemporalAASystem.js";var _=Object.freeze(P.fromCopy3(-1e20,-1e20,-1e20)),D=Object.freeze(P.fromCopy3(1e20,1e20,1e20)),j=class extends H{constructor(e){super();this.am=0;this.TT=0;this.xM=!1;this.PT=!1;this.yT=!1;this.zR=!1;this.TM=1024;this.XR=!1;this.hp=[];this.jT=new M;this.VT=[];this.HR=0;this.ZR=1;this.JR=1;this.KR=new Map;this.RT=new Map;this.GT=new Map;this.QR=-1;this.VR=new Map;this.bM=v.GT_ToneMap;this.mM=[];this.MM=[];this.kT=new Map;this.LT=!1;this.ET=new Map;this.WT=new Map;this.i=e,this.hM=new Z(e)}_M(){this.MT!=null&&(this.MT.destroy3DAPIResources(),this.MT=void 0),this.BT!=null&&(this.BT.destroy3DAPIResources(),this.BT=void 0),this.FT!=null&&(this.FT.destroy3DAPIResources(),this.FT=void 0),this.vT!=null&&(this.vT.destroy3DAPIResources(),this.vT=void 0),this.ST!=null&&(this.ST.destroy3DAPIResources(),this.ST=void 0),this.hM.destroy3DAPIResources(),this.gT!=null&&(this.gT.destroy3DAPIResources(),this.gT=void 0),this.bT=void 0,this.HT=void 0,this.ZT=void 0,this.JT=void 0,this.zT=void 0,this.XT=void 0,this.YT=void 0,this._T=void 0,this.UT=void 0,this.NT=void 0,this.kT.clear(),this.LT=!1,this.ET.clear(),this.WT.clear(),this.GT.clear(),this.VR.clear(),this.KR.clear()}async setup(e,t,{isShadow:r=!1,isBloom:i=!1,shadowMapSize:s=1024,isSimple:n=!1,isTemporalAA:a=!1}={}){if(this.am=e,this.TT=t,this.PT=i,this.xM=r,this.yT=n,this.zR=a,this.TM=s,this.bT!=null)return new L({message:"Already setup",error:void 0});let o=new ie;if(this.bT=o,!this.yT){let m=new re(this.i,{wrapS:w.Repeat,wrapT:w.Repeat,minFilter:w.LinearMipmapLinear,magFilter:w.Linear});m.create(),this.NR=m,this.DM(e,t),r&&(this.IT=new Q(this.i,s)),this.ST!=null&&!k.isMobile()&&(this.HT=this.VM(this.ST)),this.MT!=null&&(this.jR=this.GM(this.MT),this.ZT=this.OM(this.MT));let T=this.UM(),h=T.getColorAttachedRenderTargetTexture(0);if(this.SM()&&(this.gT=new ne(this.i,e,t,T.getColorAttachedRenderTargetTexture(0)),h=this.gT.outputTexture),i){let c=h,{bloomExpression:l,bloomedRenderTarget:p}=this.hM.createBloomExpression({textureToBloom:c,parameters:{}});this.JT=l,h=p}let d=this.kM(h);this.zT=d}this.$R=this.LM(),this.hp.length>0&&this.setExpressions(this.hp);let[u,f]=this.WM();return this._T=u,this.OT=f,this.XT=this.qM(),this.DT!=null&&this.YT.setBufferLessFullScreenRendering(this.DT),this.CT(),this.XR=this.PM(),new W}PM(){var t;let e=this.i._webXRSystemIfEnabled;return((t=e==null?void 0:e.isWebXRMode)!=null?t:!1)&&e.isMultiView()}vM(){let e=this.PM();this.XR!==e&&(this.XR=e,this.i.materialRepository._makeShaderInvalidateToAllMaterials(),this.resize(this.am,this.TT))}dM(){return this.MT!=null?this.qT:this.ST}UM(){return this.MT!=null?this.BT:this.vT}$T(){var e;return this.MT!=null?this.MT:(e=this.FT)!=null?e:this.vT}SM(){var e;return!this.zR||this.yT?!1:!((e=this.i._webXRSystemIfEnabled)!=null&&e.isWebXRMode)}setExpressions(e,t={isTransmission:!0}){let r=e.map(i=>i.clone());if(this.YM(e,{isTransmission:t.isTransmission}),t.isTransmission&&this.zM(r),this.IT!=null){let i=this.hp.flatMap(s=>s.renderPasses.flatMap(n=>n.entities));this.mM=this.IT.getExpressions(i,this.FM(),this.IM())}this.CT()}setGizmoExpression(e){this.jT=e}startRenderLoop(e){return this.bT==null?new L({message:"not initialized.",error:void 0}):(this.RM=e,this.CT(),this.i.startRenderLoop(()=>{this.vM();let t=this.IT;if(t!=null){let r=this.MM,i=this.FM();t.isLightChanged()&&(this.mM=t.getExpressions(r,i,this.IM()),this.CT()),t.setDepthBiasPV(r,i)}this.$M(),this.CM(),e(this.bT)}),new W)}draw(){this.vM(),this.CM(),this.RM(this.bT)}get isTemporalAA(){return this.gT!=null}resetTemporalAAHistory(){var e;(e=this.gT)==null||e.resetHistory()}set temporalAACurrentFrameWeight(e){this.gT!=null&&(this.gT.currentFrameWeight=e)}get temporalAACurrentFrameWeight(){var e,t;return(t=(e=this.gT)==null?void 0:e.currentFrameWeight)!=null?t:.1}set temporalAAStaticFrameWeight(e){this.gT!=null&&(this.gT.staticFrameWeight=e)}get temporalAAStaticFrameWeight(){var e,t;return(t=(e=this.gT)==null?void 0:e.staticFrameWeight)!=null?t:.04}_setTemporalAAVarianceClipGamma(e){this.gT!=null&&(this.gT.varianceClipGamma=e)}CM(){if(this.gT==null)return;let e=this.hp.flatMap(t=>t.renderPasses);this.gT.prepareFrame(se(this.i,e))}setNeedsShadowMapRefresh(){var e;(e=this.IT)==null||e.setNeedsRefresh()}resize(e,t){if(this.bT==null)return new L({message:"not initialized.",error:void 0});let r=this.i._webXRSystemIfEnabled;if(R.exist(r)&&(r!=null&&r.isWebXRMode)&&(e=r.getCanvasWidthForVr(),t=r.getCanvasHeightForVr()),e<=0||t<=0){let s=this.am,n=this.TT;if(s<=0||n<=0){let[a,o]=this.i.getCanvasSize();s=a,n=o}(s<=0||n<=0)&&(s=1,n=1),te.default.warn(`ForwardRenderPipeline.resize received non-positive dimensions (${e}x${t}). Falling back to ${s}x${n}.`),e=s,t=n}let i=this.getRaymarchingMaterial();return this.i.resizeCanvas(e,t),this._M(),this.setup(e,t,{isShadow:this.xM,isBloom:this.PT,shadowMapSize:this.TM,isSimple:this.yT,isTemporalAA:this.zR}),i!=null&&this.setRaymarchingMaterial(i),new W}setIBLTextures(e,t,r){this.KT=e,this.QT=t,this.wT=r,this.NM(),this.BM(),this.AT(),this.CT()}getInitialExpression(){return this.$R}setBackgroundMaterial(e){var t;this.DT=e,(t=this.YT)==null||t.setBufferLessFullScreenRendering(e),this.bT!=null&&this.CT()}getBackgroundMaterial(){return this.DT}removeBackgroundMaterial(){this.DT=void 0,this.bT!=null&&this.CT()}getToneMappingExpression(){return this.zT}setDiffuseIBLContribution(e){this.ZR=e,this.AT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();R.exist(s)&&(s.diffuseCubeMapContribution=e)}for(let t of this.VT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();R.exist(s)&&(s.diffuseCubeMapContribution=e)}}setSpecularIBLContribution(e){this.JR=e,this.AT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();R.exist(s)&&(s.specularCubeMapContribution=e)}for(let t of this.VT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();R.exist(s)&&(s.specularCubeMapContribution=e)}}setIBLRotation(e){this.HR=e,this.AT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();R.exist(s)&&(s.rotationOfCubeMap=e)}}YM(e,t={isTransmission:!0}){for(let r of e)for(let i of r.renderPasses)if(i.setToRenderOpaquePrimitives(!0),i.setToRenderBlendWithZWritePrimitives(!0),i.setToRenderBlendWithoutZWritePrimitives(!0),t.isTransmission?i.setToRenderTranslucentPrimitives(!1):i.setToRenderTranslucentPrimitives(!0),i.toClearDepthBuffer=!1,!this.yT){let s=this.$T();s!=null&&(i.setFramebuffer(s),this.FT!=null?(i.setResolveFramebuffer(this.vT),i.setResolveFramebuffer2(this.ST)):this.MT==null&&(i.setResolveFramebuffer(void 0),i.setResolveFramebuffer2(this.ST)))}this.hp=e,this.NM()}zM(e){for(let t of e){t.tryToSetUniqueName("modelTransparentForTransmission",!0);for(let r of t.renderPasses)if(r.setToRenderOpaquePrimitives(!1),r.setToRenderTranslucentPrimitives(!0),r.setToRenderBlendWithZWritePrimitives(!1),r.setToRenderBlendWithoutZWritePrimitives(!1),r.toClearDepthBuffer=!1,r.toClearColorBuffer=!1,!this.yT){r.setFramebuffer(this.$T()),this.FT!=null?r.setResolveFramebuffer(this.vT):r.setResolveFramebuffer(void 0);for(let i of r.entities){let s=i.tryToGetMesh();if(R.exist(s)){let n=s.mesh;if(R.exist(n))for(let a=0;a<n.getPrimitiveNumber();a++)n.getPrimitiveAt(a).material.setTextureParameter("backBufferTexture",this.dM().getColorAttachedRenderTargetTexture(0),this.NR)}}}}this.VT=e,this.BM()}refreshBackBufferTextureOnTransparentMaterials(){var r;if(this.yT)return;let e=(r=this.dM())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.NR;if(!(e==null||t==null))for(let i of this.VT)for(let s of i.renderPasses)for(let n of s.entities){let a=n.tryToGetMesh();if(R.exist(a)){let o=a.mesh;if(R.exist(o))for(let u=0;u<o.getPrimitiveNumber();u++)o.getPrimitiveAt(u).material.setTextureParameter("backBufferTexture",e,t)}}}LM(){let e=new M;e.tryToSetUniqueName("Initial",!0);let t=new S(this.i);if(t.clearColor=N.fromCopyArray4([0,0,0,0]),t.toClearColorBuffer=!0,t.toClearDepthBuffer=!0,t.isOutputForVr=!0,t.tryToSetUniqueName("InitialRenderPass",!0),e.addRenderPasses([t]),!this.yT){let r=new S(this.i);r.clearColor=N.fromCopyArray4([0,0,0,0]),r.toClearColorBuffer=!0,r.toClearDepthBuffer=!0,r.setFramebuffer(this.$T()),r.tryToSetUniqueName("InitialRenderPassForFrameBuffer",!0),e.addRenderPasses([r])}return e}DM(e,t){let r=this.i._webXRSystemIfEnabled,i=this.i.cgApiResourceRepository;if(R.exist(r)&&(r!=null&&r.isWebXRMode)&&i.isSupportMultiViewVRRendering(this.i)){let s=I.createFrameBufferTextureArrayForMultiView(this.i,{width:e/2,height:t,arrayLength:2,level:0,internalFormat:this.PT?y.R11F_G11F_B10F:y.RGBA8,format:this.PT?$.RGB:$.RGBA,type:this.PT?z.Float:z.UnsignedByte});s.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiView",!0);let n=I.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.PT?y.R11F_G11F_B10F:y.RGBA8],createDepthBuffer:!1});n.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlit",!0);let a=I.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.PT?y.R11F_G11F_B10F:y.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlitBackBuffer",!0),this.MT=s,this.BT=n,this.qT=a,this.FT=void 0,this.vT=void 0,this.ST=void 0}else{console.log(`canvasWidth: ${e}, canvasHeight: ${t}`);let s;this.SM()||(s=I.createFrameBufferMSAA(this.i,{width:e,height:t,colorBufferNum:1,colorFormats:[this.PT?y.R11F_G11F_B10F:y.RGBA8],sampleCountMSAA:4,depthBufferFormat:y.Depth32F}),s.tryToSetUniqueName("FramebufferTargetOfToneMappingMsaa",!0));let n=I.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.PT?y.R11F_G11F_B10F:y.RGBA8],createDepthBuffer:!0,depthTextureFormat:y.Depth32F});n.tryToSetUniqueName("FramebufferTargetOfToneMappingResolve",!0);let a=I.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.PT?y.R11F_G11F_B10F:y.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingResolveForReference",!0),this.MT=void 0,this.BT=void 0,this.qT=void 0,this.FT=s,this.vT=n,this.ST=a}}VM(e){let t=new M;t.tryToSetUniqueName("GenerateMipmaps",!0);let r=new S(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("GenerateMipmaps",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(function(){e.getColorAttachedRenderTargetTexture(0).generateMipmaps()}),t}GM(e){let t=new M;t.tryToSetUniqueName("MultiViewBlitBackBuffer",!0);let r=new S(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlitBackBuffer",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.qT!=null&&!k.isMobile()){let i=this.qT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i),i.generateMipmaps()}}),t}OM(e){let t=new M;t.tryToSetUniqueName("MultiViewBlit",!0);let r=new S(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlit",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.BT!=null){let i=this.BT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i)}}),t}kM(e){let t=new M,r=K(this.i);this.yM=r,this.setToneMappingType(this.bM);let i=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);i.tryToSetUniqueName("renderPassToneMapping",!0),i.toClearColorBuffer=!1,i.toClearDepthBuffer=!1,i.isDepthTest=!1,i.clearColor=N.fromCopyArray4([0,0,0,0]),i.isVrRendering=!1,i.isOutputForVr=!1;let s=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);return s.tryToSetUniqueName("renderPassToneMappingVr",!0),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!1,s.clearColor=N.fromCopyArray4([0,0,0,0]),s.isVrRendering=!1,s.isOutputForVr=!0,t.addRenderPasses([i,s]),t}zS(e){return I.createFrameBuffer(this.i,{width:e,height:e,textureNum:1,textureFormats:[y.RG32F],createDepthBuffer:!0,depthTextureFormat:y.Depth32F})}NM(){for(let e of this.hp)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();R.exist(i)&&i.setIBLCubeMap(this.KT,this.QT,this.wT)}}BM(){for(let e of this.VT)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();R.exist(i)&&i.setIBLCubeMap(this.KT,this.QT,this.wT)}}setToneMappingType(e){let t=this.yM;t!=null&&(this.bM=e,t.removeShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"),t.removeShaderDefine("RN_USE_REINHARD"),t.removeShaderDefine("RN_USE_GT_TONEMAP"),t.removeShaderDefine("RN_USE_ACES_NARKOWICZ"),t.removeShaderDefine("RN_USE_ACES_HILL"),t.removeShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"),e===v.KhronosPbrNeutral?t.addShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"):e===v.Reinhard?t.addShaderDefine("RN_USE_REINHARD"):e===v.GT_ToneMap?t.addShaderDefine("RN_USE_GT_TONEMAP"):e===v.ACES_Narkowicz?t.addShaderDefine("RN_USE_ACES_NARKOWICZ"):e===v.ACES_Hill?t.addShaderDefine("RN_USE_ACES_HILL"):e===v.ACES_Hill_Exposure_Boost&&t.addShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"))}WM(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=new S(this.i);return t.toClearDepthBuffer=!1,t.isDepthTest=!0,this.EM(t),t.setPreRenderFunction(()=>this.XM(t)),e.addRenderPasses([t]),t.tryToSetUniqueName("Raymarching",!0),[e,t]}qM(){let e=new M;e.tryToSetUniqueName("Background",!0);let t=new S(this.i);return t.tryToSetUniqueName("Background",!0),t.toClearColorBuffer=!1,t.toClearDepthBuffer=!1,t.isDepthTest=!1,t.depthWriteMask=!1,t.isVrRendering=!0,this.AM(t),this.YT=t,e.addRenderPasses([t]),e}AM(e){var r;let t=this.$T();e.setFramebuffer(t),t!=null&&this.FT!=null?(e.setResolveFramebuffer(this.vT),e.setResolveFramebuffer2((r=this.ST)!=null?r:void 0)):(e.setResolveFramebuffer(void 0),e.setResolveFramebuffer2(t!=null?this.ST:void 0))}EM(e){this.AM(e)}XM(e){this.AT(),this.OR();let t=e.material;if(t==null)return;let r=this.i.componentRepository.getComponentsWithType(C),i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,f=r.length>0;for(let m of r){let T=m.entity.tryToGetSceneGraph();T!=null&&(t.setParameter(`worldMatrix_${m.componentSID}`,T.matrixInner),t.setParameter(`raymarchObjectId_${m.componentSID}`,E.fromCopyNumber(m.componentSID)));let h=this.kR(m);if(h==null){f=!1;continue}i=Math.min(i,h.min.x),s=Math.min(s,h.min.y),n=Math.min(n,h.min.z),a=Math.max(a,h.max.x),o=Math.max(o,h.max.y),u=Math.max(u,h.max.z)}f?(t.setParameter("raymarchAabbMin",P.fromCopy3(i,s,n)),t.setParameter("raymarchAabbMax",P.fromCopy3(a,o,u))):(t.setParameter("raymarchAabbMin",_),t.setParameter("raymarchAabbMax",D))}setRaymarchingComponentMaterial(e,t){var r;this.RT.set(e.componentSID,t),this.AT(),this.OR(),(r=this.IT)==null||r.applyShadowParametersToMaterials([t]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}getRaymarchingComponentMaterial(e){return this.RT.get(e.componentSID)}removeRaymarchingComponentMaterial(e){this.RT.delete(e.componentSID)&&(this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT())}setRaymarchingMaterial(e){var t,r;(t=this.OT)==null||t.setBufferLessFullScreenRendering(e),this.AT(),this.OR(),(r=this.IT)==null||r.applyShadowParametersToMaterials([e]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}jM(){let e=[],t=new Set;if(this.QR=-1,this.RT.size>0)for(let r of this.LR()){let i=r.componentSID,s=this.RT.get(i);if(s==null)continue;t.add(i);let n=this.GT.get(i);n==null&&(n=new S(this.i),n.toClearDepthBuffer=!1,n.isDepthTest=!0,n.setPreRenderFunction(()=>this.HM(i)),n.tryToSetUniqueName(`Raymarching_${i}`,!0),this.GT.set(i,n)),n.setBufferLessFullScreenRendering(s),this.EM(n),e.length===0&&(this.QR=i),e.push(n)}for(let r of[...this.GT.keys()])t.has(r)||this.GT.delete(r);for(let r of[...this.RT.keys()])!t.has(r)&&this.i.componentRepository.getComponent(C,r)==null&&this.RT.delete(r);return e}HM(e){var n,a,o;e===this.QR&&(this.AT(),this.OR());let t=this.RT.get(e),r=this.i.componentRepository.getComponent(C,e),i=r==null?void 0:r.entity.tryToGetSceneGraph();if(t==null||r==null||i==null)return;t.setParameter(U,i.matrixInner);let s=this.kR(r);t.setParameter("raymarchAabbMin",(n=s==null?void 0:s.min)!=null?n:_),t.setParameter("raymarchAabbMax",(a=s==null?void 0:s.max)!=null?a:D),(o=this.GT.get(e))==null||o.setScissorRect(this.ZM(s))}kR(e){let t=e.entity.tryToGetSceneGraph();if(t==null)return null;let r=t.matrixInner,i=[r.m00,r.m01,r.m02,r.m03,r.m10,r.m11,r.m12,r.m13,r.m20,r.m21,r.m22,r.m23,r.m30,r.m31,r.m32,r.m33],s=C.getAABBVersion(this.i),n=e.componentSID,a=this.VR.get(n);if(a!=null&&a.aabbVersion===s&&a.matrix.length===i.length&&a.matrix.every((f,m)=>f===i[m]))return a.aabb;let o=e.calcWorldAABB();if(o==null)return this.VR.delete(n),null;let u={min:P.fromCopy3(o.minPoint.x,o.minPoint.y,o.minPoint.z),max:P.fromCopy3(o.maxPoint.x,o.maxPoint.y,o.maxPoint.z)};return this.VR.set(n,{aabbVersion:s,matrix:i,aabb:u}),u}ZM(e){if(e==null||this.am<=0||this.TT<=0)return;let t=this.i.componentRepository.getComponent(Y,Y.getCurrent(this.i));if(t==null)return;let r=t.viewProjectionMatrix,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let c=0;c<8;c++){let l=(c&1)===0?e.min.x:e.max.x,p=(c&2)===0?e.min.y:e.max.y,x=(c&4)===0?e.min.z:e.max.z,g=r.multiplyVector(N.fromCopy4(l,p,x,1));if(g.w<=0)return;let B=g.x/g.w,A=g.y/g.w,b=(B*.5+.5)*this.am,q=(-A*.5+.5)*this.TT;i=Math.min(i,b),s=Math.min(s,q),n=Math.max(n,b),a=Math.max(a,q)}let o=2,u=Math.max(0,Math.floor(i)-o),f=Math.max(0,Math.floor(s)-o),m=Math.min(this.am,Math.ceil(n)+o),T=Math.min(this.TT,Math.ceil(a)+o),h=m-u,d=T-f;if(h<=0||d<=0)return{x:0,y:0,width:1,height:1};if(!(u===0&&f===0&&h===this.am&&d===this.TT))return{x:u,y:f,width:h,height:d}}qR(){let e=[];for(let r of this.RT.values())e.push(r);let t=this.getRaymarchingMaterial();return t!=null&&e.push(t),e}JM(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=this.jM();return t.length>0?e.addRenderPasses(t):this.OT!=null&&this.OT.material!=null&&e.addRenderPasses([this.OT]),e}refreshRaymarchingShadowMaterial(){let e=this.NT,t=new Map(this.ET);if(this.UT=void 0,this.NT=void 0,this.kT.clear(),this.ET.clear(),this.WT.clear(),this.LT=this.RT.size>0,!(this.IT==null||this.i.config.maxLightNumber<=0)){if(this.LT)for(let r of this.LR()){let i=r.componentSID;if(!r.castShadow||!this.RT.has(i))continue;let s=G(this.i,r,"regular",t.get(i));s!=null&&this.ET.set(i,s)}else{let r=J(this.i,{castShadowOnly:!0});if(r.nodes.length>0){let i=r;this.UT=i,this.NT=O(this.i,i,"regular",e)}}this.IT.invalidateShadowVolumeFitting(),this.IT.setNeedsRefresh()}}LR(){let e=this.i.componentRepository.getComponentsWithType(C).slice();return e.sort((t,r)=>t.componentSID-r.componentSID),e}getRaymarchingShadowMaterial(){return this.NT}getRaymarchingComponentShadowMaterial(e){return this.ET.get(e.componentSID)}IM(){return{hasCaster:()=>this.LT?this.ET.size>0:this.UT!=null&&this.NT!=null,createPasses:e=>this.KM(e),updatePointLightFarPlane:(e,t)=>this.QM(e,t)}}BS(e,t,r){let i=this.kT.get(e);if(i==null){let n=this.UT;if(n==null)return;let a=O(this.i,n,"paraboloidFront"),o=O(this.i,n,"paraboloidBack");if(a==null||o==null)return;i={front:a,back:o},this.kT.set(e,i)}let s=E.fromCopyNumber(t);return i.front.setParameter("lightIndex",s),i.back.setParameter("lightIndex",s),this.YR(i,r),i}YR(e,t){let r=E.fromCopyNumber(t);e.front.setParameter("shadowFarPlane",r),e.back.setParameter("shadowFarPlane",r)}_S(e,t,r,i){let s=this.WT.get(e);s==null&&(s=new Map,this.WT.set(e,s));let n=s.get(i.componentSID);if(n==null){let o=G(this.i,i,"paraboloidFront"),u=G(this.i,i,"paraboloidBack");if(o==null||u==null)return;n={front:o,back:u},s.set(i.componentSID,n)}let a=E.fromCopyNumber(t);return n.front.setParameter("lightIndex",a),n.back.setParameter("lightIndex",a),this.YR(n,r),n}QM(e,t){let r=this.kT.get(e);r!=null&&this.YR(r,t);let i=this.WT.get(e);if(i!=null)for(let s of i.values())this.YR(s,t)}KM(e){let{lightComponent:t,kind:r,shadowSlot:i,farPlane:s}=e;if(this.LT){let a=[];for(let o of this.LR()){let u=o.componentSID;if(!o.castShadow||!this.RT.has(u))continue;let f;if(r==="regular")f=this.ET.get(u);else{let m=this._S(i,t.componentSID,s!=null?s:1e3,o);f=r==="paraboloidFront"?m==null?void 0:m.front:m==null?void 0:m.back}f!=null&&a.push(this.wM(f,e))}return a}let n;if(r==="regular")n=this.NT;else{let a=this.BS(i,t.componentSID,s!=null?s:1e3);n=r==="paraboloidFront"?a==null?void 0:a.front:a==null?void 0:a.back}return n==null?[]:[this.wM(n,e)]}wM(e,{lightEntity:t,framebuffer:r,kind:i}){let s=new S(this.i);return s.isVrRendering=!1,s.setBufferLessFullScreenRendering(e),s.setFramebuffer(r),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!0,s.depthWriteMask=!0,i==="regular"&&(s.cameraComponent=t.getCamera()),s.tryToSetUniqueName(`RaymarchingShadow_${i}`,!0),s}$M(){if(this.LT){this.LS();return}if(this.UT==null)return;let e=[];this.NT!=null&&e.push(this.NT);for(let l of this.kT.values())e.push(l.front,l.back);let t=this.RT,r=this.getRaymarchingMaterial(),i=t.size>0?t.values().next().value:r,s=(l,p,x)=>{if(i!=null)if(V.isTexture(x.compositionType)){let g=i.getTextureParameter(p);g!=null&&l.setTextureParameter(p,g[1],g[2])}else{let g=i.getParameter(p);g!=null&&l.setParameter(p,g)}},n=this.i.componentRepository.getComponentsWithType(C),a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,h=!1;for(let l of n){if(!l.castShadow)continue;h=!0;let p=this.kR(l);if(p==null){h=!1;break}a=Math.min(a,p.min.x),o=Math.min(o,p.min.y),u=Math.min(u,p.min.z),f=Math.max(f,p.max.x),m=Math.max(m,p.max.y),T=Math.max(T,p.max.z)}let d=h?P.fromCopy3(a,o,u):_,c=h?P.fromCopy3(f,m,T):D;for(let l of e){l.setParameter("raymarchAabbMin",d),l.setParameter("raymarchAabbMax",c);for(let p of l.fieldsInfoArray){let x=p.semantic;if(x.startsWith("worldMatrix_")||x.startsWith("raymarchObjectId_")||x==="raymarchAabbMin"||x==="raymarchAabbMax"||x==="lightIndex"||x==="shadowFarPlane")continue;let g=/^(.*)_(\d+)$/.exec(x),B=g!=null?t.get(Number(g[2])):void 0;if(B!=null){let A=g[1];if(V.isTexture(p.compositionType)){let b=B.getTextureParameter(A);b!=null&&l.setTextureParameter(x,b[1],b[2])}else{let b=B.getParameter(A);b!=null&&l.setParameter(x,b)}}else s(l,x,p)}for(let p of n){if(!p.castShadow)continue;let x=p.entity.tryToGetSceneGraph();x!=null&&l.setParameter(`worldMatrix_${p.componentSID}`,x.matrixInner),l.setParameter(`raymarchObjectId_${p.componentSID}`,E.fromCopyNumber(p.componentSID))}}}LS(){var e,t;for(let r of this.LR()){let i=r.componentSID;if(!r.castShadow)continue;let s=this.RT.get(i);if(s==null)continue;let n=[],a=this.ET.get(i);a!=null&&n.push(a);for(let h of this.WT.values()){let d=h.get(i);d!=null&&n.push(d.front,d.back)}if(n.length===0)continue;let o=r.entity.tryToGetSceneGraph(),u=o==null?void 0:o.matrixInner,f=this.kR(r),m=(e=f==null?void 0:f.min)!=null?e:_,T=(t=f==null?void 0:f.max)!=null?t:D;for(let h of n){u!=null&&h.setParameter(U,u),h.setParameter("raymarchAabbMin",m),h.setParameter("raymarchAabbMax",T);for(let d of h.fieldsInfoArray){let c=d.semantic;if(!(c===U||c==="raymarchAabbMin"||c==="raymarchAabbMax"||c==="lightIndex"||c==="shadowFarPlane"))if(V.isTexture(d.compositionType)){let l=s.getTextureParameter(c);l!=null&&h.setTextureParameter(c,l[1],l[2])}else{let l=s.getParameter(c);l!=null&&h.setParameter(c,l)}}}}}FM(){return this.qR()}getRaymarchingMaterial(){var e;return(e=this.OT)==null?void 0:e.material}AT(){for(let e of this.qR())this.qS(e)}qS(e){var u,f,m,T,h,d;let t=e.getTextureParameter(F.DiffuseEnvTexture.str),r=e.getTextureParameter(F.SpecularEnvTexture.str);if(t==null||r==null)return;let i=e.getTextureParameter(F.SheenEnvTexture.str),s=this.KT,n=this.QT;if(s==null||n==null)return;let a=`${s.objectUID}:${s.isTextureReady}:${n.objectUID}:${n.isTextureReady}:${(f=(u=this.wT)==null?void 0:u.objectUID)!=null?f:-1}:${(T=(m=this.wT)==null?void 0:m.isTextureReady)!=null?T:!1}:${this.HR}:${this.ZR}:${this.JR}:${n.iblMipLevelSkip}`;if(a===this.KR.get(e.objectUID))return;this.KR.set(e.objectUID,a);let o=t[2];if(s.isTextureReady&&e.setTextureParameter(F.DiffuseEnvTexture.str,s,o),n.isTextureReady&&(e.setTextureParameter(F.SpecularEnvTexture.str,n,o),i!=null)){let c=(h=this.wT)!=null&&h.isTextureReady?this.wT:n,l=(d=i[2])!=null?d:o;e.setTextureParameter(F.SheenEnvTexture.str,c,l)}e.setParameter("iblParameter",N.fromCopy4(n.mipmapLevelNumber,this.ZR,this.JR,this.HR)),e.setParameter("iblMipLevelSkip",n.iblMipLevelSkip),e.setParameter("hdriFormat",ee.fromCopy2(s.hdriFormat.index,n.hdriFormat.index))}YS(){return this.qR().some(e=>e.isShaderDefine("RN_USE_TRANSMISSION"))}OR(){var r;if(this.yT)return;let e=(r=this.dM())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.NR;if(!(e==null||t==null))for(let i of this.qR())i.setTextureParameter(F.BackBufferTexture.str,e,t)}CT(){let e=this.bT;if(e==null){console.log("Frame is not set.");return}if(e.clearExpressions(),e.addExpression(this.$R),this.DT!=null&&this.XT!=null&&(this.YT.isOutputForVr=this.yT,e.addExpression(this.XT)),this._T=this.JM(),!this.yT)for(let i of this.mM)e.addExpression(i);let t=this.YS();!t&&this._T!=null&&e.addExpression(this._T);for(let i of this.hp)this.yT?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);!this.yT&&this.HT!=null&&!k.isMobile()&&e.addExpression(this.HT),!this.yT&&this.jR!=null&&e.addExpression(this.jR),t&&this._T!=null&&e.addExpression(this._T);for(let i of this.VT)this.yT?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);if(this.jT.renderPasses.length>0){if(!this.yT){let i=this.$T();if(i!=null)for(let s of this.jT.renderPasses)s.setFramebuffer(i),this.FT!=null&&s.setResolveFramebuffer(this.vT)}e.addExpression(this.jT)}let r=this.hp.flatMap(i=>i.renderPasses.flatMap(s=>s.entities));this.MM=r,this.gT!=null&&(this.gT.setEntities(r),e.addExpression(this.gT.expression)),!this.yT&&this.ZT!=null&&e.addExpression(this.ZT),!this.yT&&this.PT&&this.JT!=null&&e.addExpression(this.JT),!this.yT&&this.zT!=null&&e.addExpression(this.zT)}};export{j as ForwardRenderPipeline};
|
|
@@ -37,7 +37,7 @@ interface EngineInitDescription {
|
|
|
37
37
|
xr?: boolean;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* The
|
|
40
|
+
* The engine class is the entry point of the Rhodonite library.
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* ```
|
|
@@ -110,6 +110,7 @@ export declare class Engine extends RnObject {
|
|
|
110
110
|
* @remarks
|
|
111
111
|
* This method performs a comprehensive cleanup of all engine resources including:
|
|
112
112
|
* - Stopping the render loop
|
|
113
|
+
* - Invalidating all shader caches in materials
|
|
113
114
|
* - Deleting all entities and their components
|
|
114
115
|
* - Destroying all textures (including dummy textures)
|
|
115
116
|
* - Clearing material repository data
|
|
@@ -125,21 +126,6 @@ export declare class Engine extends RnObject {
|
|
|
125
126
|
* engine.destroy(); // Clean up all resources
|
|
126
127
|
* ```
|
|
127
128
|
*/
|
|
128
|
-
/**
|
|
129
|
-
* Destroys the engine and releases all associated resources.
|
|
130
|
-
*
|
|
131
|
-
* @remarks
|
|
132
|
-
* This method performs a comprehensive cleanup of all engine resources including:
|
|
133
|
-
* - Stopping the render loop
|
|
134
|
-
* - Invalidating all shader caches in materials
|
|
135
|
-
* - Deleting all entities and their components
|
|
136
|
-
* - Destroying all textures (including dummy textures)
|
|
137
|
-
* - Clearing material repository data
|
|
138
|
-
* - Releasing GPU resources (WebGL/WebGPU)
|
|
139
|
-
* - Clearing memory manager buffers
|
|
140
|
-
*
|
|
141
|
-
* After calling this method, the engine instance should not be used.
|
|
142
|
-
*/
|
|
143
129
|
destroy(): void;
|
|
144
130
|
/**
|
|
145
131
|
* Internal method that performs the actual resource cleanup.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VERSION as B}from"../../version.js";import{CameraComponent as G}from"../components/Camera/CameraComponent.js";import{createCameraEntity as V}from"../components/Camera/createCameraEntity.js";import{LightComponent as E}from"../components/Light/LightComponent.js";import{MeshComponent as j}from"../components/Mesh/MeshComponent.js";import{MeshRendererComponent as P}from"../components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as S}from"../components/SceneGraph/SceneGraphComponent.js";import{SkeletalComponent as J}from"../components/Skeletal/SkeletalComponent.js";import{TransformComponent as _}from"../components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as k}from"../components/WellKnownComponentTIDs.js";import{Component as I}from"../core/Component.js";import{ComponentMemoryRegistry as H}from"../core/ComponentMemoryRegistry.js";import{ComponentRepository as y}from"../core/ComponentRepository.js";import{_getComponentRuntimeHooks as F}from"../core/ComponentRuntimeHooks.js";import{Config as X}from"../core/Config.js";import{EntityRepository as K}from"../core/EntityRepository.js";import{GlobalDataRepository as Q}from"../core/GlobalDataRepository.js";import{MemoryManager as Y}from"../core/MemoryManager.js";import{CameraType as Z}from"../definitions/CameraType.js";import{ProcessApproach as d}from"../definitions/ProcessApproach.js";import{ProcessStage as M}from"../definitions/ProcessStage.js";import{Primitive as A}from"../geometry/Primitive.js";import{DummyTextures as ee}from"../materials/core/DummyTextures.js";import{Vector3 as te}from"../math/Vector3.js";import{Vector4 as re}from"../math/Vector4.js";import{Is as L}from"../misc/Is.js";import{Logger as N}from"../misc/Logger.js";import{Time as T}from"../misc/Time.js";import{_getPhysicsBackend as se}from"../physics/PhysicsBackend.js";import{CGAPIResourceRepository as O}from"../renderer/CGAPIResourceRepository.js";import{Expression as ie}from"../renderer/Expression.js";import{Frame as oe}from"../renderer/Frame.js";import{LightClusterSystemStub as ne}from"../renderer/lightCluster/LightClusterSystemStub.js";import{RenderPass as $}from"../renderer/RenderPass.js";import{EngineState as ae}from"./EngineState.js";import{ModuleManager as U}from"./ModuleManager.js";import{WebGLGpuTimer as pe}from"../../webgl/WebGLGpuTimer.js";import{_cleanupWebGLStatesCacheForEngine as ue}from"../../webgl/WebGLStrategyCommonMethod.js";import{RnObject as ce}from"../core/RnObject.js";import{_cleanupGizmosForEngine as fe}from"../gizmos/GizmoRegistry.js";import{_cleanupRenderPassHelperForEngine as he}from"../helpers/RenderPassHelper.js";import{AbstractMaterialContent as de}from"../materials/core/AbstractMaterialContent.js";import{MaterialRepository as me}from"../materials/core/MaterialRepository.js";var m=class m extends ce{constructor(e,t,s,i,r){super();this.tC=d.None;this.oC=new ae;this.nC=0;this.pC=-1;this.WC=[];this.cC=new ne;this.wC=!1;this.o=!1;this.dC=-1;this.nr=-1;this.mC=-1;this.or=-1;this._C=0;this.LC=!1;this.BC=new Map;this.lC=!1;this.DC=-1;this.fC=i!=null?i:new X,this.xC=new N,this.xC.logLevel=this.fC.logLevel,this.DC=m.UC,this.tC=e,this.rC=t,this.GC=new H,this.uC=new y(this),this.Na=new K(this),this.EC=new me,this.of=Y.createInstanceIfNotCreated(this,s),r!=null&&this.SC(r),this.yC=Q.init(this),m.UC++}get engineUid(){return this.DC}static getEngine(e){let t=m.TC.get(e);if(!L.not.exist(t))return t}destroy(){this.stopRenderLoop(),this.RC=void 0,this.WC=[],this.Lb()}Lb(){var t,s;this.o=!0,this.EC._makeShaderInvalidateToAllMaterials();let e=this.Na._getEntities();for(let i of e)this.Na.deleteEntity(i.entityUID);if(L.exist(this.hC)&&(this.hC.destroy(),this.hC=void 0),L.exist(this.sC)){this.sC.clearCache();try{let i=this.sC.getWebGpuDeviceWrapper();i&&i.context.unconfigure()}catch{}}L.exist(this.of)&&(this.of.destroy(),this.of=void 0),this.XC(),_._cleanupForEngine(this),S._cleanupForEngine(this),G._cleanupForEngine(this),E._cleanupForEngine(this),P._cleanupForEngine(this),(t=se())==null||t.cleanupForEngine(this),fe(this),de._cleanupForEngine(this),he(this),ue(this),(s=this.aC)==null||s.destroy(),this.aC=void 0,this.GC.destroy(),this.gC=void 0,this.bC=void 0,this.nC=0,this.dC=-1,this.nr=-1,this.mC=-1,m.TC.delete(this.objectUID),this.unregister()}startRenderLoop(e,...t){this.RC=e,this.WC=t,this.pC!==-1&&this.stopRenderLoop();let s=this.FC();this.vC=s;let i=s.requestAnimationFrame.bind(s),r=this.eC,c=this.iC,u=t.length>0,n=u?[0,...t]:[],p=u?o=>{n[0]=o,e.apply(e,n)}:o=>{e.call(e,o)},a=((o,l)=>{r!=null&&r.isReadyForWebXR?(r._preRender(o,l),p(o),r._postRender()):c!=null&&c.isReadyForWebAR?(c._preRender(o,l),p(o),c._postRender()):p(o),this.pC=i(a)});this.pC=i(a)}FC(){let e=window,t=this.eC,s=this.iC;return t!=null&&t.requestedToEnterWebXR?e=t.xrSession:s!=null&&s.requestedToEnterWebAR&&(e=s.arSession),L.not.exist(e)?window:e}stopRenderLoop(){var t;let e=(t=this.vC)!=null?t:this.FC();this.pC!==-1&&e.cancelAnimationFrame(this.pC),this.pC=-1,this.vC=void 0}restartRenderLoop(){this.RC!=null&&this.startRenderLoop(this.RC,...this.WC)}processAuto(e=re.fromCopy4(0,0,0,1)){if(L.not.exist(this.gC)){let s=new ie,i=new $(this);i.toClearColorBuffer=!0,i.toClearDepthBuffer=!0,i.clearColor=e;let r=new $(this);s.addRenderPasses([i,r]),this.gC=s,this.bC=r}this.bC.clearEntities();let t=this.Na._getEntities();this.bC.addEntities(t),this.process([this.gC])}process(e){let t=this.lC;t&&this.NC(),T._processBegin(this),this.OC(),!this.wC&&E.getUpdateCount(this)>0&&this._requestLightClusterSystem();let s=e;e instanceof oe&&(s=e.expressions),G.getCurrent(this)===I.InvalidObjectUID&&m.createCamera(this);let i=this.yC.getValue("time",0);i._v[0]=T.timeFromSystemStart,this.processApproach===d.WebGPU?this._processWebGPU(s):this._processWebGL(s),T._processEnd(),t&&this.$C()}get gpuTimerEnabled(){return this.lC}set gpuTimerEnabled(e){this.lC=e}get isGpuTimerSupported(){var e,t;return this.tC===d.WebGPU?this.webGpuResourceRepository._getGpuTimer().isSupported:(t=(e=this.MC())==null?void 0:e.isSupported)!=null?t:!1}get gpuTimeMilliseconds(){var e,t;if(this.lC)return this.tC===d.WebGPU?(e=this.sC)==null?void 0:e._getGpuTimer().lastGpuTimeMilliseconds:(t=this.aC)==null?void 0:t.lastGpuTimeMilliseconds}get gpuPassTimesMilliseconds(){var e;if(!(!this.lC||this.tC!==d.WebGPU))return(e=this.sC)==null?void 0:e._getGpuTimer().lastPassGpuTimesMilliseconds}MC(){var e;if(this.aC==null){let t=(e=this.CC)==null?void 0:e.currentWebGLContextWrapper;if(t==null)return;this.aC=new pe(t.getRawContextAsWebGL2())}return this.aC}NC(){var e,t;this.tC===d.WebGPU?(e=this.sC)==null||e._getGpuTimer().beginFrame():(t=this.MC())==null||t.begin()}$C(){var e,t;this.tC===d.WebGPU?(e=this.sC)==null||e._getGpuTimer().endFrame():(t=this.aC)==null||t.end()}zC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,hasAnyEffekseerComponents:c,deferredEffekseerRenderJobs:u}){t.doPreRender();let n;if(c&&t.toRenderEffekseerEffects){n=[];let h=t.entities;for(let f=0;f<h.length;f++){let g=h[f].tryToGetEffekseer();g!=null&&n.push(g)}n.length===0&&(n=void 0)}let p=n!=null,a=p?e.getEffekseerRenderPassOptions(this,t,r):void 0,o=t.toRenderEffekseerEffects&&p,l=o&&t.getResolveFramebuffer()!=null&&u!=null;if(o&&a!=null)for(let h of n)h.prepareWebGPURendering(a);if(l&&u.push({renderPass:t,displayIdx:r,renderPassOptions:a,effekseerComponents:n}),e.clearFrameBuffer(this,t,r),this.qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:o&&!l}),o&&!l){let h=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,t,r);if(h!=null)for(let f of n)f.$renderWebGPU(h,a,r);e.endRenderPassEncoderForExternalRendering()}return t._copyResolve1ToResolve2WebGpu(),t.doPostRender(),o}VC({webGpuResourceRepository:e,currentRenderPass:t,deferredEffekseerRenderJobs:s,displayIdx:i}){if(s.length===0)return;let r=t.getResolveFramebuffer();if(r!=null)for(let c of s){if(c.displayIdx!==i||c.renderPass.getResolveFramebuffer()!==r)continue;let u=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,c.renderPass,i);if(u!=null)for(let n of c.effekseerComponents)n.$renderWebGPU(u,c.renderPassOptions,i);e.endRenderPassEncoderForExternalRendering(),c.renderPass._copyResolve1ToResolve2WebGpu()}}qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:c}){var a;let u,n=t._renderedSomethingBefore;if(n&&(c?(u=e.renderWithRenderBundleAndKeepRenderPass(this,t,r),n=u==null):n=!e.renderWithRenderBundle(this,t,r),(a=this.oC).webgpuRenderBundleMode||(a.webgpuRenderBundleMode=n)),!n)return u;e.createRenderBundleEncoder(this,t,r);let p=P.common_$render({renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,engine:this});if(t._renderedSomethingBefore=p,!p)return u;if(c)return e.finishRenderBundleEncoderAndKeepRenderPass(this,t,r);e.finishRenderBundleEncoder(this,t,r)}_processWebGPU(e){var r,c;let t=this.uC.getComponentTIDs(),s=this.webGpuResourceRepository,i=this.eC;for(let u of I._processStages){if(u===M.Render){this.cC.update(e),P.common_$prerender(this);let n=(r=i==null?void 0:i.isWebXRMode)!=null?r:!1,p=(c=i==null?void 0:i.isMultiView())!=null?c:!1,a=this.oC.xrPoseWebGPU,o=n&&!p&&a!=null?a.views.length:1,l=this.uC.hasAnyComponent(k.EffekseerComponentTID),h=o>1,f=h?new Map:void 0,g=h?new Map:void 0;for(let b=0;b<o;b++){let C=l?[]:void 0,x=!1;for(let D of e)for(let R of D.renderPasses){let v=R.renderPassUID,w=f==null?void 0:f.get(v),W;w===void 0?(w=this.nC,R._isChangedSortRenderResult=!1,W=P.sort_$render(this,R),f!=null&&(f.set(v,w),g.set(v,W))):W=g.get(v);let q=this.zC({webGpuResourceRepository:s,renderPass:R,renderPassTickCount:w,primitiveUids:W,displayIdx:b,hasAnyEffekseerComponents:l,deferredEffekseerRenderJobs:C});x||(x=q),C!=null&&C.length>0&&this.VC({webGpuResourceRepository:s,currentRenderPass:R,deferredEffekseerRenderJobs:C,displayIdx:b}),b===o-1&&(f==null||f.delete(v),g==null||g.delete(v),this.nC++)}b<o-1&&x&&s.flush()}s.flush()}else if(!this.oC.webgpuRenderBundleMode||this.AC()||_.getUpdateCount(this)!==this.nr||G.getCurrentCameraUpdateCount(this)!==this.dC||A.getPrimitiveCount()!==this.mC||E.getUpdateCount(this)!==this.or){let n=`common_${u.methodName}`;for(let p of t){let a=y.getComponentClass(p),o=a[n];o&&o({processApproach:this.tC,renderPass:void 0,processStage:u,renderPassTickCount:this.nC,displayIdx:0,engine:this}),a.process(this,a,u)}}u===M.Logic&&S._updateTransformGizmosByCameraChange(this)}this.dC=G.getCurrentCameraUpdateCount(this),this.kC(),this.nr=_.getUpdateCount(this),this.mC=A.getPrimitiveCount(),this.or=E.getUpdateCount(this)}OC(){var e;for(let t of F())(e=t.beginFrame)==null||e.call(t,this)}AC(){var e;for(let t of F())if(((e=t.isDirty)==null?void 0:e.call(t,this))===!0)return!0;return!1}kC(){var e;for(let t of F())(e=t.markUpdated)==null||e.call(t,this)}XC(){var e;for(let t of F())(e=t.cleanup)==null||e.call(t,this)}_processWebGL(e){let t=this.webglResourceRepository,s=this.uC.getComponentTIDs(),i=this.uC.getRenderingComponentTIDs();for(let r of I._processStages){let u=`common_${r.methodName}`;if(r===M.Render){t.getMultiDrawRepository(this).rebuildDirtyGroups(),this.cC.update(e),P.common_$prerender(this);for(let n of e)for(let p of i){let a=y.getComponentClass(p);for(let o of n.renderPasses){typeof spector!="undefined"&&spector.setMarker(`| ${n.uniqueName}: ${o.uniqueName}#`),o.doPreRender(),t.switchDepthTest(o.isDepthTest),this.bindFramebufferWebGL(o),this.setViewportForNormalRendering(o),this.setScissorForNormalRendering(o),p===k.MeshRendererComponentTID&&this.rC.clearFrameBuffer(this,o),o._isChangedSortRenderResult=!1;let l=P.sort_$render(this,o);if(o._renderedSomethingBefore){let f=a[u];if(f){let g=f({processApproach:this.tC,renderPass:o,processStage:r,renderPassTickCount:this.nC,primitiveUids:l,displayIdx:0,engine:this});o._renderedSomethingBefore=g}}if(p===k.EffekseerComponentTID&&o.entities.length>0){let f=this.webglResourceRepository,g=f.getCurrentTexture2DBindingsForEffekseer();f.setWebGLStateToDefaultForEffekseer();for(let b of o.entities){let C=b.tryToGetEffekseer();C!=null&&C.$render()}f.restoreTexture2DBindingsForEffekseer(g)}this.nC++,o._copyFramebufferToResolveFramebuffersWebGL(),o.doPostRender()}}}else if(this.AC()||_.getUpdateCount(this)!==this.nr||G.getCurrentCameraUpdateCount(this)!==this.dC||A.getPrimitiveCount()!==this.mC||E.getUpdateCount(this)!==this.or)for(let n of s){let p=y.getComponentClass(n),a=p[u];a&&a({processApproach:this.tC,renderPass:void 0,processStage:r,renderPassTickCount:this.nC,displayIdx:0,engine:this}),p.process(this,p,r)}r===M.Logic&&S._updateTransformGizmosByCameraChange(this)}this.dC=G.getCurrentCameraUpdateCount(this),this.kC(),this.nr=_.getUpdateCount(this),this.mC=A.getPrimitiveCount(),this.or=E.getUpdateCount(this)}static get processTime(){return T.lastTimeTimeIntervalInMilliseconds}static get timeAtProcessBegin(){return T.timeAtProcessBeginMilliseconds}static get timeAtProcessEnd(){return T.timeAtProcessEndMilliseconds}static createCamera(e){let t=V(e,!0);t.getTransform().localPosition=te.fromCopyArray([0,0,1]),t.getCamera().type=Z.Orthographic,t.getCamera().zNear=.1,t.getCamera().zFar=1e4;let s=e.cgApiResourceRepository,[i,r]=s.getCanvasSize();t.getCamera().xMag=i/r,t.getCamera().yMag=1}setViewportForNormalRendering(e){let t=this.eC,s=this.iC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)&&this.rC.setViewport(this,e.getViewport())}setScissorForNormalRendering(e){let t=this.eC,s=this.iC,i=this.rC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)?i.setScissorRect(e):i.setScissorRect(void 0)}bindFramebufferWebGL(e){let t=this.eC,s=this.iC;if(t!=null&&t.isWebXRMode&&e.isOutputForVr){let r=this.rC.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,t.framebuffer)}else if(s!=null&&s.isWebARMode){let r=this.rC.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)}else this.rC.bindFramebuffer(e.getFramebuffer()),this.rC.setDrawTargets(e)}jC(){console.log(`%cRhodonite%cWeb3D Library%c %cversion%c${B.version}%c %cbranch%c${B.branch}%c %cmode%c${this.tC.str}`,"font-weight: bold; padding: 4px 8px; border-radius: 6px 0px 0px 6px; background: linear-gradient(to right, #ff0084 0%,#ff0022 100%);","padding: 4px; border-radius: 0px 6px 6px 0px; background: linear-gradient(to right, #8400ff 0%,#4400ff 100%);","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: firebrick; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: green; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: blue; padding: 4px; border-radius: 0px 6px 6px 0px")}static JC(){y._ensureComponentClassRegistered(_),y._ensureComponentClassRegistered(S),y._ensureComponentClassRegistered(j),y._ensureComponentClassRegistered(P),y._ensureComponentClassRegistered(G),y._ensureComponentClassRegistered(E),y._ensureComponentClassRegistered(J)}static async init(e){var n,p,a,o,l;if(e.approach!==d.None&&e.approach!==d.WebGL2&&e.approach!==d.WebGPU){let h=(p=(n=e.approach)==null?void 0:n.str)!=null?p:String(e.approach);throw new Error(`Unsupported process approach "${h}". The "Uniform" and "DataTexture" modes were removed. Use ProcessApproach.WebGL2 ("WebGL2") or ProcessApproach.WebGPU ("WebGPU").`)}if(e.approach===d.WebGL2&&typeof __RN_WEBGL__!="undefined"&&!__RN_WEBGL__)throw new Error("ProcessApproach.WebGL2 is unavailable: this build was bundled with __RN_WEBGL__ = false.");if(e.approach===d.WebGPU&&typeof __RN_WEBGPU__!="undefined"&&!__RN_WEBGPU__)throw new Error("ProcessApproach.WebGPU is unavailable: this build was bundled with __RN_WEBGPU__ = false.");m.JC();let t=((a=e.xr)!=null?a:m._loadXRByDefault)?await U.getInstance().loadModule("xr"):void 0,s=0,i;if(e.approach===d.WebGPU){let R=function(W){b.features.has(W)&&D.push(W)};var u=R;await U.getInstance().loadModule("webgpu");let h=O.getWebGpuResourceRepository(),g=U.getInstance().getModule("webgpu").WebGpuDeviceWrapper,b=await navigator.gpu.requestAdapter({xrCompatible:!0}),{maxBufferSize:C,maxStorageBufferBindingSize:x}=b.limits,D=[];R("float32-filterable"),R("rg11b10ufloat-renderable"),R("texture-compression-bc"),R("texture-compression-etc2"),R("texture-compression-astc"),R("timestamp-query");let v=await b.requestDevice({requiredFeatures:D,requiredLimits:{maxStorageBufferBindingSize:x,maxBufferSize:C}});s=x;let w=new g(e.canvas,b,v);h.addWebGpuDeviceWrapper(w),h.recreateSystemDepthTexture(),h.createBindGroupLayoutForDrawParameters(),i=h}else e.approach===d.WebGL2?(await U.getInstance().loadModule("webgl"),i=O.getWebGLResourceRepository(),i.generateWebGLContext((o=e.config)!=null?o:new X,e.canvas,!0,e.webglOption),i.switchDepthTest(!0),s=i.currentWebGLContextWrapper.getMaxTextureSize()**2*4*4):s=1024**2*4*4;let r=new m(e.approach,i,s,e.config,t);return r.oC.currentProcessApproach=e.approach,r.fC.eventTargetDom=(l=r.fC.eventTargetDom)!=null?l:e.canvas,e.approach===d.WebGPU&&(r.sC=i),e.approach===d.WebGL2&&(r.CC=i),r.rC=i,e.notToDisplayRnInfoAtInit!==!0&&r.jC(),r.yC.initialize(e.approach),e.canvas!=null&&e.approach===d.WebGL2&&(e.canvas.addEventListener("webglcontextlost",(h=>{h.preventDefault(),r.stopRenderLoop(),r.logger.error("WebGL context lost occurred.")}).bind(this)),e.canvas.addEventListener("webglcontextrestored",()=>{r.logger.error("WebGL context restored."),r.restartRenderLoop()})),r.hC=await ee.init(r),r.oC.viewportAspectRatio=e.canvas!=null?e.canvas.width/e.canvas.height:1,r}get processApproach(){return this.tC}resizeCanvas(e,t){this.cgApiResourceRepository.resizeCanvas(e,t),this.oC.viewportAspectRatio=e/t}getCanvasSize(){return this.cgApiResourceRepository.getCanvasSize()}getCurrentWebGLContextWrapper(){return this.rC.currentWebGLContextWrapper}get entityRepository(){return this.Na}get componentRepository(){return this.uC}get componentMemoryRegistry(){return this.GC}get webXRSystem(){if(this.eC==null)throw new Error(m.IC);return this.eC}get webARSystem(){if(this.iC==null)throw new Error(m.IC);return this.iC}get isXREnabled(){return this.eC!=null}get _webXRSystemIfEnabled(){return this.eC}get _webARSystemIfEnabled(){return this.iC}async enableXR(){if(this.eC==null){let e=await U.getInstance().loadModule("xr");this.eC==null&&this.SC(e)}return this.eC}SC(e){this.eC=e.WebXRSystem.init(this),this.iC=e.WebARSystem.init(this)}get memoryManager(){return this.of}get globalDataRepository(){return this.yC}_requestLightClusterSystem(){this.o||this.PC!=null||(this.PC=import("../renderer/lightCluster/LightClusterSystem.js").then(({LightClusterSystem:e})=>{this.o||(this.cC=new e(this),this.wC=!0)}).catch(e=>{N.default.warn(`Failed to load the light cluster system: ${e}`)}))}async _ensureLightClusterSystem(){return this._requestLightClusterSystem(),await this.PC,this.cC}get lightClusterSystem(){return this.cC}get materialRepository(){return this.EC}get webglResourceRepository(){return this.CC}get cgApiResourceRepository(){return this.rC}get webGpuResourceRepository(){return this.sC}get dummyTextures(){return this.hC}get engineState(){return this.oC}get config(){return this.fC}get _gpuInstanceDataVersion(){return this._C}_markGpuInstanceDataDirty(){this._C++}get _isPreviousMorphWeightsEnabled(){return this.LC}_enablePreviousMorphWeights(){this.LC=!0}get logger(){return this.xC}get shaderProgramCache(){return this.BC}};m._loadXRByDefault=!1,m.TC=new Map,m.UC=0,m.IC="The XR support is not enabled. Initialize the engine with Engine.init({ xr: true }) or call await engine.enableXR() first. The default Rn namespace export enables it automatically.";var z=m;export{z as Engine};
|
|
1
|
+
import{VERSION as N}from"../../version.js";import{CameraComponent as x}from"../components/Camera/CameraComponent.js";import{createCameraEntity as j}from"../components/Camera/createCameraEntity.js";import{LightComponent as G}from"../components/Light/LightComponent.js";import{MeshComponent as J}from"../components/Mesh/MeshComponent.js";import{MeshRendererComponent as E}from"../components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as T}from"../components/SceneGraph/SceneGraphComponent.js";import{SkeletalComponent as H}from"../components/Skeletal/SkeletalComponent.js";import{TransformComponent as _}from"../components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as A}from"../components/WellKnownComponentTIDs.js";import{Component as B}from"../core/Component.js";import{ComponentMemoryRegistry as K}from"../core/ComponentMemoryRegistry.js";import{ComponentRepository as R}from"../core/ComponentRepository.js";import{_getComponentRuntimeHooks as U}from"../core/ComponentRuntimeHooks.js";import{Config as O}from"../core/Config.js";import{EntityRepository as Q}from"../core/EntityRepository.js";import{GlobalDataRepository as Y}from"../core/GlobalDataRepository.js";import{MemoryManager as Z}from"../core/MemoryManager.js";import{CameraType as ee}from"../definitions/CameraType.js";import{ProcessApproach as h}from"../definitions/ProcessApproach.js";import{ProcessStage as D}from"../definitions/ProcessStage.js";import{Primitive as F}from"../geometry/Primitive.js";import{DummyTextures as te}from"../materials/core/DummyTextures.js";import{Vector3 as re}from"../math/Vector3.js";import{Vector4 as ie}from"../math/Vector4.js";import{Is as L}from"../misc/Is.js";import{Logger as z}from"../misc/Logger.js";import{Time as S}from"../misc/Time.js";import{_getPhysicsBackend as se}from"../physics/PhysicsBackend.js";import{CGAPIResourceRepository as $}from"../renderer/CGAPIResourceRepository.js";import{Expression as oe}from"../renderer/Expression.js";import{Frame as ne}from"../renderer/Frame.js";import{LightClusterSystemStub as ae}from"../renderer/lightCluster/LightClusterSystemStub.js";import{RenderPass as q}from"../renderer/RenderPass.js";import{EngineState as pe}from"./EngineState.js";import{detectGpuIdentity as ue,findComputeDeformationBrokenGpu as ce}from"./GpuDriverWorkarounds.js";import{ModuleManager as k}from"./ModuleManager.js";import{WebGLGpuTimer as de}from"../../webgl/WebGLGpuTimer.js";import{_cleanupWebGLStatesCacheForEngine as fe}from"../../webgl/WebGLStrategyCommonMethod.js";import{RnObject as he}from"../core/RnObject.js";import{_cleanupGizmosForEngine as me}from"../gizmos/GizmoRegistry.js";import{_cleanupRenderPassHelperForEngine as le}from"../helpers/RenderPassHelper.js";import{AbstractMaterialContent as ge}from"../materials/core/AbstractMaterialContent.js";import{MaterialRepository as be}from"../materials/core/MaterialRepository.js";var m=class m extends he{constructor(e,t,r,i,s){super();this.tC=h.None;this.oC=new pe;this.nC=0;this.pC=-1;this.WC=[];this.cC=new ae;this.wC=!1;this.o=!1;this.hC=-1;this.nr=-1;this.mC=-1;this.or=-1;this._C=0;this.LC=!1;this.BC=new Map;this.lC=!1;this.TC=-1;this.dC=i!=null?i:new O,this.xC=new z,this.xC.logLevel=this.dC.logLevel,this.TC=m.kC,this.tC=e,this.rC=t,this.GC=new K,this.uC=new R(this),this.Na=new Q(this),this.EC=new be,this.of=Z.createInstanceIfNotCreated(this,r),s!=null&&this.UC(s),this.yC=Y.init(this),m.kC++}get engineUid(){return this.TC}static getEngine(e){let t=m.SC.get(e);if(!L.not.exist(t))return t}destroy(){this.stopRenderLoop(),this.RC=void 0,this.WC=[],this._M()}_M(){var t,r;this.o=!0,this.EC._makeShaderInvalidateToAllMaterials();let e=this.Na._getEntities();for(let i of e)this.Na.deleteEntity(i.entityUID);if(L.exist(this.fC)&&(this.fC.destroy(),this.fC=void 0),L.exist(this.iC)){this.iC.clearCache();try{let i=this.iC.getWebGpuDeviceWrapper();i&&i.context.unconfigure()}catch{}}L.exist(this.of)&&(this.of.destroy(),this.of=void 0),this.XC(),_._cleanupForEngine(this),T._cleanupForEngine(this),x._cleanupForEngine(this),G._cleanupForEngine(this),E._cleanupForEngine(this),(t=se())==null||t.cleanupForEngine(this),me(this),ge._cleanupForEngine(this),le(this),fe(this),(r=this.aC)==null||r.destroy(),this.aC=void 0,this.GC.destroy(),this.gC=void 0,this.bC=void 0,this.nC=0,this.hC=-1,this.nr=-1,this.mC=-1,m.SC.delete(this.objectUID),this.unregister()}startRenderLoop(e,...t){this.RC=e,this.WC=t,this.pC!==-1&&this.stopRenderLoop();let r=this.DC();this.vC=r;let i=r.requestAnimationFrame.bind(r),s=this.eC,n=this.sC,f=t.length>0,a=f?[0,...t]:[],c=f?o=>{a[0]=o,e.apply(e,a)}:o=>{e.call(e,o)},p=((o,l)=>{s!=null&&s.isReadyForWebXR?(s._preRender(o,l),c(o),s._postRender()):n!=null&&n.isReadyForWebAR?(n._preRender(o,l),c(o),n._postRender()):c(o),this.pC=i(p)});this.pC=i(p)}DC(){let e=window,t=this.eC,r=this.sC;return t!=null&&t.requestedToEnterWebXR?e=t.xrSession:r!=null&&r.requestedToEnterWebAR&&(e=r.arSession),L.not.exist(e)?window:e}stopRenderLoop(){var t;let e=(t=this.vC)!=null?t:this.DC();this.pC!==-1&&e.cancelAnimationFrame(this.pC),this.pC=-1,this.vC=void 0}restartRenderLoop(){this.RC!=null&&this.startRenderLoop(this.RC,...this.WC)}processAuto(e=ie.fromCopy4(0,0,0,1)){if(L.not.exist(this.gC)){let r=new oe,i=new q(this);i.toClearColorBuffer=!0,i.toClearDepthBuffer=!0,i.clearColor=e;let s=new q(this);r.addRenderPasses([i,s]),this.gC=r,this.bC=s}this.bC.clearEntities();let t=this.Na._getEntities();this.bC.addEntities(t),this.process([this.gC])}process(e){let t=this.lC;t&&this.NC(),S._processBegin(this),this.OC(),!this.wC&&G.getUpdateCount(this)>0&&this._requestLightClusterSystem();let r=e;e instanceof ne&&(r=e.expressions),x.getCurrent(this)===B.InvalidObjectUID&&m.createCamera(this);let i=this.yC.getValue("time",0);i._v[0]=S.timeFromSystemStart,this.processApproach===h.WebGPU?this._processWebGPU(r):this._processWebGL(r),S._processEnd(),t&&this.zC()}get gpuTimerEnabled(){return this.lC}set gpuTimerEnabled(e){this.lC=e}get isGpuTimerSupported(){var e,t;return this.tC===h.WebGPU?this.webGpuResourceRepository._getGpuTimer().isSupported:(t=(e=this.FC())==null?void 0:e.isSupported)!=null?t:!1}get gpuTimeMilliseconds(){var e,t;if(this.lC)return this.tC===h.WebGPU?(e=this.iC)==null?void 0:e._getGpuTimer().lastGpuTimeMilliseconds:(t=this.aC)==null?void 0:t.lastGpuTimeMilliseconds}get gpuPassTimesMilliseconds(){var e;if(!(!this.lC||this.tC!==h.WebGPU))return(e=this.iC)==null?void 0:e._getGpuTimer().lastPassGpuTimesMilliseconds}FC(){var e;if(this.aC==null){let t=(e=this.CC)==null?void 0:e.currentWebGLContextWrapper;if(t==null)return;this.aC=new de(t.getRawContextAsWebGL2())}return this.aC}NC(){var e,t;this.tC===h.WebGPU?(e=this.iC)==null||e._getGpuTimer().beginFrame():(t=this.FC())==null||t.begin()}zC(){var e,t;this.tC===h.WebGPU?(e=this.iC)==null||e._getGpuTimer().endFrame():(t=this.aC)==null||t.end()}$C({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:r,primitiveUids:i,displayIdx:s,hasAnyEffekseerComponents:n,deferredEffekseerRenderJobs:f}){t.doPreRender();let a;if(n&&t.toRenderEffekseerEffects){a=[];let g=t.entities;for(let d=0;d<g.length;d++){let u=g[d].tryToGetEffekseer();u!=null&&a.push(u)}a.length===0&&(a=void 0)}let c=a!=null,p=c?e.getEffekseerRenderPassOptions(this,t,s):void 0,o=t.toRenderEffekseerEffects&&c,l=o&&t.getResolveFramebuffer()!=null&&f!=null;if(o&&p!=null)for(let g of a)g.prepareWebGPURendering(p);if(l&&f.push({renderPass:t,displayIdx:s,renderPassOptions:p,effekseerComponents:a}),e.clearFrameBuffer(this,t,s),this.qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:r,primitiveUids:i,displayIdx:s,shouldKeepRenderPassForEffekseer:o&&!l}),o&&!l){let g=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,t,s);if(g!=null)for(let d of a)d.$renderWebGPU(g,p,s);e.endRenderPassEncoderForExternalRendering()}return t._copyResolve1ToResolve2WebGpu(),t.doPostRender(),o}VC({webGpuResourceRepository:e,currentRenderPass:t,deferredEffekseerRenderJobs:r,displayIdx:i}){if(r.length===0)return;let s=t.getResolveFramebuffer();if(s!=null)for(let n of r){if(n.displayIdx!==i||n.renderPass.getResolveFramebuffer()!==s)continue;let f=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,n.renderPass,i);if(f!=null)for(let a of n.effekseerComponents)a.$renderWebGPU(f,n.renderPassOptions,i);e.endRenderPassEncoderForExternalRendering(),n.renderPass._copyResolve1ToResolve2WebGpu()}}qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:r,primitiveUids:i,displayIdx:s,shouldKeepRenderPassForEffekseer:n}){var p;let f,a=t._renderedSomethingBefore;if(a&&(n?(f=e.renderWithRenderBundleAndKeepRenderPass(this,t,s),a=f==null):a=!e.renderWithRenderBundle(this,t,s),(p=this.oC).webgpuRenderBundleMode||(p.webgpuRenderBundleMode=a)),!a)return f;e.createRenderBundleEncoder(this,t,s);let c=E.common_$render({renderPass:t,renderPassTickCount:r,primitiveUids:i,displayIdx:s,engine:this});if(t._renderedSomethingBefore=c,!c)return f;if(n)return e.finishRenderBundleEncoderAndKeepRenderPass(this,t,s);e.finishRenderBundleEncoder(this,t,s)}_processWebGPU(e){var s,n;let t=this.uC.getComponentTIDs(),r=this.webGpuResourceRepository,i=this.eC;for(let f of B._processStages){if(f===D.Render){this.cC.update(e),E.common_$prerender(this);let a=(s=i==null?void 0:i.isWebXRMode)!=null?s:!1,c=(n=i==null?void 0:i.isMultiView())!=null?n:!1,p=this.oC.xrPoseWebGPU,o=a&&!c&&p!=null?p.views.length:1,l=this.uC.hasAnyComponent(A.EffekseerComponentTID),g=o>1,d=g?new Map:void 0,u=g?new Map:void 0;for(let y=0;y<o;y++){let C=l?[]:void 0,v=!1;for(let M of e)for(let P of M.renderPasses){let W=P.renderPassUID,b=d==null?void 0:d.get(W),w;b===void 0?(b=this.nC,P._isChangedSortRenderResult=!1,w=E.sort_$render(this,P),d!=null&&(d.set(W,b),u.set(W,w))):w=u.get(W);let I=this.$C({webGpuResourceRepository:r,renderPass:P,renderPassTickCount:b,primitiveUids:w,displayIdx:y,hasAnyEffekseerComponents:l,deferredEffekseerRenderJobs:C});v||(v=I),C!=null&&C.length>0&&this.VC({webGpuResourceRepository:r,currentRenderPass:P,deferredEffekseerRenderJobs:C,displayIdx:y}),y===o-1&&(d==null||d.delete(W),u==null||u.delete(W),this.nC++)}y<o-1&&v&&r.flush()}r.flush()}else if(!this.oC.webgpuRenderBundleMode||E.hasPendingLoad||this.MC()||_.getUpdateCount(this)!==this.nr||x.getCurrentCameraUpdateCount(this)!==this.hC||F.getPrimitiveCount()!==this.mC||G.getUpdateCount(this)!==this.or){let a=`common_${f.methodName}`;for(let c of t){let p=R.getComponentClass(c),o=p[a];o&&o({processApproach:this.tC,renderPass:void 0,processStage:f,renderPassTickCount:this.nC,displayIdx:0,engine:this}),p.process(this,p,f)}}f===D.Logic&&(T._updateTransformGizmosByCameraChange(this),G._updateLightGizmosByCameraChange(this))}this.hC=x.getCurrentCameraUpdateCount(this),this.IC(),this.nr=_.getUpdateCount(this),this.mC=F.getPrimitiveCount(),this.or=G.getUpdateCount(this)}OC(){var e;for(let t of U())(e=t.beginFrame)==null||e.call(t,this)}MC(){var e;for(let t of U())if(((e=t.isDirty)==null?void 0:e.call(t,this))===!0)return!0;return!1}IC(){var e;for(let t of U())(e=t.markUpdated)==null||e.call(t,this)}XC(){var e;for(let t of U())(e=t.cleanup)==null||e.call(t,this)}_processWebGL(e){let t=this.webglResourceRepository,r=this.uC.getComponentTIDs(),i=this.uC.getRenderingComponentTIDs();for(let s of B._processStages){let f=`common_${s.methodName}`;if(s===D.Render){t.getMultiDrawRepository(this).rebuildDirtyGroups(),this.cC.update(e),E.common_$prerender(this);for(let a of e)for(let c of i){let p=R.getComponentClass(c);for(let o of a.renderPasses){typeof spector!="undefined"&&spector.setMarker(`| ${a.uniqueName}: ${o.uniqueName}#`),o.doPreRender(),t.switchDepthTest(o.isDepthTest),this.bindFramebufferWebGL(o),this.setViewportForNormalRendering(o),this.setScissorForNormalRendering(o),c===A.MeshRendererComponentTID&&this.rC.clearFrameBuffer(this,o),o._isChangedSortRenderResult=!1;let l=E.sort_$render(this,o);if(o._renderedSomethingBefore){let d=p[f];if(d){let u=d({processApproach:this.tC,renderPass:o,processStage:s,renderPassTickCount:this.nC,primitiveUids:l,displayIdx:0,engine:this});o._renderedSomethingBefore=u}}if(c===A.EffekseerComponentTID&&o.entities.length>0){let d=this.webglResourceRepository,u=d.getCurrentTexture2DBindingsForEffekseer();d.setWebGLStateToDefaultForEffekseer();for(let y of o.entities){let C=y.tryToGetEffekseer();C!=null&&C.$render()}d.restoreTexture2DBindingsForEffekseer(u)}this.nC++,o._copyFramebufferToResolveFramebuffersWebGL(),o.doPostRender()}}}else if(E.hasPendingLoad||this.MC()||_.getUpdateCount(this)!==this.nr||x.getCurrentCameraUpdateCount(this)!==this.hC||F.getPrimitiveCount()!==this.mC||G.getUpdateCount(this)!==this.or)for(let a of r){let c=R.getComponentClass(a),p=c[f];p&&p({processApproach:this.tC,renderPass:void 0,processStage:s,renderPassTickCount:this.nC,displayIdx:0,engine:this}),c.process(this,c,s)}s===D.Logic&&(T._updateTransformGizmosByCameraChange(this),G._updateLightGizmosByCameraChange(this))}this.hC=x.getCurrentCameraUpdateCount(this),this.IC(),this.nr=_.getUpdateCount(this),this.mC=F.getPrimitiveCount(),this.or=G.getUpdateCount(this)}static get processTime(){return S.lastTimeTimeIntervalInMilliseconds}static get timeAtProcessBegin(){return S.timeAtProcessBeginMilliseconds}static get timeAtProcessEnd(){return S.timeAtProcessEndMilliseconds}static createCamera(e){let t=j(e,!0);t.getTransform().localPosition=re.fromCopyArray([0,0,1]),t.getCamera().type=ee.Orthographic,t.getCamera().zNear=.1,t.getCamera().zFar=1e4;let r=e.cgApiResourceRepository,[i,s]=r.getCanvasSize();t.getCamera().xMag=i/s,t.getCamera().yMag=1}setViewportForNormalRendering(e){let t=this.eC,r=this.sC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(r!=null&&r.isWebARMode)&&this.rC.setViewport(this,e.getViewport())}setScissorForNormalRendering(e){let t=this.eC,r=this.sC,i=this.rC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(r!=null&&r.isWebARMode)?i.setScissorRect(e):i.setScissorRect(void 0)}bindFramebufferWebGL(e){let t=this.eC,r=this.sC;if(t!=null&&t.isWebXRMode&&e.isOutputForVr){let s=this.rC.currentWebGLContextWrapper.getRawContext();s.bindFramebuffer(s.FRAMEBUFFER,t.framebuffer)}else if(r!=null&&r.isWebARMode){let s=this.rC.currentWebGLContextWrapper.getRawContext();s.bindFramebuffer(s.FRAMEBUFFER,r.framebuffer)}else this.rC.bindFramebuffer(e.getFramebuffer()),this.rC.setDrawTargets(e)}jC(){console.log(`%cRhodonite%cWeb3D Library%c %cversion%c${N.version}%c %cbranch%c${N.branch}%c %cmode%c${this.tC.str}`,"font-weight: bold; padding: 4px 8px; border-radius: 6px 0px 0px 6px; background: linear-gradient(to right, #ff0084 0%,#ff0022 100%);","padding: 4px; border-radius: 0px 6px 6px 0px; background: linear-gradient(to right, #8400ff 0%,#4400ff 100%);","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: firebrick; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: green; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: blue; padding: 4px; border-radius: 0px 6px 6px 0px")}static JC(){R._ensureComponentClassRegistered(_),R._ensureComponentClassRegistered(T),R._ensureComponentClassRegistered(J),R._ensureComponentClassRegistered(E),R._ensureComponentClassRegistered(x),R._ensureComponentClassRegistered(G),R._ensureComponentClassRegistered(H)}static async init(e){var c,p,o,l,g,d;if(e.approach!==h.None&&e.approach!==h.WebGL2&&e.approach!==h.WebGPU){let u=(p=(c=e.approach)==null?void 0:c.str)!=null?p:String(e.approach);throw new Error(`Unsupported process approach "${u}". The "Uniform" and "DataTexture" modes were removed. Use ProcessApproach.WebGL2 ("WebGL2") or ProcessApproach.WebGPU ("WebGPU").`)}if(e.approach===h.WebGL2&&typeof __RN_WEBGL__!="undefined"&&!__RN_WEBGL__)throw new Error("ProcessApproach.WebGL2 is unavailable: this build was bundled with __RN_WEBGL__ = false.");if(e.approach===h.WebGPU&&typeof __RN_WEBGPU__!="undefined"&&!__RN_WEBGPU__)throw new Error("ProcessApproach.WebGPU is unavailable: this build was bundled with __RN_WEBGPU__ = false.");m.JC();let t=((o=e.xr)!=null?o:m._loadXRByDefault)?await k.getInstance().loadModule("xr"):void 0,r=0,i,s;if(e.approach===h.WebGPU){let b=function(X){v.features.has(X)&&W.push(X)};var a=b;await k.getInstance().loadModule("webgpu");let u=$.getWebGpuResourceRepository(),C=k.getInstance().getModule("webgpu").WebGpuDeviceWrapper,v=await navigator.gpu.requestAdapter({xrCompatible:!0});s=((l=e.config)==null?void 0:l.isComputeSkinningWorkaroundEnabled)!==!1?ue(v):void 0;let{maxBufferSize:M,maxStorageBufferBindingSize:P}=v.limits,W=[];b("float32-filterable"),b("rg11b10ufloat-renderable"),b("texture-compression-bc"),b("texture-compression-etc2"),b("texture-compression-astc"),b("timestamp-query");let w=await v.requestDevice({requiredFeatures:W,requiredLimits:{maxStorageBufferBindingSize:P,maxBufferSize:M}});r=P;let I=new C(e.canvas,v,w);u.addWebGpuDeviceWrapper(I),u.recreateSystemDepthTexture(),u.createBindGroupLayoutForDrawParameters(),i=u}else e.approach===h.WebGL2?(await k.getInstance().loadModule("webgl"),i=$.getWebGLResourceRepository(),i.generateWebGLContext((g=e.config)!=null?g:new O,e.canvas,!0,e.webglOption),i.switchDepthTest(!0),r=i.currentWebGLContextWrapper.getMaxTextureSize()**2*4*4):r=1024**2*4*4;let n=new m(e.approach,i,r,e.config,t);if(n.oC.currentProcessApproach=e.approach,n.dC.eventTargetDom=(d=n.dC.eventTargetDom)!=null?d:e.canvas,e.approach===h.WebGPU&&(n.iC=i),e.approach===h.WebGL2&&(n.CC=i),n.rC=i,s!==void 0&&n.config.isComputeSkinningWorkaroundEnabled){let u=ce(s);u!==void 0&&(n.config.isComputeSkinningEnabled=!1,n.engineState.computeSkinningWorkaroundGpu=u,n.logger.warn(`Rhodonite: compute skinning is disabled because this GPU (${u}) is known to misrender it. Skinned and morphing meshes are deformed in the vertex shaders instead, and the other meshes keep the GPU culling. Set Config.isComputeSkinningWorkaroundEnabled = false to keep the compute skinning.`))}return e.notToDisplayRnInfoAtInit!==!0&&n.jC(),n.yC.initialize(e.approach),e.canvas!=null&&e.approach===h.WebGL2&&(e.canvas.addEventListener("webglcontextlost",(u=>{u.preventDefault(),n.stopRenderLoop(),n.logger.error("WebGL context lost occurred.")}).bind(this)),e.canvas.addEventListener("webglcontextrestored",()=>{n.logger.error("WebGL context restored."),n.restartRenderLoop()})),n.fC=await te.init(n),n.oC.viewportAspectRatio=e.canvas!=null?e.canvas.width/e.canvas.height:1,n}get processApproach(){return this.tC}resizeCanvas(e,t){this.cgApiResourceRepository.resizeCanvas(e,t),this.oC.viewportAspectRatio=e/t}getCanvasSize(){return this.cgApiResourceRepository.getCanvasSize()}getCurrentWebGLContextWrapper(){return this.rC.currentWebGLContextWrapper}get entityRepository(){return this.Na}get componentRepository(){return this.uC}get componentMemoryRegistry(){return this.GC}get webXRSystem(){if(this.eC==null)throw new Error(m.AC);return this.eC}get webARSystem(){if(this.sC==null)throw new Error(m.AC);return this.sC}get isXREnabled(){return this.eC!=null}get _webXRSystemIfEnabled(){return this.eC}get _webARSystemIfEnabled(){return this.sC}async enableXR(){if(this.eC==null){let e=await k.getInstance().loadModule("xr");this.eC==null&&this.UC(e)}return this.eC}UC(e){this.eC=e.WebXRSystem.init(this),this.sC=e.WebARSystem.init(this)}get memoryManager(){return this.of}get globalDataRepository(){return this.yC}_requestLightClusterSystem(){this.o||this.PC!=null||(this.PC=import("../renderer/lightCluster/LightClusterSystem.js").then(({LightClusterSystem:e})=>{this.o||(this.cC=new e(this),this.wC=!0)}).catch(e=>{z.default.warn(`Failed to load the light cluster system: ${e}`)}))}async _ensureLightClusterSystem(){return this._requestLightClusterSystem(),await this.PC,this.cC}get lightClusterSystem(){return this.cC}get materialRepository(){return this.EC}get webglResourceRepository(){return this.CC}get cgApiResourceRepository(){return this.rC}get webGpuResourceRepository(){return this.iC}get dummyTextures(){return this.fC}get engineState(){return this.oC}get config(){return this.dC}get _gpuInstanceDataVersion(){return this._C}_markGpuInstanceDataDirty(){this._C++}get _isPreviousMorphWeightsEnabled(){return this.LC}_enablePreviousMorphWeights(){this.LC=!0}get logger(){return this.xC}get shaderProgramCache(){return this.BC}};m._loadXRByDefault=!1,m.SC=new Map,m.kC=0,m.AC="The XR support is not enabled. Initialize the engine with Engine.init({ xr: true }) or call await engine.enableXR() first. The default Rn namespace export enables it automatically.";var V=m;export{V as Engine};
|
|
@@ -27,6 +27,12 @@ export declare class EngineState {
|
|
|
27
27
|
* @default 0
|
|
28
28
|
*/
|
|
29
29
|
totalSizeOfGPUShaderDataStorageExceptMorphData: number;
|
|
30
|
+
/**
|
|
31
|
+
* The GPU name that matched a known driver workaround (currently the compute deformation one, see
|
|
32
|
+
* `Config.isComputeSkinningWorkaroundEnabled`), or undefined when no workaround applied. Meant for
|
|
33
|
+
* diagnostics and for applications that display the effective render settings.
|
|
34
|
+
*/
|
|
35
|
+
computeSkinningWorkaroundGpu?: string;
|
|
30
36
|
xrPoseWebGPU?: XRViewerPose;
|
|
31
37
|
xrGpuBinding?: any;
|
|
32
38
|
xrProjectionLayerWebGPU?: XRLayer;
|