@babylonjs/core 8.34.0 → 8.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/audioSceneComponent.d.ts +9 -5
- package/Audio/audioSceneComponent.js +1 -0
- package/Audio/audioSceneComponent.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +8 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +2 -2
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/camera.d.ts +4 -0
- package/Cameras/camera.js +18 -9
- package/Cameras/camera.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
- package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
- package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
- package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/pass.d.ts +11 -1
- package/FrameGraph/Passes/pass.js +11 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +1 -1
- package/FrameGraph/frameGraph.js +3 -6
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +3 -2
- package/FrameGraph/frameGraphTask.js +5 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.js +2 -2
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Lights/directionalLight.js +1 -4
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/pointLight.js +2 -5
- package/Lights/pointLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +9 -5
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.d.ts +14 -0
- package/Materials/PBR/openpbrMaterial.js +16 -0
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/clipPlaneMaterialHelper.js +11 -1
- package/Materials/clipPlaneMaterialHelper.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
- package/Materials/floatingOriginMatrixOverrides.js +14 -2
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Maths/math.like.d.ts +7 -2
- package/Maths/math.like.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +57 -15
- package/Maths/math.vector.functions.js +77 -8
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/decorators.d.ts +1 -1
- package/Misc/decorators.js.map +1 -1
- package/Misc/dumpTools.d.ts +20 -0
- package/Misc/dumpTools.js +60 -49
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/index.d.ts +1 -2
- package/Misc/index.js +1 -2
- package/Misc/index.js.map +1 -1
- package/Misc/sceneSerializer.js +4 -1
- package/Misc/sceneSerializer.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +8 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +25 -2
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
- package/Particles/Node/Blocks/Emitters/index.js +5 -4
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +36 -0
- package/Particles/Node/Blocks/systemBlock.js +84 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
- package/Particles/Node/nodeParticleBuildState.js +12 -22
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
- package/Particles/Node/nodeParticleSystemSet.helper.js +285 -110
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +1 -1
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +4 -0
- package/PostProcesses/postProcess.js +4 -0
- package/PostProcesses/postProcess.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
- package/PostProcesses/thinSSAO2PostProcess.js +18 -6
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js +4 -0
- package/Shaders/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrFuzzLayerData.js +1 -1
- package/Shaders/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
- package/Shaders/particles.vertex.js +1 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js +4 -0
- package/ShadersWGSL/ShadersInclude/openpbrCoatLayerData.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
- package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrFuzzLayerData.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +1 -1
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +7 -2
- package/scene.js +15 -8
- package/scene.js.map +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FloatingOriginCurrentScene } from "./floatingOriginMatrixOverrides.js";
|
|
2
|
+
import { Vector3 } from "../Maths/math.vector.js";
|
|
1
3
|
/** @internal */
|
|
2
4
|
export function AddClipPlaneUniforms(uniforms) {
|
|
3
5
|
if (uniforms.indexOf("vClipPlane") === -1) {
|
|
@@ -99,7 +101,15 @@ export function BindClipPlane(effect, primaryHolder, secondaryHolder) {
|
|
|
99
101
|
}
|
|
100
102
|
function SetClipPlane(effect, uniformName, clipPlane) {
|
|
101
103
|
if (clipPlane) {
|
|
102
|
-
|
|
104
|
+
// Original clipplane is using equation normal.dot(p) + d = 0
|
|
105
|
+
// Assume we have p' = p - offset, that means normal.dot(p') + d' = 0
|
|
106
|
+
// So to get the offset plane,
|
|
107
|
+
// normal.dot(p' + offset) + d = 0
|
|
108
|
+
// normal.dot(p') + normal.dot(offset) + d = 0
|
|
109
|
+
// -d' + normal.dot(offset) + d = 0
|
|
110
|
+
// d' = d + normal.dot(offset)
|
|
111
|
+
const offset = FloatingOriginCurrentScene.getScene()?.floatingOriginOffset || Vector3.ZeroReadOnly;
|
|
112
|
+
effect.setFloat4(uniformName, clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d + Vector3.Dot(clipPlane.normal, offset));
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
//# sourceMappingURL=clipPlaneMaterialHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipPlaneMaterialHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/clipPlaneMaterialHelper.ts"],"names":[],"mappings":"AAKA,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,QAAkB;IACnD,IAAI,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACxC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,iCAAiC,CAAC,aAAgC,EAAE,eAAkC,EAAE,OAAiB;IACrI,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,IAAI,eAAe,CA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AE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3G,CAAC;AACL,CAAC","sourcesContent":["import type { Effect } from \"./effect\";\r\nimport type { IClipPlanesHolder } from \"../Misc/interfaces/iClipPlanesHolder\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\n/** @internal */\r\nexport function AddClipPlaneUniforms(uniforms: string[]): void {\r\n if (uniforms.indexOf(\"vClipPlane\") === -1) {\r\n uniforms.push(\"vClipPlane\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane2\") === -1) {\r\n uniforms.push(\"vClipPlane2\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane3\") === -1) {\r\n uniforms.push(\"vClipPlane3\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane4\") === -1) {\r\n uniforms.push(\"vClipPlane4\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane5\") === -1) {\r\n uniforms.push(\"vClipPlane5\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane6\") === -1) {\r\n uniforms.push(\"vClipPlane6\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function PrepareStringDefinesForClipPlanes(primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder, defines: string[]): void {\r\n const clipPlane = !!(primaryHolder.clipPlane ?? secondaryHolder.clipPlane);\r\n const clipPlane2 = !!(primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2);\r\n const clipPlane3 = !!(primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3);\r\n const clipPlane4 = !!(primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4);\r\n const clipPlane5 = !!(primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5);\r\n const clipPlane6 = !!(primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6);\r\n\r\n if (clipPlane) {\r\n defines.push(\"#define CLIPPLANE\");\r\n }\r\n if (clipPlane2) {\r\n defines.push(\"#define CLIPPLANE2\");\r\n }\r\n if (clipPlane3) {\r\n defines.push(\"#define CLIPPLANE3\");\r\n }\r\n if (clipPlane4) {\r\n defines.push(\"#define CLIPPLANE4\");\r\n }\r\n if (clipPlane5) {\r\n defines.push(\"#define CLIPPLANE5\");\r\n }\r\n if (clipPlane6) {\r\n defines.push(\"#define CLIPPLANE6\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function PrepareDefinesForClipPlanes(primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder, defines: Record<string, any>): boolean {\r\n let changed = false;\r\n\r\n const clipPlane = !!(primaryHolder.clipPlane ?? secondaryHolder.clipPlane);\r\n const clipPlane2 = !!(primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2);\r\n const clipPlane3 = !!(primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3);\r\n const clipPlane4 = !!(primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4);\r\n const clipPlane5 = !!(primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5);\r\n const clipPlane6 = !!(primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6);\r\n\r\n // Do not factorize this code, it breaks browsers optimizations.\r\n if (defines[\"CLIPPLANE\"] !== clipPlane) {\r\n defines[\"CLIPPLANE\"] = clipPlane;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE2\"] !== clipPlane2) {\r\n defines[\"CLIPPLANE2\"] = clipPlane2;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE3\"] !== clipPlane3) {\r\n defines[\"CLIPPLANE3\"] = clipPlane3;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE4\"] !== clipPlane4) {\r\n defines[\"CLIPPLANE4\"] = clipPlane4;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE5\"] !== clipPlane5) {\r\n defines[\"CLIPPLANE5\"] = clipPlane5;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE6\"] !== clipPlane6) {\r\n defines[\"CLIPPLANE6\"] = clipPlane6;\r\n changed = true;\r\n }\r\n\r\n return changed;\r\n}\r\n\r\n/** @internal */\r\nexport function BindClipPlane(effect: Effect, primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder): void {\r\n let clipPlane = primaryHolder.clipPlane ?? secondaryHolder.clipPlane;\r\n SetClipPlane(effect, \"vClipPlane\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2;\r\n SetClipPlane(effect, \"vClipPlane2\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3;\r\n SetClipPlane(effect, \"vClipPlane3\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4;\r\n SetClipPlane(effect, \"vClipPlane4\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5;\r\n SetClipPlane(effect, \"vClipPlane5\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6;\r\n SetClipPlane(effect, \"vClipPlane6\", clipPlane);\r\n}\r\n\r\nfunction SetClipPlane(effect: Effect, uniformName: string, clipPlane: Nullable<Plane>): void {\r\n if (clipPlane) {\r\n effect.setFloat4(uniformName, clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"clipPlaneMaterialHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/clipPlaneMaterialHelper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAC,QAAkB;IACnD,IAAI,QAA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AS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnJ,CAAC;AACL,CAAC","sourcesContent":["import type { Effect } from \"./effect\";\r\nimport type { IClipPlanesHolder } from \"../Misc/interfaces/iClipPlanesHolder\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport { FloatingOriginCurrentScene } from \"./floatingOriginMatrixOverrides\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\n\r\n/** @internal */\r\nexport function AddClipPlaneUniforms(uniforms: string[]): void {\r\n if (uniforms.indexOf(\"vClipPlane\") === -1) {\r\n uniforms.push(\"vClipPlane\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane2\") === -1) {\r\n uniforms.push(\"vClipPlane2\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane3\") === -1) {\r\n uniforms.push(\"vClipPlane3\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane4\") === -1) {\r\n uniforms.push(\"vClipPlane4\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane5\") === -1) {\r\n uniforms.push(\"vClipPlane5\");\r\n }\r\n if (uniforms.indexOf(\"vClipPlane6\") === -1) {\r\n uniforms.push(\"vClipPlane6\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function PrepareStringDefinesForClipPlanes(primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder, defines: string[]): void {\r\n const clipPlane = !!(primaryHolder.clipPlane ?? secondaryHolder.clipPlane);\r\n const clipPlane2 = !!(primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2);\r\n const clipPlane3 = !!(primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3);\r\n const clipPlane4 = !!(primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4);\r\n const clipPlane5 = !!(primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5);\r\n const clipPlane6 = !!(primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6);\r\n\r\n if (clipPlane) {\r\n defines.push(\"#define CLIPPLANE\");\r\n }\r\n if (clipPlane2) {\r\n defines.push(\"#define CLIPPLANE2\");\r\n }\r\n if (clipPlane3) {\r\n defines.push(\"#define CLIPPLANE3\");\r\n }\r\n if (clipPlane4) {\r\n defines.push(\"#define CLIPPLANE4\");\r\n }\r\n if (clipPlane5) {\r\n defines.push(\"#define CLIPPLANE5\");\r\n }\r\n if (clipPlane6) {\r\n defines.push(\"#define CLIPPLANE6\");\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function PrepareDefinesForClipPlanes(primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder, defines: Record<string, any>): boolean {\r\n let changed = false;\r\n\r\n const clipPlane = !!(primaryHolder.clipPlane ?? secondaryHolder.clipPlane);\r\n const clipPlane2 = !!(primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2);\r\n const clipPlane3 = !!(primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3);\r\n const clipPlane4 = !!(primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4);\r\n const clipPlane5 = !!(primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5);\r\n const clipPlane6 = !!(primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6);\r\n\r\n // Do not factorize this code, it breaks browsers optimizations.\r\n if (defines[\"CLIPPLANE\"] !== clipPlane) {\r\n defines[\"CLIPPLANE\"] = clipPlane;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE2\"] !== clipPlane2) {\r\n defines[\"CLIPPLANE2\"] = clipPlane2;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE3\"] !== clipPlane3) {\r\n defines[\"CLIPPLANE3\"] = clipPlane3;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE4\"] !== clipPlane4) {\r\n defines[\"CLIPPLANE4\"] = clipPlane4;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE5\"] !== clipPlane5) {\r\n defines[\"CLIPPLANE5\"] = clipPlane5;\r\n changed = true;\r\n }\r\n if (defines[\"CLIPPLANE6\"] !== clipPlane6) {\r\n defines[\"CLIPPLANE6\"] = clipPlane6;\r\n changed = true;\r\n }\r\n\r\n return changed;\r\n}\r\n\r\n/** @internal */\r\nexport function BindClipPlane(effect: Effect, primaryHolder: IClipPlanesHolder, secondaryHolder: IClipPlanesHolder): void {\r\n let clipPlane = primaryHolder.clipPlane ?? secondaryHolder.clipPlane;\r\n SetClipPlane(effect, \"vClipPlane\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane2 ?? secondaryHolder.clipPlane2;\r\n SetClipPlane(effect, \"vClipPlane2\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane3 ?? secondaryHolder.clipPlane3;\r\n SetClipPlane(effect, \"vClipPlane3\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane4 ?? secondaryHolder.clipPlane4;\r\n SetClipPlane(effect, \"vClipPlane4\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane5 ?? secondaryHolder.clipPlane5;\r\n SetClipPlane(effect, \"vClipPlane5\", clipPlane);\r\n clipPlane = primaryHolder.clipPlane6 ?? secondaryHolder.clipPlane6;\r\n SetClipPlane(effect, \"vClipPlane6\", clipPlane);\r\n}\r\n\r\nfunction SetClipPlane(effect: Effect, uniformName: string, clipPlane: Nullable<Plane>): void {\r\n if (clipPlane) {\r\n // Original clipplane is using equation normal.dot(p) + d = 0\r\n // Assume we have p' = p - offset, that means normal.dot(p') + d' = 0\r\n // So to get the offset plane,\r\n // normal.dot(p' + offset) + d = 0\r\n // normal.dot(p') + normal.dot(offset) + d = 0\r\n // -d' + normal.dot(offset) + d = 0\r\n // d' = d + normal.dot(offset)\r\n const offset = FloatingOriginCurrentScene.getScene()?.floatingOriginOffset || Vector3.ZeroReadOnly;\r\n effect.setFloat4(uniformName, clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d + Vector3.Dot(clipPlane.normal, offset));\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Matrix } from "../Maths/math.vector.js";
|
|
1
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
2
|
import type { IMatrixLike, IVector3Like } from "../Maths/math.like.js";
|
|
3
3
|
import type { Scene } from "../scene.js";
|
|
4
4
|
import type { DeepImmutable } from "../types.js";
|
|
5
|
+
import type { Plane } from "../Maths/math.plane.js";
|
|
5
6
|
/**
|
|
6
7
|
* When rendering, each scene will reset this to ensure the correct floating origin offset is when overriding the below functions
|
|
7
8
|
*/
|
|
@@ -9,6 +10,8 @@ export declare const FloatingOriginCurrentScene: {
|
|
|
9
10
|
getScene: () => Scene | undefined;
|
|
10
11
|
eyeAtCamera: boolean;
|
|
11
12
|
};
|
|
13
|
+
export declare function OffsetViewToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike>;
|
|
14
|
+
export declare function OffsetClipPlaneToRef(offset: Vector3, plane: Plane, ref: Plane): Plane;
|
|
12
15
|
export declare function GetOffsetTransformMatrices(offset: IVector3Like, viewMatrices: Array<Matrix>, projectionMatrices: Array<Matrix>, length: number, resultArray: Float32Array): Float32Array;
|
|
13
16
|
export declare function GetFullOffsetViewProjectionToRef(offset: IVector3Like, viewMatrix: DeepImmutable<IMatrixLike>, projectionMatrix: DeepImmutable<IMatrixLike>, ref: IMatrixLike): DeepImmutable<IMatrixLike>;
|
|
14
17
|
export declare function ResetMatrixFunctions(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "../Materials/effect.js";
|
|
2
|
-
import { Matrix } from "../Maths/math.vector.js";
|
|
2
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
3
3
|
import { InvertMatrixToRef, MultiplyMatricesToRef } from "../Maths/ThinMaths/thinMath.matrix.functions.js";
|
|
4
4
|
import { UniformBuffer } from "./uniformBuffer.js";
|
|
5
5
|
const TempFinalMat = new Matrix();
|
|
@@ -30,7 +30,7 @@ function GetFullOffsetView(offset, viewMatrix, ref) {
|
|
|
30
30
|
InvertMatrixToRef(TempMat2, ref); // TempMat1 = offset view matrix
|
|
31
31
|
return ref;
|
|
32
32
|
}
|
|
33
|
-
function OffsetViewToRef(offset, view, ref) {
|
|
33
|
+
export function OffsetViewToRef(offset, view, ref) {
|
|
34
34
|
// When eye is not at camera, we cannot assume the translation of view matrix is at origin, so we perform full offset calculation
|
|
35
35
|
if (!FloatingOriginCurrentScene.eyeAtCamera) {
|
|
36
36
|
return GetFullOffsetView(offset, view, ref);
|
|
@@ -50,6 +50,18 @@ function OffsetViewProjectionToRef(offset, view, projection, ref) {
|
|
|
50
50
|
MultiplyMatricesToRef(OffsetViewToRef(offset, view, ref), projection, ref);
|
|
51
51
|
return ref;
|
|
52
52
|
}
|
|
53
|
+
export function OffsetClipPlaneToRef(offset, plane, ref) {
|
|
54
|
+
// Original clipplane is using equation normal.dot(p) + d = 0
|
|
55
|
+
// Assume we have p' = p - offset, that means normal.dot(p') + d' = 0
|
|
56
|
+
// So to get the offset plane,
|
|
57
|
+
// normal.dot(p' + offset) + d = 0
|
|
58
|
+
// normal.dot(p') + normal.dot(offset) + d = 0
|
|
59
|
+
// -d' + normal.dot(offset) + d = 0
|
|
60
|
+
// d' = d + normal.dot(offset)
|
|
61
|
+
ref.normal.copyFrom(plane.normal);
|
|
62
|
+
ref.d = plane.d + Vector3.Dot(plane.normal, offset);
|
|
63
|
+
return ref;
|
|
64
|
+
}
|
|
53
65
|
export function GetOffsetTransformMatrices(offset, viewMatrices, projectionMatrices, length, resultArray) {
|
|
54
66
|
for (let cascadeIndex = 0; cascadeIndex < length; ++cascadeIndex) {
|
|
55
67
|
GetFullOffsetViewProjectionToRef(offset, viewMatrices[cascadeIndex], projectionMatrices[cascadeIndex], Temp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CAAC,+BAA+B,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { Effect } from \"../Materials/effect\";\r\nimport { Matrix } from \"../Maths/math.vector\";\r\nimport type { IMatrixLike, IVector3Like } from \"../Maths/math.like\";\r\nimport { InvertMatrixToRef, MultiplyMatricesToRef } from \"../Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { UniformBuffer } from \"./uniformBuffer\";\r\n\r\nconst TempFinalMat: Matrix = new Matrix();\r\nconst TempMat1: Matrix = new Matrix();\r\nconst TempMat2: Matrix = new Matrix();\r\n\r\n/**\r\n * When rendering, each scene will reset this to ensure the correct floating origin offset is when overriding the below functions\r\n */\r\nexport const FloatingOriginCurrentScene = {\r\n getScene: () => undefined as Scene | undefined,\r\n eyeAtCamera: true, // When true, we can assume viewMatrix translation is at origin. Otherwise, we must do full offset calculations\r\n};\r\n\r\nfunction OffsetWorldToRef(offset: IVector3Like, world: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n const refArray = ref.asArray();\r\n const worldArray = world.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = worldArray[i];\r\n }\r\n refArray[12] -= offset.x;\r\n refArray[13] -= offset.y;\r\n refArray[14] -= offset.z;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction GetFullOffsetView(offset: IVector3Like, viewMatrix: DeepImmutable<IMatrixLike>, ref: IMatrixLike) {\r\n InvertMatrixToRef(viewMatrix, TempMat1); // TempMat1 = light world matrix (inverse of view)\r\n OffsetWorldToRef(offset, TempMat1, TempMat2); // TempMat2 = offset light world matrix\r\n InvertMatrixToRef(TempMat2, ref); // TempMat1 = offset view matrix\r\n return ref;\r\n}\r\n\r\nfunction OffsetViewToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // When eye is not at camera, we cannot assume the translation of view matrix is at origin, so we perform full offset calculation\r\n if (!FloatingOriginCurrentScene.eyeAtCamera) {\r\n return GetFullOffsetView(offset, view, ref);\r\n }\r\n const refArray = ref.asArray();\r\n const viewArray = view.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = viewArray[i];\r\n }\r\n refArray[12] = 0;\r\n refArray[13] = 0;\r\n refArray[14] = 0;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction OffsetViewProjectionToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, projection: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n MultiplyMatricesToRef(OffsetViewToRef(offset, view, ref), projection, ref);\r\n return ref;\r\n}\r\n\r\nexport function GetOffsetTransformMatrices(\r\n offset: IVector3Like,\r\n viewMatrices: Array<Matrix>,\r\n projectionMatrices: Array<Matrix>,\r\n length: number,\r\n resultArray: Float32Array\r\n): Float32Array {\r\n for (let cascadeIndex = 0; cascadeIndex < length; ++cascadeIndex) {\r\n GetFullOffsetViewProjectionToRef(offset, viewMatrices[cascadeIndex], projectionMatrices[cascadeIndex], TempMat1);\r\n TempMat1.copyToArray(resultArray, cascadeIndex * 16);\r\n }\r\n return resultArray;\r\n}\r\n\r\nfunction OffsetWorldViewToRef(offset: IVector3Like, worldView: DeepImmutable<IMatrixLike>, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // ( world * view ) * inverse ( view ) = world\r\n InvertMatrixToRef(view, TempMat1); // TempMat1 = inverseView\r\n MultiplyMatricesToRef(worldView, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetView ) = offsetWorldView\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewToRef(offset, view, TempMat2); // TempMat2 = offsetView\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nexport function GetFullOffsetViewProjectionToRef(\r\n offset: IVector3Like,\r\n viewMatrix: DeepImmutable<IMatrixLike>,\r\n projectionMatrix: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n GetFullOffsetView(offset, viewMatrix, TempMat2);\r\n MultiplyMatricesToRef(TempMat2, projectionMatrix, ref);\r\n return ref;\r\n}\r\n\r\nfunction OffsetWorldViewProjectionToRef(\r\n offset: IVector3Like,\r\n worldViewProjection: DeepImmutable<IMatrixLike>,\r\n viewProjection: DeepImmutable<IMatrixLike>,\r\n view: DeepImmutable<IMatrixLike>,\r\n projection: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n // ( world * view * projection ) * inverse(projection) * inverse(view) = world\r\n // ( world * view * projection ) * inverse (view * projection) = world\r\n InvertMatrixToRef(viewProjection, TempMat1); // TempMat1 = inverse (view * projection)\r\n MultiplyMatricesToRef(worldViewProjection, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetViewProjection) = offsetWorldViewProjection\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewProjectionToRef(offset, view, projection, TempMat2); // TempMat2 = offsetViewProjection\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nfunction GetOffsetMatrix(uniformName: string, mat: IMatrixLike): IMatrixLike {\r\n const scene = FloatingOriginCurrentScene.getScene();\r\n // Early out for scenes that don't have floatingOriginMode enabled\r\n // Effect.setMatrix will call pipelineContext.setMatrix. In WebGPU, this will in turn call ubo.updateMatrix. To avoid double offset, early out if mat is TempFinalMat\r\n if (!scene || TempFinalMat === mat) {\r\n return mat;\r\n }\r\n TempFinalMat.updateFlag = mat.updateFlag;\r\n const offset = scene.floatingOriginOffset;\r\n switch (uniformName) {\r\n case \"world\":\r\n return OffsetWorldToRef(offset, mat, TempFinalMat);\r\n case \"view\":\r\n return OffsetViewToRef(offset, mat, TempFinalMat);\r\n case \"worldView\":\r\n return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);\r\n case \"viewProjection\":\r\n return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n case \"worldViewProjection\":\r\n return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n default:\r\n return mat;\r\n }\r\n}\r\n\r\n// ---- Overriding the prototypes of effect and uniformBuffer's setMatrix functions ----\r\nconst UniformBufferInternal = UniformBuffer as any;\r\nconst EffectInternal = Effect as any;\r\nconst OriginalUpdateMatrixForUniform = UniformBufferInternal.prototype._updateMatrixForUniform;\r\nconst OriginalSetMatrix = Effect.prototype.setMatrix;\r\n\r\nexport function ResetMatrixFunctions() {\r\n Effect.prototype.setMatrix = OriginalSetMatrix;\r\n EffectInternal._setMatrixOverride = undefined;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = undefined;\r\n}\r\n\r\nexport function OverrideMatrixFunctions() {\r\n EffectInternal.prototype._setMatrixOverride = OriginalSetMatrix;\r\n EffectInternal.prototype.setMatrix = function (uniformName: string, matrix: IMatrixLike) {\r\n this._setMatrixOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n return this;\r\n };\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = function (uniformName: string, matrix: IMatrixLike) {\r\n this._updateMatrixForUniformOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"floatingOriginMat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AAC;IAChE,cAAc,CAAC,SAAS,CAAC,SAAS,GAAG,UAAU,WAAmB,EAAE,MAAmB;QACnF,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;IACF,qBAAqB,CAAC,SAAS,CAAC,+BAA+B,GAAG,8BAA8B,CAAC;IACjG,qBAAqB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAU,WAAmB,EAAE,MAAmB;QACxG,IAAI,CAAC,+BAA+B,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5F,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { Effect } from \"../Materials/effect\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { IMatrixLike, IVector3Like } from \"../Maths/math.like\";\r\nimport { InvertMatrixToRef, MultiplyMatricesToRef } from \"../Maths/ThinMaths/thinMath.matrix.functions\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport { UniformBuffer } from \"./uniformBuffer\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\n\r\nconst TempFinalMat: Matrix = new Matrix();\r\nconst TempMat1: Matrix = new Matrix();\r\nconst TempMat2: Matrix = new Matrix();\r\n\r\n/**\r\n * When rendering, each scene will reset this to ensure the correct floating origin offset is when overriding the below functions\r\n */\r\nexport const FloatingOriginCurrentScene = {\r\n getScene: () => undefined as Scene | undefined,\r\n eyeAtCamera: true, // When true, we can assume viewMatrix translation is at origin. Otherwise, we must do full offset calculations\r\n};\r\n\r\nfunction OffsetWorldToRef(offset: IVector3Like, world: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n const refArray = ref.asArray();\r\n const worldArray = world.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = worldArray[i];\r\n }\r\n refArray[12] -= offset.x;\r\n refArray[13] -= offset.y;\r\n refArray[14] -= offset.z;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction GetFullOffsetView(offset: IVector3Like, viewMatrix: DeepImmutable<IMatrixLike>, ref: IMatrixLike) {\r\n InvertMatrixToRef(viewMatrix, TempMat1); // TempMat1 = light world matrix (inverse of view)\r\n OffsetWorldToRef(offset, TempMat1, TempMat2); // TempMat2 = offset light world matrix\r\n InvertMatrixToRef(TempMat2, ref); // TempMat1 = offset view matrix\r\n return ref;\r\n}\r\n\r\nexport function OffsetViewToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // When eye is not at camera, we cannot assume the translation of view matrix is at origin, so we perform full offset calculation\r\n if (!FloatingOriginCurrentScene.eyeAtCamera) {\r\n return GetFullOffsetView(offset, view, ref);\r\n }\r\n const refArray = ref.asArray();\r\n const viewArray = view.asArray();\r\n for (let i = 0; i < 16; i++) {\r\n refArray[i] = viewArray[i];\r\n }\r\n refArray[12] = 0;\r\n refArray[13] = 0;\r\n refArray[14] = 0;\r\n ref.markAsUpdated();\r\n return ref;\r\n}\r\n\r\nfunction OffsetViewProjectionToRef(offset: IVector3Like, view: DeepImmutable<IMatrixLike>, projection: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n MultiplyMatricesToRef(OffsetViewToRef(offset, view, ref), projection, ref);\r\n return ref;\r\n}\r\n\r\nexport function OffsetClipPlaneToRef(offset: Vector3, plane: Plane, ref: Plane): Plane {\r\n // Original clipplane is using equation normal.dot(p) + d = 0\r\n // Assume we have p' = p - offset, that means normal.dot(p') + d' = 0\r\n // So to get the offset plane,\r\n // normal.dot(p' + offset) + d = 0\r\n // normal.dot(p') + normal.dot(offset) + d = 0\r\n // -d' + normal.dot(offset) + d = 0\r\n // d' = d + normal.dot(offset)\r\n ref.normal.copyFrom(plane.normal);\r\n ref.d = plane.d + Vector3.Dot(plane.normal, offset);\r\n return ref;\r\n}\r\n\r\nexport function GetOffsetTransformMatrices(\r\n offset: IVector3Like,\r\n viewMatrices: Array<Matrix>,\r\n projectionMatrices: Array<Matrix>,\r\n length: number,\r\n resultArray: Float32Array\r\n): Float32Array {\r\n for (let cascadeIndex = 0; cascadeIndex < length; ++cascadeIndex) {\r\n GetFullOffsetViewProjectionToRef(offset, viewMatrices[cascadeIndex], projectionMatrices[cascadeIndex], TempMat1);\r\n TempMat1.copyToArray(resultArray, cascadeIndex * 16);\r\n }\r\n return resultArray;\r\n}\r\n\r\nfunction OffsetWorldViewToRef(offset: IVector3Like, worldView: DeepImmutable<IMatrixLike>, view: DeepImmutable<IMatrixLike>, ref: Matrix): DeepImmutable<IMatrixLike> {\r\n // ( world * view ) * inverse ( view ) = world\r\n InvertMatrixToRef(view, TempMat1); // TempMat1 = inverseView\r\n MultiplyMatricesToRef(worldView, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetView ) = offsetWorldView\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewToRef(offset, view, TempMat2); // TempMat2 = offsetView\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nexport function GetFullOffsetViewProjectionToRef(\r\n offset: IVector3Like,\r\n viewMatrix: DeepImmutable<IMatrixLike>,\r\n projectionMatrix: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n GetFullOffsetView(offset, viewMatrix, TempMat2);\r\n MultiplyMatricesToRef(TempMat2, projectionMatrix, ref);\r\n return ref;\r\n}\r\n\r\nfunction OffsetWorldViewProjectionToRef(\r\n offset: IVector3Like,\r\n worldViewProjection: DeepImmutable<IMatrixLike>,\r\n viewProjection: DeepImmutable<IMatrixLike>,\r\n view: DeepImmutable<IMatrixLike>,\r\n projection: DeepImmutable<IMatrixLike>,\r\n ref: IMatrixLike\r\n): DeepImmutable<IMatrixLike> {\r\n // ( world * view * projection ) * inverse(projection) * inverse(view) = world\r\n // ( world * view * projection ) * inverse (view * projection) = world\r\n InvertMatrixToRef(viewProjection, TempMat1); // TempMat1 = inverse (view * projection)\r\n MultiplyMatricesToRef(worldViewProjection, TempMat1, TempMat2); // TempMat2 = world, TempMat1 can be reused\r\n\r\n // ( offsetWorld * offsetViewProjection) = offsetWorldViewProjection\r\n OffsetWorldToRef(offset, TempMat2, TempMat1); // TempMat1 = offsetWorld\r\n OffsetViewProjectionToRef(offset, view, projection, TempMat2); // TempMat2 = offsetViewProjection\r\n MultiplyMatricesToRef(TempMat1, TempMat2, ref);\r\n\r\n return ref;\r\n}\r\n\r\nfunction GetOffsetMatrix(uniformName: string, mat: IMatrixLike): IMatrixLike {\r\n const scene = FloatingOriginCurrentScene.getScene();\r\n // Early out for scenes that don't have floatingOriginMode enabled\r\n // Effect.setMatrix will call pipelineContext.setMatrix. In WebGPU, this will in turn call ubo.updateMatrix. To avoid double offset, early out if mat is TempFinalMat\r\n if (!scene || TempFinalMat === mat) {\r\n return mat;\r\n }\r\n TempFinalMat.updateFlag = mat.updateFlag;\r\n const offset = scene.floatingOriginOffset;\r\n switch (uniformName) {\r\n case \"world\":\r\n return OffsetWorldToRef(offset, mat, TempFinalMat);\r\n case \"view\":\r\n return OffsetViewToRef(offset, mat, TempFinalMat);\r\n case \"worldView\":\r\n return OffsetWorldViewToRef(offset, mat, scene.getViewMatrix(), TempFinalMat);\r\n case \"viewProjection\":\r\n return OffsetViewProjectionToRef(offset, scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n case \"worldViewProjection\":\r\n return OffsetWorldViewProjectionToRef(offset, mat, scene.getTransformMatrix(), scene.getViewMatrix(), scene.getProjectionMatrix(), TempFinalMat);\r\n default:\r\n return mat;\r\n }\r\n}\r\n\r\n// ---- Overriding the prototypes of effect and uniformBuffer's setMatrix functions ----\r\nconst UniformBufferInternal = UniformBuffer as any;\r\nconst EffectInternal = Effect as any;\r\nconst OriginalUpdateMatrixForUniform = UniformBufferInternal.prototype._updateMatrixForUniform;\r\nconst OriginalSetMatrix = Effect.prototype.setMatrix;\r\n\r\nexport function ResetMatrixFunctions() {\r\n Effect.prototype.setMatrix = OriginalSetMatrix;\r\n EffectInternal._setMatrixOverride = undefined;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = undefined;\r\n}\r\n\r\nexport function OverrideMatrixFunctions() {\r\n EffectInternal.prototype._setMatrixOverride = OriginalSetMatrix;\r\n EffectInternal.prototype.setMatrix = function (uniformName: string, matrix: IMatrixLike) {\r\n this._setMatrixOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n return this;\r\n };\r\n UniformBufferInternal.prototype._updateMatrixForUniformOverride = OriginalUpdateMatrixForUniform;\r\n UniformBufferInternal.prototype._updateMatrixForUniform = function (uniformName: string, matrix: IMatrixLike) {\r\n this._updateMatrixForUniformOverride(uniformName, GetOffsetMatrix(uniformName, matrix));\r\n };\r\n}\r\n"]}
|
package/Materials/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export * from "./materialHelper.functions.js";
|
|
|
41
41
|
export * from "./materialHelper.geometryrendering.js";
|
|
42
42
|
export * from "./materialStencilState.js";
|
|
43
43
|
export * from "./uv.defines.js";
|
|
44
|
+
export * from "./floatingOriginMatrixOverrides.js";
|
|
44
45
|
import "./material.decalMap.js";
|
|
45
46
|
export * from "../Shaders/default.fragment.js";
|
|
46
47
|
export * from "../Shaders/default.vertex.js";
|
package/Materials/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./materialHelper.functions.js";
|
|
|
42
42
|
export * from "./materialHelper.geometryrendering.js";
|
|
43
43
|
export * from "./materialStencilState.js";
|
|
44
44
|
export * from "./uv.defines.js";
|
|
45
|
+
export * from "./floatingOriginMatrixOverrides.js";
|
|
45
46
|
import "./material.decalMap.js";
|
|
46
47
|
// async-loaded shaders
|
|
47
48
|
// StandardMaterial
|
package/Materials/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAE7B,uBAAuB;AAEvB,mBAAmB;AACnB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAE9C,2BAA2B;AAC3B,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Background/index\";\r\nexport * from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,iCAAiC,CAAC;AAChD,OAAO,qBAAqB,CAAC;AAE7B,uBAAuB;AAEvB,mBAAmB;AACnB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAE9C,2BAA2B;AAC3B,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Background/index\";\r\nexport * from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nexport * from \"./floatingOriginMatrixOverrides\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
|
package/Maths/math.like.d.ts
CHANGED
|
@@ -29,11 +29,16 @@ export interface IVector3Like extends IVector2Like {
|
|
|
29
29
|
/**
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
|
-
export interface
|
|
32
|
+
export interface IDirtyFlagLike {
|
|
33
|
+
_isDirty?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export interface IVector3LikeInternal extends IDirtyFlagLike {
|
|
33
39
|
_x: number;
|
|
34
40
|
_y: number;
|
|
35
41
|
_z: number;
|
|
36
|
-
_isDirty?: boolean;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* @internal
|
package/Maths/math.like.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.like.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.like.ts"],"names":[],"mappings":"","sourcesContent":["import type { float, int, Tuple } from \"../types\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor3Like {\r\n r: float;\r\n g: float;\r\n b: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor4Like extends IColor3Like {\r\n a: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector2Like {\r\n x: float;\r\n y: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3Like extends IVector2Like {\r\n z: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3LikeInternal {\r\n _x: number;\r\n _y: number;\r\n _z: number;\r\n
|
|
1
|
+
{"version":3,"file":"math.like.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.like.ts"],"names":[],"mappings":"","sourcesContent":["import type { float, int, Tuple } from \"../types\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor3Like {\r\n r: float;\r\n g: float;\r\n b: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IColor4Like extends IColor3Like {\r\n a: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector2Like {\r\n x: float;\r\n y: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3Like extends IVector2Like {\r\n z: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IDirtyFlagLike {\r\n _isDirty?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector3LikeInternal extends IDirtyFlagLike {\r\n _x: number;\r\n _y: number;\r\n _z: number;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IVector4Like extends IVector3Like {\r\n w: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IQuaternionLike extends IVector3Like {\r\n w: float;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IPlaneLike {\r\n normal: IVector3Like;\r\n d: float;\r\n normalize(): void;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IMatrixLike {\r\n asArray(): Tuple<number, 16>;\r\n updateFlag: int;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface IViewportLike {\r\n x: float;\r\n y: float;\r\n width: float;\r\n height: float;\r\n}\r\n"]}
|
|
@@ -1,59 +1,101 @@
|
|
|
1
1
|
import type { DeepImmutable } from "../types.js";
|
|
2
|
-
import type { IVector2Like, IVector3Like } from "./math.like.js";
|
|
2
|
+
import type { IDirtyFlagLike, IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from "./math.like.js";
|
|
3
3
|
import { Quaternion, Vector3 } from "./math.vector.js";
|
|
4
|
-
import type { Vector4 } from "./math.vector.js";
|
|
5
4
|
/**
|
|
6
5
|
* Creates a string representation of the IVector2Like
|
|
7
6
|
* @param vector defines the IVector2Like to stringify
|
|
8
7
|
* @param decimalCount defines the number of decimals to use
|
|
9
8
|
* @returns a string with the IVector2Like coordinates.
|
|
10
9
|
*/
|
|
11
|
-
export declare function Vector2ToFixed(vector: IVector2Like
|
|
10
|
+
export declare function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string;
|
|
12
11
|
/**
|
|
13
12
|
* Computes the dot product of two IVector3Like objects.
|
|
14
13
|
* @param a defines the first vector
|
|
15
14
|
* @param b defines the second vector
|
|
16
15
|
* @returns the dot product
|
|
17
16
|
*/
|
|
18
|
-
export declare function Vector3Dot
|
|
17
|
+
export declare function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
18
|
+
/**
|
|
19
|
+
* Computes the squared length of the IVector3Like
|
|
20
|
+
* @param vector the vector to measure
|
|
21
|
+
* @returns the squared length of the vector
|
|
22
|
+
*/
|
|
23
|
+
export declare function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number;
|
|
24
|
+
/**
|
|
25
|
+
* Computes the length of the IVector3Like
|
|
26
|
+
* @param vector the vector to measure
|
|
27
|
+
* @returns the length of the vector
|
|
28
|
+
*/
|
|
29
|
+
export declare function Vector3Length(vector: DeepImmutable<IVector3Like>): number;
|
|
30
|
+
/**
|
|
31
|
+
* Computes the squared distance between the IVector3Like objects
|
|
32
|
+
* @param a defines the first vector
|
|
33
|
+
* @param b defines the second vector
|
|
34
|
+
* @returns the squared distance
|
|
35
|
+
*/
|
|
36
|
+
export declare function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
37
|
+
/**
|
|
38
|
+
* Computes the distance between the IVector3Like objects
|
|
39
|
+
* @param a defines the first vector
|
|
40
|
+
* @param b defines the second vector
|
|
41
|
+
* @returns the distance
|
|
42
|
+
*/
|
|
43
|
+
export declare function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number;
|
|
19
44
|
/**
|
|
20
45
|
* Sets the given floats into the result.
|
|
46
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
21
47
|
* @param x defines the x coordinate
|
|
22
48
|
* @param y defines the y coordinate
|
|
23
49
|
* @param z defines the z coordinate
|
|
24
50
|
* @param result defines the target vector
|
|
25
51
|
* @returns the result vector
|
|
26
52
|
*/
|
|
27
|
-
export declare function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T;
|
|
53
|
+
export declare function Vector3FromFloatsToRef<T extends IVector3Like & IDirtyFlagLike>(x: number, y: number, z: number, result: T): T;
|
|
28
54
|
/**
|
|
29
55
|
* Stores the scaled values of a vector into the result.
|
|
56
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
30
57
|
* @param a defines the source vector
|
|
31
58
|
* @param scale defines the scale factor
|
|
32
59
|
* @param result defines the target vector
|
|
33
60
|
* @returns the scaled vector
|
|
34
61
|
*/
|
|
35
|
-
export declare function Vector3ScaleToRef<T extends IVector3Like
|
|
62
|
+
export declare function Vector3ScaleToRef<T extends IVector3Like & IDirtyFlagLike>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T;
|
|
63
|
+
/**
|
|
64
|
+
* Scales the current vector values in place by a factor.
|
|
65
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
66
|
+
* @param vector defines the vector to scale
|
|
67
|
+
* @param scale defines the scale factor
|
|
68
|
+
* @returns the input scaled vector
|
|
69
|
+
*/
|
|
70
|
+
export declare function Vector3ScaleInPlace<T extends IVector3Like & IDirtyFlagLike>(vector: T, scale: number): T;
|
|
36
71
|
/**
|
|
37
|
-
* Creates a string representation of the
|
|
38
|
-
* @param vector defines the
|
|
72
|
+
* Creates a string representation of the IVector3Like
|
|
73
|
+
* @param vector defines the IVector3Like to stringify
|
|
39
74
|
* @param decimalCount defines the number of decimals to use
|
|
40
|
-
* @returns a string with the
|
|
75
|
+
* @returns a string with the IVector3Like coordinates.
|
|
76
|
+
*/
|
|
77
|
+
export declare function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string;
|
|
78
|
+
/**
|
|
79
|
+
* Computes the dot product of two IVector4Like objects
|
|
80
|
+
* @param a defines the first vector
|
|
81
|
+
* @param b defines the second vector
|
|
82
|
+
* @returns the dot product
|
|
41
83
|
*/
|
|
42
|
-
export declare function
|
|
84
|
+
export declare function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number;
|
|
43
85
|
/**
|
|
44
|
-
* Creates a string representation of the
|
|
45
|
-
* @param vector defines the
|
|
86
|
+
* Creates a string representation of the IVector4Like
|
|
87
|
+
* @param vector defines the IVector4Like to stringify
|
|
46
88
|
* @param decimalCount defines the number of decimals to use
|
|
47
|
-
* @returns a string with the
|
|
89
|
+
* @returns a string with the IVector4Like coordinates.
|
|
48
90
|
*/
|
|
49
|
-
export declare function Vector4ToFixed(vector:
|
|
91
|
+
export declare function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string;
|
|
50
92
|
/**
|
|
51
93
|
* Returns the angle in radians between two quaternions
|
|
52
94
|
* @param q1 defines the first quaternion
|
|
53
95
|
* @param q2 defines the second quaternion
|
|
54
96
|
* @returns the angle in radians between the two quaternions
|
|
55
97
|
*/
|
|
56
|
-
export declare function GetAngleBetweenQuaternions(q1: DeepImmutable<
|
|
98
|
+
export declare function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number;
|
|
57
99
|
/**
|
|
58
100
|
* Creates a quaternion from two direction vectors
|
|
59
101
|
* @param a defines the first direction vector
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Clamp } from "./math.scalar.functions.js";
|
|
2
2
|
import { Quaternion, Vector3 } from "./math.vector.js";
|
|
3
|
+
function SetDirtyFlag(x) {
|
|
4
|
+
if (x._isDirty !== undefined) {
|
|
5
|
+
x._isDirty = true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
3
8
|
/**
|
|
4
9
|
* Creates a string representation of the IVector2Like
|
|
5
10
|
* @param vector defines the IVector2Like to stringify
|
|
@@ -18,8 +23,46 @@ export function Vector2ToFixed(vector, decimalCount) {
|
|
|
18
23
|
export function Vector3Dot(a, b) {
|
|
19
24
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Computes the squared length of the IVector3Like
|
|
28
|
+
* @param vector the vector to measure
|
|
29
|
+
* @returns the squared length of the vector
|
|
30
|
+
*/
|
|
31
|
+
export function Vector3LengthSquared(vector) {
|
|
32
|
+
return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Computes the length of the IVector3Like
|
|
36
|
+
* @param vector the vector to measure
|
|
37
|
+
* @returns the length of the vector
|
|
38
|
+
*/
|
|
39
|
+
export function Vector3Length(vector) {
|
|
40
|
+
return Math.sqrt(Vector3LengthSquared(vector));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Computes the squared distance between the IVector3Like objects
|
|
44
|
+
* @param a defines the first vector
|
|
45
|
+
* @param b defines the second vector
|
|
46
|
+
* @returns the squared distance
|
|
47
|
+
*/
|
|
48
|
+
export function Vector3DistanceSquared(a, b) {
|
|
49
|
+
const x = b.x - a.x;
|
|
50
|
+
const y = b.y - a.y;
|
|
51
|
+
const z = b.z - a.z;
|
|
52
|
+
return x * x + y * y + z * z;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Computes the distance between the IVector3Like objects
|
|
56
|
+
* @param a defines the first vector
|
|
57
|
+
* @param b defines the second vector
|
|
58
|
+
* @returns the distance
|
|
59
|
+
*/
|
|
60
|
+
export function Vector3Distance(a, b) {
|
|
61
|
+
return Math.sqrt(Vector3DistanceSquared(a, b));
|
|
62
|
+
}
|
|
21
63
|
/**
|
|
22
64
|
* Sets the given floats into the result.
|
|
65
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
23
66
|
* @param x defines the x coordinate
|
|
24
67
|
* @param y defines the y coordinate
|
|
25
68
|
* @param z defines the z coordinate
|
|
@@ -30,10 +73,12 @@ export function Vector3FromFloatsToRef(x, y, z, result) {
|
|
|
30
73
|
result.x = x;
|
|
31
74
|
result.y = y;
|
|
32
75
|
result.z = z;
|
|
76
|
+
SetDirtyFlag(result);
|
|
33
77
|
return result;
|
|
34
78
|
}
|
|
35
79
|
/**
|
|
36
80
|
* Stores the scaled values of a vector into the result.
|
|
81
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
37
82
|
* @param a defines the source vector
|
|
38
83
|
* @param scale defines the scale factor
|
|
39
84
|
* @param result defines the target vector
|
|
@@ -43,22 +88,46 @@ export function Vector3ScaleToRef(a, scale, result) {
|
|
|
43
88
|
result.x = a.x * scale;
|
|
44
89
|
result.y = a.y * scale;
|
|
45
90
|
result.z = a.z * scale;
|
|
91
|
+
SetDirtyFlag(result);
|
|
46
92
|
return result;
|
|
47
93
|
}
|
|
48
94
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
95
|
+
* Scales the current vector values in place by a factor.
|
|
96
|
+
* Marks the result as dirty if an `_isDirty` flag is defined on the object.
|
|
97
|
+
* @param vector defines the vector to scale
|
|
98
|
+
* @param scale defines the scale factor
|
|
99
|
+
* @returns the input scaled vector
|
|
100
|
+
*/
|
|
101
|
+
export function Vector3ScaleInPlace(vector, scale) {
|
|
102
|
+
vector.x *= scale;
|
|
103
|
+
vector.y *= scale;
|
|
104
|
+
vector.z *= scale;
|
|
105
|
+
SetDirtyFlag(vector);
|
|
106
|
+
return vector;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Creates a string representation of the IVector3Like
|
|
110
|
+
* @param vector defines the IVector3Like to stringify
|
|
51
111
|
* @param decimalCount defines the number of decimals to use
|
|
52
|
-
* @returns a string with the
|
|
112
|
+
* @returns a string with the IVector3Like coordinates.
|
|
53
113
|
*/
|
|
54
114
|
export function Vector3ToFixed(vector, decimalCount) {
|
|
55
|
-
return `{X: ${vector.
|
|
115
|
+
return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Computes the dot product of two IVector4Like objects
|
|
119
|
+
* @param a defines the first vector
|
|
120
|
+
* @param b defines the second vector
|
|
121
|
+
* @returns the dot product
|
|
122
|
+
*/
|
|
123
|
+
export function Vector4Dot(a, b) {
|
|
124
|
+
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
|
56
125
|
}
|
|
57
126
|
/**
|
|
58
|
-
* Creates a string representation of the
|
|
59
|
-
* @param vector defines the
|
|
127
|
+
* Creates a string representation of the IVector4Like
|
|
128
|
+
* @param vector defines the IVector4Like to stringify
|
|
60
129
|
* @param decimalCount defines the number of decimals to use
|
|
61
|
-
* @returns a string with the
|
|
130
|
+
* @returns a string with the IVector4Like coordinates.
|
|
62
131
|
*/
|
|
63
132
|
export function Vector4ToFixed(vector, decimalCount) {
|
|
64
133
|
return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;
|
|
@@ -70,7 +139,7 @@ export function Vector4ToFixed(vector, decimalCount) {
|
|
|
70
139
|
* @returns the angle in radians between the two quaternions
|
|
71
140
|
*/
|
|
72
141
|
export function GetAngleBetweenQuaternions(q1, q2) {
|
|
73
|
-
return Math.acos(Clamp(
|
|
142
|
+
return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;
|
|
74
143
|
}
|
|
75
144
|
/**
|
|
76
145
|
* Creates a quaternion from two direction vectors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAA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AC;IAClD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { Clamp } from \"./math.scalar.functions\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { IVector2Like, IVector3Like } from \"./math.like\";\r\nimport { Quaternion, Vector3 } from \"./math.vector\";\r\nimport type { Vector4 } from \"./math.vector\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: IVector2Like, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot<T extends IVector3Like, U extends IVector3Like>(a: DeepImmutable<T>, b: DeepImmutable<U>) {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\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 vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the target vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like, ResultT extends IVector3Like>(a: DeepImmutable<T>, scale: number, result: ResultT): ResultT {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the Vector3\r\n * @param vector defines the Vector3 to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the Vector3 coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: Vector3, decimalCount: number): string {\r\n return `{X: ${vector._x.toFixed(decimalCount)} Y: ${vector._y.toFixed(decimalCount)} Z: ${vector._z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the Vector4\r\n * @param vector defines the Vector4 to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the Vector4 coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: Vector4, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Returns the angle in radians between two quaternions\r\n * @param q1 defines the first quaternion\r\n * @param q2 defines the second quaternion\r\n * @returns the angle in radians between the two quaternions\r\n */\r\nexport function GetAngleBetweenQuaternions(q1: DeepImmutable<Quaternion>, q2: DeepImmutable<Quaternion>): number {\r\n return Math.acos(Clamp(Quaternion.Dot(q1, q2))) * 2;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion {\r\n const result = new Quaternion();\r\n GetQuaternionFromDirectionsToRef(a, b, result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @param result defines the target quaternion\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT {\r\n const axis = Vector3.Cross(a, b);\r\n const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));\r\n Quaternion.RotationAxisToRef(axis, angle, result);\r\n return result;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpD,SAAS,YAAY,CAAC,CAAiB;IACnC,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAmC;IACpE,OAAO,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAmC;IAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;;;;GAKG;A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,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAoB,CAAmB,EAAE,CAAmB;IACnG,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,gCAAgC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAgD,CAAmB,EAAE,CAAmB,EAAE,MAAe;IACrJ,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { Clamp } from \"./math.scalar.functions\";\r\nimport type { DeepImmutable } from \"../types\";\r\nimport type { IDirtyFlagLike, IQuaternionLike, IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\nimport { Quaternion, Vector3 } from \"./math.vector\";\r\n\r\nfunction SetDirtyFlag(x: IDirtyFlagLike) {\r\n if (x._isDirty !== undefined) {\r\n x._isDirty = true;\r\n }\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * Marks the result as dirty if an `_isDirty` flag is defined on the object.\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 vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like & IDirtyFlagLike>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n SetDirtyFlag(result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * Marks the result as dirty if an `_isDirty` flag is defined on the object.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the target vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like & IDirtyFlagLike>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n SetDirtyFlag(result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * Marks the result as dirty if an `_isDirty` flag is defined on the object.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the input scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like & IDirtyFlagLike>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n SetDirtyFlag(vector);\r\n return vector;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Returns the angle in radians between two quaternions\r\n * @param q1 defines the first quaternion\r\n * @param q2 defines the second quaternion\r\n * @returns the angle in radians between the two quaternions\r\n */\r\nexport function GetAngleBetweenQuaternions(q1: DeepImmutable<IQuaternionLike>, q2: DeepImmutable<IQuaternionLike>): number {\r\n return Math.acos(Clamp(Vector4Dot(q1, q2))) * 2;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirections<T extends Vector3>(a: DeepImmutable<T>, b: DeepImmutable<T>): Quaternion {\r\n const result = new Quaternion();\r\n GetQuaternionFromDirectionsToRef(a, b, result);\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from two direction vectors\r\n * @param a defines the first direction vector\r\n * @param b defines the second direction vector\r\n * @param result defines the target quaternion\r\n * @returns the target quaternion\r\n */\r\nexport function GetQuaternionFromDirectionsToRef<T extends Vector3, ResultT extends Quaternion>(a: DeepImmutable<T>, b: DeepImmutable<T>, result: ResultT): ResultT {\r\n const axis = Vector3.Cross(a, b);\r\n const angle = Math.acos(Clamp(Vector3Dot(a, b), -1, 1));\r\n Quaternion.RotationAxisToRef(axis, angle, result);\r\n return result;\r\n}\r\n"]}
|
package/Meshes/mesh.js
CHANGED
|
@@ -2105,7 +2105,7 @@ export class Mesh extends AbstractMesh {
|
|
|
2105
2105
|
if (!instanceDataStorage.isFrozen &&
|
|
2106
2106
|
(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling ||
|
|
2107
2107
|
this._internalMeshDataInfo._effectiveMaterial.sideOrientation !== null ||
|
|
2108
|
-
this._internalMeshDataInfo._effectiveMaterial.
|
|
2108
|
+
this._internalMeshDataInfo._effectiveMaterial._twoSidedLighting)) {
|
|
2109
2109
|
// Note: if two sided lighting is enabled, we need to ensure that the normal will point in the right direction even if the determinant of the world matrix is negative
|
|
2110
2110
|
const mainDeterminant = effectiveMesh._getWorldMatrixDeterminant();
|
|
2111
2111
|
sideOrientation = this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this);
|