@babylonjs/core 8.8.3 → 8.8.5
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/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Maths/ThinMaths/thinMath.matrix.functions.d.ts +24 -1
- package/Maths/ThinMaths/thinMath.matrix.functions.js +37 -3
- package/Maths/ThinMaths/thinMath.matrix.functions.js.map +1 -1
- package/Maths/math.vector.d.ts +0 -1
- package/Maths/math.vector.js +3 -4
- package/Maths/math.vector.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +6 -2
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +11 -6
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance0.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js +33 -8
- package/Shaders/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/Shaders/pbr.fragment.js +3 -3
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +6 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +7 -0
- package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +11 -6
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js +39 -7
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectivity.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +3 -3
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -242,7 +242,7 @@ export class SubSurfaceBlock extends NodeMaterialBlock {
|
|
|
242
242
|
#endif
|
|
243
243
|
#endif
|
|
244
244
|
#else
|
|
245
|
-
subSurfaceOut.specularEnvironmentReflectance =
|
|
245
|
+
subSurfaceOut.specularEnvironmentReflectance = colorSpecularEnvironmentReflectance;
|
|
246
246
|
#endif\n`;
|
|
247
247
|
return code;
|
|
248
248
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subSurfaceBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/PBR/subSurfaceBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAI1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AAKxG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,sB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EAAE;0BACvC,QAAQ,CAAC,CAAC,CAAC,KAAK,eAAe,EAAE,cAAc,SAAS,CAAC,CAAC,CAAC,EAAE;;;;;;;wBAO/D,eAAe,EAAE,6BAA6B,IAAI,EAAE;;;;;;;;;;;oBAWxD,6BAA6B;;;4BAGrB,KAAK,CAAC,OAAO;;;;;;;;;;;;;iBAaxB,CAAC;QAEV,OAAO,IAAI,CAAC;IAChB,CAAC;IAEkB,WAAW,CAAC,KAA6B;QACxD,IAAI,KAAK,CAAC,MAAM,KAAK,wBAAwB,CAAC,QAAQ,EAAE,CAAC;YACrD,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AArPU;IADN,sBAAsB,CAAC,gCAAgC,0CAAkC,UAAU,CAAC;mEACQ;AAuPjH,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialConnectionPointDirection } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { InputBlock } from \"../Input/inputBlock\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport type { ReflectionBlock } from \"./reflectionBlock\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport { RefractionBlock } from \"./refractionBlock\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport { PBRSubSurfaceConfiguration } from \"core/Materials/PBR/pbrSubSurfaceConfiguration\";\r\n\r\n/**\r\n * Block used to implement the sub surface module of the PBR material\r\n */\r\nexport class SubSurfaceBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new SubSurfaceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"thickness\", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"tintColor\", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"translucencyIntensity\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"translucencyDiffusionDist\", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\r\n \"refraction\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"refraction\", this, NodeMaterialConnectionPointDirection.Input, RefractionBlock, \"RefractionBlock\")\r\n );\r\n this.registerInput(\"dispersion\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\r\n \"subsurface\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"subsurface\", this, NodeMaterialConnectionPointDirection.Output, SubSurfaceBlock, \"SubSurfaceBlock\")\r\n );\r\n }\r\n\r\n /**\r\n * Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface properties (transmission, refraction, etc.)\r\n */\r\n @editableInPropertyPage(\"Apply albedo after sub-surface\", PropertyTypeForEdition.Boolean, \"ADVANCED\")\r\n public applyAlbedoAfterSubSurface: boolean = PBRSubSurfaceConfiguration.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE;\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"subSurfaceOut\");\r\n state._excludeVariableName(\"vThicknessParam\");\r\n state._excludeVariableName(\"vTintColor\");\r\n state._excludeVariableName(\"vTranslucencyColor\");\r\n state._excludeVariableName(\"vSubSurfaceIntensity\");\r\n state._excludeVariableName(\"dispersion\");\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SubSurfaceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the thickness component\r\n */\r\n public get thickness(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the tint color input component\r\n */\r\n public get tintColor(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the translucency intensity input component\r\n */\r\n public get translucencyIntensity(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the translucency diffusion distance input component\r\n */\r\n public get translucencyDiffusionDist(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the refraction object parameters\r\n */\r\n public get refraction(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the dispersion input component\r\n */\r\n public get dispersion(): NodeMaterialConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the sub surface object output component\r\n */\r\n public get subsurface(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.thickness.isConnected) {\r\n const thicknessInput = new InputBlock(\"SubSurface thickness\", NodeMaterialBlockTargets.Fragment, NodeMaterialBlockConnectionPointTypes.Float);\r\n thicknessInput.value = 0;\r\n thicknessInput.output.connectTo(this.thickness);\r\n }\r\n }\r\n\r\n public override prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n super.prepareDefines(mesh, nodeMaterial, defines);\r\n\r\n const translucencyEnabled = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;\r\n\r\n defines.setValue(\"SUBSURFACE\", translucencyEnabled || this.refraction.isConnected, true);\r\n defines.setValue(\"SS_TRANSLUCENCY\", translucencyEnabled, true);\r\n defines.setValue(\"SS_THICKNESSANDMASK_TEXTURE\", false, true);\r\n defines.setValue(\"SS_REFRACTIONINTENSITY_TEXTURE\", false, true);\r\n defines.setValue(\"SS_TRANSLUCENCYINTENSITY_TEXTURE\", false, true);\r\n defines.setValue(\"SS_USE_GLTF_TEXTURES\", false, true);\r\n defines.setValue(\"SS_DISPERSION\", this.dispersion.isConnected, true);\r\n defines.setValue(\"SS_APPLY_ALBEDO_AFTER_SUBSURFACE\", this.applyAlbedoAfterSubSurface, true);\r\n }\r\n\r\n /**\r\n * Gets the main code of the block (fragment side)\r\n * @param state current state of the node material building\r\n * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module\r\n * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module\r\n * @param worldPosVarName name of the variable holding the world position\r\n * @returns the shader code\r\n */\r\n public static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string {\r\n let code = \"\";\r\n\r\n const thickness = ssBlock?.thickness.isConnected ? ssBlock.thickness.associatedVariableName : \"0.\";\r\n const tintColor = ssBlock?.tintColor.isConnected ? ssBlock.tintColor.associatedVariableName : \"vec3(1.)\";\r\n const translucencyIntensity = ssBlock?.translucencyIntensity.isConnected ? ssBlock?.translucencyIntensity.associatedVariableName : \"1.\";\r\n const translucencyDiffusionDistance = ssBlock?.translucencyDiffusionDist.isConnected ? ssBlock?.translucencyDiffusionDist.associatedVariableName : \"vec3(1.)\";\r\n\r\n const refractionBlock: Nullable<RefractionBlock> = (ssBlock?.refraction.isConnected ? ssBlock?.refraction.connectedPoint?.ownerBlock : null) as Nullable<RefractionBlock>;\r\n\r\n const refractionTintAtDistance = refractionBlock?.tintAtDistance.isConnected ? refractionBlock.tintAtDistance.associatedVariableName : \"1.\";\r\n const refractionIntensity = refractionBlock?.intensity.isConnected ? refractionBlock.intensity.associatedVariableName : \"1.\";\r\n const refractionView = refractionBlock?.view.isConnected ? refractionBlock.view.associatedVariableName : \"\";\r\n\r\n const dispersion = ssBlock?.dispersion.isConnected ? ssBlock?.dispersion.associatedVariableName : \"0.0\";\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n code += refractionBlock?.getCode(state) ?? \"\";\r\n\r\n code += `${isWebGPU ? \"var subSurfaceOut: subSurfaceOutParams\" : \"subSurfaceOutParams subSurfaceOut\"};\r\n\r\n #ifdef SUBSURFACE\r\n ${state._declareLocalVar(\"vThicknessParam\", NodeMaterialBlockConnectionPointTypes.Vector2)} = vec2${state.fSuffix}(0., ${thickness});\r\n ${state._declareLocalVar(\"vTintColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = vec4${state.fSuffix}(${tintColor}, ${refractionTintAtDistance});\r\n ${state._declareLocalVar(\"vSubSurfaceIntensity\", NodeMaterialBlockConnectionPointTypes.Vector3)} = vec3(${refractionIntensity}, ${translucencyIntensity}, 0.);\r\n ${state._declareLocalVar(\"dispersion\", NodeMaterialBlockConnectionPointTypes.Float)} = ${dispersion};\r\n subSurfaceOut = subSurfaceBlock(\r\n vSubSurfaceIntensity\r\n , vThicknessParam\r\n , vTintColor\r\n , normalW\r\n #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION\r\n , vec3(max(cumulativeSpecularEnvironmentReflectance.r, max(cumulativeSpecularEnvironmentReflectance.g, cumulativeSpecularEnvironmentReflectance.b)))\r\n #else\r\n , baseSpecularEnvironmentReflectance\r\n #endif\r\n #ifdef SS_THICKNESSANDMASK_TEXTURE\r\n , vec4${state.fSuffix}(0.)\r\n #endif\r\n #ifdef REFLECTION\r\n #ifdef SS_TRANSLUCENCY\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + reflectionBlock?._reflectionMatrixName}\r\n #ifdef USESPHERICALFROMREFLECTIONMAP\r\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\r\n , reflectionOut.irradianceVector\r\n #endif\r\n #if defined(REALTIME_FILTERING)\r\n , ${reflectionBlock?._cubeSamplerName}\r\n ${isWebGPU ? `, ${reflectionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n , ${reflectionBlock?._vReflectionFilteringInfoName}\r\n #endif\r\n #endif\r\n #ifdef USEIRRADIANCEMAP\r\n , irradianceSampler\r\n ${isWebGPU ? `, irradianceSamplerSampler` : \"\"}\r\n #endif\r\n #endif\r\n #endif\r\n #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\r\n , surfaceAlbedo\r\n #endif\r\n #ifdef SS_REFRACTION\r\n , ${worldPosVarName}.xyz\r\n , viewDirectionW\r\n , ${refractionView}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._vRefractionInfosName ?? \"\")}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._refractionMatrixName ?? \"\")}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._vRefractionMicrosurfaceInfosName ?? \"\")}\r\n , ${isWebGPU ? \"uniforms.\" : \"\"}vLightingIntensity\r\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\r\n , alpha\r\n #endif\r\n #ifdef ${refractionBlock?._defineLODRefractionAlpha ?? \"IGNORE\"}\r\n , NdotVUnclamped\r\n #endif\r\n #ifdef ${refractionBlock?._defineLinearSpecularRefraction ?? \"IGNORE\"}\r\n , roughness\r\n #endif\r\n , alphaG\r\n #ifdef ${refractionBlock?._define3DName ?? \"IGNORE\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n #else\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n #endif\r\n #ifndef LODBASEDMICROSFURACE\r\n #ifdef ${refractionBlock?._define3DName ?? \"IGNORE\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"} \r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"} \r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n #else\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n #endif\r\n #endif\r\n #ifdef ANISOTROPIC\r\n , anisotropicOut\r\n #endif\r\n #ifdef REALTIME_FILTERING\r\n , ${refractionBlock?._vRefractionFilteringInfoName ?? \"\"}\r\n #endif\r\n #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\r\n , vRefractionPosition\r\n , vRefractionSize\r\n #endif\r\n #ifdef SS_DISPERSION\r\n , dispersion\r\n #endif\r\n #endif\r\n #ifdef SS_TRANSLUCENCY\r\n , ${translucencyDiffusionDistance}\r\n , vTintColor\r\n #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE\r\n , vec4${state.fSuffix}(0.)\r\n #endif\r\n #endif \r\n );\r\n\r\n #ifdef SS_REFRACTION\r\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\r\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\r\n alpha = subSurfaceOut.alpha;\r\n #endif\r\n #endif\r\n #else\r\n subSurfaceOut.specularEnvironmentReflectance = cumulativeSpecularEnvironmentReflectance;\r\n #endif\\n`;\r\n\r\n return code;\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n state.sharedData.blocksWithDefines.push(this);\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SubSurfaceBlock\", SubSurfaceBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"subSurfaceBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/PBR/subSurfaceBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAI1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AAKxG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,0BAA0B,EAAE,mDAAsD;AAE3F;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAClD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAyBnD;;WAEG;QAEI,+BAA0B,GAAY,0BAA0B,CAAC,oCAAoC,CAAC;QA3BzG,IAAI,CAAC,SAAS,GAAG,I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,wBAAwB,CAAC,QAAQ,EAAE,CAAC;YACrD,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AArPU;IADN,sBAAsB,CAAC,gCAAgC,0CAAkC,UAAU,CAAC;mEACQ;AAuPjH,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialConnectionPointDirection } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { InputBlock } from \"../Input/inputBlock\";\r\nimport { NodeMaterialConnectionPointCustomObject } from \"../../nodeMaterialConnectionPointCustomObject\";\r\nimport type { NodeMaterial, NodeMaterialDefines } from \"../../nodeMaterial\";\r\nimport type { AbstractMesh } from \"../../../../Meshes/abstractMesh\";\r\nimport type { ReflectionBlock } from \"./reflectionBlock\";\r\nimport type { Nullable } from \"../../../../types\";\r\nimport { RefractionBlock } from \"./refractionBlock\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\nimport { PBRSubSurfaceConfiguration } from \"core/Materials/PBR/pbrSubSurfaceConfiguration\";\r\n\r\n/**\r\n * Block used to implement the sub surface module of the PBR material\r\n */\r\nexport class SubSurfaceBlock extends NodeMaterialBlock {\r\n /**\r\n * Create a new SubSurfaceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Fragment);\r\n\r\n this._isUnique = true;\r\n\r\n this.registerInput(\"thickness\", NodeMaterialBlockConnectionPointTypes.Float, false, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"tintColor\", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"translucencyIntensity\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\"translucencyDiffusionDist\", NodeMaterialBlockConnectionPointTypes.Color3, true, NodeMaterialBlockTargets.Fragment);\r\n this.registerInput(\r\n \"refraction\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n true,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"refraction\", this, NodeMaterialConnectionPointDirection.Input, RefractionBlock, \"RefractionBlock\")\r\n );\r\n this.registerInput(\"dispersion\", NodeMaterialBlockConnectionPointTypes.Float, true, NodeMaterialBlockTargets.Fragment);\r\n\r\n this.registerOutput(\r\n \"subsurface\",\r\n NodeMaterialBlockConnectionPointTypes.Object,\r\n NodeMaterialBlockTargets.Fragment,\r\n new NodeMaterialConnectionPointCustomObject(\"subsurface\", this, NodeMaterialConnectionPointDirection.Output, SubSurfaceBlock, \"SubSurfaceBlock\")\r\n );\r\n }\r\n\r\n /**\r\n * Set it to true if your rendering in 8.0+ is different from that in 7 when you use sub-surface properties (transmission, refraction, etc.)\r\n */\r\n @editableInPropertyPage(\"Apply albedo after sub-surface\", PropertyTypeForEdition.Boolean, \"ADVANCED\")\r\n public applyAlbedoAfterSubSurface: boolean = PBRSubSurfaceConfiguration.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE;\r\n\r\n /**\r\n * Initialize the block and prepare the context for build\r\n * @param state defines the state that will be used for the build\r\n */\r\n public override initialize(state: NodeMaterialBuildState) {\r\n state._excludeVariableName(\"subSurfaceOut\");\r\n state._excludeVariableName(\"vThicknessParam\");\r\n state._excludeVariableName(\"vTintColor\");\r\n state._excludeVariableName(\"vTranslucencyColor\");\r\n state._excludeVariableName(\"vSubSurfaceIntensity\");\r\n state._excludeVariableName(\"dispersion\");\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SubSurfaceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the thickness component\r\n */\r\n public get thickness(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the tint color input component\r\n */\r\n public get tintColor(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the translucency intensity input component\r\n */\r\n public get translucencyIntensity(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the translucency diffusion distance input component\r\n */\r\n public get translucencyDiffusionDist(): NodeMaterialConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the refraction object parameters\r\n */\r\n public get refraction(): NodeMaterialConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the dispersion input component\r\n */\r\n public get dispersion(): NodeMaterialConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the sub surface object output component\r\n */\r\n public get subsurface(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.thickness.isConnected) {\r\n const thicknessInput = new InputBlock(\"SubSurface thickness\", NodeMaterialBlockTargets.Fragment, NodeMaterialBlockConnectionPointTypes.Float);\r\n thicknessInput.value = 0;\r\n thicknessInput.output.connectTo(this.thickness);\r\n }\r\n }\r\n\r\n public override prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {\r\n super.prepareDefines(mesh, nodeMaterial, defines);\r\n\r\n const translucencyEnabled = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;\r\n\r\n defines.setValue(\"SUBSURFACE\", translucencyEnabled || this.refraction.isConnected, true);\r\n defines.setValue(\"SS_TRANSLUCENCY\", translucencyEnabled, true);\r\n defines.setValue(\"SS_THICKNESSANDMASK_TEXTURE\", false, true);\r\n defines.setValue(\"SS_REFRACTIONINTENSITY_TEXTURE\", false, true);\r\n defines.setValue(\"SS_TRANSLUCENCYINTENSITY_TEXTURE\", false, true);\r\n defines.setValue(\"SS_USE_GLTF_TEXTURES\", false, true);\r\n defines.setValue(\"SS_DISPERSION\", this.dispersion.isConnected, true);\r\n defines.setValue(\"SS_APPLY_ALBEDO_AFTER_SUBSURFACE\", this.applyAlbedoAfterSubSurface, true);\r\n }\r\n\r\n /**\r\n * Gets the main code of the block (fragment side)\r\n * @param state current state of the node material building\r\n * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module\r\n * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module\r\n * @param worldPosVarName name of the variable holding the world position\r\n * @returns the shader code\r\n */\r\n public static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string {\r\n let code = \"\";\r\n\r\n const thickness = ssBlock?.thickness.isConnected ? ssBlock.thickness.associatedVariableName : \"0.\";\r\n const tintColor = ssBlock?.tintColor.isConnected ? ssBlock.tintColor.associatedVariableName : \"vec3(1.)\";\r\n const translucencyIntensity = ssBlock?.translucencyIntensity.isConnected ? ssBlock?.translucencyIntensity.associatedVariableName : \"1.\";\r\n const translucencyDiffusionDistance = ssBlock?.translucencyDiffusionDist.isConnected ? ssBlock?.translucencyDiffusionDist.associatedVariableName : \"vec3(1.)\";\r\n\r\n const refractionBlock: Nullable<RefractionBlock> = (ssBlock?.refraction.isConnected ? ssBlock?.refraction.connectedPoint?.ownerBlock : null) as Nullable<RefractionBlock>;\r\n\r\n const refractionTintAtDistance = refractionBlock?.tintAtDistance.isConnected ? refractionBlock.tintAtDistance.associatedVariableName : \"1.\";\r\n const refractionIntensity = refractionBlock?.intensity.isConnected ? refractionBlock.intensity.associatedVariableName : \"1.\";\r\n const refractionView = refractionBlock?.view.isConnected ? refractionBlock.view.associatedVariableName : \"\";\r\n\r\n const dispersion = ssBlock?.dispersion.isConnected ? ssBlock?.dispersion.associatedVariableName : \"0.0\";\r\n const isWebGPU = state.shaderLanguage === ShaderLanguage.WGSL;\r\n\r\n code += refractionBlock?.getCode(state) ?? \"\";\r\n\r\n code += `${isWebGPU ? \"var subSurfaceOut: subSurfaceOutParams\" : \"subSurfaceOutParams subSurfaceOut\"};\r\n\r\n #ifdef SUBSURFACE\r\n ${state._declareLocalVar(\"vThicknessParam\", NodeMaterialBlockConnectionPointTypes.Vector2)} = vec2${state.fSuffix}(0., ${thickness});\r\n ${state._declareLocalVar(\"vTintColor\", NodeMaterialBlockConnectionPointTypes.Vector4)} = vec4${state.fSuffix}(${tintColor}, ${refractionTintAtDistance});\r\n ${state._declareLocalVar(\"vSubSurfaceIntensity\", NodeMaterialBlockConnectionPointTypes.Vector3)} = vec3(${refractionIntensity}, ${translucencyIntensity}, 0.);\r\n ${state._declareLocalVar(\"dispersion\", NodeMaterialBlockConnectionPointTypes.Float)} = ${dispersion};\r\n subSurfaceOut = subSurfaceBlock(\r\n vSubSurfaceIntensity\r\n , vThicknessParam\r\n , vTintColor\r\n , normalW\r\n #ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION\r\n , vec3(max(cumulativeSpecularEnvironmentReflectance.r, max(cumulativeSpecularEnvironmentReflectance.g, cumulativeSpecularEnvironmentReflectance.b)))\r\n #else\r\n , baseSpecularEnvironmentReflectance\r\n #endif\r\n #ifdef SS_THICKNESSANDMASK_TEXTURE\r\n , vec4${state.fSuffix}(0.)\r\n #endif\r\n #ifdef REFLECTION\r\n #ifdef SS_TRANSLUCENCY\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + reflectionBlock?._reflectionMatrixName}\r\n #ifdef USESPHERICALFROMREFLECTIONMAP\r\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\r\n , reflectionOut.irradianceVector\r\n #endif\r\n #if defined(REALTIME_FILTERING)\r\n , ${reflectionBlock?._cubeSamplerName}\r\n ${isWebGPU ? `, ${reflectionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n , ${reflectionBlock?._vReflectionFilteringInfoName}\r\n #endif\r\n #endif\r\n #ifdef USEIRRADIANCEMAP\r\n , irradianceSampler\r\n ${isWebGPU ? `, irradianceSamplerSampler` : \"\"}\r\n #endif\r\n #endif\r\n #endif\r\n #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)\r\n , surfaceAlbedo\r\n #endif\r\n #ifdef SS_REFRACTION\r\n , ${worldPosVarName}.xyz\r\n , viewDirectionW\r\n , ${refractionView}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._vRefractionInfosName ?? \"\")}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._refractionMatrixName ?? \"\")}\r\n , ${(isWebGPU ? \"uniforms.\" : \"\") + (refractionBlock?._vRefractionMicrosurfaceInfosName ?? \"\")}\r\n , ${isWebGPU ? \"uniforms.\" : \"\"}vLightingIntensity\r\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\r\n , alpha\r\n #endif\r\n #ifdef ${refractionBlock?._defineLODRefractionAlpha ?? \"IGNORE\"}\r\n , NdotVUnclamped\r\n #endif\r\n #ifdef ${refractionBlock?._defineLinearSpecularRefraction ?? \"IGNORE\"}\r\n , roughness\r\n #endif\r\n , alphaG\r\n #ifdef ${refractionBlock?._define3DName ?? \"IGNORE\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n #else\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n #endif\r\n #ifndef LODBASEDMICROSFURACE\r\n #ifdef ${refractionBlock?._define3DName ?? \"IGNORE\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"} \r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n , ${refractionBlock?._cubeSamplerName ?? \"\"} \r\n ${isWebGPU ? `, ${refractionBlock?._cubeSamplerName}Sampler` : \"\"}\r\n #else\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n , ${refractionBlock?._2DSamplerName ?? \"\"}\r\n ${isWebGPU ? `, ${refractionBlock?._2DSamplerName}Sampler` : \"\"}\r\n #endif\r\n #endif\r\n #ifdef ANISOTROPIC\r\n , anisotropicOut\r\n #endif\r\n #ifdef REALTIME_FILTERING\r\n , ${refractionBlock?._vRefractionFilteringInfoName ?? \"\"}\r\n #endif\r\n #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC\r\n , vRefractionPosition\r\n , vRefractionSize\r\n #endif\r\n #ifdef SS_DISPERSION\r\n , dispersion\r\n #endif\r\n #endif\r\n #ifdef SS_TRANSLUCENCY\r\n , ${translucencyDiffusionDistance}\r\n , vTintColor\r\n #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE\r\n , vec4${state.fSuffix}(0.)\r\n #endif\r\n #endif \r\n );\r\n\r\n #ifdef SS_REFRACTION\r\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\r\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\r\n alpha = subSurfaceOut.alpha;\r\n #endif\r\n #endif\r\n #else\r\n subSurfaceOut.specularEnvironmentReflectance = colorSpecularEnvironmentReflectance;\r\n #endif\\n`;\r\n\r\n return code;\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n if (state.target === NodeMaterialBlockTargets.Fragment) {\r\n state.sharedData.blocksWithDefines.push(this);\r\n }\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SubSurfaceBlock\", SubSurfaceBlock);\r\n"]}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { IMatrixLike } from "../math.like.js";
|
|
2
2
|
import type { ThinMatrix } from "./thinMath.matrix.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare class MatrixManagement {
|
|
5
|
+
/** @internal */
|
|
6
|
+
static _UpdateFlagSeed: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Marks the given matrix as dirty
|
|
10
|
+
* @param matrix defines the matrix to mark as dirty
|
|
11
|
+
*/
|
|
12
|
+
export declare function MarkAsDirty(matrix: ThinMatrix): void;
|
|
3
13
|
/**
|
|
4
14
|
* Sets the given matrix to the identity matrix
|
|
5
15
|
* @param result defines the target matrix
|
|
@@ -37,6 +47,12 @@ export declare function MultiplyMatricesToArray(a: IMatrixLike, b: IMatrixLike,
|
|
|
37
47
|
* @param offset defines the offset in the target matrix where to store the result (0 by default)
|
|
38
48
|
*/
|
|
39
49
|
export declare function MultiplyMatricesToRef(a: IMatrixLike, b: IMatrixLike, result: ThinMatrix, offset?: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Populates the given matrix with the current matrix values
|
|
52
|
+
* @param matrix defines the source matrix
|
|
53
|
+
* @param target defines the target matrix
|
|
54
|
+
*/
|
|
55
|
+
export declare function CopyMatrixToRef(matrix: IMatrixLike, target: ThinMatrix): void;
|
|
40
56
|
/**
|
|
41
57
|
* Populates the given array from the starting index with the current matrix values
|
|
42
58
|
* @param matrix defines the source matrix
|
|
@@ -44,10 +60,17 @@ export declare function MultiplyMatricesToRef(a: IMatrixLike, b: IMatrixLike, re
|
|
|
44
60
|
* @param offset defines the offset in the target array where to start storing values
|
|
45
61
|
*/
|
|
46
62
|
export declare function CopyMatrixToArray(matrix: IMatrixLike, array: Float32Array | Array<number>, offset?: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Inverts the given matrix and stores the result in the target matrix
|
|
65
|
+
* @param source defines the source matrix
|
|
66
|
+
* @param target defines the target matrix
|
|
67
|
+
* @returns true if the matrix was inverted successfully, false otherwise
|
|
68
|
+
*/
|
|
69
|
+
export declare function InvertMatrixToRef(source: IMatrixLike, target: ThinMatrix): boolean;
|
|
47
70
|
/**
|
|
48
71
|
* Inverts the given matrix and stores the result in the target array
|
|
49
72
|
* @param source defines the source matrix
|
|
50
73
|
* @param target defines the target array
|
|
51
74
|
* @returns true if the matrix was inverted successfully, false otherwise
|
|
52
75
|
*/
|
|
53
|
-
export declare function
|
|
76
|
+
export declare function InvertMatrixToArray(source: IMatrixLike, target: Float32Array | Array<number>): boolean;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export class MatrixManagement {
|
|
3
|
+
}
|
|
4
|
+
/** @internal */
|
|
5
|
+
MatrixManagement._UpdateFlagSeed = 0;
|
|
1
6
|
function SetMatrixData(result, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15) {
|
|
2
7
|
const mat = result.asArray();
|
|
3
8
|
mat[0] = m0;
|
|
@@ -16,7 +21,14 @@ function SetMatrixData(result, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11,
|
|
|
16
21
|
mat[13] = m13;
|
|
17
22
|
mat[14] = m14;
|
|
18
23
|
mat[15] = m15;
|
|
19
|
-
result
|
|
24
|
+
MarkAsDirty(result);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Marks the given matrix as dirty
|
|
28
|
+
* @param matrix defines the matrix to mark as dirty
|
|
29
|
+
*/
|
|
30
|
+
export function MarkAsDirty(matrix) {
|
|
31
|
+
matrix.updateFlag = MatrixManagement._UpdateFlagSeed++;
|
|
20
32
|
}
|
|
21
33
|
/**
|
|
22
34
|
* Sets the given matrix to the identity matrix
|
|
@@ -89,7 +101,16 @@ export function MultiplyMatricesToArray(a, b, output, offset = 0) {
|
|
|
89
101
|
*/
|
|
90
102
|
export function MultiplyMatricesToRef(a, b, result, offset = 0) {
|
|
91
103
|
MultiplyMatricesToArray(a, b, result.asArray(), offset);
|
|
92
|
-
result
|
|
104
|
+
MarkAsDirty(result);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Populates the given matrix with the current matrix values
|
|
108
|
+
* @param matrix defines the source matrix
|
|
109
|
+
* @param target defines the target matrix
|
|
110
|
+
*/
|
|
111
|
+
export function CopyMatrixToRef(matrix, target) {
|
|
112
|
+
CopyMatrixToArray(matrix, target.asArray());
|
|
113
|
+
MarkAsDirty(target);
|
|
93
114
|
}
|
|
94
115
|
/**
|
|
95
116
|
* Populates the given array from the starting index with the current matrix values
|
|
@@ -116,13 +137,26 @@ export function CopyMatrixToArray(matrix, array, offset = 0) {
|
|
|
116
137
|
array[offset + 14] = source[14];
|
|
117
138
|
array[offset + 15] = source[15];
|
|
118
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Inverts the given matrix and stores the result in the target matrix
|
|
142
|
+
* @param source defines the source matrix
|
|
143
|
+
* @param target defines the target matrix
|
|
144
|
+
* @returns true if the matrix was inverted successfully, false otherwise
|
|
145
|
+
*/
|
|
146
|
+
export function InvertMatrixToRef(source, target) {
|
|
147
|
+
const result = InvertMatrixToArray(source, target.asArray());
|
|
148
|
+
if (result) {
|
|
149
|
+
MarkAsDirty(target);
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
119
153
|
/**
|
|
120
154
|
* Inverts the given matrix and stores the result in the target array
|
|
121
155
|
* @param source defines the source matrix
|
|
122
156
|
* @param target defines the target array
|
|
123
157
|
* @returns true if the matrix was inverted successfully, false otherwise
|
|
124
158
|
*/
|
|
125
|
-
export function
|
|
159
|
+
export function InvertMatrixToArray(source, target) {
|
|
126
160
|
// the inverse of a matrix is the transpose of cofactor matrix divided by the determinant
|
|
127
161
|
const m = source.asArray();
|
|
128
162
|
const m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinMath.matrix.functions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Maths/ThinMaths/thinMath.matrix.functions.ts"],"names":[],"mappings":"AAIA,SAAS,aAAa,CAClB,MAAkB,EAClB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW;IAEX,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC7B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACZ,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAEd,MAAM,CAAC,UAAU,EAAE,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,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M,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAEhC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IMatrixLike } from \"../math.like\";\r\nimport type { ThinMatrix } from \"./thinMath.matrix\";\r\n\r\nfunction SetMatrixData(\r\n result: ThinMatrix,\r\n m0: number,\r\n m1: number,\r\n m2: number,\r\n m3: number,\r\n m4: number,\r\n m5: number,\r\n m6: number,\r\n m7: number,\r\n m8: number,\r\n m9: number,\r\n m10: number,\r\n m11: number,\r\n m12: number,\r\n m13: number,\r\n m14: number,\r\n m15: number\r\n): void {\r\n const mat = result.asArray();\r\n mat[0] = m0;\r\n mat[1] = m1;\r\n mat[2] = m2;\r\n mat[3] = m3;\r\n mat[4] = m4;\r\n mat[5] = m5;\r\n mat[6] = m6;\r\n mat[7] = m7;\r\n mat[8] = m8;\r\n mat[9] = m9;\r\n mat[10] = m10;\r\n mat[11] = m11;\r\n mat[12] = m12;\r\n mat[13] = m13;\r\n mat[14] = m14;\r\n mat[15] = m15;\r\n\r\n result.updateFlag++;\r\n}\r\n\r\n/**\r\n * Sets the given matrix to the identity matrix\r\n * @param result defines the target matrix\r\n */\r\nexport function IdentityMatrixToRef(result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new translation matrix.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the target matrix\r\n */\r\nexport function TranslationMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new scaling matrix.\r\n * @param x defines the scale factor on X axis\r\n * @param y defines the scale factor on Y axis\r\n * @param z defines the scale factor on Z axis\r\n * @param result defines the target matrix\r\n */\r\nexport function ScalingMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in the target array.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param output defines the target array\r\n * @param offset defines the offset in the target array where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToArray(a: IMatrixLike, b: IMatrixLike, output: Float32Array | Array<number>, offset = 0): void {\r\n const m = a.asArray();\r\n const otherM = b.asArray();\r\n const tm0 = m[0],\r\n tm1 = m[1],\r\n tm2 = m[2],\r\n tm3 = m[3];\r\n const tm4 = m[4],\r\n tm5 = m[5],\r\n tm6 = m[6],\r\n tm7 = m[7];\r\n const tm8 = m[8],\r\n tm9 = m[9],\r\n tm10 = m[10],\r\n tm11 = m[11];\r\n const tm12 = m[12],\r\n tm13 = m[13],\r\n tm14 = m[14],\r\n tm15 = m[15];\r\n\r\n const om0 = otherM[0],\r\n om1 = otherM[1],\r\n om2 = otherM[2],\r\n om3 = otherM[3];\r\n const om4 = otherM[4],\r\n om5 = otherM[5],\r\n om6 = otherM[6],\r\n om7 = otherM[7];\r\n const om8 = otherM[8],\r\n om9 = otherM[9],\r\n om10 = otherM[10],\r\n om11 = otherM[11];\r\n const om12 = otherM[12],\r\n om13 = otherM[13],\r\n om14 = otherM[14],\r\n om15 = otherM[15];\r\n output[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;\r\n output[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;\r\n output[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;\r\n output[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;\r\n\r\n output[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;\r\n output[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;\r\n output[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;\r\n output[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;\r\n\r\n output[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;\r\n output[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;\r\n output[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;\r\n output[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;\r\n\r\n output[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;\r\n output[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;\r\n output[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;\r\n output[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in a third matrix.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param result defines the target matrix\r\n * @param offset defines the offset in the target matrix where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToRef(a: IMatrixLike, b: IMatrixLike, result: ThinMatrix, offset = 0): void {\r\n MultiplyMatricesToArray(a, b, result.asArray(), offset);\r\n result.updateFlag++;\r\n}\r\n\r\n/**\r\n * Populates the given array from the starting index with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param array defines the target array\r\n * @param offset defines the offset in the target array where to start storing values\r\n */\r\nexport function CopyMatrixToArray(matrix: IMatrixLike, array: Float32Array | Array<number>, offset: number = 0) {\r\n const source = matrix.asArray();\r\n array[offset] = source[0];\r\n array[offset + 1] = source[1];\r\n array[offset + 2] = source[2];\r\n array[offset + 3] = source[3];\r\n array[offset + 4] = source[4];\r\n array[offset + 5] = source[5];\r\n array[offset + 6] = source[6];\r\n array[offset + 7] = source[7];\r\n array[offset + 8] = source[8];\r\n array[offset + 9] = source[9];\r\n array[offset + 10] = source[10];\r\n array[offset + 11] = source[11];\r\n array[offset + 12] = source[12];\r\n array[offset + 13] = source[13];\r\n array[offset + 14] = source[14];\r\n array[offset + 15] = source[15];\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target array\r\n * @param source defines the source matrix\r\n * @param target defines the target array\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToRef(source: IMatrixLike, target: Float32Array | Array<number>) {\r\n // the inverse of a matrix is the transpose of cofactor matrix divided by the determinant\r\n const m = source.asArray();\r\n const m00 = m[0],\r\n m01 = m[1],\r\n m02 = m[2],\r\n m03 = m[3];\r\n const m10 = m[4],\r\n m11 = m[5],\r\n m12 = m[6],\r\n m13 = m[7];\r\n const m20 = m[8],\r\n m21 = m[9],\r\n m22 = m[10],\r\n m23 = m[11];\r\n const m30 = m[12],\r\n m31 = m[13],\r\n m32 = m[14],\r\n m33 = m[15];\r\n\r\n const det_22_33 = m22 * m33 - m32 * m23;\r\n const det_21_33 = m21 * m33 - m31 * m23;\r\n const det_21_32 = m21 * m32 - m31 * m22;\r\n const det_20_33 = m20 * m33 - m30 * m23;\r\n const det_20_32 = m20 * m32 - m22 * m30;\r\n const det_20_31 = m20 * m31 - m30 * m21;\r\n\r\n const cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);\r\n const cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);\r\n const cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);\r\n const cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);\r\n\r\n const det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;\r\n\r\n if (det === 0) {\r\n // Not invertible\r\n return false;\r\n }\r\n\r\n const detInv = 1 / det;\r\n const det_12_33 = m12 * m33 - m32 * m13;\r\n const det_11_33 = m11 * m33 - m31 * m13;\r\n const det_11_32 = m11 * m32 - m31 * m12;\r\n const det_10_33 = m10 * m33 - m30 * m13;\r\n const det_10_32 = m10 * m32 - m30 * m12;\r\n const det_10_31 = m10 * m31 - m30 * m11;\r\n const det_12_23 = m12 * m23 - m22 * m13;\r\n const det_11_23 = m11 * m23 - m21 * m13;\r\n const det_11_22 = m11 * m22 - m21 * m12;\r\n const det_10_23 = m10 * m23 - m20 * m13;\r\n const det_10_22 = m10 * m22 - m20 * m12;\r\n const det_10_21 = m10 * m21 - m20 * m11;\r\n\r\n const cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);\r\n const cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);\r\n const cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);\r\n const cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);\r\n\r\n const cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);\r\n const cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);\r\n const cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);\r\n const cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);\r\n\r\n const cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);\r\n const cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);\r\n const cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);\r\n const cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);\r\n\r\n target[0] = cofact_00 * detInv;\r\n target[1] = cofact_10 * detInv;\r\n target[2] = cofact_20 * detInv;\r\n target[3] = cofact_30 * detInv;\r\n target[4] = cofact_01 * detInv;\r\n target[5] = cofact_11 * detInv;\r\n target[6] = cofact_21 * detInv;\r\n target[7] = cofact_31 * detInv;\r\n target[8] = cofact_02 * detInv;\r\n target[9] = cofact_12 * detInv;\r\n target[10] = cofact_22 * detInv;\r\n target[11] = cofact_32 * detInv;\r\n target[12] = cofact_03 * detInv;\r\n target[13] = cofact_13 * detInv;\r\n target[14] = cofact_23 * detInv;\r\n target[15] = cofact_33 * detInv;\r\n\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"thinMath.matrix.functions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Maths/ThinMaths/thinMath.matrix.functions.ts"],"names":[],"mappings":"AAIA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;;AACzB,gBAAgB;AACT,gCAAe,GAAG,CAAC,CAAC;AAG/B,SAAS,aAAa,CAClB,MAAkB,EAClB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU,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SAAS,GAAG,GAAG,GAAG,SAAS,CAAC,CAAC;IAEzE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAEhC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IMatrixLike } from \"../math.like\";\r\nimport type { ThinMatrix } from \"./thinMath.matrix\";\r\n\r\n/** @internal */\r\nexport class MatrixManagement {\r\n /** @internal */\r\n static _UpdateFlagSeed = 0;\r\n}\r\n\r\nfunction SetMatrixData(\r\n result: ThinMatrix,\r\n m0: number,\r\n m1: number,\r\n m2: number,\r\n m3: number,\r\n m4: number,\r\n m5: number,\r\n m6: number,\r\n m7: number,\r\n m8: number,\r\n m9: number,\r\n m10: number,\r\n m11: number,\r\n m12: number,\r\n m13: number,\r\n m14: number,\r\n m15: number\r\n): void {\r\n const mat = result.asArray();\r\n mat[0] = m0;\r\n mat[1] = m1;\r\n mat[2] = m2;\r\n mat[3] = m3;\r\n mat[4] = m4;\r\n mat[5] = m5;\r\n mat[6] = m6;\r\n mat[7] = m7;\r\n mat[8] = m8;\r\n mat[9] = m9;\r\n mat[10] = m10;\r\n mat[11] = m11;\r\n mat[12] = m12;\r\n mat[13] = m13;\r\n mat[14] = m14;\r\n mat[15] = m15;\r\n\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Marks the given matrix as dirty\r\n * @param matrix defines the matrix to mark as dirty\r\n */\r\nexport function MarkAsDirty(matrix: ThinMatrix): void {\r\n matrix.updateFlag = MatrixManagement._UpdateFlagSeed++;\r\n}\r\n\r\n/**\r\n * Sets the given matrix to the identity matrix\r\n * @param result defines the target matrix\r\n */\r\nexport function IdentityMatrixToRef(result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new translation matrix.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the target matrix\r\n */\r\nexport function TranslationMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0);\r\n}\r\n\r\n/**\r\n * Creates a new scaling matrix.\r\n * @param x defines the scale factor on X axis\r\n * @param y defines the scale factor on Y axis\r\n * @param z defines the scale factor on Z axis\r\n * @param result defines the target matrix\r\n */\r\nexport function ScalingMatrixToRef(x: number, y: number, z: number, result: ThinMatrix): void {\r\n SetMatrixData(result, x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0);\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in the target array.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param output defines the target array\r\n * @param offset defines the offset in the target array where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToArray(a: IMatrixLike, b: IMatrixLike, output: Float32Array | Array<number>, offset = 0): void {\r\n const m = a.asArray();\r\n const otherM = b.asArray();\r\n const tm0 = m[0],\r\n tm1 = m[1],\r\n tm2 = m[2],\r\n tm3 = m[3];\r\n const tm4 = m[4],\r\n tm5 = m[5],\r\n tm6 = m[6],\r\n tm7 = m[7];\r\n const tm8 = m[8],\r\n tm9 = m[9],\r\n tm10 = m[10],\r\n tm11 = m[11];\r\n const tm12 = m[12],\r\n tm13 = m[13],\r\n tm14 = m[14],\r\n tm15 = m[15];\r\n\r\n const om0 = otherM[0],\r\n om1 = otherM[1],\r\n om2 = otherM[2],\r\n om3 = otherM[3];\r\n const om4 = otherM[4],\r\n om5 = otherM[5],\r\n om6 = otherM[6],\r\n om7 = otherM[7];\r\n const om8 = otherM[8],\r\n om9 = otherM[9],\r\n om10 = otherM[10],\r\n om11 = otherM[11];\r\n const om12 = otherM[12],\r\n om13 = otherM[13],\r\n om14 = otherM[14],\r\n om15 = otherM[15];\r\n output[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;\r\n output[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;\r\n output[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;\r\n output[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;\r\n\r\n output[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;\r\n output[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;\r\n output[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;\r\n output[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;\r\n\r\n output[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;\r\n output[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;\r\n output[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;\r\n output[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;\r\n\r\n output[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;\r\n output[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;\r\n output[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;\r\n output[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;\r\n}\r\n\r\n/**\r\n * Multiplies two matrices and stores the result in a third matrix.\r\n * @param a defines the first matrix\r\n * @param b defines the second matrix\r\n * @param result defines the target matrix\r\n * @param offset defines the offset in the target matrix where to store the result (0 by default)\r\n */\r\nexport function MultiplyMatricesToRef(a: IMatrixLike, b: IMatrixLike, result: ThinMatrix, offset = 0): void {\r\n MultiplyMatricesToArray(a, b, result.asArray(), offset);\r\n MarkAsDirty(result);\r\n}\r\n\r\n/**\r\n * Populates the given matrix with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param target defines the target matrix\r\n */\r\nexport function CopyMatrixToRef(matrix: IMatrixLike, target: ThinMatrix) {\r\n CopyMatrixToArray(matrix, target.asArray());\r\n MarkAsDirty(target);\r\n}\r\n\r\n/**\r\n * Populates the given array from the starting index with the current matrix values\r\n * @param matrix defines the source matrix\r\n * @param array defines the target array\r\n * @param offset defines the offset in the target array where to start storing values\r\n */\r\nexport function CopyMatrixToArray(matrix: IMatrixLike, array: Float32Array | Array<number>, offset: number = 0) {\r\n const source = matrix.asArray();\r\n array[offset] = source[0];\r\n array[offset + 1] = source[1];\r\n array[offset + 2] = source[2];\r\n array[offset + 3] = source[3];\r\n array[offset + 4] = source[4];\r\n array[offset + 5] = source[5];\r\n array[offset + 6] = source[6];\r\n array[offset + 7] = source[7];\r\n array[offset + 8] = source[8];\r\n array[offset + 9] = source[9];\r\n array[offset + 10] = source[10];\r\n array[offset + 11] = source[11];\r\n array[offset + 12] = source[12];\r\n array[offset + 13] = source[13];\r\n array[offset + 14] = source[14];\r\n array[offset + 15] = source[15];\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target matrix\r\n * @param source defines the source matrix\r\n * @param target defines the target matrix\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToRef(source: IMatrixLike, target: ThinMatrix) {\r\n const result = InvertMatrixToArray(source, target.asArray());\r\n\r\n if (result) {\r\n MarkAsDirty(target);\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Inverts the given matrix and stores the result in the target array\r\n * @param source defines the source matrix\r\n * @param target defines the target array\r\n * @returns true if the matrix was inverted successfully, false otherwise\r\n */\r\nexport function InvertMatrixToArray(source: IMatrixLike, target: Float32Array | Array<number>) {\r\n // the inverse of a matrix is the transpose of cofactor matrix divided by the determinant\r\n const m = source.asArray();\r\n const m00 = m[0],\r\n m01 = m[1],\r\n m02 = m[2],\r\n m03 = m[3];\r\n const m10 = m[4],\r\n m11 = m[5],\r\n m12 = m[6],\r\n m13 = m[7];\r\n const m20 = m[8],\r\n m21 = m[9],\r\n m22 = m[10],\r\n m23 = m[11];\r\n const m30 = m[12],\r\n m31 = m[13],\r\n m32 = m[14],\r\n m33 = m[15];\r\n\r\n const det_22_33 = m22 * m33 - m32 * m23;\r\n const det_21_33 = m21 * m33 - m31 * m23;\r\n const det_21_32 = m21 * m32 - m31 * m22;\r\n const det_20_33 = m20 * m33 - m30 * m23;\r\n const det_20_32 = m20 * m32 - m22 * m30;\r\n const det_20_31 = m20 * m31 - m30 * m21;\r\n\r\n const cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);\r\n const cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);\r\n const cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);\r\n const cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);\r\n\r\n const det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;\r\n\r\n if (det === 0) {\r\n // Not invertible\r\n return false;\r\n }\r\n\r\n const detInv = 1 / det;\r\n const det_12_33 = m12 * m33 - m32 * m13;\r\n const det_11_33 = m11 * m33 - m31 * m13;\r\n const det_11_32 = m11 * m32 - m31 * m12;\r\n const det_10_33 = m10 * m33 - m30 * m13;\r\n const det_10_32 = m10 * m32 - m30 * m12;\r\n const det_10_31 = m10 * m31 - m30 * m11;\r\n const det_12_23 = m12 * m23 - m22 * m13;\r\n const det_11_23 = m11 * m23 - m21 * m13;\r\n const det_11_22 = m11 * m22 - m21 * m12;\r\n const det_10_23 = m10 * m23 - m20 * m13;\r\n const det_10_22 = m10 * m22 - m20 * m12;\r\n const det_10_21 = m10 * m21 - m20 * m11;\r\n\r\n const cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);\r\n const cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);\r\n const cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);\r\n const cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);\r\n\r\n const cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);\r\n const cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);\r\n const cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);\r\n const cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);\r\n\r\n const cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);\r\n const cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);\r\n const cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);\r\n const cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);\r\n\r\n target[0] = cofact_00 * detInv;\r\n target[1] = cofact_10 * detInv;\r\n target[2] = cofact_20 * detInv;\r\n target[3] = cofact_30 * detInv;\r\n target[4] = cofact_01 * detInv;\r\n target[5] = cofact_11 * detInv;\r\n target[6] = cofact_21 * detInv;\r\n target[7] = cofact_31 * detInv;\r\n target[8] = cofact_02 * detInv;\r\n target[9] = cofact_12 * detInv;\r\n target[10] = cofact_22 * detInv;\r\n target[11] = cofact_32 * detInv;\r\n target[12] = cofact_03 * detInv;\r\n target[13] = cofact_13 * detInv;\r\n target[14] = cofact_23 * detInv;\r\n target[15] = cofact_33 * detInv;\r\n\r\n return true;\r\n}\r\n"]}
|
package/Maths/math.vector.d.ts
CHANGED
|
@@ -3298,7 +3298,6 @@ export declare class Matrix implements Tensor<Tuple<Tuple<number, 4>, 4>, Matrix
|
|
|
3298
3298
|
* Gets the precision of matrix computations
|
|
3299
3299
|
*/
|
|
3300
3300
|
static get Use64Bits(): boolean;
|
|
3301
|
-
private static _UpdateFlagSeed;
|
|
3302
3301
|
private static _IdentityReadOnly;
|
|
3303
3302
|
private _isIdentity;
|
|
3304
3303
|
private _isIdentityDirty;
|
package/Maths/math.vector.js
CHANGED
|
@@ -5,7 +5,7 @@ import { RegisterClass } from "../Misc/typeStore.js";
|
|
|
5
5
|
import { PerformanceConfigurator } from "../Engines/performanceConfigurator.js";
|
|
6
6
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
7
7
|
import { Clamp, Lerp, NormalizeRadians, RandomRange, WithinEpsilon } from "./math.scalar.functions.js";
|
|
8
|
-
import { CopyMatrixToArray,
|
|
8
|
+
import { CopyMatrixToArray, InvertMatrixToArray, MatrixManagement, MultiplyMatricesToArray } from "./ThinMaths/thinMath.matrix.functions.js";
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
10
|
const ExtractAsInt = (value) => {
|
|
11
11
|
return parseInt(value.toString().replace(/\W/g, ""));
|
|
@@ -5267,7 +5267,7 @@ export class Matrix {
|
|
|
5267
5267
|
* Update the updateFlag to indicate that the matrix has been updated
|
|
5268
5268
|
*/
|
|
5269
5269
|
markAsUpdated() {
|
|
5270
|
-
this.updateFlag =
|
|
5270
|
+
this.updateFlag = MatrixManagement._UpdateFlagSeed++;
|
|
5271
5271
|
this._isIdentity = false;
|
|
5272
5272
|
this._isIdentity3x2 = false;
|
|
5273
5273
|
this._isIdentityDirty = true;
|
|
@@ -5578,7 +5578,7 @@ export class Matrix {
|
|
|
5578
5578
|
Matrix.IdentityToRef(other);
|
|
5579
5579
|
return other;
|
|
5580
5580
|
}
|
|
5581
|
-
if (
|
|
5581
|
+
if (InvertMatrixToArray(this, other.asArray())) {
|
|
5582
5582
|
other.markAsUpdated();
|
|
5583
5583
|
}
|
|
5584
5584
|
else {
|
|
@@ -7477,7 +7477,6 @@ export class Matrix {
|
|
|
7477
7477
|
return result;
|
|
7478
7478
|
}
|
|
7479
7479
|
}
|
|
7480
|
-
Matrix._UpdateFlagSeed = 0;
|
|
7481
7480
|
Matrix._IdentityReadOnly = Matrix.Identity();
|
|
7482
7481
|
Object.defineProperties(Matrix.prototype, {
|
|
7483
7482
|
dimension: { value: [4, 4] },
|