@@ -224,9 +224,32 @@ class ModelInstance {
224224 * @returns {Matrix4 } The scaled relative instance transform.
225225 * @private
226226 */
227- getRelativeScaledTransform ( model , frameState , result ) {
227+ getRelativeScaledTransform ( model , frameState , useModelMatrix2D , result ) {
228+ let relativeTransform = this . _relativeTransform ;
229+ if ( useModelMatrix2D ) {
230+ const transform2D = Transforms . basisTo2D (
231+ frameState . mapProjection ,
232+ this . transform ,
233+ scratchTransform ,
234+ ) ;
235+ const translationRotationScale = scratchTranslationRotationScale ;
236+ translationRotationScale . translation = Cartesian3 . ZERO ;
237+ translationRotationScale . scale = Matrix4 . getScale (
238+ transform2D ,
239+ translationRotationScale . scale ,
240+ ) ;
241+
242+ const rotation = Matrix4 . getRotation ( transform2D , scratchRotation ) ;
243+ translationRotationScale . rotation = Quaternion . fromRotationMatrix (
244+ rotation ,
245+ translationRotationScale . rotation ,
246+ ) ;
247+ relativeTransform = Matrix4 . fromTranslationRotationScale (
248+ translationRotationScale ,
249+ ) ;
250+ }
228251 if ( ! model . ready || ! ( model . minimumPixelSize > 0 ) ) {
229- return this . _relativeTransform ;
252+ return relativeTransform ;
230253 }
231254 let scale = model . scale ;
232255 const radius = model . sceneGraph . rootBoundingSphere . radius ;
@@ -248,11 +271,7 @@ class ModelInstance {
248271 scale = ( model . minimumPixelSize * scaleInPixels ) / diameter ;
249272 }
250273
251- return Matrix4 . multiplyByUniformScale (
252- this . _relativeTransform ,
253- scale ,
254- result ,
255- ) ;
274+ return Matrix4 . multiplyByUniformScale ( relativeTransform , scale , result ) ;
256275 }
257276
258277 /**
0 commit comments