Skip to content

Commit 4d6bb1e

Browse files
committed
fix model matrix for 2D draw command
1 parent eab030f commit 4d6bb1e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/engine/Source/Scene/Model/ModelDrawCommands.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import ModelFS from "../../Shaders/Model/ModelFS.js";
1414
import ModelUtility from "./ModelUtility.js";
1515
import DeveloperError from "../../Core/DeveloperError.js";
1616

17+
const modelMatrixScratch = new Matrix4();
18+
1719
/**
1820
* Internal functions to build draw commands for models.
1921
*
@@ -213,6 +215,17 @@ ModelDrawCommands.createCommandModelMatrix = function (
213215
}
214216

215217
if (sceneGraph.hasInstances) {
218+
if (use2D) {
219+
const inverseAxisCorrection = Matrix4.inverse(
220+
sceneGraph._axisCorrectionMatrix,
221+
modelMatrixScratch,
222+
);
223+
return Matrix4.multiplyTransformation(
224+
sceneGraph._computedModelMatrix2D,
225+
inverseAxisCorrection,
226+
result,
227+
);
228+
}
216229
return modelMatrix;
217230
}
218231

0 commit comments

Comments
 (0)