Skip to content

Commit e3a2676

Browse files
committed
fixes to model scale
1 parent daa0838 commit e3a2676

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ function updateSceneGraph(model, frameState) {
24782478
const modelMatrix = defined(model._clampedModelMatrix)
24792479
? model._clampedModelMatrix
24802480
: model.modelMatrix;
2481-
sceneGraph.updateModelMatrix(modelMatrix, frameState);
2481+
sceneGraph.updateModelMatrix(modelMatrix, model._computedScale, frameState);
24822482
model._updateModelMatrix = false;
24832483
}
24842484

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ ModelSceneGraph.prototype.initialize = function (model, components) {
275275
);
276276

277277
this._projectTo2D = model._projectTo2D;
278+
this._computedModelScale = model._computedScale;
278279
// TODO: 2DBoundingSphere?
279280

280281
// If the model has a height reference that modifies the model matrix,
@@ -283,6 +284,7 @@ ModelSceneGraph.prototype.initialize = function (model, components) {
283284
this._rootTransform = computeRootTransform(this, this._rootTransform);
284285
this._computedModelMatrix = computeModelMatrix(
285286
modelMatrix,
287+
this._computedModelScale,
286288
this._rootTransform,
287289
this._computedModelMatrix,
288290
);
@@ -390,13 +392,17 @@ function computeRootTransform(sceneGraph, result) {
390392
* @param {Matrix4} result
391393
* @returns {Matrix4}
392394
*/
393-
function computeModelMatrix(modelMatrix, rootTransform, result) {
394-
// TODO: include model scaling
395-
// modelMatrix = Matrix4.multiplyByUniformScale(
396-
// modelMatrix,
397-
// computedModelScale,
398-
// result,
399-
// );
395+
function computeModelMatrix(
396+
modelMatrix,
397+
computedModelScale,
398+
rootTransform,
399+
result,
400+
) {
401+
modelMatrix = Matrix4.multiplyByUniformScale(
402+
modelMatrix,
403+
computedModelScale,
404+
result,
405+
);
400406

401407
const transform = Matrix4.multiplyTransformation(
402408
modelMatrix,
@@ -767,11 +773,14 @@ ModelSceneGraph.prototype.update = function (frameState, updateForAnimations) {
767773

768774
ModelSceneGraph.prototype.updateModelMatrix = function (
769775
modelMatrix,
776+
computedScale,
770777
frameState,
771778
) {
772779
this._rootTransform = computeRootTransform(this, this._rootTransform);
780+
this._computedModelScale = computedScale;
773781
this._computedModelMatrix = computeModelMatrix(
774782
modelMatrix,
783+
this._computedModelScale,
775784
this._rootTransform,
776785
this._computedModelMatrix,
777786
);

0 commit comments

Comments
 (0)