rhodonite 0.27.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/definitions/ShaderSemantics.js +1 -1
- 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.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.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/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.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 +82 -9
- 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.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.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.js +4 -4
- package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
- package/dist/esm/webgl/WebGLStrategyWebGL2.js +48 -48
- 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 -5
- 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 -40
- 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 +124 -112
- 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 +54 -1
- 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/DiscardShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/EndShader.js +1 -1
- package/dist/esm/webgl/shaders/nodes/SdApplyTransform.js +5 -5
- 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.js +3 -3
- 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 -6
- package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +44 -41
- 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 -114
- 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 +55 -1
- 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.js +27 -27
- package/dist/esmdev/foundation/core/RnObject.js +36 -36
- 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.js +6 -6
- 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 +40 -40
- package/dist/esmdev/foundation/geometry/Mesh.d.ts +15 -0
- package/dist/esmdev/foundation/geometry/Mesh.js +249 -219
- 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 +210 -210
- 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 +41 -18
- 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 +24 -12
- package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
- package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
- package/dist/esmdev/foundation/importer/Gltf2Importer.js +14 -14
- 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 +27 -27
- 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 +197 -170
- package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +19 -19
- 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.js +116 -116
- 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/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 +55 -55
- 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.js +101 -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 +82 -9
- package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +582 -458
- 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.js +32 -32
- 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.js +18 -18
- 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.js +315 -311
- package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
- package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +270 -263
- 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.js +604 -604
- 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 +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Component as T}from"../../core/Component.js";import{applyMixins as R}from"../../core/EntityRepository.js";import{ProcessStage as d}from"../../definitions/ProcessStage.js";import{Matrix44 as p}from"../../math/index.js";import{MutableQuaternion as h}from"../../math/MutableQuaternion.js";import{Quaternion as I}from"../../math/Quaternion.js";import{Transform3D as g}from"../../math/Transform3D.js";import{Is as a}from"../../misc/index.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var o=class o extends T{constructor(){super(...arguments);this.
|
|
1
|
+
import{Component as T}from"../../core/Component.js";import{applyMixins as R}from"../../core/EntityRepository.js";import{ProcessStage as d}from"../../definitions/ProcessStage.js";import{Matrix44 as p}from"../../math/index.js";import{MutableQuaternion as h}from"../../math/MutableQuaternion.js";import{Quaternion as I}from"../../math/Quaternion.js";import{Transform3D as g}from"../../math/Transform3D.js";import{Is as a}from"../../misc/index.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var o=class o extends T{constructor(){super(...arguments);this.tl=new g;this.nl=0}static get renderedPropertyCount(){return null}static get componentTID(){return m.TransformComponentTID}get componentTID(){return m.TransformComponentTID}get restOrPose(){return this.el!==void 0?this.el:this.tl}static getUpdateCount(t){var e;return(e=this.pi.get(t))!=null?e:0}static fi(t){var s;let e=(s=this.pi.get(t))!=null?s:0;this.pi.set(t,e+1)}_backupTransformAsRest(){this.el===void 0&&(this.el=this.tl.clone(),this.entity.tryToGetSceneGraph().setWorldMatrixRestDirty())}_restoreTransformFromRest(){this.el!==void 0&&this.tl.setTransform(this.el.positionInner,this.el.scaleInner,h.fromCopyQuaternion(this.el.rotationInner))}get localTransform(){return this.tl}set localTransform(t){this.tl.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}get localTransformRest(){return this.restOrPose}set localTransformRest(t){a.undefined(this.el)&&(this.el=new g),this.el.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}set localPosition(t){this.tl.position=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setPositionToPhysics(s.matrixInner.multiplyVector3(t)):e.setPositionToPhysics(t)}o.fi(this.i)}set localPositionWithoutPhysics(t){this.tl.position=t,o.fi(this.i)}setLocalPositionAsArray3(t){this.tl.setPositionAsArray3(t),o.fi(this.i)}get localPosition(){return this.tl.position}get localPositionInner(){return this.tl.positionInner}set localPositionRest(t){a.undefined(this.el)&&(this.el=this.tl.clone()),this.el.position=t,o.fi(this.i)}get localPositionRest(){return this.restOrPose.position}get localPositionRestInner(){return this.restOrPose.positionInner}set localEulerAngles(t){this.tl.eulerAngles=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=Math.sin(t._v[0]*.5),i=Math.cos(t._v[0]*.5),n=Math.sin(t._v[1]*.5),r=Math.cos(t._v[1]*.5),l=Math.sin(t._v[2]*.5),c=Math.cos(t._v[2]*.5),u=h.fromCopy4(s*r*c-i*n*l,i*n*c+s*r*l,i*r*l-s*n*c,i*r*c+s*n*l),f=e.parent;f!==void 0?e.setRotationToPhysics(I.multiply(f.rotation,u)):e.setRotationToPhysics(u)}o.fi(this.i)}set localEulerAnglesWithoutPhysics(t){this.tl.eulerAngles=t,o.fi(this.i)}get localEulerAngles(){return this.tl.eulerAngles}get localEulerAnglesInner(){return this.tl.eulerAnglesInner}set localEulerAnglesRest(t){a.undefined(this.el)&&(this.el=this.tl.clone()),this.el.eulerAngles=t,o.fi(this.i)}get localEulerAnglesRest(){return this.restOrPose.eulerAngles}get localEulerAnglesRestInner(){return this.restOrPose.eulerAnglesInner}set localScale(t){this.tl.scale=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent,i=s===void 0?this.tl.matrixInner:p.multiply(s.matrixInner,this.tl.matrixInner);e.setScaleToPhysics(e._getPhysicsWorldScale(i))}o.fi(this.i)}set localScaleWithoutPhysics(t){this.tl.scale=t,o.fi(this.i)}setLocalScaleAsArray3(t){this.tl.setScaleAsArray3(t),o.fi(this.i)}get localScale(){return this.tl.scale}get localScaleInner(){return this.tl.scaleInner}set localScaleRest(t){a.undefined(this.el)&&(this.el=this.tl.clone()),this.el.scale=t,o.fi(this.i)}get localScaleRest(){return this.restOrPose.scale}get localScaleRestInner(){return this.restOrPose.scaleInner}set localRotation(t){this.tl.rotation=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setRotationToPhysics(I.multiply(s.rotationInner,t)):e.setRotationToPhysics(t)}o.fi(this.i)}set localRotationWithoutPhysics(t){this.tl.rotation=t,o.fi(this.i)}setLocalRotationAsArray4(t){this.tl.setRotationAsArray4(t),o.fi(this.i)}get localRotation(){return this.tl.rotation}get localRotationInner(){return this.tl.rotationInner}set localRotationRest(t){a.undefined(this.el)&&(this.el=this.tl.clone()),this.el.rotation=t,o.fi(this.i)}get localRotationRest(){return this.restOrPose.rotation}get localRotationRestInner(){return this.restOrPose.rotationInner}set localMatrix(t){this.tl.matrix=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setMatrixToPhysics(p.multiply(s.matrix,t)):e.setMatrixToPhysics(t)}o.fi(this.i)}set localMatrixWithoutPhysics(t){this.tl.matrix=t,o.fi(this.i)}get localMatrix(){return this.tl.matrix}get localMatrixInner(){return this.tl.matrixInner}getLocalMatrixInnerTo(t){this.tl.getMatrixInnerTo(t)}set localMatrixRest(t){a.undefined(this.el)&&(this.el=this.tl.clone()),this.el.matrix=t,o.fi(this.i)}get localMatrixRest(){return this.restOrPose.matrix}get localMatrixRestInner(){return this.restOrPose.matrixInner}$load(){this.moveStageTo(d.Logic)}$logic(){this.nl!==this.tl.updateCount&&(this.entity.tryToGetSceneGraph().setWorldMatrixDirty(),this.nl=this.tl.updateCount)}_shallowCopyFrom(t){let e=t;this.tl=e.tl.clone(),e.el!=null&&(this.el=e.el.clone()),this.nl=e.nl,o.fi(this.i)}get entity(){return this.i.entityRepository.getEntity(this.gn)}_destroy(){super._destroy()}addThisComponentToEntity(t,e){class s extends t.constructor{getTransform(){return this.ol===void 0&&(this.ol=this.getComponentByComponentTID(m.TransformComponentTID)),this.ol}set localPosition(n){let r=this.getTransform();r.localPosition=n}get localPosition(){return this.localPositionInner.clone()}get localPositionInner(){return this.getTransform().localPositionInner}set localPositionRest(n){let r=this.getTransform();r.localPositionRest=n}get localPositionRest(){return this.getTransform().localPositionRest}get localPositionRestInner(){return this.getTransform().localPositionRestInner}set localScale(n){let r=this.getTransform();r.localScale=n}get localScale(){return this.localScaleInner.clone()}get localScaleInner(){return this.getTransform().localScaleInner}set localScaleRest(n){let r=this.getTransform();r.localScaleRest=n}get localScaleRest(){return this.getTransform().localScaleRest}get localScaleRestInner(){return this.getTransform().localScaleRestInner}set localEulerAngles(n){let r=this.getTransform();r.localEulerAngles=n}get localEulerAngles(){return this.localEulerAnglesInner.clone()}get localEulerAnglesInner(){return this.getTransform().localEulerAnglesInner}set localEulerAnglesRest(n){let r=this.getTransform();r.localEulerAnglesRest=n}get localEulerAnglesRest(){return this.localEulerAnglesRestInner.clone()}get localEulerAnglesRestInner(){return this.getTransform().localEulerAnglesRestInner}set localRotation(n){let r=this.getTransform();r.localRotation=n}get localRotation(){return this.localRotationInner.clone()}get localRotationInner(){return this.getTransform().localRotationInner}set localRotationRest(n){let r=this.getTransform();r.localRotationRest=n}get localRotationRest(){return this.localQuaternionRestInner.clone()}get localRotationRestInner(){return this.getTransform().localRotationRestInner}set localMatrix(n){let r=this.getTransform();r.localMatrix=n}get localMatrix(){return this.localMatrixInner.clone()}get localMatrixInner(){return this.getTransform().localMatrixInner}set localMatrixRest(n){let r=this.getTransform();r.localMatrixRest=n}get localMatrixRest(){return this.localMatrixRestInner.clone()}get localMatrixRestInner(){return this.getTransform().localMatrixRestInner}}return R(t,s),t}static _cleanupForEngine(t){o.pi.delete(t)}};o.pi=new Map;var y=o;export{y as TransformComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Quaternion as t}from"../math/Quaternion.js";import{Vector3 as i}from"../math/Vector3.js";var a=class{constructor(o,n,r,e){this.Ea=o,this.
|
|
1
|
+
import{Quaternion as t}from"../math/Quaternion.js";import{Vector3 as i}from"../math/Vector3.js";var a=class{constructor(o,n,r,e){this.Ea=o,this.rl=n,this.Np=r,this.vp=e,this.vp.getTransform()._backupTransformAsRest()}getAxisVector(o){switch(o){case"X":return i.fromCopy3(1,0,0);case"Y":return i.fromCopy3(0,1,0);case"Z":return i.fromCopy3(0,0,1);default:throw new Error("Invalid roll axis")}}update(){let o=t.multiply(t.invert(this.Ea.localRotationRestInner),this.Ea.localRotationInner),n=t.multiply(t.multiply(this.Ea.localRotationRestInner,o),t.invert(this.Ea.localRotationRestInner)),r=t.multiply(t.multiply(t.invert(this.vp.localRotationRestInner),n),this.vp.localRotationRestInner),e=this.getAxisVector(this.rl),s=r.transformVector3(e),l=t.fromToRotation(e,s),c=t.lerp(this.vp.localRotationRestInner,t.multiply(t.multiply(this.vp.localRotationRestInner,t.invert(l)),r),this.Np);this.vp.localRotation=c}};export{a as VrmRollConstraint};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ComponentType as V}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{ProcessStage as E}from"../definitions/ProcessStage.js";import{VectorN as I}from"../math/VectorN.js";import{RnException as O}from"../misc/index.js";import{Err as A,Ok as L}from"../misc/Result.js";import{RnObject as S}from"./RnObject.js";var a=class a extends S{constructor(e,o,t,r,n){super();this._isAlive=!0;this.
|
|
1
|
+
import{ComponentType as V}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{ProcessStage as E}from"../definitions/ProcessStage.js";import{VectorN as I}from"../math/VectorN.js";import{RnException as O}from"../misc/index.js";import{Err as A,Ok as L}from"../misc/Result.js";import{RnObject as S}from"./RnObject.js";var a=class a extends S{constructor(e,o,t,r,n){super();this._isAlive=!0;this.Wo=!1;this.nf=E.Load;this.i=e,this.gn=o,this._component_sid=t,this.of=e.memoryManager,this.Na=r,n&&(this.Wo=!0)}moveStageTo(e){this.nf=e}static get componentTID(){return 0}get componentTID(){return 0}get componentSID(){return this._component_sid}get entityUID(){return this.gn}get currentProcessStage(){return this.nf}static doesTheProcessStageMethodExist(e,o){return e.prototype[o.methodName]!=null}isExistProcessStageMethod(e){return this[e.methodName]!=null}static process(e,o,t){if(!a.doesTheProcessStageMethodExist(o,t))return;let r=t.methodName,n=e.componentRepository._getComponents(o);if(n!=null)for(let i of n)i!=null&&t===i.nf&&i[r]()}static updateComponentsForRenderStage(e,o,t){let r=e.sort_$render;return r(t)}registerDependency(e,o){}rf(e,o,t,r,n,i){let m=this[`_${e}`];if(m!=null&&!m.isDummy())return;let y=Math.floor(n/i),l=n%i,s=this._componentMemoryRegistry,f=this.constructor,u=s.getAccessor(f,e,y)._takeExistedOne(l);if(this[`_${e}`]=new o(u,!1,!0),!(t instanceof I))for(let p=0;p<this[`_${e}`]._v.length;++p)this[`_${e}`]._v[p]=t[p];return null}sf(e,o){var g,h,d,C;let t=e.memberName,r=this[`_${t}`];if(r!=null&&!r.isDummy())return;let n=this.constructor,i=this._componentMemoryRegistry,m=Math.max((d=(h=this._getArrayLengthForAllocation(t))!=null?h:(g=a.tf.get(n))==null?void 0:g.get(t))!=null?d:1,1),y=e.compositionType.getNumberOfComponents()*m,l=y*e.componentType.getSizeInBytes(),s=i.getVariableLengthChunk(n,t,o);(s==null||s.byteCapacity<l)&&(s!=null&&i.releaseVariableLengthChunk(n,t,s),s=(C=i.takeFreeVariableLengthChunk(n,t,l))!=null?C:a.af(this.i,e.bufferUse,l),i.setVariableLengthChunk(n,t,o,s));let f=s.bufferView,c=new Float32Array(f.buffer.getArrayBuffer(),f.byteOffsetInRawArrayBufferOfBuffer,y);c.fill(0);let u=e.dataClassType;this[`_${t}`]=new u(c,!1,!0);let p=this[`_${a._getVariableLengthLocationMemberName(t)}`],b=a._variableLengthLocationRadix;p._v[0]=Math.floor(s.location/b),p._v[1]=s.location%b,p._v[2]=m,p._v[3]=0}static af(e,o,t){let r,n=0;do r=e.memoryManager.createOrGetBuffer(o,n).takeBufferView({byteLengthToNeed:t,byteStride:0}),r.isErr()&&n++;while(r.isErr());let i=r.get(),m=e.memoryManager.getByteOffsetOfExistingBuffers(o,i.buffer.indexOfTheBufferUsage)+i.byteOffsetInBuffer;return{bufferView:i,byteCapacity:t,location:m/4/4}}static _getVariableLengthLocationMemberName(e){return`${e}Location`}get _componentMemoryRegistry(){return this.i.componentMemoryRegistry}static ff(e,o,t,r,n,i,m,y,l){let s=e.componentMemoryRegistry,f=h(),c=s.getAccessor(r,t,m);if(c!=null&&c.elementCount===y&&c.byteStride===f&&c.compositionType===n&&c.componentType===i)return new L(c);let p,b=0;do p=e.memoryManager.createOrGetBuffer(o,b).takeBufferView({byteLengthToNeed:f*y,byteStride:0}),p.isErr()&&b++;while(p.isErr());let g=p.get().takeAccessor({compositionType:n,componentType:i,count:y,byteStride:f,arrayLength:l});if(g.isErr())return new A({message:`Failed to take accessor: ${g.getRnError().message}`,error:void 0});return s.setAccessor(r,t,m,g.get()),g;function h(){let d=n.getNumberOfComponents(),C=i.getSizeInBytes(),B=d*C;return M.isArray(n)&&(B*=l),B}}static registerMember({bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,arrayLength:y,componentSID:l,convertToBool:s,isVariableLength:f}){a.ef.has(this)||a.ef.set(this,new Map);let c=a.ef.get(this);if(f===!0){if(n!==M.Vec4Array&&n!==M.Mat4Array&&n!==M.Mat4x3Array)throw new Error(`Variable-length member ${o} must be Vec4Array, Mat4Array or Mat4x3Array.`);if(i!==V.Float)throw new Error(`Variable-length member ${o} must have the Float component type.`);let u=c.get(a._getVariableLengthLocationMemberName(o));if(u==null||u.compositionType!==M.Vec4)throw new Error(`Register a Vec4 member named ${a._getVariableLengthLocationMemberName(o)} before the variable-length member ${o}.`)}if(c.set(o,{bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,convertToBool:s,isVariableLength:f}),y!=null&&l!=null){a.tf.has(this)||a.tf.set(this,new Map);let u=a.tf.get(this),p=u.get(o);(p==null||y>p)&&u.set(o,y)}}submitToAllocation(e,o){let t=this.constructor,r=this._componentMemoryRegistry;r.setComponentCountPerBufferView(t,e);let n=a.ef.get(t),i=this.i,m=Math.floor(this._component_sid/e);(this._component_sid%e===0||y(m))&&l(m),n.forEach(s=>{s.isVariableLength!==!0&&this.rf(s.memberName,s.dataClassType,s.initValues,o,this._component_sid,e)}),n.forEach(s=>{s.isVariableLength===!0&&this.sf(s,this._component_sid)});function y(s){for(let f of n.values())if(f.isVariableLength!==!0&&r.getAccessor(t,f.memberName,s)==null)return!0;return!1}function l(s){n.forEach(f=>{var h;if(f.isVariableLength===!0)return;let c=(h=a.tf.get(t))==null?void 0:h.get(f.memberName),u=a.ff(i,f.bufferUse,f.memberName,t,f.compositionType,f.componentType,s,e,c!=null?c:1);if(u.isErr())throw new O(u.getRnError());let p=u.get(),g=i.memoryManager.getByteOffsetOfExistingBuffers(f.bufferUse,p.bufferView.buffer.indexOfTheBufferUsage)+p.byteOffsetInBuffer;r.setByteOffset(t,f.memberName,s,g)})}}_getArrayLengthForAllocation(e){}get entity(){return this.Na.getEntity(this.gn)}static getLocationOffsetOfMemberOfComponent(e,o,t){let r=[],i=e.componentMemoryRegistry.getByteOffsetsForMember(o,t);if(i==null)return[0];for(let[m,y]of i)r[m]=y/4/4;for(let m=0;m<r.length;m++)r[m]===void 0&&(r[m]=0);return r}addThisComponentToEntity(e,o){throw"Invalid Calling"}static getCompositionTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.compositionType}static getComponentTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.componentType}static getMemberInfo(e){return new Map(a.ef)}static getComponentCountPerBufferView(e){return e.componentMemoryRegistry.getAllComponentCountPerBufferView()}static getArrayLengthOfMember(e){return new Map(a.tf)}_destroy(){this._isAlive=!1}_shallowCopyFrom(e){}static getStateVersion(e){return e.componentMemoryRegistry.getStateVersion()}};a.ef=new Map,a.tf=new Map,a._processStages=[E.Load,E.Logic,E.Render],a._variableLengthLocationRadix=65536;var T=a;export{T as Component};
|
|
@@ -24,6 +24,7 @@ type ConfigInitDescription = {
|
|
|
24
24
|
isDepthPrepassEnabled?: boolean;
|
|
25
25
|
isGpuCullingEnabled?: boolean;
|
|
26
26
|
isComputeSkinningEnabled?: boolean;
|
|
27
|
+
isComputeSkinningWorkaroundEnabled?: boolean;
|
|
27
28
|
isClusteredForwardEnabled?: boolean;
|
|
28
29
|
clusteredForwardBuildMode?: ClusteredForwardBuildMode;
|
|
29
30
|
clusteredForwardGridSize?: [number, number, number];
|
|
@@ -300,6 +301,20 @@ export declare class Config {
|
|
|
300
301
|
* vertex shader deformation.
|
|
301
302
|
*/
|
|
302
303
|
isComputeSkinningEnabled: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Whether the engine turns `isComputeSkinningEnabled` off automatically on a GPU whose driver is known to misrender
|
|
306
|
+
* the compute deformation (WebGPU only).
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* The browser exposes no driver version, so the workaround is keyed on the GPU names in
|
|
310
|
+
* `computeDeformationBrokenGpuPatterns` (`src/foundation/system/GpuDriverWorkarounds.ts`). Only GPUs whose failure
|
|
311
|
+
* was observed are listed; currently that is the Adreno 740 (Meta Quest 3 / Quest 3S), where a skinned morphing mesh
|
|
312
|
+
* fed by the compute deformation was not drawn at all while the same mesh rendered correctly through the vertex
|
|
313
|
+
* shader deformation. On such a GPU the skinned and morphing meshes keep the CPU culling and deform in the vertex
|
|
314
|
+
* shaders, while the other meshes keep the GPU culling; the detected GPU name is logged and stored in
|
|
315
|
+
* `EngineState.computeSkinningWorkaroundGpu`. Set this to false to keep the compute deformation everywhere.
|
|
316
|
+
*/
|
|
317
|
+
isComputeSkinningWorkaroundEnabled: boolean;
|
|
303
318
|
constructor(initDescription?: ConfigInitDescription);
|
|
304
319
|
}
|
|
305
320
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as u,LogLevel as r}from"../misc/Logger.js";var a=class{constructor(e={}){this.scenegraphComponentCountPerBufferView=1e3;this.skeletalComponentCountPerBufferView=100;this.cameraComponentCountPerBufferView=1;this.lightComponentCountPerBufferView=64;this.eu=6;this.isClusteredForwardEnabled=!0;this.clusteredForwardBuildMode="auto";this.clusteredForwardGridSize=[48,27,48];this.clusteredForwardMaxViewNumber=4;this.clusteredForwardMinLocalLightNumber=1;this.clusteredForwardLightCapacityPerCluster=96;this.maxLightListLength=1024;this.lightAutoRangeThreshold=0;this.uu=1;this.materialCountPerBufferView=100;this.boneDataType=void 0;this.isUboEnabled=!1;this.cacheWebGpuRenderBundles=!0;this.cgApiDebugConsoleOutput=!1;this.multiViewForWebVR=!1;this.physicsTimeIntervalScale=1;this.isMobile=!1;this.bufferSizeDivisionRatiosForGPUInstanceDataUsage=[1/32,5/32,6/32,12/32];this.logLevel=r.Warn;this.isMultiDrawEnabled=!0;this.isDepthPrepassEnabled=!1;this.isGpuCullingEnabled=!0;this.isComputeSkinningEnabled=!0;e.scenegraphComponentCountPerBufferView!==void 0&&(this.scenegraphComponentCountPerBufferView=e.scenegraphComponentCountPerBufferView),e.skeletalComponentCountPerBufferView!==void 0&&(this.skeletalComponentCountPerBufferView=e.skeletalComponentCountPerBufferView),e.cameraComponentCountPerBufferView!==void 0&&(this.cameraComponentCountPerBufferView=e.cameraComponentCountPerBufferView),e.lightComponentCountPerBufferView!==void 0&&(this.lightComponentCountPerBufferView=e.lightComponentCountPerBufferView),e.maxLightNumber!==void 0&&(this.maxLightNumber=e.maxLightNumber),e.materialCountPerBufferView!==void 0&&(this.materialCountPerBufferView=e.materialCountPerBufferView),e.boneDataType!==void 0&&(this.boneDataType=e.boneDataType),e.isUboEnabled!==void 0&&(this.isUboEnabled=e.isUboEnabled),e.eventTargetDom!==void 0&&(this.eventTargetDom=e.eventTargetDom),e.cacheWebGpuRenderBundles!==void 0&&(this.cacheWebGpuRenderBundles=e.cacheWebGpuRenderBundles),e.cgApiDebugConsoleOutput!==void 0&&(this.cgApiDebugConsoleOutput=e.cgApiDebugConsoleOutput),e.multiViewForWebVR!==void 0&&(this.multiViewForWebVR=e.multiViewForWebVR),e.physicsTimeIntervalScale!==void 0&&(this.physicsTimeIntervalScale=e.physicsTimeIntervalScale),e.isMobile!==void 0&&(this.isMobile=e.isMobile),e.bufferSizeDivisionRatiosForGPUInstanceDataUsage!==void 0&&(this.bufferSizeDivisionRatiosForGPUInstanceDataUsage=e.bufferSizeDivisionRatiosForGPUInstanceDataUsage),e.logLevel!==void 0&&(this.logLevel=e.logLevel),e.isMultiDrawEnabled!==void 0&&(this.isMultiDrawEnabled=e.isMultiDrawEnabled),e.isDepthPrepassEnabled!==void 0&&(this.isDepthPrepassEnabled=e.isDepthPrepassEnabled),e.isGpuCullingEnabled!==void 0&&(this.isGpuCullingEnabled=e.isGpuCullingEnabled),e.isComputeSkinningEnabled!==void 0&&(this.isComputeSkinningEnabled=e.isComputeSkinningEnabled),e.isClusteredForwardEnabled!==void 0&&(this.isClusteredForwardEnabled=e.isClusteredForwardEnabled),e.clusteredForwardBuildMode!==void 0&&(this.clusteredForwardBuildMode=e.clusteredForwardBuildMode),e.clusteredForwardGridSize!==void 0&&(this.clusteredForwardGridSize=[...e.clusteredForwardGridSize]),e.clusteredForwardMinLocalLightNumber!==void 0&&(this.clusteredForwardMinLocalLightNumber=e.clusteredForwardMinLocalLightNumber),e.clusteredForwardMaxViewNumber!==void 0&&(this.clusteredForwardMaxViewNumber=e.clusteredForwardMaxViewNumber),e.clusteredForwardLightCapacityPerCluster!==void 0&&(this.clusteredForwardLightCapacityPerCluster=e.clusteredForwardLightCapacityPerCluster),e.maxLightListLength!==void 0&&(this.maxLightListLength=e.maxLightListLength),e.lightAutoRangeThreshold!==void 0&&(this.lightAutoRangeThreshold=e.lightAutoRangeThreshold),e.lightRangeScale!==void 0&&(this.lightRangeScale=e.lightRangeScale)}get maxLightNumber(){return this.eu}set maxLightNumber(e){if(!(e>=0)){u.default.warn(`Config.maxLightNumber (${e}) is invalid. Values below 0 are treated as 0.`),this.eu=0;return}this.eu=e}get maxLightNumberOrOne(){return this.eu>0?this.eu:1}get lightRangeScale(){return this.uu}set lightRangeScale(e){if(!(e>0)||e>1){u.default.warn(`Config.lightRangeScale (${e}) is invalid. Use a value in (0, 1].`),this.uu=1;return}this.uu=e}};export{a as Config};
|
|
1
|
+
import{Logger as u,LogLevel as r}from"../misc/Logger.js";var a=class{constructor(e={}){this.scenegraphComponentCountPerBufferView=1e3;this.skeletalComponentCountPerBufferView=100;this.cameraComponentCountPerBufferView=1;this.lightComponentCountPerBufferView=64;this.eu=6;this.isClusteredForwardEnabled=!0;this.clusteredForwardBuildMode="auto";this.clusteredForwardGridSize=[48,27,48];this.clusteredForwardMaxViewNumber=4;this.clusteredForwardMinLocalLightNumber=1;this.clusteredForwardLightCapacityPerCluster=96;this.maxLightListLength=1024;this.lightAutoRangeThreshold=0;this.uu=1;this.materialCountPerBufferView=100;this.boneDataType=void 0;this.isUboEnabled=!1;this.cacheWebGpuRenderBundles=!0;this.cgApiDebugConsoleOutput=!1;this.multiViewForWebVR=!1;this.physicsTimeIntervalScale=1;this.isMobile=!1;this.bufferSizeDivisionRatiosForGPUInstanceDataUsage=[1/32,5/32,6/32,12/32];this.logLevel=r.Warn;this.isMultiDrawEnabled=!0;this.isDepthPrepassEnabled=!1;this.isGpuCullingEnabled=!0;this.isComputeSkinningEnabled=!0;this.isComputeSkinningWorkaroundEnabled=!0;e.scenegraphComponentCountPerBufferView!==void 0&&(this.scenegraphComponentCountPerBufferView=e.scenegraphComponentCountPerBufferView),e.skeletalComponentCountPerBufferView!==void 0&&(this.skeletalComponentCountPerBufferView=e.skeletalComponentCountPerBufferView),e.cameraComponentCountPerBufferView!==void 0&&(this.cameraComponentCountPerBufferView=e.cameraComponentCountPerBufferView),e.lightComponentCountPerBufferView!==void 0&&(this.lightComponentCountPerBufferView=e.lightComponentCountPerBufferView),e.maxLightNumber!==void 0&&(this.maxLightNumber=e.maxLightNumber),e.materialCountPerBufferView!==void 0&&(this.materialCountPerBufferView=e.materialCountPerBufferView),e.boneDataType!==void 0&&(this.boneDataType=e.boneDataType),e.isUboEnabled!==void 0&&(this.isUboEnabled=e.isUboEnabled),e.eventTargetDom!==void 0&&(this.eventTargetDom=e.eventTargetDom),e.cacheWebGpuRenderBundles!==void 0&&(this.cacheWebGpuRenderBundles=e.cacheWebGpuRenderBundles),e.cgApiDebugConsoleOutput!==void 0&&(this.cgApiDebugConsoleOutput=e.cgApiDebugConsoleOutput),e.multiViewForWebVR!==void 0&&(this.multiViewForWebVR=e.multiViewForWebVR),e.physicsTimeIntervalScale!==void 0&&(this.physicsTimeIntervalScale=e.physicsTimeIntervalScale),e.isMobile!==void 0&&(this.isMobile=e.isMobile),e.bufferSizeDivisionRatiosForGPUInstanceDataUsage!==void 0&&(this.bufferSizeDivisionRatiosForGPUInstanceDataUsage=e.bufferSizeDivisionRatiosForGPUInstanceDataUsage),e.logLevel!==void 0&&(this.logLevel=e.logLevel),e.isMultiDrawEnabled!==void 0&&(this.isMultiDrawEnabled=e.isMultiDrawEnabled),e.isDepthPrepassEnabled!==void 0&&(this.isDepthPrepassEnabled=e.isDepthPrepassEnabled),e.isGpuCullingEnabled!==void 0&&(this.isGpuCullingEnabled=e.isGpuCullingEnabled),e.isComputeSkinningEnabled!==void 0&&(this.isComputeSkinningEnabled=e.isComputeSkinningEnabled),e.isComputeSkinningWorkaroundEnabled!==void 0&&(this.isComputeSkinningWorkaroundEnabled=e.isComputeSkinningWorkaroundEnabled),e.isClusteredForwardEnabled!==void 0&&(this.isClusteredForwardEnabled=e.isClusteredForwardEnabled),e.clusteredForwardBuildMode!==void 0&&(this.clusteredForwardBuildMode=e.clusteredForwardBuildMode),e.clusteredForwardGridSize!==void 0&&(this.clusteredForwardGridSize=[...e.clusteredForwardGridSize]),e.clusteredForwardMinLocalLightNumber!==void 0&&(this.clusteredForwardMinLocalLightNumber=e.clusteredForwardMinLocalLightNumber),e.clusteredForwardMaxViewNumber!==void 0&&(this.clusteredForwardMaxViewNumber=e.clusteredForwardMaxViewNumber),e.clusteredForwardLightCapacityPerCluster!==void 0&&(this.clusteredForwardLightCapacityPerCluster=e.clusteredForwardLightCapacityPerCluster),e.maxLightListLength!==void 0&&(this.maxLightListLength=e.maxLightListLength),e.lightAutoRangeThreshold!==void 0&&(this.lightAutoRangeThreshold=e.lightAutoRangeThreshold),e.lightRangeScale!==void 0&&(this.lightRangeScale=e.lightRangeScale)}get maxLightNumber(){return this.eu}set maxLightNumber(e){if(!(e>=0)){u.default.warn(`Config.maxLightNumber (${e}) is invalid. Values below 0 are treated as 0.`),this.eu=0;return}this.eu=e}get maxLightNumberOrOne(){return this.eu>0?this.eu:1}get lightRangeScale(){return this.uu}set lightRangeScale(e){if(!(e>0)||e>1){u.default.warn(`Config.lightRangeScale (${e}) is invalid. Use a value in (0, 1].`),this.uu=1;return}this.uu=e}};export{a as Config};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{WellKnownComponentTIDs as p}from"../components/WellKnownComponentTIDs.js";import{BufferUse as y}from"../definitions/BufferUse.js";import{ComponentType as
|
|
1
|
+
import{WellKnownComponentTIDs as p}from"../components/WellKnownComponentTIDs.js";import{BufferUse as y}from"../definitions/BufferUse.js";import{ComponentType as i}from"../definitions/ComponentType.js";import{CompositionType as s}from"../definitions/CompositionType.js";import{calcAlignedByteLength as x}from"../definitions/ShaderSemanticsInfo.js";import{ShaderType as o}from"../definitions/ShaderType.js";import{MathClassUtil as h}from"../math/MathClassUtil.js";import{Scalar as f}from"../math/Scalar.js";import{Vector2 as d}from"../math/Vector2.js";import{Vector3 as A}from"../math/Vector3.js";import{VectorN as S}from"../math/VectorN.js";import{getLightClusterGlobalPropertyLength as T}from"../renderer/lightCluster/LightClusterLayout.js";var g=class b{constructor(e){this.em=new Map;this.i=e}initialize(e){let t={semantic:"currentComponentSIDs",compositionType:s.ScalarArray,componentType:i.Float,arrayLength:p.maxWellKnownTidNumber,stage:o.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:new S(new Float32Array(p.maxWellKnownTidNumber))};this.tm(t,1),this.takeOne("currentComponentSIDs");let n={semantic:"skinningMode",compositionType:s.Scalar,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:1,isInternalSetting:!0,initialValue:f.fromCopyNumber(-1)};this.tm(n,1),this.takeOne("skinningMode");let a={semantic:"lightNumber",compositionType:s.Scalar,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(a,1),this.takeOne("lightNumber");let r=T(this.i.config.maxLightListLength),m={semantic:"clusteredLightData",compositionType:s.Vec4Array,componentType:i.Float,arrayLength:r,stage:o.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:new S(new Float32Array(r*4))};this.tm(m,1),this.takeOne("clusteredLightData");let c={semantic:"ambientLightIntensity",compositionType:s.Vec3,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:A.fromCopy3(0,0,0)};this.tm(c,1),this.takeOne("ambientLightIntensity");let u={semantic:"backBufferTextureSize",compositionType:s.Vec2,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(u,1),this.takeOne("backBufferTextureSize");let l={semantic:"vrState",compositionType:s.Vec2,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(l,1),this.takeOne("vrState");let I={semantic:"time",compositionType:s.Scalar,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(I,1),this.takeOne("time")}static init(e){return new b(e)}tm(e,t){let n=x(e),a,r=0;do a=this.i.memoryManager.createOrGetBuffer(y.GPUInstanceData,r).takeBufferView({byteLengthToNeed:n*t,byteStride:0}),a.isErr()&&r++;while(a.isErr());let m=e.arrayLength;s.isArray(e.compositionType)&&m==null&&(m=100);let c=a.get().takeAccessor({compositionType:e.compositionType,componentType:i.Float,count:t,byteStride:n,arrayLength:m}).unwrapForce(),u={shaderSemanticsInfo:e,values:[],maxCount:t,accessor:c};this.em.set(e.semantic,u)}takeOne(e){let t=this.em.get(e);if(t){let n=t.shaderSemanticsInfo,a=t.accessor.takeOne(),r=t.values.length,m=h.initWithFloat32Array(n.initialValue,a);return t.values[r]=m,m}}setValue(e,t,n){let a=this.em.get(e);if(a){let r=a.values[t];h._setForce(r,n)}}getValue(e,t){let n=this.em.get(e);if(n)return n.values[t]}getPropertyTable(){let e=[];return this.em.forEach((t,n)=>{e.push({semantic:n,info:t.shaderSemanticsInfo,value:t.values[0],vec4Index:this.getLocationOffsetOfProperty(n),maxCount:t.maxCount})}),e}_setUniformLocationsForWebGL2ModeOnly(e){let t=this.i.webglResourceRepository,n=[];this.em.forEach(a=>{let r=a.shaderSemanticsInfo;r.needUniformInDataTextureMode&&n.push(r)}),t.setupUniformLocations(this.i.config,e,n)}getLocationOffsetOfProperty(e){let t=this.em.get(e);if(t){let n=t.accessor;return(this.i.memoryManager.getByteOffsetOfExistingBuffers(y.GPUInstanceData,n.bufferView.buffer.indexOfTheBufferUsage)+n.byteOffsetInBuffer)/4/4}return-1}_addPropertiesStr(e,t,n){return this.em.forEach(a=>{let r=a.shaderSemanticsInfo;(r.stage===o.VertexShader||r.stage===o.VertexAndPixelShader)&&(e+=n(this.i,r)),(r.stage===o.PixelShader||r.stage===o.VertexAndPixelShader)&&(t+=n(this.i,r))}),[e,t]}};export{g as GlobalDataRepository};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_from as Gt,_fromString as $t,_fromStringCaseSensitively as zt,EnumClass as Vt}from"../misc/EnumIO.js";import{CompositionType as m}from"./CompositionType.js";var n=class n extends Vt{constructor({str:t}){super({index:++n.
|
|
1
|
+
import{_from as Gt,_fromString as $t,_fromStringCaseSensitively as zt,EnumClass as Vt}from"../misc/EnumIO.js";import{CompositionType as m}from"./CompositionType.js";var n=class n extends Vt{constructor({str:t}){super({index:++n.ec*n._scale,str:t,noCheckStrUnique:!0}),n.tc[this.index]=this}static getShaderSemanticByIndex(t){return this.tc[Math.abs(t)-Math.abs(t)%this._scale]}static isNonArrayShaderSemanticIndex(t){return t>=this._scale}static isArrayAndZeroIndexShaderSemanticIndex(t){return t<0&&Math.abs(t)%n._scale===0}static isArrayAndNonZeroIndexShaderSemanticIndex(t){return t<0&&Math.abs(t)%n._scale!==0}static getIndexCount(){return n.ec}};n.ec=-1,n._scale=1e4,n.tc=[];var e=n,S=new e({str:"worldMatrix"}),d=new e({str:"viewMatrix"}),h=new e({str:"isBillboard"}),l=new e({str:"enableViewMatrix"}),x=new e({str:"projectionMatrix"}),T=new e({str:"normalMatrix"}),w=new e({str:"boneMatrix"}),p=new e({str:"baseColorFactor"}),E=new e({str:"baseColorTexture"}),g=new e({str:"normalTexture"}),f=new e({str:"metallicRoughnessTexture"}),C=new e({str:"occlusionTexture"}),I=new e({str:"emissiveFactor"}),y=new e({str:"emissiveTexture"}),R=new e({str:"lightNumber"}),b=new e({str:"lightPosition"}),v=new e({str:"lightDirection"}),M=new e({str:"lightIntensity"}),F=new e({str:"lightProperty"}),P=new e({str:"metallicRoughnessFactor"}),k=new e({str:"brdfLutTexture"}),B=new e({str:"diffuseEnvTexture"}),N=new e({str:"specularEnvTexture"}),D=new e({str:"sheenEnvTexture"}),L=new e({str:"inverseEnvironment"}),O=new e({str:"iblParameter"}),A=new e({str:"iblMipLevelSkip"}),G=new e({str:"viewPosition"}),$=new e({str:"wireframe"}),z=new e({str:"diffuseColorFactor"}),V=new e({str:"diffuseColorTexture"}),_=new e({str:"shininess"}),H=new e({str:"shadingModel"}),j=new e({str:"skinningMode"}),Q=new e({str:"generalTexture"}),W=new e({str:"boneQuaternion"}),U=new e({str:"boneTranslateScale"}),K=new e({str:"boneTranslatePackedQuat"}),Z=new e({str:"boneScalePackedQuat"}),q=new e({str:"boneCompressedChunk"}),J=new e({str:"boneCompressedInfo"}),X=new e({str:"pointSize"}),Y=new e({str:"colorEnvTexture"}),ee=new e({str:"pointDistanceAttenuation"}),te=new e({str:"hdriFormat"}),ne=new e({str:"screenInfo"}),re=new e({str:"depthTexture"}),se=new e({str:"lightViewProjectionMatrix"}),ae=new e({str:"anisotropy"}),oe=new e({str:"clearcoatParameter"}),ie=new e({str:"sheenColorFactor"}),ce=new e({str:"sheenColorTexture"}),ue=new e({str:"sheenRoughnessFactor"}),me=new e({str:"sheenRoughnessTexture"}),Se=new e({str:"sheenLutTexture"}),de=new e({str:"specularGlossinessFactor"}),he=new e({str:"specularGlossinessTexture"}),le=new e({str:"entityUID"}),xe=new e({str:"morphTargetNumber"}),Te=new e({str:"dataTextureMorphOffsetPosition"}),we=new e({str:"morphWeights"}),pe=new e({str:"currentComponentSIDs"}),Ee=new e({str:"alphaCutoff"}),ge=new e({str:"alphaTexture"}),fe=new e({str:"makeOutputSrgb"}),_t=new e({str:"framebufferSize"}),Ce=new e({str:"clearCoatFactor"}),Ie=new e({str:"clearCoatTexture"}),ye=new e({str:"clearCoatRoughnessFactor"}),Re=new e({str:"clearCoatRoughnessTexture"}),be=new e({str:"clearCoatNormalTexture"}),ve=new e({str:"transmissionFactor"}),Me=new e({str:"transmissionTexture"}),Fe=new e({str:"backBufferTexture"}),Pe=new e({str:"backBufferTextureSize"}),ke=new e({str:"thicknessFactor"}),Be=new e({str:"thicknessTexture"}),Ne=new e({str:"attenuationDistance"}),De=new e({str:"attenuationColor"}),Le=new e({str:"isOutputHDR"}),Oe=new e({str:"baseColorTextureTransform"}),Ae=new e({str:"baseColorTextureRotation"}),Ge=new e({str:"normalTextureTransform"}),$e=new e({str:"normalTextureRotation"}),ze=new e({str:"metallicRoughnessTextureTransform"}),Ve=new e({str:"metallicRoughnessTextureRotation"}),_e=new e({str:"normalTexcoordIndex"}),He=new e({str:"baseColorTexcoordIndex"}),je=new e({str:"metallicRoughnessTexcoordIndex"}),Qe=new e({str:"occlusionTexcoordIndex"}),We=new e({str:"occlusionTextureTransform"}),Ue=new e({str:"occlusionTextureRotation"}),Ke=new e({str:"emissiveTexcoordIndex"}),Ze=new e({str:"emissiveTextureTransform"}),qe=new e({str:"emissiveTextureRotation"}),Je=new e({str:"normalScale"}),Xe=new e({str:"occlusionStrength"}),Ye=new e({str:"envRotation"}),et=new e({str:"envHdriFormat"}),tt=new e({str:"vrState"}),nt=new e({str:"enableLinearToSrgb"}),rt=new e({str:"specularFactor"}),st=new e({str:"specularTexture"}),at=new e({str:"specularColorFactor"}),ot=new e({str:"specularColorTexture"}),it=new e({str:"ior"}),ct=new e({str:"depthBiasPV"}),ut=new e({str:"clearCoatTextureTransform"}),mt=new e({str:"clearCoatTextureRotation"}),St=new e({str:"clearCoatRoughnessTextureTransform"}),dt=new e({str:"clearCoatRoughnessTextureRotation"}),ht=new e({str:"clearCoatNormalTextureTransform"}),lt=new e({str:"clearCoatNormalTextureRotation"}),xt=new e({str:"clearCoatTexcoordIndex"}),Tt=new e({str:"clearCoatRoughnessTexcoordIndex"}),wt=new e({str:"clearCoatNormalTexcoordIndex"}),pt=new e({str:"iridescenceFactor"}),Et=new e({str:"iridescenceTexture"}),gt=new e({str:"iridescenceIor"}),ft=new e({str:"iridescenceThicknessMinimum"}),Ct=new e({str:"iridescenceThicknessMaximum"}),It=new e({str:"iridescenceThicknessTexture"}),yt=new e({str:"gaussianKernelSize"}),Rt=new e({str:"gaussianRatio"}),bt=new e({str:"isHorizontal"}),vt=new e({str:"anisotropyStrength"}),Mt=new e({str:"anisotropyRotation"}),Ft=new e({str:"anisotropyTexture"}),Pt=new e({str:"emissiveStrength"}),kt=new e({str:"time"}),Bt=new e({str:"cubeMapFaceId"}),Nt=new e({str:"roughness"}),Dt=new e({str:"distributionType"}),i=[S,d,h,l,x,T,w,p,E,g,f,C,I,y,R,b,v,M,F,P,k,B,N,D,L,O,A,G,$,z,V,_,H,j,Q,W,U,K,Z,q,J,X,Y,ee,te,ne,re,se,ae,oe,ie,ce,ue,me,Se,de,he,le,xe,Te,we,pe,Ee,ge,fe,Ce,Ie,ye,Re,be,ve,Me,Fe,Pe,ke,Be,Ne,De,Le,Oe,Ae,Ge,$e,ze,Ve,_e,He,je,Qe,We,Ue,Ke,Ze,qe,Je,Xe,Ye,et,tt,nt,rt,st,at,ot,it,ct,ut,mt,St,dt,ht,lt,xt,Tt,wt,pt,Et,gt,ft,Ct,It,yt,Rt,bt,vt,Mt,Ft,Pt,kt,Bt,Nt,Dt];function Ht(r){return Gt({typeList:i,index:r})}function jt(r){return $t({typeList:i,str:r})}function Qt(r){return zt({typeList:i,str:r})}function qt(r){return r.index}function Wt(r,t,a){return Lt(r,a)}function Lt(r,t){let a=t.compositionType.getGlslStr(t.componentType),s=t.semantic,Ot=t.compositionType.getGlslStr(t.componentType),c="";t.arrayLength&&(c=`[${t.arrayLength}]`);let At=` uniform ${Ot} u_${s}${c};
|
|
2
2
|
`,o="";m.isArray(t.compositionType)?(s.match(/\[.+?\]/)?s=s.replace(/\[.+?\]/g,"[i]"):s+="[i]",o+=`
|
|
3
3
|
${a} val;
|
|
4
4
|
int i = int(index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as
|
|
1
|
+
import{Logger as r}from"../misc/Logger.js";import{CompositionType as a}from"./CompositionType.js";function s(n){let m=n.compositionType.getNumberOfComponents(),i=n.componentType.getSizeInBytes(),o=m*i,e=o;if(e%16!==0&&(e=o+16-o%16),a.isArray(n.compositionType)){let t=n.arrayLength;t!=null?e*=t:(r.default.error("semanticInfo has invalid maxIndex!"),e*=100)}return e}export{s as calcAlignedByteLength};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_from as d,_fromString as f,EnumClass as E}from"../misc/EnumIO.js";import{RnException as X}from"../misc/RnException.js";var i=class i extends E{constructor({str:r,shaderStr:N,attributeSlot:T,gltfComponentN:V,isIntegerType:g}){super({index:i.
|
|
1
|
+
import{_from as d,_fromString as f,EnumClass as E}from"../misc/EnumIO.js";import{RnException as X}from"../misc/RnException.js";var i=class i extends E{constructor({str:r,shaderStr:N,attributeSlot:T,gltfComponentN:V,isIntegerType:g}){super({index:i.ec++,str:r}),this.Au=T,this.Su=N,this.bu=V,this.Cu=g!=null?g:!1}getAttributeSlot(){return this.Au}get shaderStr(){return this.Su}get isIntegerType(){return this.Cu}get attributeTypeName(){return this.str}_setShaderStr(r){this.Su=this.Su+r}get X(){return`${this.attributeTypeName}.X`}get Y(){return`${this.attributeTypeName}.Y`}get Z(){return`${this.attributeTypeName}.Z`}get W(){return`${this.attributeTypeName}.W`}get XY(){return`${this.attributeTypeName}.X,${this.attributeTypeName}.Y`}get XYZ(){return`${this.attributeTypeName}.X,${this.attributeTypeName}.Y,${this.attributeTypeName}.Z`}get XYZW(){return`${this.attributeTypeName}.X,${this.attributeTypeName}.Y,${this.attributeTypeName}.Z,${this.attributeTypeName}.W`}getVertexAttributeComponentsAsGltf(){if(this.bu===1)return this.X;if(this.bu===2)return this.XY;if(this.bu===3)return this.XYZ;if(this.bu===4)return this.XYZW;throw new X({message:"Invalid gltf component number",error:this.bu})}static mu(r){return new i(r)}};i.ec=-1;var e=i,h=e.mu({str:"UNKNOWN",shaderStr:"a_unknown",attributeSlot:-1,gltfComponentN:0}),s=e.mu({str:"POSITION",shaderStr:"a_position",attributeSlot:0,gltfComponentN:3}),u=e.mu({str:"NORMAL",shaderStr:"a_normal",attributeSlot:1,gltfComponentN:3}),a=e.mu({str:"TANGENT",shaderStr:"a_tangent",attributeSlot:2,gltfComponentN:4}),m=e.mu({str:"TEXCOORD_0",shaderStr:"a_texcoord_0",attributeSlot:3,gltfComponentN:2}),p=e.mu({str:"TEXCOORD_1",shaderStr:"a_texcoord_1",attributeSlot:4,gltfComponentN:2}),b=e.mu({str:"COLOR_0",shaderStr:"a_color_0",attributeSlot:5,gltfComponentN:4}),n=e.mu({str:"JOINTS_0",shaderStr:"a_joints_0",attributeSlot:6,gltfComponentN:4,isIntegerType:!0}),c=e.mu({str:"WEIGHTS_0",shaderStr:"a_weights_0",attributeSlot:7,gltfComponentN:4}),o=e.mu({str:"INSTANCE",shaderStr:"a_instanceBase",attributeSlot:8,gltfComponentN:4,isIntegerType:!0}),S=e.mu({str:"FACE_NORMAL",shaderStr:"a_faceNormal",attributeSlot:9,gltfComponentN:3}),A=e.mu({str:"BARY_CENTRIC_COORD",shaderStr:"a_baryCentricCoord",attributeSlot:10,gltfComponentN:4}),C=e.mu({str:"TEXCOORD_2",shaderStr:"a_texcoord_2",attributeSlot:11,gltfComponentN:2}),l=e.mu({str:"MATERIAL_SID",shaderStr:"a_materialSid",attributeSlot:12,gltfComponentN:1,isIntegerType:!0}),x=[h,s,u,a,m,p,b,n,c,o,S,A,C,l],O=x.length-1;function y(t){return t instanceof e}function _(t){return d({typeList:x,index:t})}function Y(t){let r=t;return t==="COLOR"?r="COLOR_0":t==="TEXCOORD"?r="TEXCOORD_0":t==="JOINTS"?r="JOINTS_0":t==="WEIGHTS"&&(r="WEIGHTS_0"),f({typeList:x,str:r})}function I(t){switch(t){case s:return t.XYZ;case b:return t.XYZ;case u:return t.XYZ;case a:return t.XYZ;case m:return t.XY;case p:return t.XY;case C:return t.XY;case n:return t.XYZW;case c:return t.XYZW;case o:return t.XYZW;case S:return t.XYZW;case A:return t.XYZW;default:throw new Error("Invalied glTF VertexAttributeEnum")}}function $(t){switch(t){case s.XYZ:return s.getAttributeSlot();case b.XYZ:return b.getAttributeSlot();case u.XYZ:return u.getAttributeSlot();case a.XYZ:return a.getAttributeSlot();case m.XY:return m.getAttributeSlot();case p.XY:return p.getAttributeSlot();case C.XY:return C.getAttributeSlot();case n.XYZW:return n.getAttributeSlot();case c.XYZW:return c.getAttributeSlot();case o.XYZW:return o.getAttributeSlot();case S.XYZ:return S.getAttributeSlot();case A.XYZ:return A.getAttributeSlot();default:throw new Error("Invalied glTF VertexAttributeEnum")}}function Z(t){return t.split(",").length}var R=[n,o,l],D=Object.freeze({Unknown:h,Position:s,Normal:u,Tangent:a,Texcoord0:m,Texcoord1:p,Color0:b,Joints0:n,Weights0:c,Instance:o,FaceNormal:S,BaryCentricCoord:A,MaterialSid:l,AttributeTypeNumber:O,integerTypeAttributes:R,isInstanceOfVertexAttributeClass:y,toVertexAttributeSemanticJoinedStringAsGltfStyle:I,toAttributeSlotFromJoinedString:$,toVectorComponentN:Z,from:_,fromString:Y});export{D as VertexAttribute,e as VertexAttributeClass};
|
|
@@ -120,6 +120,12 @@ export declare class Gltf2Exporter {
|
|
|
120
120
|
*/
|
|
121
121
|
static __createNodes(json: Gltf2Ex, entities: ISceneGraphEntity[], topLevelEntities: ISceneGraphEntity[]): void;
|
|
122
122
|
private static __exportLight;
|
|
123
|
+
/**
|
|
124
|
+
* Exports an ambient light. KHR_lights_punctual has no ambient light type, so the light is stored in the
|
|
125
|
+
* Rhodonite extras of the node (`node.extras.rhodonite.ambientLight`), which ModelConverter restores. Other
|
|
126
|
+
* viewers see the node as an empty node.
|
|
127
|
+
*/
|
|
128
|
+
private static __exportAmbientLight;
|
|
123
129
|
private static __ensureLightsExtension;
|
|
124
130
|
/**
|
|
125
131
|
* Exports the graph of a RaymarchingComponent as a Rhodonite node extension.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isSameGlTF2TextureSampler as M,TagKhrNodeVisibilityEnabled as B,TagKhrNodeVisibilityVisible as S}from"../../types/glTF2.js";import{VERSION as V}from"../../version.js";import{SceneGraphComponent as D}from"../components/SceneGraph/SceneGraphComponent.js";import{CameraType as w,LightType as H,TextureParameter as I}from"../definitions/index.js";import{MathUtil as F}from"../math/MathUtil.js";import{Quaternion as C}from"../math/Quaternion.js";import{DataUtil as O}from"../misc/DataUtil.js";import{Is as l}from"../misc/Is.js";import{Logger as P}from"../misc/Logger.js";import{createEffekseer as k}from"./Gltf2ExporterEffekseer.js";import{__createBufferViewsAndAccessorsOfAnimation as U,__createBufferViewsAndAccessorsOfMesh as z,__createBufferViewsAndAccessorsOfSkin as $,__deleteEmptyArrays as X,__outputBaseMaterialInfo as W,__outputKhrMaterialsAnisotropyInfo as q,__outputKhrMaterialsClearcoatInfo as Y,__outputKhrMaterialsDiffuseTransmissionInfo as J,__outputKhrMaterialsDispersionInfo as Q,__outputKhrMaterialsEmissiveStrengthInfo as Z,__outputKhrMaterialsIorInfo as j,__outputKhrMaterialsIridescenceInfo as ee,__outputKhrMaterialsSheenInfo as te,__outputKhrMaterialsSpecularInfo as ne,__outputKhrMaterialsTransmissionInfo as ie,__outputKhrMaterialsVolumeInfo as re,__pruneUnusedVertexAttributes as se,__removeUnusedAccessorsAndBufferViews as ae,generateGlbArrayBuffer as oe,handleTextureImage as N,isNumericArrayBufferView as v,isRuntimeOnlyAnimationPath as ce}from"./Gltf2ExporterOps.js";var K="glTF",L="glTF-Binary",Ae="glTF-Draco",Ie="glTF-Embedded",we="No-Download",G=class{constructor(){}static async export(t,e,i={entities:void 0,type:L}){let{collectedEntities:r,topLevelEntities:s}=this.dc(t,i);this.ac.clear(),this.cc.clear(),this.lc.clear(),this.uc.clear(),this.fc.clear();let{json:a,fileName:x}=this.yc(e);this._c(a,r),this.Tc(a,r,s),await this.bc(a,r,i),await this.Ec(a,i),this.Rc(a,r),k(a,r),ae(a);let u=this.Ac(a);X(a);let c=oe(a,u);return i.type===L?this.Ic(a,x,c):i.type===K&&this.wc(a,x,u),c}static dc(t,e){let i=u=>{if(l.exist(e)&&l.exist(e.excludeTags)){for(let c of e.excludeTags)if(u.matchTag(c.tag,c.value))return!1;if(u.matchTag("Being","gizmo"))return!0}return!0},r=u=>{if(l.exist(e)&&l.exist(e.excludeTags)){for(let c of e.excludeTags)if(u.matchTag(c.tag,c.value))return[]}return[u]},s=(u,c)=>{let f=u.getSceneGraph();if(f.children.length>0){let n=c?[]:r(u);for(let m=0;m<f.children.length;m++){let o=f.children[m];Array.prototype.push.apply(n,s(o.entity,!1))}return n}return c?[]:r(u)};if(l.exist(e)&&l.exist(e.entities)&&e.entities.length>0){let u=e.entities.flatMap(n=>s(n,!0)),c=[];e.entities.forEach(n=>{u.indexOf(n)===-1&&i(n)&&c.push(n)});let f=e.entities.concat();return Array.prototype.push.apply(f,u),f=[...new Set(f)],c.length===0&&(c=f),{collectedEntities:f,topLevelEntities:c}}let a=t.entityRepository._getEntities();a=a.filter(u=>i(u));let x=D.getTopLevelComponents().flatMap(u=>u.entity);return x=x.filter(u=>i(u)),a=a.flatMap(u=>s(u,!0)),Array.prototype.push.apply(a,x),a=[...new Set(a)],{collectedEntities:a,topLevelEntities:x}}static yc(t){let e=t||`Rhodonite_${Date.now()}`;return{json:{asset:{version:"2.0",generator:`Rhodonite (${V.version})`},buffers:[{uri:`${e}.bin`,byteLength:0}],bufferViews:[],accessors:[],animations:[],meshes:[],skins:[],materials:[],textures:[],images:[],extensionsUsed:[],extensions:{},extras:{rnSkins:[],bufferViewByteLengthAccumulatedArray:[]},cameras:[],samplers:[]},fileName:e}}static _c(t,e){let i=[],r=[],s=[];z(t,e,i,r,s),$(t,e,i,r,s)}static Rc(t,e){U(t,e,{resolveAnimationTarget:({channel:r,trackName:s})=>this.Gc(t,r,s)})}static Tc(t,e,i){t.nodes=[],t.scenes=[{nodes:[]}];let r=t.scenes[0],s=new Set,a=new Array(e.length),x=[];for(let c=0;c<e.length;c++){let f=e[c];f.gltfNodeIndex=c}let u=0;for(let c=0;c<e.length;c++){let f=e[c];t.nodes[c]={};let n=t.nodes[c];n.name=f.uniqueName;let m=f.getSceneGraph(),o=m.children;if(o.length>0){n.children=[];for(let T=0;T<o.length;T++){let R=o[T];if(l.exist(R.entity.gltfNodeIndex)){let A=R.entity.gltfNodeIndex;n.children.push(A),a[A]=c}}n.children.length===0&&(n.children=void 0)}m.isBillboard&&(n.extensions={RHODONITE_billboard:{isBillboard:!0}},t.extensionsUsed.indexOf("RHODONITE_billboard")===-1&&t.extensionsUsed.push("RHODONITE_billboard"));let g=f.getTagValue(S);f.getTagValue(B)===!0&&typeof g=="boolean"&&(l.not.exist(n.extensions)&&(n.extensions={}),n.extensions.KHR_node_visibility={visible:g},this.ic(t,"KHR_node_visibility"));let h=f.getTransform(),d=C.normalize(h.localRotationInner),p=[d.x,d.y,d.z,d.w];n.rotation=p.map(T=>Math.min(1,Math.max(-1,T))),n.scale=[h.localScaleInner.x,h.localScaleInner.y,h.localScaleInner.z],n.translation=[h.localPositionInner.x,h.localPositionInner.y,h.localPositionInner.z];let b=f.tryToGetMesh();l.exist(b)&&l.exist(b.mesh)&&(n.mesh=u++);let y=f.tryToGetBlendShape();if(l.exist(y)){let T=y.weights;T.length>0&&(n.weights=T)}let E=f.tryToGetSkeletal();if(l.exist(E)){let T=t.extras.rnSkins.indexOf(E.entity);T>=0&&(n.skin=T,l.exist(n.mesh)&&x.push(c))}let _=f.tryToGetCamera();if(l.exist(_)){let T;if(_.type===w.Perspective){let R=_.getTagValue("OriginalAspect"),A=_.getTagValue("OriginalFovY");T={name:_.entity.uniqueName,type:"perspective",perspective:{aspectRatio:l.exist(R)?R:_.aspect,yfov:l.exist(A)?F.degreeToRadian(A):F.degreeToRadian(_.fovy),znear:_.zNear,zfar:_.zFar}}}else if(_.type===w.Orthographic){let R=_.getTagValue("OriginalXMag"),A=_.getTagValue("OriginalYMag");T={name:_.entity.uniqueName,type:"orthographic",orthographic:{xmag:l.exist(R)?R:_.xMag,ymag:l.exist(A)?A:_.yMag,znear:_.zNear,zfar:_.zFar}}}t.cameras.push(T),n.camera=t.cameras.length-1,this.lc.set(_,n.camera)}this.vc(t,f,n),this.Oc(t,f,n)}for(let c of x){let f=t.nodes[c],n=a[c];if(l.exist(n)){let p=t.nodes[n];l.exist(p.children)&&(p.children=p.children.filter(b=>b!==c),p.children.length===0&&(p.children=void 0)),a[c]=void 0}let o=e[c].getSceneGraph().matrixInner,g=o.getTranslate(),h=o.getScale(),d=C.normalize(C.fromMatrix(o));f.translation=[g.x,g.y,g.z],f.rotation=[Math.min(1,Math.max(-1,d.x)),Math.min(1,Math.max(-1,d.y)),Math.min(1,Math.max(-1,d.z)),Math.min(1,Math.max(-1,d.w))],f.scale=[h.x,h.y,h.z],s.has(c)||(r.nodes.push(c),s.add(c))}i.forEach(c=>{let f=e.indexOf(c);f>=0&&!s.has(f)&&(r.nodes.push(f),s.add(f))})}static vc(t,e,i){var o,g;let r=(o=e.tryToGetLight)==null?void 0:o.call(e);if(l.not.exist(r)||r.enable!==!0)return;let s;if(r.type===H.Point?s="point":r.type===H.Directional?s="directional":r.type===H.Spot&&(s="spot"),l.not.exist(s))return;let a=r.color,x=[Number.isFinite(a.x)?a.x:1,Number.isFinite(a.y)?a.y:1,Number.isFinite(a.z)?a.z:1],u={type:s,color:x};l.exist(e.uniqueName)&&e.uniqueName.length>0&&(u.name=e.uniqueName);let c=r.intensity;if(Number.isFinite(c)&&(u.intensity=c),s!=="directional"){let h=r.range;Number.isFinite(h)&&h>0&&(u.range=h)}if(s==="spot"){let h=Number.isFinite(r.outerConeAngle)?r.outerConeAngle:Math.PI/4,d=Number.isFinite(r.innerConeAngle)?r.innerConeAngle:0,p=Math.max(0,Math.min(h,Math.PI/2)),b=Math.max(0,Math.min(d,p));u.spot={innerConeAngle:b,outerConeAngle:p}}let f={castShadow:r.castShadow,pointLightShadowFarPlane:r.pointLightShadowFarPlane};r.isShadowZNearForSpotLightAuto||(f.shadowZNearForSpotLight=r.shadowZNearForSpotLight),u.extras={...(g=u.extras)!=null?g:{},rhodonite:f};let n=this.Hc(t),m=n.lights.length;n.lights.push(u),this.cc.set(r,m),this.ic(t,"KHR_lights_punctual"),l.not.exist(i.extensions)&&(i.extensions={}),i.extensions.KHR_lights_punctual={light:m}}static Hc(t){l.not.exist(t.extensions)&&(t.extensions={});let e=t.extensions;return l.not.exist(e.KHR_lights_punctual)&&(e.KHR_lights_punctual={lights:[]}),e.KHR_lights_punctual}static Oc(t,e,i){var s,a;let r=(s=e.tryToGetRaymarching)==null?void 0:s.call(e);l.not.exist(r)||(l.not.exist(i.extensions)&&(i.extensions={}),i.extensions.RHODONITE_raymarching={graph:(a=r.rrnJson)!=null?a:null,sdfShapeType:r.sdfShapeType.index,isPickable:r.isPickable,castShadow:r.castShadow},this.ic(t,"RHODONITE_raymarching"))}static ic(t,e){t.extensionsUsed.indexOf(e)===-1&&t.extensionsUsed.push(e)}static mc(t,e){if(l.not.exist(t))return;let i=this.ac.get(t);l.not.exist(i)&&(i=[],this.ac.set(t,i)),i.push(e)}static oc(t,e){let i=this.uc.get(t);return l.not.exist(i)&&(i=new Set,this.uc.set(t,i)),i.has(e)?!1:(i.add(e),!0)}static Gc(t,e,i){let r=e.target.pathName;if(typeof r=="string"){if(ce(r))return null;if(r.startsWith("material/")){let s=r.substring(9);return this.Cc(t,e,s,i)}if(r.startsWith("light_"))return this.Kc(t,e,r,i);if(r.startsWith("camera_"))return this.Mc(t,e,r,i);if(r==="visibility")return this.Sc(t,e,i)}}static Sc(t,e,i){var u;let r=e.target.entity.gltfNodeIndex;if(l.not.exist(r))return null;let s=(u=t.nodes)==null?void 0:u[r];if(l.not.exist(s))return null;let a=e.target.entity.getTagValue(S);l.not.exist(s.extensions)&&(s.extensions={}),s.extensions.KHR_node_visibility={visible:typeof a=="boolean"?a:e.target.entity.getSceneGraph().isVisible};let x=`/nodes/${r}/extensions/KHR_node_visibility/visible`;return this.oc(i,x)?(this.ic(t,"KHR_animation_pointer"),this.ic(t,"KHR_node_visibility"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:x}}}):null}static Cc(t,e,i,r){let s=this.Fc(i,e.animatedValue);if(s.length===0)return this.xc(i,!0),null;let a=this.Pc(i);if(l.not.exist(a))return this.xc(i,!1),null;this.ic(t,"KHR_animation_pointer");let x=[];for(let u of s){let c=`/materials/${u}${a}`;this.oc(r,c)&&x.push({path:"pointer",extensions:{KHR_animation_pointer:{pointer:c}}})}return x.length>0?x:null}static Fc(t,e){let i=[];for(let[r,s]of this.ac.entries())r.getParameter(t)===e&&i.push(...s);return Array.from(new Set(i))}static Kc(t,e,i,r){var c,f;let s=(f=(c=e.target.entity).tryToGetLight)==null?void 0:f.call(c);if(l.not.exist(s))return null;let a=this.cc.get(s);if(l.not.exist(a))return null;let x=fe[i];if(l.not.exist(x))return null;let u=`/extensions/KHR_lights_punctual/lights/${a}${x}`;return this.oc(r,u)?(this.ic(t,"KHR_animation_pointer"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:u}}}):null}static Mc(t,e,i,r){var c,f;let s=(f=(c=e.target.entity).tryToGetCamera)==null?void 0:f.call(c);if(l.not.exist(s))return null;let a=this.lc.get(s);if(l.not.exist(a))return null;let x=this.Nc(i,s);if(l.not.exist(x))return null;let u=`/cameras/${a}${x}`;return this.oc(r,u)?(this.ic(t,"KHR_animation_pointer"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:u}}}):null}static Pc(t){let e=le[t];if(l.exist(e))return e;let i=t.match(/^(.*)Transform(Offset|Scale|Rotation)$/);if(i){let r=i[1],s=i[2],a=ue[r];if(l.not.exist(a))return;let x=s.toLowerCase();return`${a}/extensions/KHR_texture_transform/${x}`}}static xc(t,e){this.fc.has(t)||(this.fc.add(t),e?P.default.warn(`KHR_animation_pointer: No material parameter found for semantic "${t}".`):P.default.warn(`KHR_animation_pointer: Unsupported material semantic "${t}". Animation skipped.`))}static Nc(t,e){let i=e.type;switch(t){case"camera_znear":return i===w.Perspective?"/perspective/znear":"/orthographic/znear";case"camera_zfar":return i===w.Perspective?"/perspective/zfar":"/orthographic/zfar";case"camera_fovy":return i===w.Perspective?"/perspective/yfov":void 0;case"camera_xmag":return i===w.Orthographic?"/orthographic/xmag":void 0;case"camera_ymag":return i===w.Orthographic?"/orthographic/ymag":void 0;default:return}}static async bc(t,e,i){let r=0,s=[],a=new Map;t.extras.bufferViewByteLengthAccumulatedArray.push(0);let x=t.extras.bufferViewByteLengthAccumulatedArray.length-1;for(let u=0;u<e.length;u++){let f=e[u].tryToGetMesh();if(f!=null&&f.mesh){let n=t.meshes[r++];await this.Lc(t,f.mesh,n,s,x,i,a)}}return Promise.all(s)}static async Lc(t,e,i,r,s,a,x){let u=e.getPrimitiveNumber();for(let c=0;c<u;c++){let f=e.getPrimitiveAt(c),n=i.primitives[c],m=f.material,o=await this.hc(t,m,r,s,a),g=t.materials.length;t.materials.push(o),n.material=g,this.mc(m,g),se(n,o),await this.Bc(t,f,n,r,s,a,x,g)}}static async Bc(t,e,i,r,s,a,x,u){var m;let c=e.getVariantNames();if(c.length===0)return;let f=[];for(let o of c){if(l.not.exist(o)||o.length===0)continue;let g=e.getVariantMaterial(o);if(g==null)continue;let h=u;if(g!==e.material){let p=await this.hc(t,g,r,s,a);h=t.materials.length,t.materials.push(p),this.mc(g,h)}let d=this.Vc(t,o,x);f.push({material:h,variants:[d]})}if(f.length===0)return;i.extensions=(m=i.extensions)!=null?m:{};let n=i.extensions;l.exist(n.KHR_materials_variants)?n.KHR_materials_variants.mappings.push(...f):n.KHR_materials_variants={mappings:f},this.ic(t,"KHR_materials_variants")}static Vc(t,e,i){let r=i.get(e);if(r!==void 0)return r;let s=this.Dc(t);return r=s.variants.length,s.variants.push({name:e}),i.set(e,r),r}static Dc(t){l.not.exist(t.extensions)&&(t.extensions={});let e=t.extensions;return l.not.exist(e.KHR_materials_variants)&&(e.KHR_materials_variants={variants:[]}),e.KHR_materials_variants}static async hc(t,e,i,r,s){let a={pbrMetallicRoughness:{metallicFactor:1,roughnessFactor:1}};return l.exist(e)&&(e.isNodeBasedMaterial&&e.shaderNodeJson!=null?await this.kc(a,e,t,i,r,s):await this.Uc(a,e,t,i,r,s)),a}static async kc(t,e,i,r,s,a){var n;let x="RHODONITE_materials_node";t.extensions||(t.extensions={});let c={uri:`./${(n=e.shaderNodeFileName)!=null?n:`${e.materialTypeName}_${e.materialUID}.rmn`}`};e.shaderNodeUniforms!=null&&(c.uniforms={...e.shaderNodeUniforms});let f=await this.pc(e,i,r,s,a);Object.keys(f).length>0&&(c.uniforms||(c.uniforms={}),Object.assign(c.uniforms,f)),t.extensions[x]=c,this.ic(i,x)}static async pc(t,e,i,r,s,a=()=>!0){let x={},u=[],c=o=>{let g={magFilter:o!=null?o.magFilter.index:I.Linear.index,minFilter:o!=null?o.minFilter.index:I.Linear.index,wrapS:o!=null?o.wrapS.index:I.TextureWrapS.index,wrapT:o!=null?o.wrapT.index:I.TextureWrapT.index},h=e.samplers.findIndex(d=>M(g,d));return h===-1&&(e.samplers.push(g),h=e.samplers.length-1),h},f=o=>{var d;let g=e.images.length,h=!1;for(let p=0;p<e.images.length;p++){let y=(d=e.images[p].extras)==null?void 0:d.rnTextureUID;l.exist(y)&&y===o.textureUID&&(g=p,h=!0)}if(!h){let p={uri:o.name,name:o.name||void 0,extras:{rnTextureUID:o.textureUID}};u.indexOf(o.name)!==-1&&(p.uri+=`_${o.textureUID}`),u.push(p.uri),l.not.exist(p.uri.match(/\.(png)/))&&(p.uri+=".png");let b=o.htmlCanvasElement;if(b){let y=new Promise((E,_)=>{b.toBlob(T=>{if(l.exist(T))N(e,r,T,s,p,E,_,K);else throw Error("canvas to blob error!")})});i.push(y)}e.images.push(p)}return g},n=(o,g)=>{if(!o||!o.isTextureReady||o.isDummyTexture||o.width<1||o.height<1)return;let h=c(g),d=f(o),p={sampler:h,source:d},b=e.textures.findIndex(y=>y.sampler===p.sampler&&y.source===p.source);return b===-1&&(e.textures.push(p),b=e.textures.length-1),b},m=t.fieldsInfoArray;for(let o of m){let g=o.compositionType;if(a(o.semantic)&&(g.index===7||g.index===8||g.index===16||g.index===17||g.index===18)){let h=t.getTextureParameter(o.semantic);if(h&&Array.isArray(h)&&h.length>=2){let d=h[1],p=h[2];if(d&&!d.isDummyTexture){let b=n(d,p);b!=null&&(x[o.semantic]={index:b})}}}}return x}static async Ec(t,e){let i=e.raymarchingComponentMaterials;if(i!=null&&i.length>0){await this.zc(t,i,e);return}let r=e.raymarchingMaterial;if(r==null)return;let s=await this.gc(t,r,e);s!=null&&(l.not.exist(t.extensions)&&(t.extensions={}),t.extensions.RHODONITE_raymarching_materials={textures:s},this.ic(t,"RHODONITE_raymarching_materials"))}static async zc(t,e,i){var r;for(let{entity:s,material:a}of e){let x=s.gltfNodeIndex;if(x==null)continue;let u=(r=t.nodes)==null?void 0:r[x];if(u==null)continue;let c=await this.gc(t,a,i);if(c==null)continue;l.not.exist(u.extensions)&&(u.extensions={});let f=u.extensions,n=f.RHODONITE_raymarching;n==null&&(n={},f.RHODONITE_raymarching=n),n.textures=c,this.ic(t,"RHODONITE_raymarching")}}static async gc(t,e,i){var c,f,n;let r=e.shaderNodeJson,s=new Set;for(let m of(c=r==null?void 0:r.nodes)!=null?c:[])if(m.name==="Texture2D"){let o=(n=(f=m.controls)==null?void 0:f.name)==null?void 0:n.value;typeof o=="string"&&o.length>0&&s.add(o)}if(s.size===0)return;let a=[];t.extras.bufferViewByteLengthAccumulatedArray.push(0);let x=t.extras.bufferViewByteLengthAccumulatedArray.length-1,u=await this.pc(e,t,a,x,i,m=>s.has(m));return await Promise.all(a),Object.keys(u).length>0?u:void 0}static async Uc(t,e,i,r,s,a){let x=[],u=n=>{let m={magFilter:n!=null?n.magFilter.index:I.Linear.index,minFilter:n!=null?n.minFilter.index:I.Linear.index,wrapS:n!=null?n.wrapS.index:I.TextureWrapS.index,wrapT:n!=null?n.wrapT.index:I.TextureWrapT.index},o=i.samplers.findIndex(g=>M(m,g));return o===-1&&(i.samplers.push(m),o=i.samplers.length-1),o},c=n=>{var g;let m=i.images.length,o=!1;for(let h=0;h<i.images.length;h++){let p=(g=i.images[h].extras)==null?void 0:g.rnTextureUID;l.exist(p)&&p===n.textureUID&&(m=h,o=!0)}if(!o){let h={uri:n.name,name:n.name||void 0,extras:{rnTextureUID:n.textureUID}};x.indexOf(n.name)!==-1&&(h.uri+=`_${n.textureUID}`),x.push(h.uri),l.not.exist(h.uri.match(/\.(png)/))&&(h.uri+=".png");let d=n.htmlCanvasElement;if(d){let p=new Promise((b,y)=>{d.toBlob(E=>{if(l.exist(E))N(i,s,E,a,h,b,y,K);else throw Error("canvas to blob error!")})});r.push(p)}i.images.push(h)}return m},f=(n,m)=>{let o=n;if(!o||!o.isTextureReady||o.isDummyTexture||o.width<1||o.height<1)return;let g=u(m),h=c(o),d={sampler:g,source:h};return i.textures.indexOf(d)===-1&&i.textures.push(d),i.textures.indexOf(d)};this.$c(i,t,e,f)}static $c(t,e,i,r){let s=n=>{t.extensionsUsed.indexOf(n)===-1&&t.extensionsUsed.push(n)},a=n=>{if(!l.not.exist(n)){if(typeof n=="number")return n;if(Array.isArray(n))return n.length>0?n[0]:void 0;if(typeof n=="object"){if(typeof n.x=="number"&&typeof n.y=="undefined")return n.x;if(ArrayBuffer.isView(n)){let o=n;if(v(o)&&o.length>0)return o[0]}let m=n._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>0)return o[0]}if(Array.isArray(m))return m.length>0?m[0]:void 0}}},x=n=>{if(!l.not.exist(n)){if(Array.isArray(n)){if(n.length>=2)return[n[0],n[1]];if(n.length===1)return[n[0],n[0]]}if(typeof n=="object"){if(typeof n.x=="number"&&typeof n.y=="number")return[n.x,n.y];let m=n._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>=2)return[o[0],o[1]]}if(Array.isArray(m)&&m.length>=2)return[m[0],m[1]];if(ArrayBuffer.isView(n)){let o=n;if(v(o)&&o.length>=2)return[o[0],o[1]]}}}},u=n=>{if(!l.not.exist(n)){if(Array.isArray(n)){if(n.length>=3)return[n[0],n[1],n[2]];if(n.length===2)return[n[0],n[1],n[1]];if(n.length===1)return[n[0],n[0],n[0]]}if(typeof n=="object"){if(typeof n.x=="number"&&typeof n.y=="number"&&typeof n.z=="number")return[n.x,n.y,n.z];let m=n._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>=3)return[o[0],o[1],o[2]]}if(Array.isArray(m)&&m.length>=3)return[m[0],m[1],m[2]];if(ArrayBuffer.isView(n)){let o=n;if(v(o)&&o.length>=3)return[o[0],o[1],o[2]]}}}},c=(n,m)=>{var b;let o=i.getTextureParameter(n);if(l.not.exist(o))return;let g=o[1],h=o[2],d=r(g,h);if(d==null)return;let p={index:d};if(l.exist(m.texCoordParam)){let y=a(i.getParameter(m.texCoordParam));l.exist(y)&&(p.texCoord=y)}if(l.exist(m.scaleParam)){let y=a(i.getParameter(m.scaleParam));l.exist(y)&&(p.scale=y)}if(l.exist(m.strengthParam)){let y=a(i.getParameter(m.strengthParam));l.exist(y)&&(p.strength=y)}if(l.exist(m.transform)){let y=l.exist(m.transform.scale)?x(i.getParameter(m.transform.scale)):void 0,E=l.exist(m.transform.offset)?x(i.getParameter(m.transform.offset)):void 0,_=l.exist(m.transform.rotation)?a(i.getParameter(m.transform.rotation)):void 0;if(l.exist(y)||l.exist(E)||l.exist(_)){let T={};l.exist(y)&&(T.scale=y),l.exist(E)&&(T.offset=E),l.exist(_)&&(T.rotation=_),Object.keys(T).length>0&&(p.extensions=(b=p.extensions)!=null?b:{},p.extensions.KHR_texture_transform=T,s("KHR_texture_transform"))}}m.onAssign(p)},f=l.false(i.isLighting);W(i,c,e,t,{skipAdditionalTextures:f}),!f&&(Z(s,a,i,e),J(s,a,u,i,c,e),ie(s,a,i,c,e),re(s,a,u,i,c,e),Q(s,a,i,e),j(s,a,i,e),ee(s,a,i,c,e),Y(s,a,i,c,e),te(s,a,u,i,c,e),ne(s,a,u,i,c,e),q(s,a,x,i,c,e))}static Ac(t){if(l.undefined(t.accessors)||l.undefined(t.bufferViews))return new ArrayBuffer(0);let e=t.bufferViews.reduce((s,a)=>{var u;let x=(u=a.extras)==null?void 0:u.uint8Array;return l.not.exist(x)?s+O.addPaddingBytes(a.byteLength,4):s+O.addPaddingBytes(x.byteLength,4)},0);if(e>0){let s=t.buffers[0];s.byteLength=e+O.calcPaddingBytes(e,4)}let i=new ArrayBuffer(t.buffers[0].byteLength),r=0;for(let s=0;s<t.bufferViews.length;s++){let a=t.bufferViews[s],x=a.extras.uint8Array;a.extras=void 0;let u=r;O.copyArrayBufferWithPadding({src:x.buffer,dist:i,srcByteOffset:x.byteOffset,copyByteLength:x.byteLength,distByteOffset:u}),r+=O.addPaddingBytes(x.byteLength,4),a.byteOffset=u,a.buffer=0}return i}static Ic(t,e,i){{let r=document.createElement("a");r.download=`${e}.glb`;let s=new Blob([i],{type:"octet/stream"}),a=URL.createObjectURL(s);r.href=a;let x=new MouseEvent("click");r.dispatchEvent(x)}}exportGlbAsArrayBuffer(){}static wc(t,e,i){{let r=document.createElement("a");r.download=`${e}.gltf`;let s=JSON.stringify(t,null,2);r.href=`data:application/octet-stream,${encodeURIComponent(s)}`;let a=new MouseEvent("click");r.dispatchEvent(a)}{let r=document.createElement("a");r.download=`${e}.bin`;let s=new Blob([i],{type:"octet/stream"}),a=URL.createObjectURL(s);r.href=a;let x=new MouseEvent("click");r.dispatchEvent(x)}}};G.ac=new Map,G.cc=new Map,G.lc=new Map,G.uc=new Map,G.fc=new Set;var le={baseColorFactor:"/pbrMetallicRoughness/baseColorFactor",metallicFactor:"/pbrMetallicRoughness/metallicFactor",roughnessFactor:"/pbrMetallicRoughness/roughnessFactor",emissiveFactor:"/emissiveFactor",emissiveStrength:"/extensions/KHR_materials_emissive_strength/emissiveStrength",diffuseTransmissionFactor:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",diffuseTransmissionColorFactor:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",transmissionFactor:"/extensions/KHR_materials_transmission/transmissionFactor",thicknessFactor:"/extensions/KHR_materials_volume/thicknessFactor",attenuationDistance:"/extensions/KHR_materials_volume/attenuationDistance",attenuationColor:"/extensions/KHR_materials_volume/attenuationColor",dispersion:"/extensions/KHR_materials_dispersion/dispersion",ior:"/extensions/KHR_materials_ior/ior",iridescenceFactor:"/extensions/KHR_materials_iridescence/iridescenceFactor",iridescenceIor:"/extensions/KHR_materials_iridescence/iridescenceIor",iridescenceThicknessMinimum:"/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",iridescenceThicknessMaximum:"/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",clearcoatFactor:"/extensions/KHR_materials_clearcoat/clearcoatFactor",clearcoatRoughnessFactor:"/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",clearcoatNormalScale:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",clearcoatNormalTextureScale:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",sheenColorFactor:"/extensions/KHR_materials_sheen/sheenColorFactor",sheenRoughnessFactor:"/extensions/KHR_materials_sheen/sheenRoughnessFactor",specularFactor:"/extensions/KHR_materials_specular/specularFactor",specularColorFactor:"/extensions/KHR_materials_specular/specularColorFactor",anisotropyStrength:"/extensions/KHR_materials_anisotropy/anisotropyStrength",anisotropyRotation:"/extensions/KHR_materials_anisotropy/anisotropyRotation",normalScale:"/normalTexture/scale",occlusionStrength:"/occlusionTexture/strength"},ue={baseColorTexture:"/pbrMetallicRoughness/baseColorTexture",metallicRoughnessTexture:"/pbrMetallicRoughness/metallicRoughnessTexture",normalTexture:"/normalTexture",occlusionTexture:"/occlusionTexture",emissiveTexture:"/emissiveTexture",diffuseTransmissionTexture:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture",diffuseTransmissionColorTexture:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture",transmissionTexture:"/extensions/KHR_materials_transmission/transmissionTexture",thicknessTexture:"/extensions/KHR_materials_volume/thicknessTexture",clearcoatTexture:"/extensions/KHR_materials_clearcoat/clearcoatTexture",clearcoatRoughnessTexture:"/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture",clearcoatNormalTexture:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture",sheenColorTexture:"/extensions/KHR_materials_sheen/sheenColorTexture",sheenRoughnessTexture:"/extensions/KHR_materials_sheen/sheenRoughnessTexture",specularTexture:"/extensions/KHR_materials_specular/specularTexture",specularColorTexture:"/extensions/KHR_materials_specular/specularColorTexture",iridescenceTexture:"/extensions/KHR_materials_iridescence/iridescenceTexture",iridescenceThicknessTexture:"/extensions/KHR_materials_iridescence/iridescenceThicknessTexture",anisotropyTexture:"/extensions/KHR_materials_anisotropy/anisotropyTexture"},fe={light_color:"/color",light_intensity:"/intensity",light_range:"/range",light_spot_innerConeAngle:"/spot/innerConeAngle",light_spot_outerConeAngle:"/spot/outerConeAngle"};export{Ae as GLTF2_EXPORT_DRACO,Ie as GLTF2_EXPORT_EMBEDDED,L as GLTF2_EXPORT_GLB,K as GLTF2_EXPORT_GLTF,we as GLTF2_EXPORT_NO_DOWNLOAD,G as Gltf2Exporter};
|
|
1
|
+
import{isSameGlTF2TextureSampler as M,TagKhrNodeVisibilityEnabled as B,TagKhrNodeVisibilityVisible as F}from"../../types/glTF2.js";import{VERSION as V}from"../../version.js";import{SceneGraphComponent as D}from"../components/SceneGraph/SceneGraphComponent.js";import{CameraType as w,LightType as H,TextureParameter as I}from"../definitions/index.js";import{MathUtil as S}from"../math/MathUtil.js";import{Quaternion as K}from"../math/Quaternion.js";import{DataUtil as O}from"../misc/DataUtil.js";import{Is as u}from"../misc/Is.js";import{Logger as N}from"../misc/Logger.js";import{createEffekseer as k}from"./Gltf2ExporterEffekseer.js";import{__createBufferViewsAndAccessorsOfAnimation as U,__createBufferViewsAndAccessorsOfMesh as z,__createBufferViewsAndAccessorsOfSkin as $,__deleteEmptyArrays as X,__outputBaseMaterialInfo as W,__outputKhrMaterialsAnisotropyInfo as q,__outputKhrMaterialsClearcoatInfo as Y,__outputKhrMaterialsDiffuseTransmissionInfo as J,__outputKhrMaterialsDispersionInfo as Q,__outputKhrMaterialsEmissiveStrengthInfo as Z,__outputKhrMaterialsIorInfo as j,__outputKhrMaterialsIridescenceInfo as ee,__outputKhrMaterialsSheenInfo as te,__outputKhrMaterialsSpecularInfo as ne,__outputKhrMaterialsTransmissionInfo as ie,__outputKhrMaterialsVolumeInfo as re,__pruneUnusedVertexAttributes as se,__removeUnusedAccessorsAndBufferViews as ae,generateGlbArrayBuffer as oe,handleTextureImage as P,isNumericArrayBufferView as v,isRuntimeOnlyAnimationPath as ce}from"./Gltf2ExporterOps.js";var C="glTF",L="glTF-Binary",Ae="glTF-Draco",Ie="glTF-Embedded",we="No-Download",G=class{constructor(){}static async export(t,e,n={entities:void 0,type:L}){let{collectedEntities:r,topLevelEntities:s}=this.hc(t,n);this.ic.clear(),this.sc.clear(),this.ac.clear(),this.oc.clear(),this.cc.clear();let{json:a,fileName:x}=this.pc(e);this.gc(a,r),this.dc(a,r,s),await this.yc(a,r,n),await this._c(a,n),this.Tc(a,r),k(a,r),ae(a);let l=this.bc(a);X(a);let c=oe(a,l);return n.type===L?this.Rc(a,x,c):n.type===C&&this.Ec(a,x,l),c}static hc(t,e){let n=l=>{if(u.exist(e)&&u.exist(e.excludeTags)){for(let c of e.excludeTags)if(l.matchTag(c.tag,c.value))return!1;if(l.matchTag("Being","gizmo"))return!0}return!0},r=l=>{if(u.exist(e)&&u.exist(e.excludeTags)){for(let c of e.excludeTags)if(l.matchTag(c.tag,c.value))return[]}return[l]},s=(l,c)=>{let f=l.getSceneGraph();if(f.children.length>0){let i=c?[]:r(l);for(let m=0;m<f.children.length;m++){let o=f.children[m];Array.prototype.push.apply(i,s(o.entity,!1))}return i}return c?[]:r(l)};if(u.exist(e)&&u.exist(e.entities)&&e.entities.length>0){let l=e.entities.flatMap(i=>s(i,!0)),c=[];e.entities.forEach(i=>{l.indexOf(i)===-1&&n(i)&&c.push(i)});let f=e.entities.concat();return Array.prototype.push.apply(f,l),f=[...new Set(f)],c.length===0&&(c=f),{collectedEntities:f,topLevelEntities:c}}let a=t.entityRepository._getEntities();a=a.filter(l=>n(l));let x=D.getTopLevelComponents().flatMap(l=>l.entity);return x=x.filter(l=>n(l)),a=a.flatMap(l=>s(l,!0)),Array.prototype.push.apply(a,x),a=[...new Set(a)],{collectedEntities:a,topLevelEntities:x}}static pc(t){let e=t||`Rhodonite_${Date.now()}`;return{json:{asset:{version:"2.0",generator:`Rhodonite (${V.version})`},buffers:[{uri:`${e}.bin`,byteLength:0}],bufferViews:[],accessors:[],animations:[],meshes:[],skins:[],materials:[],textures:[],images:[],extensionsUsed:[],extensions:{},extras:{rnSkins:[],bufferViewByteLengthAccumulatedArray:[]},cameras:[],samplers:[]},fileName:e}}static gc(t,e){let n=[],r=[],s=[];z(t,e,n,r,s),$(t,e,n,r,s)}static Tc(t,e){U(t,e,{resolveAnimationTarget:({channel:r,trackName:s})=>this.Ac(t,r,s)})}static dc(t,e,n){t.nodes=[],t.scenes=[{nodes:[]}];let r=t.scenes[0],s=new Set,a=new Array(e.length),x=[];for(let c=0;c<e.length;c++){let f=e[c];f.gltfNodeIndex=c}let l=0;for(let c=0;c<e.length;c++){let f=e[c];t.nodes[c]={};let i=t.nodes[c];i.name=f.uniqueName;let m=f.getSceneGraph(),o=m.children;if(o.length>0){i.children=[];for(let T=0;T<o.length;T++){let E=o[T];if(u.exist(E.entity.gltfNodeIndex)){let A=E.entity.gltfNodeIndex;i.children.push(A),a[A]=c}}i.children.length===0&&(i.children=void 0)}m.isBillboard&&(i.extensions={RHODONITE_billboard:{isBillboard:!0}},t.extensionsUsed.indexOf("RHODONITE_billboard")===-1&&t.extensionsUsed.push("RHODONITE_billboard"));let g=f.getTagValue(F);f.getTagValue(B)===!0&&typeof g=="boolean"&&(u.not.exist(i.extensions)&&(i.extensions={}),i.extensions.KHR_node_visibility={visible:g},this.nc(t,"KHR_node_visibility"));let h=f.getTransform(),d=K.normalize(h.localRotationInner),p=[d.x,d.y,d.z,d.w];i.rotation=p.map(T=>Math.min(1,Math.max(-1,T))),i.scale=[h.localScaleInner.x,h.localScaleInner.y,h.localScaleInner.z],i.translation=[h.localPositionInner.x,h.localPositionInner.y,h.localPositionInner.z];let b=f.tryToGetMesh();u.exist(b)&&u.exist(b.mesh)&&(i.mesh=l++);let y=f.tryToGetBlendShape();if(u.exist(y)){let T=y.weights;T.length>0&&(i.weights=T)}let R=f.tryToGetSkeletal();if(u.exist(R)){let T=t.extras.rnSkins.indexOf(R.entity);T>=0&&(i.skin=T,u.exist(i.mesh)&&x.push(c))}let _=f.tryToGetCamera();if(u.exist(_)){let T;if(_.type===w.Perspective){let E=_.getTagValue("OriginalAspect"),A=_.getTagValue("OriginalFovY");T={name:_.entity.uniqueName,type:"perspective",perspective:{aspectRatio:u.exist(E)?E:_.aspect,yfov:u.exist(A)?S.degreeToRadian(A):S.degreeToRadian(_.fovy),znear:_.zNear,zfar:_.zFar}}}else if(_.type===w.Orthographic){let E=_.getTagValue("OriginalXMag"),A=_.getTagValue("OriginalYMag");T={name:_.entity.uniqueName,type:"orthographic",orthographic:{xmag:u.exist(E)?E:_.xMag,ymag:u.exist(A)?A:_.yMag,znear:_.zNear,zfar:_.zFar}}}t.cameras.push(T),i.camera=t.cameras.length-1,this.ac.set(_,i.camera)}this.Ic(t,f,i),this.wc(t,f,i)}for(let c of x){let f=t.nodes[c],i=a[c];if(u.exist(i)){let p=t.nodes[i];u.exist(p.children)&&(p.children=p.children.filter(b=>b!==c),p.children.length===0&&(p.children=void 0)),a[c]=void 0}let o=e[c].getSceneGraph().matrixInner,g=o.getTranslate(),h=o.getScale(),d=K.normalize(K.fromMatrix(o));f.translation=[g.x,g.y,g.z],f.rotation=[Math.min(1,Math.max(-1,d.x)),Math.min(1,Math.max(-1,d.y)),Math.min(1,Math.max(-1,d.z)),Math.min(1,Math.max(-1,d.w))],f.scale=[h.x,h.y,h.z],s.has(c)||(r.nodes.push(c),s.add(c))}n.forEach(c=>{let f=e.indexOf(c);f>=0&&!s.has(f)&&(r.nodes.push(f),s.add(f))})}static Ic(t,e,n){var o,g;let r=(o=e.tryToGetLight)==null?void 0:o.call(e);if(u.not.exist(r)||r.enable!==!0)return;if(r.type===H.Ambient){this.Gc(r,n);return}let s;if(r.type===H.Point?s="point":r.type===H.Directional?s="directional":r.type===H.Spot&&(s="spot"),u.not.exist(s))return;let a=r.color,x=[Number.isFinite(a.x)?a.x:1,Number.isFinite(a.y)?a.y:1,Number.isFinite(a.z)?a.z:1],l={type:s,color:x};u.exist(e.uniqueName)&&e.uniqueName.length>0&&(l.name=e.uniqueName);let c=r.intensity;if(Number.isFinite(c)&&(l.intensity=c),s!=="directional"){let h=r.range;Number.isFinite(h)&&h>0&&(l.range=h)}if(s==="spot"){let h=Number.isFinite(r.outerConeAngle)?r.outerConeAngle:Math.PI/4,d=Number.isFinite(r.innerConeAngle)?r.innerConeAngle:0,p=Math.max(0,Math.min(h,Math.PI/2)),b=Math.max(0,Math.min(d,p));l.spot={innerConeAngle:b,outerConeAngle:p}}let f={castShadow:r.castShadow,pointLightShadowFarPlane:r.pointLightShadowFarPlane};r.isShadowZNearForSpotLightAuto||(f.shadowZNearForSpotLight=r.shadowZNearForSpotLight),l.extras={...(g=l.extras)!=null?g:{},rhodonite:f};let i=this.vc(t),m=i.lights.length;i.lights.push(l),this.sc.set(r,m),this.nc(t,"KHR_lights_punctual"),u.not.exist(n.extensions)&&(n.extensions={}),n.extensions.KHR_lights_punctual={light:m}}static Gc(t,e){var x,l;let n=t.color,r={color:[Number.isFinite(n.x)?n.x:1,Number.isFinite(n.y)?n.y:1,Number.isFinite(n.z)?n.z:1],intensity:Number.isFinite(t.intensity)?t.intensity:1},s=(x=e.extras)!=null?x:{},a=(l=s.rhodonite)!=null?l:{};e.extras={...s,rhodonite:{...a,ambientLight:r}}}static vc(t){u.not.exist(t.extensions)&&(t.extensions={});let e=t.extensions;return u.not.exist(e.KHR_lights_punctual)&&(e.KHR_lights_punctual={lights:[]}),e.KHR_lights_punctual}static wc(t,e,n){var s,a;let r=(s=e.tryToGetRaymarching)==null?void 0:s.call(e);u.not.exist(r)||(u.not.exist(n.extensions)&&(n.extensions={}),n.extensions.RHODONITE_raymarching={graph:(a=r.rrnJson)!=null?a:null,sdfShapeType:r.sdfShapeType.index,isPickable:r.isPickable,castShadow:r.castShadow},this.nc(t,"RHODONITE_raymarching"))}static nc(t,e){t.extensionsUsed.indexOf(e)===-1&&t.extensionsUsed.push(e)}static lc(t,e){if(u.not.exist(t))return;let n=this.ic.get(t);u.not.exist(n)&&(n=[],this.ic.set(t,n)),n.push(e)}static rc(t,e){let n=this.oc.get(t);return u.not.exist(n)&&(n=new Set,this.oc.set(t,n)),n.has(e)?!1:(n.add(e),!0)}static Ac(t,e,n){let r=e.target.pathName;if(typeof r=="string"){if(ce(r))return null;if(r.startsWith("material/")){let s=r.substring(9);return this.Oc(t,e,s,n)}if(r.startsWith("light_"))return this.Hc(t,e,r,n);if(r.startsWith("camera_"))return this.Kc(t,e,r,n);if(r==="visibility")return this.Cc(t,e,n)}}static Cc(t,e,n){var l;let r=e.target.entity.gltfNodeIndex;if(u.not.exist(r))return null;let s=(l=t.nodes)==null?void 0:l[r];if(u.not.exist(s))return null;let a=e.target.entity.getTagValue(F);u.not.exist(s.extensions)&&(s.extensions={}),s.extensions.KHR_node_visibility={visible:typeof a=="boolean"?a:e.target.entity.getSceneGraph().isVisible};let x=`/nodes/${r}/extensions/KHR_node_visibility/visible`;return this.rc(n,x)?(this.nc(t,"KHR_animation_pointer"),this.nc(t,"KHR_node_visibility"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:x}}}):null}static Oc(t,e,n,r){let s=this.Mc(n,e.animatedValue);if(s.length===0)return this.uc(n,!0),null;let a=this.Fc(n);if(u.not.exist(a))return this.uc(n,!1),null;this.nc(t,"KHR_animation_pointer");let x=[];for(let l of s){let c=`/materials/${l}${a}`;this.rc(r,c)&&x.push({path:"pointer",extensions:{KHR_animation_pointer:{pointer:c}}})}return x.length>0?x:null}static Mc(t,e){let n=[];for(let[r,s]of this.ic.entries())r.getParameter(t)===e&&n.push(...s);return Array.from(new Set(n))}static Hc(t,e,n,r){var c,f;let s=(f=(c=e.target.entity).tryToGetLight)==null?void 0:f.call(c);if(u.not.exist(s))return null;let a=this.sc.get(s);if(u.not.exist(a))return null;let x=fe[n];if(u.not.exist(x))return null;let l=`/extensions/KHR_lights_punctual/lights/${a}${x}`;return this.rc(r,l)?(this.nc(t,"KHR_animation_pointer"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:l}}}):null}static Kc(t,e,n,r){var c,f;let s=(f=(c=e.target.entity).tryToGetCamera)==null?void 0:f.call(c);if(u.not.exist(s))return null;let a=this.ac.get(s);if(u.not.exist(a))return null;let x=this.Sc(n,s);if(u.not.exist(x))return null;let l=`/cameras/${a}${x}`;return this.rc(r,l)?(this.nc(t,"KHR_animation_pointer"),{path:"pointer",extensions:{KHR_animation_pointer:{pointer:l}}}):null}static Fc(t){let e=le[t];if(u.exist(e))return e;let n=t.match(/^(.*)Transform(Offset|Scale|Rotation)$/);if(n){let r=n[1],s=n[2],a=ue[r];if(u.not.exist(a))return;let x=s.toLowerCase();return`${a}/extensions/KHR_texture_transform/${x}`}}static uc(t,e){this.cc.has(t)||(this.cc.add(t),e?N.default.warn(`KHR_animation_pointer: No material parameter found for semantic "${t}".`):N.default.warn(`KHR_animation_pointer: Unsupported material semantic "${t}". Animation skipped.`))}static Sc(t,e){let n=e.type;switch(t){case"camera_znear":return n===w.Perspective?"/perspective/znear":"/orthographic/znear";case"camera_zfar":return n===w.Perspective?"/perspective/zfar":"/orthographic/zfar";case"camera_fovy":return n===w.Perspective?"/perspective/yfov":void 0;case"camera_xmag":return n===w.Orthographic?"/orthographic/xmag":void 0;case"camera_ymag":return n===w.Orthographic?"/orthographic/ymag":void 0;default:return}}static async yc(t,e,n){let r=0,s=[],a=new Map;t.extras.bufferViewByteLengthAccumulatedArray.push(0);let x=t.extras.bufferViewByteLengthAccumulatedArray.length-1;for(let l=0;l<e.length;l++){let f=e[l].tryToGetMesh();if(f!=null&&f.mesh){let i=t.meshes[r++];await this.Nc(t,f.mesh,i,s,x,n,a)}}return Promise.all(s)}static async Nc(t,e,n,r,s,a,x){let l=e.getPrimitiveNumber();for(let c=0;c<l;c++){let f=e.getPrimitiveAt(c),i=n.primitives[c],m=f.material,o=await this.fc(t,m,r,s,a),g=t.materials.length;t.materials.push(o),i.material=g,this.lc(m,g),se(i,o),await this.Pc(t,f,i,r,s,a,x,g)}}static async Pc(t,e,n,r,s,a,x,l){var m;let c=e.getVariantNames();if(c.length===0)return;let f=[];for(let o of c){if(u.not.exist(o)||o.length===0)continue;let g=e.getVariantMaterial(o);if(g==null)continue;let h=l;if(g!==e.material){let p=await this.fc(t,g,r,s,a);h=t.materials.length,t.materials.push(p),this.lc(g,h)}let d=this.Lc(t,o,x);f.push({material:h,variants:[d]})}if(f.length===0)return;n.extensions=(m=n.extensions)!=null?m:{};let i=n.extensions;u.exist(i.KHR_materials_variants)?i.KHR_materials_variants.mappings.push(...f):i.KHR_materials_variants={mappings:f},this.nc(t,"KHR_materials_variants")}static Lc(t,e,n){let r=n.get(e);if(r!==void 0)return r;let s=this.Bc(t);return r=s.variants.length,s.variants.push({name:e}),n.set(e,r),r}static Bc(t){u.not.exist(t.extensions)&&(t.extensions={});let e=t.extensions;return u.not.exist(e.KHR_materials_variants)&&(e.KHR_materials_variants={variants:[]}),e.KHR_materials_variants}static async fc(t,e,n,r,s){let a={pbrMetallicRoughness:{metallicFactor:1,roughnessFactor:1}};return u.exist(e)&&(e.isNodeBasedMaterial&&e.shaderNodeJson!=null?await this.Vc(a,e,t,n,r,s):await this.Dc(a,e,t,n,r,s)),a}static async Vc(t,e,n,r,s,a){var i;let x="RHODONITE_materials_node";t.extensions||(t.extensions={});let c={uri:`./${(i=e.shaderNodeFileName)!=null?i:`${e.materialTypeName}_${e.materialUID}.rmn`}`};e.shaderNodeUniforms!=null&&(c.uniforms={...e.shaderNodeUniforms});let f=await this.mc(e,n,r,s,a);Object.keys(f).length>0&&(c.uniforms||(c.uniforms={}),Object.assign(c.uniforms,f)),t.extensions[x]=c,this.nc(n,x)}static async mc(t,e,n,r,s,a=()=>!0){let x={},l=[],c=o=>{let g={magFilter:o!=null?o.magFilter.index:I.Linear.index,minFilter:o!=null?o.minFilter.index:I.Linear.index,wrapS:o!=null?o.wrapS.index:I.TextureWrapS.index,wrapT:o!=null?o.wrapT.index:I.TextureWrapT.index},h=e.samplers.findIndex(d=>M(g,d));return h===-1&&(e.samplers.push(g),h=e.samplers.length-1),h},f=o=>{var d;let g=e.images.length,h=!1;for(let p=0;p<e.images.length;p++){let y=(d=e.images[p].extras)==null?void 0:d.rnTextureUID;u.exist(y)&&y===o.textureUID&&(g=p,h=!0)}if(!h){let p={uri:o.name,name:o.name||void 0,extras:{rnTextureUID:o.textureUID}};l.indexOf(o.name)!==-1&&(p.uri+=`_${o.textureUID}`),l.push(p.uri),u.not.exist(p.uri.match(/\.(png)/))&&(p.uri+=".png");let b=o.htmlCanvasElement;if(b){let y=new Promise((R,_)=>{b.toBlob(T=>{if(u.exist(T))P(e,r,T,s,p,R,_,C);else throw Error("canvas to blob error!")})});n.push(y)}e.images.push(p)}return g},i=(o,g)=>{if(!o||!o.isTextureReady||o.isDummyTexture||o.width<1||o.height<1)return;let h=c(g),d=f(o),p={sampler:h,source:d},b=e.textures.findIndex(y=>y.sampler===p.sampler&&y.source===p.source);return b===-1&&(e.textures.push(p),b=e.textures.length-1),b},m=t.fieldsInfoArray;for(let o of m){let g=o.compositionType;if(a(o.semantic)&&(g.index===7||g.index===8||g.index===16||g.index===17||g.index===18)){let h=t.getTextureParameter(o.semantic);if(h&&Array.isArray(h)&&h.length>=2){let d=h[1],p=h[2];if(d&&!d.isDummyTexture){let b=i(d,p);b!=null&&(x[o.semantic]={index:b})}}}}return x}static async _c(t,e){let n=e.raymarchingComponentMaterials;if(n!=null&&n.length>0){await this.kc(t,n,e);return}let r=e.raymarchingMaterial;if(r==null)return;let s=await this.xc(t,r,e);s!=null&&(u.not.exist(t.extensions)&&(t.extensions={}),t.extensions.RHODONITE_raymarching_materials={textures:s},this.nc(t,"RHODONITE_raymarching_materials"))}static async kc(t,e,n){var r;for(let{entity:s,material:a}of e){let x=s.gltfNodeIndex;if(x==null)continue;let l=(r=t.nodes)==null?void 0:r[x];if(l==null)continue;let c=await this.xc(t,a,n);if(c==null)continue;u.not.exist(l.extensions)&&(l.extensions={});let f=l.extensions,i=f.RHODONITE_raymarching;i==null&&(i={},f.RHODONITE_raymarching=i),i.textures=c,this.nc(t,"RHODONITE_raymarching")}}static async xc(t,e,n){var c,f,i;let r=e.shaderNodeJson,s=new Set;for(let m of(c=r==null?void 0:r.nodes)!=null?c:[])if(m.name==="Texture2D"){let o=(i=(f=m.controls)==null?void 0:f.name)==null?void 0:i.value;typeof o=="string"&&o.length>0&&s.add(o)}if(s.size===0)return;let a=[];t.extras.bufferViewByteLengthAccumulatedArray.push(0);let x=t.extras.bufferViewByteLengthAccumulatedArray.length-1,l=await this.mc(e,t,a,x,n,m=>s.has(m));return await Promise.all(a),Object.keys(l).length>0?l:void 0}static async Dc(t,e,n,r,s,a){let x=[],l=i=>{let m={magFilter:i!=null?i.magFilter.index:I.Linear.index,minFilter:i!=null?i.minFilter.index:I.Linear.index,wrapS:i!=null?i.wrapS.index:I.TextureWrapS.index,wrapT:i!=null?i.wrapT.index:I.TextureWrapT.index},o=n.samplers.findIndex(g=>M(m,g));return o===-1&&(n.samplers.push(m),o=n.samplers.length-1),o},c=i=>{var g;let m=n.images.length,o=!1;for(let h=0;h<n.images.length;h++){let p=(g=n.images[h].extras)==null?void 0:g.rnTextureUID;u.exist(p)&&p===i.textureUID&&(m=h,o=!0)}if(!o){let h={uri:i.name,name:i.name||void 0,extras:{rnTextureUID:i.textureUID}};x.indexOf(i.name)!==-1&&(h.uri+=`_${i.textureUID}`),x.push(h.uri),u.not.exist(h.uri.match(/\.(png)/))&&(h.uri+=".png");let d=i.htmlCanvasElement;if(d){let p=new Promise((b,y)=>{d.toBlob(R=>{if(u.exist(R))P(n,s,R,a,h,b,y,C);else throw Error("canvas to blob error!")})});r.push(p)}n.images.push(h)}return m},f=(i,m)=>{let o=i;if(!o||!o.isTextureReady||o.isDummyTexture||o.width<1||o.height<1)return;let g=l(m),h=c(o),d={sampler:g,source:h};return n.textures.indexOf(d)===-1&&n.textures.push(d),n.textures.indexOf(d)};this.Uc(n,t,e,f)}static Uc(t,e,n,r){let s=i=>{t.extensionsUsed.indexOf(i)===-1&&t.extensionsUsed.push(i)},a=i=>{if(!u.not.exist(i)){if(typeof i=="number")return i;if(Array.isArray(i))return i.length>0?i[0]:void 0;if(typeof i=="object"){if(typeof i.x=="number"&&typeof i.y=="undefined")return i.x;if(ArrayBuffer.isView(i)){let o=i;if(v(o)&&o.length>0)return o[0]}let m=i._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>0)return o[0]}if(Array.isArray(m))return m.length>0?m[0]:void 0}}},x=i=>{if(!u.not.exist(i)){if(Array.isArray(i)){if(i.length>=2)return[i[0],i[1]];if(i.length===1)return[i[0],i[0]]}if(typeof i=="object"){if(typeof i.x=="number"&&typeof i.y=="number")return[i.x,i.y];let m=i._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>=2)return[o[0],o[1]]}if(Array.isArray(m)&&m.length>=2)return[m[0],m[1]];if(ArrayBuffer.isView(i)){let o=i;if(v(o)&&o.length>=2)return[o[0],o[1]]}}}},l=i=>{if(!u.not.exist(i)){if(Array.isArray(i)){if(i.length>=3)return[i[0],i[1],i[2]];if(i.length===2)return[i[0],i[1],i[1]];if(i.length===1)return[i[0],i[0],i[0]]}if(typeof i=="object"){if(typeof i.x=="number"&&typeof i.y=="number"&&typeof i.z=="number")return[i.x,i.y,i.z];let m=i._v;if(ArrayBuffer.isView(m)){let o=m;if(v(o)&&o.length>=3)return[o[0],o[1],o[2]]}if(Array.isArray(m)&&m.length>=3)return[m[0],m[1],m[2]];if(ArrayBuffer.isView(i)){let o=i;if(v(o)&&o.length>=3)return[o[0],o[1],o[2]]}}}},c=(i,m)=>{var b;let o=n.getTextureParameter(i);if(u.not.exist(o))return;let g=o[1],h=o[2],d=r(g,h);if(d==null)return;let p={index:d};if(u.exist(m.texCoordParam)){let y=a(n.getParameter(m.texCoordParam));u.exist(y)&&(p.texCoord=y)}if(u.exist(m.scaleParam)){let y=a(n.getParameter(m.scaleParam));u.exist(y)&&(p.scale=y)}if(u.exist(m.strengthParam)){let y=a(n.getParameter(m.strengthParam));u.exist(y)&&(p.strength=y)}if(u.exist(m.transform)){let y=u.exist(m.transform.scale)?x(n.getParameter(m.transform.scale)):void 0,R=u.exist(m.transform.offset)?x(n.getParameter(m.transform.offset)):void 0,_=u.exist(m.transform.rotation)?a(n.getParameter(m.transform.rotation)):void 0;if(u.exist(y)||u.exist(R)||u.exist(_)){let T={};u.exist(y)&&(T.scale=y),u.exist(R)&&(T.offset=R),u.exist(_)&&(T.rotation=_),Object.keys(T).length>0&&(p.extensions=(b=p.extensions)!=null?b:{},p.extensions.KHR_texture_transform=T,s("KHR_texture_transform"))}}m.onAssign(p)},f=u.false(n.isLighting);W(n,c,e,t,{skipAdditionalTextures:f}),!f&&(Z(s,a,n,e),J(s,a,l,n,c,e),ie(s,a,n,c,e),re(s,a,l,n,c,e),Q(s,a,n,e),j(s,a,n,e),ee(s,a,n,c,e),Y(s,a,n,c,e),te(s,a,l,n,c,e),ne(s,a,l,n,c,e),q(s,a,x,n,c,e))}static bc(t){if(u.undefined(t.accessors)||u.undefined(t.bufferViews))return new ArrayBuffer(0);let e=t.bufferViews.reduce((s,a)=>{var l;let x=(l=a.extras)==null?void 0:l.uint8Array;return u.not.exist(x)?s+O.addPaddingBytes(a.byteLength,4):s+O.addPaddingBytes(x.byteLength,4)},0);if(e>0){let s=t.buffers[0];s.byteLength=e+O.calcPaddingBytes(e,4)}let n=new ArrayBuffer(t.buffers[0].byteLength),r=0;for(let s=0;s<t.bufferViews.length;s++){let a=t.bufferViews[s],x=a.extras.uint8Array;a.extras=void 0;let l=r;O.copyArrayBufferWithPadding({src:x.buffer,dist:n,srcByteOffset:x.byteOffset,copyByteLength:x.byteLength,distByteOffset:l}),r+=O.addPaddingBytes(x.byteLength,4),a.byteOffset=l,a.buffer=0}return n}static Rc(t,e,n){{let r=document.createElement("a");r.download=`${e}.glb`;let s=new Blob([n],{type:"octet/stream"}),a=URL.createObjectURL(s);r.href=a;let x=new MouseEvent("click");r.dispatchEvent(x)}}exportGlbAsArrayBuffer(){}static Ec(t,e,n){{let r=document.createElement("a");r.download=`${e}.gltf`;let s=JSON.stringify(t,null,2);r.href=`data:application/octet-stream,${encodeURIComponent(s)}`;let a=new MouseEvent("click");r.dispatchEvent(a)}{let r=document.createElement("a");r.download=`${e}.bin`;let s=new Blob([n],{type:"octet/stream"}),a=URL.createObjectURL(s);r.href=a;let x=new MouseEvent("click");r.dispatchEvent(x)}}};G.ic=new Map,G.sc=new Map,G.ac=new Map,G.oc=new Map,G.cc=new Set;var le={baseColorFactor:"/pbrMetallicRoughness/baseColorFactor",metallicFactor:"/pbrMetallicRoughness/metallicFactor",roughnessFactor:"/pbrMetallicRoughness/roughnessFactor",emissiveFactor:"/emissiveFactor",emissiveStrength:"/extensions/KHR_materials_emissive_strength/emissiveStrength",diffuseTransmissionFactor:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",diffuseTransmissionColorFactor:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",transmissionFactor:"/extensions/KHR_materials_transmission/transmissionFactor",thicknessFactor:"/extensions/KHR_materials_volume/thicknessFactor",attenuationDistance:"/extensions/KHR_materials_volume/attenuationDistance",attenuationColor:"/extensions/KHR_materials_volume/attenuationColor",dispersion:"/extensions/KHR_materials_dispersion/dispersion",ior:"/extensions/KHR_materials_ior/ior",iridescenceFactor:"/extensions/KHR_materials_iridescence/iridescenceFactor",iridescenceIor:"/extensions/KHR_materials_iridescence/iridescenceIor",iridescenceThicknessMinimum:"/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",iridescenceThicknessMaximum:"/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",clearcoatFactor:"/extensions/KHR_materials_clearcoat/clearcoatFactor",clearcoatRoughnessFactor:"/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",clearcoatNormalScale:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",clearcoatNormalTextureScale:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",sheenColorFactor:"/extensions/KHR_materials_sheen/sheenColorFactor",sheenRoughnessFactor:"/extensions/KHR_materials_sheen/sheenRoughnessFactor",specularFactor:"/extensions/KHR_materials_specular/specularFactor",specularColorFactor:"/extensions/KHR_materials_specular/specularColorFactor",anisotropyStrength:"/extensions/KHR_materials_anisotropy/anisotropyStrength",anisotropyRotation:"/extensions/KHR_materials_anisotropy/anisotropyRotation",normalScale:"/normalTexture/scale",occlusionStrength:"/occlusionTexture/strength"},ue={baseColorTexture:"/pbrMetallicRoughness/baseColorTexture",metallicRoughnessTexture:"/pbrMetallicRoughness/metallicRoughnessTexture",normalTexture:"/normalTexture",occlusionTexture:"/occlusionTexture",emissiveTexture:"/emissiveTexture",diffuseTransmissionTexture:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture",diffuseTransmissionColorTexture:"/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture",transmissionTexture:"/extensions/KHR_materials_transmission/transmissionTexture",thicknessTexture:"/extensions/KHR_materials_volume/thicknessTexture",clearcoatTexture:"/extensions/KHR_materials_clearcoat/clearcoatTexture",clearcoatRoughnessTexture:"/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture",clearcoatNormalTexture:"/extensions/KHR_materials_clearcoat/clearcoatNormalTexture",sheenColorTexture:"/extensions/KHR_materials_sheen/sheenColorTexture",sheenRoughnessTexture:"/extensions/KHR_materials_sheen/sheenRoughnessTexture",specularTexture:"/extensions/KHR_materials_specular/specularTexture",specularColorTexture:"/extensions/KHR_materials_specular/specularColorTexture",iridescenceTexture:"/extensions/KHR_materials_iridescence/iridescenceTexture",iridescenceThicknessTexture:"/extensions/KHR_materials_iridescence/iridescenceThicknessTexture",anisotropyTexture:"/extensions/KHR_materials_anisotropy/anisotropyTexture"},fe={light_color:"/color",light_intensity:"/intensity",light_range:"/range",light_spot_innerConeAngle:"/spot/innerConeAngle",light_spot_outerConeAngle:"/spot/outerConeAngle"};export{Ae as GLTF2_EXPORT_DRACO,Ie as GLTF2_EXPORT_EMBEDDED,L as GLTF2_EXPORT_GLB,C as GLTF2_EXPORT_GLTF,we as GLTF2_EXPORT_NO_DOWNLOAD,G as Gltf2Exporter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Matrix44 as c}from"../math/Matrix44.js";import{MutableMatrix44 as l}from"../math/MutableMatrix44.js";import{MutableVector4 as t}from"../math/MutableVector4.js";import{Vector4 as o}from"../math/Vector4.js";var N=class{constructor(){this.top=t.zero();this.bottom=t.zero();this.right=t.zero();this.left=t.zero();this.zNear=t.zero();this.zFar=t.zero();this.X=!1;this.
|
|
1
|
+
import{Matrix44 as c}from"../math/Matrix44.js";import{MutableMatrix44 as l}from"../math/MutableMatrix44.js";import{MutableVector4 as t}from"../math/MutableVector4.js";import{Vector4 as o}from"../math/Vector4.js";var N=class{constructor(){this.top=t.zero();this.bottom=t.zero();this.right=t.zero();this.left=t.zero();this.zNear=t.zero();this.zFar=t.zero();this.X=!1;this.ih=l.zero();this.hh=l.zero();this.rh=l.zero();this.sh=t.zero();this.oh=t.zero();this.mh=[t.zero(),t.zero(),t.zero(),t.zero(),t.zero(),t.zero(),t.zero(),t.zero()];this.nh=[o.fromCopy4(-1,1,1,1),o.fromCopy4(1,1,1,1),o.fromCopy4(1,-1,1,1),o.fromCopy4(-1,-1,1,1),o.fromCopy4(-1,1,-1,1),o.fromCopy4(1,1,-1,1),o.fromCopy4(1,-1,-1,1),o.fromCopy4(-1,-1,-1,1)];this.corners=[]}update(e,r){c.multiplyTo(r,e,this.ih),this.zNear.x=this.ih.m20+this.ih.m30,this.zNear.y=this.ih.m21+this.ih.m31,this.zNear.z=this.ih.m22+this.ih.m32,this.zNear.w=this.ih.m23+this.ih.m33,this.zFar.x=-this.ih.m20+this.ih.m30,this.zFar.y=-this.ih.m21+this.ih.m31,this.zFar.z=-this.ih.m22+this.ih.m32,this.zFar.w=-this.ih.m23+this.ih.m33,this.bottom.x=this.ih.m10+this.ih.m30,this.bottom.y=this.ih.m11+this.ih.m31,this.bottom.z=this.ih.m12+this.ih.m32,this.bottom.w=this.ih.m13+this.ih.m33,this.top.x=-this.ih.m10+this.ih.m30,this.top.y=-this.ih.m11+this.ih.m31,this.top.z=-this.ih.m12+this.ih.m32,this.top.w=-this.ih.m13+this.ih.m33,this.left.x=this.ih.m00+this.ih.m30,this.left.y=this.ih.m01+this.ih.m31,this.left.z=this.ih.m02+this.ih.m32,this.left.w=this.ih.m03+this.ih.m33,this.right.x=-this.ih.m00+this.ih.m30,this.right.y=-this.ih.m01+this.ih.m31,this.right.z=-this.ih.m02+this.ih.m32,this.right.w=-this.ih.m03+this.ih.m33,c.invertTo(r,this.hh),c.invertTo(e,this.rh);for(let i=0;i<8;i++)this.hh.multiplyVectorTo(this.nh[i],this.sh),this.oh.x=this.sh.x/this.sh.w,this.oh.y=this.sh.y/this.sh.w,this.oh.z=this.sh.z/this.sh.w,this.oh.w=1,this.rh.multiplyVectorTo(this.oh,this.mh[i]),this.corners[i]=this.mh[i]}culling(e){let r=e.entity.getSceneGraph().worldMergedAABBWithSkeletal,i=r.minPoint._v,p=r.maxPoint._v,z=i[0],f=i[1],u=i[2],y=p[0],x=p[1],b=p[2];for(let h=0;h<6;h++){let s=this.getPlane(h)._v,m=s[0],n=s[1],a=s[2],F=m>=0?y:z,V=n>=0?x:f,P=a>=0?b:u;if(m*F+n*V+a*P+s[3]<0)return!1}let T=this.corners,M=0,v=0,w=0,C=0,g=0,d=0;for(let h=0;h<8;h++){let s=T[h]._v,m=s[0],n=s[1],a=s[2];v+=m>y?1:0,M+=m<z?1:0,C+=n>x?1:0,w+=n<f?1:0,d+=a>b?1:0,g+=a<u?1:0}return!(v===8||M===8||C===8||w===8||d===8||g===8)}getPlane(e){switch(e){case 0:return this.top;case 1:return this.bottom;case 2:return this.right;case 3:return this.left;case 4:return this.zNear;case 5:return this.zFar;default:throw new Error("Invalid plane index.")}}};export{N as Frustum};
|
|
@@ -60,6 +60,13 @@ export declare class Mesh implements IMesh {
|
|
|
60
60
|
private __latestPrimitivePositionAccessorVersionForAABB;
|
|
61
61
|
private __latestPrimitivePositionAccessorVersionForSetUpDone;
|
|
62
62
|
private __belongToEntities;
|
|
63
|
+
/**
|
|
64
|
+
* True when the set of entities that share this mesh changed. The variation data (the instance
|
|
65
|
+
* identities written to the VBO, or the instance SID table in multi-draw mode) then has to be
|
|
66
|
+
* rebuilt, otherwise a draw whose instance count follows `meshEntitiesInner` reads past the end
|
|
67
|
+
* of the buffer. `isSetUpDone` reports false until the next Load stage rebuilds it.
|
|
68
|
+
*/
|
|
69
|
+
private __isVariationDataDirty;
|
|
63
70
|
/**
|
|
64
71
|
* Specification of when calculate the tangent of a vertex to apply Normal texture (for pbr/MToon shader)
|
|
65
72
|
* 0: Not calculate tangent (not apply normal texture)
|
|
@@ -115,6 +122,14 @@ export declare class Mesh implements IMesh {
|
|
|
115
122
|
* @returns Array of mesh entities
|
|
116
123
|
*/
|
|
117
124
|
get meshEntitiesInner(): IMeshEntity[];
|
|
125
|
+
/**
|
|
126
|
+
* The number of instances whose identities are in the variation data (the instance data the GPU
|
|
127
|
+
* reads). A draw has to use this instead of `meshEntitiesInner.length`: an entity that joined
|
|
128
|
+
* the mesh after the last Load stage is not in the variation data yet, so drawing it would read
|
|
129
|
+
* past the end of the instance buffer.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
get _variationInstanceCount(): number;
|
|
118
133
|
/**
|
|
119
134
|
* Registers this mesh as belonging to a mesh component.
|
|
120
135
|
* @param meshComponent - The mesh component that owns this mesh
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{ProcessStage as z}from"../definitions/ProcessStage.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as O}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as H,isBlendWithZWrite as k,isOpaque as F,isTranslucent as E}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.Zc=[];this.Bu=[];this.Mu=[];this.Uu=[];this.Tu=[];this.ju=[];this.Pu=new G;this.Xc=[];this.vu=new Set;this.qc=v.InvalidCGAPIResourceUid;this.Ou=!1;this.xu=!1;this.Hu=!1;this.Nu=!1;this.ku=-1;this.Fu=-1;this.Eu=!1;this.du=0;this.gu=-1;this.Jc=-1;this.Ru=0;this.Lu=-1;this.Wu=0;this.Zu=0;this.Yc=[];this.tangentCalculationMode=1;this.Xu=!1;this.Qc=0;this.i=t,this.Gu=++c.qu}static get _primitivePositionUpdateVersion(){return c.Yu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.Zc.findIndex(e=>e.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Yc}_belongToMeshComponent(t){this.Yc.push(t.entity),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){let r=t.entity;this.Yc=this.Yc.filter(e=>e!==r),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),F(t)?this.Bu.push(t):E(t)?this.Mu.push(t):k(t)?this.Uu.push(t):H(t)&&this.Tu.push(t),this.hl(this.Bu.concat(this.Mu).concat(this.Uu).concat(this.Tu))}hl(t){this.Zc=t}isExistOpaque(){return this.Bu.length>0}isExistTranslucent(){return this.Mu.length>0}isExistBlendWithZWrite(){return this.Uu.length>0}isExistBlendWithoutZWrite(){return this.Tu.length>0}getPrimitiveAt(t){return this.Zc[t]}getPrimitiveNumber(){return this.Zc.length}hu(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Yc.length,r=this.i.webglResourceRepository.instanceSidTable,e=this.Jc;(e<0||this.Ru!==t)&&(e>=0&&r.free(e,this.Ru),e=r.allocate(t),this.Jc=e,this.Ru=t,r.writeIdentityRemap(e,t));let i=4294967295;for(let s=0;s<t;s++){let n=this.Yc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(e+s,a,o!=null?o.componentSID:i,u!=null?u.componentSID:i)}return e}get _instanceSidBase(){return this.Jc}get _remapPrepassId(){return this.Lu}set _remapPrepassId(t){this.Lu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.qc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.qc);let r=4294967295,e=this.Yc.length,i=new Uint32Array(e*4),s=new Int32Array(e),n=!1,a=!1;for(let o=0;o<e;o++){s[o]=this.Yc[o].entityUID,i[4*o+0]=this.Yc[o].getSceneGraph().componentSID;let u=this.Yc[o].tryToGetSkeletal();u!=null?i[4*o+1]=u.componentSID:i[4*o+1]=r;let f=this.Yc[o].tryToGetBlendShape();f!=null?i[4*o+2]=f.componentSID:i[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.Ou=e>0,this.xu=n,this.Hu=a,this.hu()?(this.qc=v.InvalidCGAPIResourceUid,this.Iu=i,this.Vu=s,this.Du=void 0,this.wu=void 0,this.du=e,this.yu=void 0,this.gu=-1,this._ensureInstanceSidBase(),!0):(this.qc=t.createVertexBufferFromTypedArray(i),this.Iu=i,this.Vu=s,this.Du=i.slice(),this.wu=new Uint32Array(i.length),this.du=e,this.yu=void 0,this.gu=-1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.hu())return this._packVisibleInstancesToInstanceRemap(t,r);let e=this.Iu,i=this.Vu,s=this.Du,n=this.wu;if(e===void 0||i===void 0||s===void 0||n===void 0||this.qc===v.InvalidCGAPIResourceUid)return this.Yc.length;if(t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let a=i.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=i[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=e[h+0],n[m+1]=e[h+1],n[m+2]=e[h+2],n[m+3]=e[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.qc,l),s.set(l)}return this.du=o,o}_packVisibleInstancesToInstanceRemap(t,r){let e=this.Vu;if(e===void 0)return this.Yc.length;if(this.Jc<0&&this._ensureInstanceSidBase(),t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let i=this.i.webglResourceRepository.instanceSidTable,s=this.Jc,n=e.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=e[o];if(u<t.length&&t[u]===r)continue}i.setRemap(s+a,o),a++}return this.du=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.qc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.qc),this.qc=v.InvalidCGAPIResourceUid,this.Iu=void 0,this.Vu=void 0,this.Du=void 0,this.wu=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let i=0;i<this.Zc.length;i++){let s=this.Zc[i],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[i]=n.vertexHandles.vaoHandle,this.vu.add(i);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[i])||this.Xc[i]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[i]=t.createVertexArray(),a.vaoHandle=this.Xc[i]),t.setVertexDataToPipeline(a,s,this.qc)}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=this.Zc.length;i<this.Xc.length;i++){let s=this.Xc[i];s&&!r.hasVaoHandle(s)&&(e.has(s)||(e.add(s),t.deleteVertexArray(s))),this.Xc[i]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.vu.clear();return}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=0;i<this.Xc.length;i++){let s=this.Xc[i];s&&!e.has(s)&&!r.hasVaoHandle(s)&&(e.add(s),t.deleteVertexArray(s)),this.Xc[i]=v.InvalidCGAPIResourceUid}this.vu.clear()}_clearMultiDrawVaoUids(){for(let t of this.vu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.vu.clear()}castRay(t,r,e=0){var o;let i,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.Zc){let f=u.castRay(t,r,!0,!0,e,this.Xu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,i=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(i)?{result:!0,data:{t:s,u:n,v:a,position:i}}:{result:!1}}get primitives(){return this.Zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.qc}get _variationEntityInfo(){return this.Iu}get _isGpuCullable(){return this.Ou?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.xu)return!0;if(!this.Hu)return!1;for(let t=0;t<this.Zc.length;t++)if(this.Zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.ku===this.Zc.length&&this.Fu===this.Qc&&this.Eu===this.xu?this.Nu:(this.ku=this.Zc.length,this.Fu=this.Qc,this.Eu=this.xu,this.Nu=this.fl(),this.Nu)}fl(){if(this.Zc.length===0)return!1;let t=(r,e)=>r.some(i=>i.split(".")[0]===e);for(let r of this.Zc){let e=r.attributeSemantics;if(!t(e,"POSITION")||this.xu&&(!t(e,"JOINTS_0")||!t(e,"WEIGHTS_0")))return!1;for(let i of r.targets){let s=!1;for(let n of i.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Qc++,c.Yu++;for(let t of this.Yc)t.getMeshRenderer().moveStageTo(z.Load)}get primitivePositionUpdateCount(){return this.Qc}get AABB(){if(this.Qc!==this.Wu&&(this.Pu.initialize(),this.Wu=this.Qc),this.Pu.isVanilla())for(let t of this.Zc)this.Pu.mergeAABB(t.AABB);return this.Pu}bl(){for(let t=0;t<this.Zc.length;t++){let r=this.ju[t],e=this.Zc[t];e.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,e.getAttribute(n))})}}_calcTangents(){if(this.pl())for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let e=t.attributeSemantics.indexOf(g.Texcoord0.XY),i=t.attributeSemantics.indexOf(g.Normal.XYZ);if(e!==-1&&i!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[e],o=t.attributeAccessors[i],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),S=n.getVec3(d+2,{indicesAccessor:u}),M=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),T=a.getVec2(d+2,{indicesAccessor:u}),N=o.getVec3(d,{indicesAccessor:u});this.dl(d,I,A,S,M,U,T,N,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}dl(t,r,e,i,s,n,a,o,u,f){let l=this.zu(r,e,i,s,n,a,o,c.cl),h=this.zu(e,i,r,n,a,s,o,c.ul),m=this.zu(i,r,e,a,s,n,o,c.ll);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}zu(t,r,e,i,s,n,a,o){let u=[c.Tt.setComponents(t.x,i.x,i.y),c.bt.setComponents(t.y,i.x,i.y),c.ve.setComponents(t.z,i.x,i.y)],f=[c.Ju.setComponents(r.x,s.x,s.y),c._u.setComponents(r.y,s.x,s.y),c.Ku.setComponents(r.z,s.x,s.y)],l=[c.Qu.setComponents(e.x,n.x,n.y),c.$u.setComponents(e.y,n.x,n.y),c.il.setComponents(e.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.rl),d=b.subtractTo(l[p],f[p],c.sl),I=b.crossTo(y,d,c.al),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),O.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}pl(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.Zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Xu=!0;let e=t.attributeSemantics.indexOf(g.Position.XYZ),i=t.attributeAccessors[e],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=i.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:i.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=i.getVec3(h,{indicesAccessor:s}),p=i.getVec3(h+1,{indicesAccessor:s}),y=i.getVec3(h+2,{indicesAccessor:s});this.ml(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}ml(t,r,e,i,s,n){let a=e.x-r.x,o=e.y-r.y,u=e.z-r.z,f=i.x-r.x,l=i.y-r.y,h=i.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(e){return e.every(i=>i===e[0])}let r=this.primitives.map(e=>e.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Zu!==this.Qc?(this.Zu=this.Qc,!1):!0:!1}_invalidateMultiDrawStructure(){this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.hu()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let e=this.getPrimitiveAt(r);x.exist(e.vertexHandles)?e.update3DAPIVertexData():e.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.Zc)t.delete3DAPIVertexData();this.Jc>=0&&this.Yc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.Jc,this.Ru),this.Jc=-1,this.Ru=0)}};c.invalidateMeshUID=-1,c.qu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c.Ju=b.zero(),c._u=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.il=b.zero(),c.rl=b.zero(),c.sl=b.zero(),c.al=b.zero(),c.cl=b.zero(),c.ul=b.zero(),c.ll=b.zero(),c.Yu=0;var B=c;export{B as Mesh};
|
|
1
|
+
import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as z}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as O,isBlendWithZWrite as H,isOpaque as k,isTranslucent as F}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.zc=[];this.wu=[];this.Bu=[];this.Mu=[];this.Uu=[];this.qu=[];this.Ru=new G;this.Xc=[];this.gu=new Set;this.Yc=v.InvalidCGAPIResourceUid;this.zu=!1;this.Iu=!1;this.Ou=!1;this.Nu=!1;this.Hu=-1;this.ku=-1;this.Fu=!1;this.hu=0;this.yu=-1;this.qc=-1;this.Vu=0;this.Eu=-1;this.Lu=0;this.Wu=0;this.Zc=[];this.xu=!1;this.tangentCalculationMode=1;this.Zu=!1;this.Jc=0;this.i=t,this.Gu=++c.Yu}static get _primitivePositionUpdateVersion(){return c.Xu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.zc.findIndex(i=>i.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Zc}get _variationInstanceCount(){return this.Qc==null?this.Zc.length:this.Qc.length/4}_belongToMeshComponent(t){this.Zc.push(t.entity),this.xu=!0,this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){var i;let r=t.entity;this.Zc=this.Zc.filter(e=>e!==r),this.xu=!0;for(let e of this.Zc)(i=e.tryToGetMeshRenderer())==null||i.markNeedsLoad();this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),k(t)?this.wu.push(t):F(t)?this.Bu.push(t):H(t)?this.Mu.push(t):O(t)&&this.Uu.push(t),this.hl(this.wu.concat(this.Bu).concat(this.Mu).concat(this.Uu))}hl(t){this.zc=t}isExistOpaque(){return this.wu.length>0}isExistTranslucent(){return this.Bu.length>0}isExistBlendWithZWrite(){return this.Mu.length>0}isExistBlendWithoutZWrite(){return this.Uu.length>0}getPrimitiveAt(t){return this.zc[t]}getPrimitiveNumber(){return this.zc.length}$c(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Zc.length,r=this.i.webglResourceRepository.instanceSidTable,i=this.qc;(i<0||this.Vu!==t)&&(i>=0&&r.free(i,this.Vu),i=r.allocate(t),this.qc=i,this.Vu=t,r.writeIdentityRemap(i,t));let e=4294967295;for(let s=0;s<t;s++){let n=this.Zc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(i+s,a,o!=null?o.componentSID:e,u!=null?u.componentSID:e)}return i}get _instanceSidBase(){return this.qc}get _remapPrepassId(){return this.Eu}set _remapPrepassId(t){this.Eu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.Yc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.Yc);let r=4294967295,i=this.Zc.length,e=new Uint32Array(i*4),s=new Int32Array(i),n=!1,a=!1;for(let o=0;o<i;o++){s[o]=this.Zc[o].entityUID,e[4*o+0]=this.Zc[o].getSceneGraph().componentSID;let u=this.Zc[o].tryToGetSkeletal();u!=null?e[4*o+1]=u.componentSID:e[4*o+1]=r;let f=this.Zc[o].tryToGetBlendShape();f!=null?e[4*o+2]=f.componentSID:e[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.zu=i>0,this.Iu=n,this.Ou=a,this.$c()?(this.Yc=v.InvalidCGAPIResourceUid,this.Qc=e,this.vu=s,this.Pu=void 0,this.Du=void 0,this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,this._ensureInstanceSidBase(),!0):(this.Yc=t.createVertexBufferFromTypedArray(e),this.Qc=e,this.vu=s,this.Pu=e.slice(),this.Du=new Uint32Array(e.length),this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.$c())return this._packVisibleInstancesToInstanceRemap(t,r);let i=this.Qc,e=this.vu,s=this.Pu,n=this.Du;if(i===void 0||e===void 0||s===void 0||n===void 0||this.Yc===v.InvalidCGAPIResourceUid)return this.Zc.length;if(t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let a=e.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=e[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=i[h+0],n[m+1]=i[h+1],n[m+2]=i[h+2],n[m+3]=i[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.Yc,l),s.set(l)}return this.hu=o,o}_packVisibleInstancesToInstanceRemap(t,r){let i=this.vu;if(i===void 0)return this.Zc.length;if(this.qc<0&&this._ensureInstanceSidBase(),t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let e=this.i.webglResourceRepository.instanceSidTable,s=this.qc,n=i.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=i[o];if(u<t.length&&t[u]===r)continue}e.setRemap(s+a,o),a++}return this.hu=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.Yc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.Yc),this.Yc=v.InvalidCGAPIResourceUid,this.Qc=void 0,this.vu=void 0,this.Pu=void 0,this.Du=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let e=0;e<this.zc.length;e++){let s=this.zc[e],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[e]=n.vertexHandles.vaoHandle,this.gu.add(e);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[e])||this.Xc[e]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[e]=t.createVertexArray(),a.vaoHandle=this.Xc[e]),t.setVertexDataToPipeline(a,s,this.Yc)}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=this.zc.length;e<this.Xc.length;e++){let s=this.Xc[e];s&&!r.hasVaoHandle(s)&&(i.has(s)||(i.add(s),t.deleteVertexArray(s))),this.Xc[e]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.gu.clear();return}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=0;e<this.Xc.length;e++){let s=this.Xc[e];s&&!i.has(s)&&!r.hasVaoHandle(s)&&(i.add(s),t.deleteVertexArray(s)),this.Xc[e]=v.InvalidCGAPIResourceUid}this.gu.clear()}_clearMultiDrawVaoUids(){for(let t of this.gu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.gu.clear()}castRay(t,r,i=0){var o;let e,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.zc){let f=u.castRay(t,r,!0,!0,i,this.Zu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,e=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(e)?{result:!0,data:{t:s,u:n,v:a,position:e}}:{result:!1}}get primitives(){return this.zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.Yc}get _variationEntityInfo(){return this.Qc}get _isGpuCullable(){return this.zu?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.Iu)return!0;if(!this.Ou)return!1;for(let t=0;t<this.zc.length;t++)if(this.zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.Hu===this.zc.length&&this.ku===this.Jc&&this.Fu===this.Iu?this.Nu:(this.Hu=this.zc.length,this.ku=this.Jc,this.Fu=this.Iu,this.Nu=this.fl(),this.Nu)}fl(){if(this.zc.length===0)return!1;let t=(r,i)=>r.some(e=>e.split(".")[0]===i);for(let r of this.zc){let i=r.attributeSemantics;if(!t(i,"POSITION")||this.Iu&&(!t(i,"JOINTS_0")||!t(i,"WEIGHTS_0")))return!1;for(let e of r.targets){let s=!1;for(let n of e.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Jc++,c.Xu++;for(let t of this.Zc)t.getMeshRenderer().markNeedsLoad()}get primitivePositionUpdateCount(){return this.Jc}get AABB(){if(this.Jc!==this.Lu&&(this.Ru.initialize(),this.Lu=this.Jc),this.Ru.isVanilla())for(let t of this.zc)this.Ru.mergeAABB(t.AABB);return this.Ru}bl(){for(let t=0;t<this.zc.length;t++){let r=this.qu[t],i=this.zc[t];i.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,i.getAttribute(n))})}}_calcTangents(){if(this.pl())for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let i=t.attributeSemantics.indexOf(g.Texcoord0.XY),e=t.attributeSemantics.indexOf(g.Normal.XYZ);if(i!==-1&&e!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[i],o=t.attributeAccessors[e],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),M=n.getVec3(d+2,{indicesAccessor:u}),S=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),N=a.getVec2(d+2,{indicesAccessor:u}),T=o.getVec3(d,{indicesAccessor:u});this.dl(d,I,A,M,S,U,N,T,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}dl(t,r,i,e,s,n,a,o,u,f){let l=this.Tu(r,i,e,s,n,a,o,c.cl),h=this.Tu(i,e,r,n,a,s,o,c.ul),m=this.Tu(e,r,i,a,s,n,o,c.ll);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}Tu(t,r,i,e,s,n,a,o){let u=[c.Tt.setComponents(t.x,e.x,e.y),c.bt.setComponents(t.y,e.x,e.y),c.ve.setComponents(t.z,e.x,e.y)],f=[c._u.setComponents(r.x,s.x,s.y),c.ju.setComponents(r.y,s.x,s.y),c.Ju.setComponents(r.z,s.x,s.y)],l=[c.Ku.setComponents(i.x,n.x,n.y),c.Qu.setComponents(i.y,n.x,n.y),c.$u.setComponents(i.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.il),d=b.subtractTo(l[p],f[p],c.sl),I=b.crossTo(y,d,c.al),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),z.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}pl(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Zu=!0;let i=t.attributeSemantics.indexOf(g.Position.XYZ),e=t.attributeAccessors[i],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=e.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:e.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=e.getVec3(h,{indicesAccessor:s}),p=e.getVec3(h+1,{indicesAccessor:s}),y=e.getVec3(h+2,{indicesAccessor:s});this.ml(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}ml(t,r,i,e,s,n){let a=i.x-r.x,o=i.y-r.y,u=i.z-r.z,f=e.x-r.x,l=e.y-r.y,h=e.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(i){return i.every(e=>e===i[0])}let r=this.primitives.map(i=>i.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){if(this.xu)return!1;let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Wu!==this.Jc?(this.Wu=this.Jc,!1):!0:!1}_invalidateMultiDrawStructure(){this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.$c()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let i=this.getPrimitiveAt(r);x.exist(i.vertexHandles)?i.update3DAPIVertexData():i.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.zc)t.delete3DAPIVertexData();this.qc>=0&&this.Zc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.qc,this.Vu),this.qc=-1,this.Vu=0)}};c.invalidateMeshUID=-1,c.Yu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c._u=b.zero(),c.ju=b.zero(),c.Ju=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.il=b.zero(),c.sl=b.zero(),c.al=b.zero(),c.cl=b.zero(),c.ul=b.zero(),c.ll=b.zero(),c.Xu=0;var B=c;export{B as Mesh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RnObject as H}from"../core/RnObject.js";import{BufferUse as k}from"../definitions/BufferUse.js";import{ComponentType as I}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{VertexAttribute as w}from"../definitions/VertexAttribute.js";import{createClassicUberMaterial as z}from"../helpers/materials/createClassicUberMaterial.js";import{AABB as F}from"../math/AABB.js";import{MutableVector3 as x}from"../math/MutableVector3.js";import{Vector3 as T}from"../math/Vector3.js";import{DataUtil as N}from"../misc/DataUtil.js";import{Is as B}from"../misc/Is.js";import{None as R,Some as O}from"../misc/Option.js";import{RnException as L}from"../misc/RnException.js";import{PrimitiveSortKey_BitLength_Material as G,PrimitiveSortKey_BitLength_PrimitiveType as W,PrimitiveSortKey_BitLength_RenderQueue as K,PrimitiveSortKey_BitLength_TranslucencyType as J,PrimitiveSortKey_BitOffset_Material as X,PrimitiveSortKey_BitOffset_PrimitiveType as Y,PrimitiveSortKey_BitOffset_RenderQueue as Z,PrimitiveSortKey_BitOffset_TranslucencyType as Q}from"./types/GeometryTypes.js";var s=class s extends H{constructor(e){super();this.Rp=V.Unknown;this.Op=new Map;this.gl="";this.Mp=new Map;this.wp=new R;this.Lp=-1;this.Hp=new F;this.Jp=[];this.Wp=-1;this._sortkey=0;this._viewDepth=0;this.jp=0;this.$p=0;this.Nn="";this.i=e,s.Kp==null&&(s.Kp=z(this.i,{isSkinning:!0,isLighting:!0})),this.kp=s.Kp,this._prevMaterial=new WeakRef(s.Kp)}calcFingerPrint(){let e="";e+=this.Rp.index,this.wp.has()&&(e+=this.getRenderIndexBitSize()),e+=this.targets.length,e+=s.getPrimitiveIdxHasMorph(this.Lp);for(let[t,i]of this.Mp)e+=t,e+=i.componentType.webgpu+i.compositionType.webgpu,e+=i.actualByteStride;this.Nn=e}_getFingerPrint(){return this.Nn}getRenderIndexBitSize(){return this.wp.has()?this.Bp!=null?"uint32":this.getIndexBitSize():"uint16"}get _engine(){return this.i}get _multiDrawGroup(){return this.Bp}get _multiDrawEntry(){if(!(this.Bp==null||this.Wp<0))return this.Bp.entries[this.Wp]}_setMultiDrawGroup(e,t){this.Bp=e,this.Wp=t,this.Vp=e.vertexHandles,this.calcFingerPrint()}_clearMultiDrawGroup(){this.Bp=void 0,this.Wp=-1,this.Vp=void 0,this.calcFingerPrint()}static getPrimitiveIdxHasMorph(e){return this.Qp.get(e)}static getPrimitiveHasMorph(e){return this.qp.get(e)}getIndexBitSize(){let e=this.wp.unwrapOrUndefined();if(e==null)throw new Error("indexAccessor is null");if(e.componentType===I.UnsignedShort)return"uint16";if(e.componentType===I.UnsignedInt)return"uint32";if(e.componentType===I.UnsignedByte)return"uint16";throw new Error("unknown indexAccessor.componentType")}get _vertexHandles(){return this.Vp}static get variantUpdateCount(){return this.Yp}setMaterialVariant(e,t){this.Op.set(e,t),s.Yp++}applyMaterialVariant(e){let t=this.Op.get(e);t&&(this.material=t,this.gl=e,s.Yp++)}getCurrentVariantName(){for(let[e,t]of this.Op)if(t===this.kp)return e;return""}getVariantNames(){return Array.from(this.Op.keys())}getVariantMaterial(e){return this.Op.get(e)}set material(e){this.kp=e,this.setSortKey(X,G,e.materialUID);let t=0;e.isTranslucentOpaque()?t=1:e.isBlend()&&(e.zWriteWhenBlend?t=2:t=3),this.setSortKey(Q,J,t),e._addBelongPrimitive(this),this.zp()}get material(){return this.kp}setSortKey(e,t,i){let a=i<<e;this._sortkey|=a;let y=(1<<t)-1;this._sortkey&=~(y<<e),this._sortkey|=(i&y)<<e}setRenderQueue(e){let t=(1<<K)-1,i=Math.max(0,Math.min(t,e|0));this.setSortKey(Z,K,i)}_belongToMesh(e){this.eo=e}get mesh(){return this.eo}_backupMaterial(){this._prevMaterial=new WeakRef(this.kp)}_restoreMaterial(){let e=this._prevMaterial.deref();e!=null&&(this.kp=e)}static getPrimitive(e){var t;return(t=this.Zc[e])==null?void 0:t.deref()}static forEachPrimitive(e){var t;for(let i=0;i<this.Zc.length;i++){let a=(t=this.Zc[i])==null?void 0:t.deref();a!=null&&e(a)}}static getPrimitiveCount(){return this.Zp}onAccessorUpdated(e){this.$p=e,this.eo!=null&&this.eo._onPrimitivePositionUpdated()}setData(e,t,i,a){a!=null?this.wp=new O(a):this.wp=new R,this.Mp=e;let y=this.Mp.get(w.Position.XYZ);y._primitive=new WeakRef(this),i!=null?this.material=i:this.material=z(this.i,{isSkinning:!0,isLighting:!0}),this.Rp=t,this.setSortKey(Y,W,t.index),this.Lp=s.Zp++,s.Zc[this.Lp]=new WeakRef(this),this.calcFingerPrint(),this.zp()}copyVertexData({attributes:e,attributeSemantics:t,primitiveMode:i,indices:a,material:y}){let g=0,n=4;e.forEach(r=>{g+=r.byteLength});let p=g;a!=null&&(p+=N.addPaddingBytes(a.byteLength,n));let u=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,p,n),m,f;if(a!=null){m=I.fromTypedArray(a);let r=u.takeBufferView({byteLengthToNeed:a.byteLength,byteStride:0});if(r.isErr())throw new L(r.getRnError());let c=r.get().takeAccessor({compositionType:M.Scalar,componentType:m,count:a.byteLength/m.getSizeInBytes()});if(c.isErr())throw new L(c.getRnError());f=c.get();for(let l=0;l<a.byteLength/f.componentSizeInBytes;l++)f.setScalar(l,a[l],{})}let o=u.takeBufferView({byteLengthToNeed:g,byteStride:0}).unwrapForce(),b=[],S=[];e.forEach((r,c)=>{let l=M.vectorFrom(w.toVectorComponentN(t[c]));S[c]=I.fromTypedArray(e[c]);let A=o.takeAccessor({compositionType:l,componentType:I.fromTypedArray(e[c]),count:r.byteLength/l.getNumberOfComponents()/S[c].getSizeInBytes()}).unwrapForce();A.copyFromTypedArray(r),b.push(A)});let v=new Map;for(let r=0;r<t.length;r++){let c=t[r];v.set(c,b[r])}this.setData(v,i,y,f)}static createPrimitive(e,t){let i=new s(e);return i.copyVertexData(t),i}get indicesAccessor(){return this.wp.unwrapOrUndefined()}getVertexCountAsIndicesBased(){return this.indicesAccessor?this.indicesAccessor.elementCount:this.getVertexCountAsVerticesBased()}getVertexCountAsVerticesBased(){for(let e of this.Mp.values())return e.elementCount;return 0}getTriangleCountAsIndicesBased(){if(this.indicesAccessor)switch(this.Rp){case V.Triangles:return this.indicesAccessor.elementCount/3;case V.TriangleStrip:return this.indicesAccessor.elementCount-2;case V.TriangleFan:return this.indicesAccessor.elementCount-2;default:return 0}return this.getTriangleCountAsVerticesBased()}getTriangleCountAsVerticesBased(){for(let e of this.Mp.values())switch(this.Rp){case V.Triangles:return e.elementCount/3;case V.TriangleStrip:return e.elementCount-2;case V.TriangleFan:return e.elementCount-2;default:return 0}return 0}hasIndices(){return this.wp.has()}get attributeAccessors(){let e=[];return this.Mp.forEach(t=>{e.push(t)}),e}getAttribute(e){return this.Mp.get(e)}get attributeSemantics(){let e=[];return this.Mp.forEach((t,i)=>{e.push(i)}),e}get attributeEntries(){return this.Mp.entries()}get attributeCompositionTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.compositionType)}),e}get attributeComponentTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.componentType)}),e}get primitiveMode(){return this.Rp}get primitiveUid(){return this.Lp}get positionAccessorVersion(){return this.$p}get AABB(){if(this.Hp.isVanilla()||this.positionAccessorVersion!==this.jp){let e=this.Mp.get(w.Position.XYZ),t=e.min;this.Hp.minPoint=s.Tt.setComponents(t[0],t[1],t[2]);let i=e.max;this.Hp.maxPoint=s.Tt.setComponents(i[0],i[1],i[2]),this.jp=e.version}return this.Hp}zp(){let e=this.eo;e!=null&&e._invalidateMultiDrawStructure()}setVertexAttribute(e,t){this.Mp.set(t,e),this.calcFingerPrint(),this.zp()}removeIndices(){this.wp=new R,this.calcFingerPrint(),this.zp()}setIndices(e){this.wp=new O(e),this.calcFingerPrint(),this.zp()}setBlendShapeTargets(e){s.qp.set(s.Xp,this),s.Qp.set(this.Lp,s.Xp++),this.Jp=e,this.calcFingerPrint(),this.zp()}static getMorphUniformDataTargetNumbers(){let e=[];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(i.targets.length)}return e.length===0?[0]:e}static getMorphUniformDataOffsets(){let e=[0];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(e[e.length-1]+i.targets.length)}return e}static getPrimitiveCountHasMorph(){return this.Xp}getBlendShapeTargets(){return this.Jp.concat()}get targets(){return this.Jp}isBlend(){return!(this.material==null||!this.material.isBlend())}isOpaque(){return!this.isBlend()}create3DAPIVertexData(){if(this.Bp!=null||this.Vp!=null)return!1;let e=this.i.cgApiResourceRepository;return this.Vp=e.createVertexBufferAndIndexBuffer(this),!0}update3DAPIVertexData(){if(this.Bp!=null)return!0;let e=this.Vp;return B.not.exist(this.Vp)?!1:(this.i.cgApiResourceRepository.updateVertexBufferAndIndexBuffer(this,e),!0)}delete3DAPIVertexData(){return this.Bp!=null||this.Vp==null?!1:(this.i.cgApiResourceRepository.deleteVertexDataResources(this.Vp),this.Vp=void 0,!0)}get vertexHandles(){return this.Vp}convertToUnindexedGeometry(){let e=this.indicesAccessor;if(e==null)return;let t=e.getTypedArray(),i=0;for(let g=0;g<this.attributeAccessors.length;g++){let p=this.attributeAccessors[g].compositionType,u=0;p.index===M.Vec4.index?u=4:p.index===M.Vec3.index?u=3:p.index===M.Vec2.index?u=2:p.index===M.Scalar.index&&(u=1),i+=t.length*u*4}let y=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,i,4).takeBufferView({byteLengthToNeed:i,byteStride:0}).unwrapForce();for(let[g,n]of this.Mp){let p=n.compositionType,u=y.takeAccessor({compositionType:p,componentType:n.componentType,count:t.length}).unwrapForce();for(let m=0;m<t.length;m++){let f=t[m];if(p.index===M.Vec4.index){let o=n.getVec4(f,{});u.setVec4(m,o.x,o.y,o.z,o.w,{})}else if(p.index===M.Vec3.index){let o=n.getVec3(f,{});u.setVec3(m,o.x,o.y,o.z,{})}else if(p.index===M.Vec2.index){let o=n.getVec2(f,{});u.setVec2(m,o.x,o.y,{})}else if(p.index===M.Scalar.index){let o=n.getScalar(f,{});u.setScalar(m,o,{})}}this.setVertexAttribute(u,g)}this.removeIndices()}castRay(e,t,i,a,y,g){let n=Number.MAX_VALUE,p=3;if(this.Rp===V.TriangleStrip)p=1;else if(this.Rp===V.Points)return{result:!1};let u=0,m=0,f=0,o=0,b=0;if(this.hasIndices()){let v=this.wp.unwrapForce();for(let r=0;r<v.elementCount-2;r++){let c=r*p;if(c+2>v.elementCount-1)break;let l=v.getScalar(c,{}),A=v.getScalar(c+1,{}),h=v.getScalar(c+2,{}),d=this.yl(e,t,r,l,A,h,i,a,y,g);B.false(d)||B.not.exist(d.data)||d.data.t<n&&(n=d.data.t,o=d.data.u,b=d.data.v,u=l,m=A,f=h)}}else{let v=0;for(let r of this.Mp.values()){v=r.elementCount;break}for(let r=0;r+2<v;r+=p){let c=r,l=r+1,A=r+2,h=this.yl(e,t,r,c,l,A,i,a,y,g);if(h.result&&B.defined(h.data)){let d=h.data.t;d<n&&(n=d,o=h.data.u,b=h.data.v,u=c,m=l,f=A)}}}if(n===Number.MAX_VALUE)return{result:!1};let S=T.fromCopy3(t.x*n+e.x,t.y*n+e.y,t.z*n+e.z);return{result:!0,data:{t:n,u:o,v:b,position:S}}}yl(e,t,i,a,y,g,n,p,u,m){if(m){let E=this.Mp.get(w.Normal.XYZ);if(E){let U=E.getVec3(i,{});if(U.dot(t)<u&&!n)return{result:!1};if(U.dot(t)>-u&&!p)return{result:!1}}}let f=this.Mp.get(w.Position.XYZ),o=f.getVec3(a,{}),b=f.getVec3(y,{}),S=f.getVec3(g,{}),v=x.zero(),r=x.zero(),c=x.zero(),l=x.zero(),A=x.zero(),h=0,d=0;x.subtractTo(b,o,v),x.subtractTo(S,o,r),x.crossTo(t,r,c);let P=T.dot(v,c);if(P>1e-4){if(x.subtractTo(e,o,l),h=T.dot(l,c),h<0||h>P)return{result:!1};if(x.crossTo(l,v,A),d=T.dot(t,A),d<0||h+d>P)return{result:!1}}else if(P<-1e-4){if(x.subtractTo(e,o,l),h=T.dot(l,c),h>0||h<P)return{result:!1};if(x.crossTo(l,v,A),d=T.dot(t,A),d>0||h+d<P)return{result:!1}}else return{result:!1};let C=1/P,D=T.dot(r,A);return D*=C,h*=C,d*=C,{result:!0,data:{t:D,u:h,v:d}}}vl(e,t,i,a,y){let g=1-a-y,n=this.Mp.get(w.Position.XYZ),p=n.getVec3(e,{}),u=n.getVec3(t,{}),m=n.getVec3(i,{}),f=T.multiply(p,g),o=T.multiply(u,a),b=T.multiply(m,y);return x.zero().add(f).add(o).add(b)}};s.Zp=0,s.Zc=[],s.Qp=new Map,s.qp=new Map,s.Xp=0,s.Tt=x.zero(),s.Yp=0;var _=s;export{_ as Primitive};
|
|
1
|
+
import{RnObject as H}from"../core/RnObject.js";import{BufferUse as k}from"../definitions/BufferUse.js";import{ComponentType as I}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{PrimitiveMode as T}from"../definitions/PrimitiveMode.js";import{VertexAttribute as w}from"../definitions/VertexAttribute.js";import{createClassicUberMaterial as z}from"../helpers/materials/createClassicUberMaterial.js";import{AABB as F}from"../math/AABB.js";import{MutableVector3 as x}from"../math/MutableVector3.js";import{Vector3 as V}from"../math/Vector3.js";import{DataUtil as N}from"../misc/DataUtil.js";import{Is as B}from"../misc/Is.js";import{None as D,Some as O}from"../misc/Option.js";import{RnException as L}from"../misc/RnException.js";import{PrimitiveSortKey_BitLength_Material as G,PrimitiveSortKey_BitLength_PrimitiveType as W,PrimitiveSortKey_BitLength_RenderQueue as K,PrimitiveSortKey_BitLength_TranslucencyType as J,PrimitiveSortKey_BitOffset_Material as X,PrimitiveSortKey_BitOffset_PrimitiveType as Y,PrimitiveSortKey_BitOffset_RenderQueue as Z,PrimitiveSortKey_BitOffset_TranslucencyType as Q}from"./types/GeometryTypes.js";var s=class s extends H{constructor(e){super();this.Rp=T.Unknown;this.Op=new Map;this.yl="";this.Mp=new Map;this.wp=new D;this.Lp=-1;this.Hp=new F;this.Jp=[];this.Wp=-1;this._sortkey=0;this._viewDepth=0;this.jp=0;this.$p=0;this.Nn="";this.i=e,s.Kp==null&&(s.Kp=z(this.i,{isSkinning:!0,isLighting:!0})),this.kp=s.Kp,this._prevMaterial=new WeakRef(s.Kp)}calcFingerPrint(){let e="";e+=this.Rp.index,this.wp.has()&&(e+=this.getRenderIndexBitSize()),e+=this.targets.length,e+=s.getPrimitiveIdxHasMorph(this.Lp);for(let[t,i]of this.Mp)e+=t,e+=i.componentType.webgpu+i.compositionType.webgpu,e+=i.actualByteStride;this.Nn=e}_getFingerPrint(){return this.Nn}getRenderIndexBitSize(){return this.wp.has()?this.Bp!=null?"uint32":this.getIndexBitSize():"uint16"}get _engine(){return this.i}get _multiDrawGroup(){return this.Bp}get _multiDrawEntry(){if(!(this.Bp==null||this.Wp<0))return this.Bp.entries[this.Wp]}_setMultiDrawGroup(e,t){this.Bp=e,this.Wp=t,this.Vp=e.vertexHandles,this.calcFingerPrint()}_clearMultiDrawGroup(){this.Bp=void 0,this.Wp=-1,this.Vp=void 0,this.calcFingerPrint()}static getPrimitiveIdxHasMorph(e){return this.Qp.get(e)}static getPrimitiveHasMorph(e){return this.qp.get(e)}getIndexBitSize(){let e=this.wp.unwrapOrUndefined();if(e==null)throw new Error("indexAccessor is null");if(e.componentType===I.UnsignedShort)return"uint16";if(e.componentType===I.UnsignedInt)return"uint32";if(e.componentType===I.UnsignedByte)return"uint16";throw new Error("unknown indexAccessor.componentType")}get _vertexHandles(){return this.Vp}static get variantUpdateCount(){return this.Yp}setMaterialVariant(e,t){this.Op.set(e,t),s.Yp++}applyMaterialVariant(e){let t=this.Op.get(e);t&&(this.material=t,this.yl=e,s.Yp++)}getCurrentVariantName(){for(let[e,t]of this.Op)if(t===this.kp)return e;return""}getVariantNames(){return Array.from(this.Op.keys())}getVariantMaterial(e){return this.Op.get(e)}set material(e){this.kp=e,this.setSortKey(X,G,e.materialUID);let t=0;e.isTranslucentOpaque()?t=1:e.isBlend()&&(e.zWriteWhenBlend?t=2:t=3),this.setSortKey(Q,J,t),e._addBelongPrimitive(this),this.zp()}get material(){return this.kp}setSortKey(e,t,i){let n=i<<e;this._sortkey|=n;let g=(1<<t)-1;this._sortkey&=~(g<<e),this._sortkey|=(i&g)<<e}setRenderQueue(e){let t=(1<<K)-1,i=Math.max(0,Math.min(t,e|0));this.setSortKey(Z,K,i)}_belongToMesh(e){this.eo=e}get mesh(){return this.eo}_backupMaterial(){this._prevMaterial=new WeakRef(this.kp)}_restoreMaterial(){let e=this._prevMaterial.deref();e!=null&&(this.kp=e)}static getPrimitive(e){var t;return(t=this.zc[e])==null?void 0:t.deref()}static forEachPrimitive(e){var t;for(let i=0;i<this.zc.length;i++){let n=(t=this.zc[i])==null?void 0:t.deref();n!=null&&e(n)}}static getPrimitiveCount(){return this.Zp}onAccessorUpdated(e){this.$p=e,this.eo!=null&&this.eo._onPrimitivePositionUpdated()}setData(e,t,i,n){n!=null?this.wp=new O(n):this.wp=new D,this.Mp=e;let g=this.Mp.get(w.Position.XYZ);g._primitive=new WeakRef(this),i!=null?this.material=i:this.material=z(this.i,{isSkinning:!0,isLighting:!0}),this.Rp=t,this.setSortKey(Y,W,t.index),this.Lp=s.Zp++,s.zc[this.Lp]=new WeakRef(this),this.calcFingerPrint(),this.zp()}copyVertexData({attributes:e,attributeSemantics:t,primitiveMode:i,indices:n,material:g}){let y=0,o=4;e.forEach(r=>{y+=r.byteLength});let p=y;n!=null&&(p+=N.addPaddingBytes(n.byteLength,o));let u=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,p,o),m,f;if(n!=null){m=I.fromTypedArray(n);let r=u.takeBufferView({byteLengthToNeed:n.byteLength,byteStride:0});if(r.isErr())throw new L(r.getRnError());let c=r.get().takeAccessor({compositionType:M.Scalar,componentType:m,count:n.byteLength/m.getSizeInBytes()});if(c.isErr())throw new L(c.getRnError());f=c.get();for(let l=0;l<n.byteLength/f.componentSizeInBytes;l++)f.setScalar(l,n[l],{})}let a=u.takeBufferView({byteLengthToNeed:y,byteStride:0}).unwrapForce(),b=[],P=[];e.forEach((r,c)=>{let l=M.vectorFrom(w.toVectorComponentN(t[c]));P[c]=I.fromTypedArray(e[c]);let v=a.takeAccessor({compositionType:l,componentType:I.fromTypedArray(e[c]),count:r.byteLength/l.getNumberOfComponents()/P[c].getSizeInBytes()}).unwrapForce();v.copyFromTypedArray(r),b.push(v)});let A=new Map;for(let r=0;r<t.length;r++){let c=t[r];A.set(c,b[r])}this.setData(A,i,g,f)}static createPrimitive(e,t){let i=new s(e);return i.copyVertexData(t),i}get indicesAccessor(){return this.wp.unwrapOrUndefined()}getVertexCountAsIndicesBased(){return this.indicesAccessor?this.indicesAccessor.elementCount:this.getVertexCountAsVerticesBased()}getVertexCountAsVerticesBased(){for(let e of this.Mp.values())return e.elementCount;return 0}getTriangleCountAsIndicesBased(){if(this.indicesAccessor)switch(this.Rp){case T.Triangles:return this.indicesAccessor.elementCount/3;case T.TriangleStrip:return this.indicesAccessor.elementCount-2;case T.TriangleFan:return this.indicesAccessor.elementCount-2;default:return 0}return this.getTriangleCountAsVerticesBased()}getTriangleCountAsVerticesBased(){for(let e of this.Mp.values())switch(this.Rp){case T.Triangles:return e.elementCount/3;case T.TriangleStrip:return e.elementCount-2;case T.TriangleFan:return e.elementCount-2;default:return 0}return 0}hasIndices(){return this.wp.has()}get attributeAccessors(){let e=[];return this.Mp.forEach(t=>{e.push(t)}),e}getAttribute(e){return this.Mp.get(e)}get attributeSemantics(){let e=[];return this.Mp.forEach((t,i)=>{e.push(i)}),e}get attributeEntries(){return this.Mp.entries()}get attributeCompositionTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.compositionType)}),e}get attributeComponentTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.componentType)}),e}get primitiveMode(){return this.Rp}get primitiveUid(){return this.Lp}get positionAccessorVersion(){return this.$p}get AABB(){if(this.Hp.isVanilla()||this.positionAccessorVersion!==this.jp){let e=this.Mp.get(w.Position.XYZ),t=e.min;this.Hp.minPoint=s.Tt.setComponents(t[0],t[1],t[2]);let i=e.max;this.Hp.maxPoint=s.Tt.setComponents(i[0],i[1],i[2]),this.jp=e.version}return this.Hp}zp(){let e=this.eo;e!=null&&e._invalidateMultiDrawStructure()}setVertexAttribute(e,t){this.Mp.set(t,e),this.calcFingerPrint(),this.zp()}removeIndices(){this.wp=new D,this.calcFingerPrint(),this.zp()}setIndices(e){this.wp=new O(e),this.calcFingerPrint(),this.zp()}setBlendShapeTargets(e){s.qp.set(s.Xp,this),s.Qp.set(this.Lp,s.Xp++),this.Jp=e,this.calcFingerPrint(),this.zp()}static getMorphUniformDataTargetNumbers(){let e=[];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(i.targets.length)}return e.length===0?[0]:e}static getMorphUniformDataOffsets(){let e=[0];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(e[e.length-1]+i.targets.length)}return e}static getPrimitiveCountHasMorph(){return this.Xp}getBlendShapeTargets(){return this.Jp.concat()}get targets(){return this.Jp}isBlend(){return!(this.material==null||!this.material.isBlend())}isOpaque(){return!this.isBlend()}create3DAPIVertexData(){if(this.Bp!=null||this.Vp!=null)return!1;let e=this.i.cgApiResourceRepository;return this.Vp=e.createVertexBufferAndIndexBuffer(this),!0}update3DAPIVertexData(){if(this.Bp!=null)return!0;let e=this.Vp;if(B.not.exist(this.Vp))return!1;let t=e.vboHandles.length!==this.attributeAccessors.length,i=B.exist(e.iboHandle)!==this.hasIndices();return t||i?(this.delete3DAPIVertexData(),this.create3DAPIVertexData()):(this.i.cgApiResourceRepository.updateVertexBufferAndIndexBuffer(this,e),!0)}delete3DAPIVertexData(){return this.Bp!=null||this.Vp==null?!1:(this.i.cgApiResourceRepository.deleteVertexDataResources(this.Vp),this.Vp=void 0,!0)}get vertexHandles(){return this.Vp}convertToUnindexedGeometry(){let e=this.indicesAccessor;if(e==null)return;let t=e.getTypedArray(),i=0;for(let y=0;y<this.attributeAccessors.length;y++){let p=this.attributeAccessors[y].compositionType,u=0;p.index===M.Vec4.index?u=4:p.index===M.Vec3.index?u=3:p.index===M.Vec2.index?u=2:p.index===M.Scalar.index&&(u=1),i+=t.length*u*4}let g=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,i,4).takeBufferView({byteLengthToNeed:i,byteStride:0}).unwrapForce();for(let[y,o]of this.Mp){let p=o.compositionType,u=g.takeAccessor({compositionType:p,componentType:o.componentType,count:t.length}).unwrapForce();for(let m=0;m<t.length;m++){let f=t[m];if(p.index===M.Vec4.index){let a=o.getVec4(f,{});u.setVec4(m,a.x,a.y,a.z,a.w,{})}else if(p.index===M.Vec3.index){let a=o.getVec3(f,{});u.setVec3(m,a.x,a.y,a.z,{})}else if(p.index===M.Vec2.index){let a=o.getVec2(f,{});u.setVec2(m,a.x,a.y,{})}else if(p.index===M.Scalar.index){let a=o.getScalar(f,{});u.setScalar(m,a,{})}}this.setVertexAttribute(u,y)}this.removeIndices()}castRay(e,t,i,n,g,y){let o=Number.MAX_VALUE,p=3;if(this.Rp===T.TriangleStrip)p=1;else if(this.Rp===T.Points)return{result:!1};let u=0,m=0,f=0,a=0,b=0;if(this.hasIndices()){let A=this.wp.unwrapForce();for(let r=0;r<A.elementCount-2;r++){let c=r*p;if(c+2>A.elementCount-1)break;let l=A.getScalar(c,{}),v=A.getScalar(c+1,{}),h=A.getScalar(c+2,{}),d=this.gl(e,t,r,l,v,h,i,n,g,y);B.false(d)||B.not.exist(d.data)||d.data.t<o&&(o=d.data.t,a=d.data.u,b=d.data.v,u=l,m=v,f=h)}}else{let A=0;for(let r of this.Mp.values()){A=r.elementCount;break}for(let r=0;r+2<A;r+=p){let c=r,l=r+1,v=r+2,h=this.gl(e,t,r,c,l,v,i,n,g,y);if(h.result&&B.defined(h.data)){let d=h.data.t;d<o&&(o=d,a=h.data.u,b=h.data.v,u=c,m=l,f=v)}}}if(o===Number.MAX_VALUE)return{result:!1};let P=V.fromCopy3(t.x*o+e.x,t.y*o+e.y,t.z*o+e.z);return{result:!0,data:{t:o,u:a,v:b,position:P}}}gl(e,t,i,n,g,y,o,p,u,m){if(m){let E=this.Mp.get(w.Normal.XYZ);if(E){let U=E.getVec3(i,{});if(U.dot(t)<u&&!o)return{result:!1};if(U.dot(t)>-u&&!p)return{result:!1}}}let f=this.Mp.get(w.Position.XYZ),a=f.getVec3(n,{}),b=f.getVec3(g,{}),P=f.getVec3(y,{}),A=x.zero(),r=x.zero(),c=x.zero(),l=x.zero(),v=x.zero(),h=0,d=0;x.subtractTo(b,a,A),x.subtractTo(P,a,r),x.crossTo(t,r,c);let S=V.dot(A,c);if(S>1e-4){if(x.subtractTo(e,a,l),h=V.dot(l,c),h<0||h>S)return{result:!1};if(x.crossTo(l,A,v),d=V.dot(t,v),d<0||h+d>S)return{result:!1}}else if(S<-1e-4){if(x.subtractTo(e,a,l),h=V.dot(l,c),h>0||h<S)return{result:!1};if(x.crossTo(l,A,v),d=V.dot(t,v),d>0||h+d<S)return{result:!1}}else return{result:!1};let C=1/S,R=V.dot(r,v);return R*=C,h*=C,d*=C,{result:!0,data:{t:R,u:h,v:d}}}Al(e,t,i,n,g){let y=1-n-g,o=this.Mp.get(w.Position.XYZ),p=o.getVec3(e,{}),u=o.getVec3(t,{}),m=o.getVec3(i,{}),f=V.multiply(p,y),a=V.multiply(u,n),b=V.multiply(m,g);return x.zero().add(f).add(a).add(b)}};s.Zp=0,s.zc=[],s.Qp=new Map,s.qp=new Map,s.Xp=0,s.Tt=x.zero(),s.Yp=0;var _=s;export{_ as Primitive};
|