yokewang Posted January 3, 2018 Share Posted January 3, 2018 I want to set the _worldMatrix directly instead of calling computeWorldMatrix from position/scale/rotation. (For performance issue) But the _worldMatrix will be updated when the rendering system calls computeWorldMatrix internally. So, I have to use below code to prevent computeWorldMatrix. Quote myMesh._worldMatrix = matrix; (<any>myMesh)._isWorldMatrixFrozen = true; But I am not sure If this is the correct way. Thanks. Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 3, 2018 Share Posted January 3, 2018 Instead of accessing isWorldMatrixFrozen directly, you could call myMesh.freezeWorldMatrix(); There is no setter to the world matrix (as far as I know), so technically, the only way to do this is to set it the way you do. But why not set the transformation once, have the matrix calculated and then freeze it? wouldn't it be better? Quote Link to comment Share on other sites More sharing options...
yokewang Posted January 4, 2018 Author Share Posted January 4, 2018 Thanks RaananW, I have first tried freezeWorldMatrix, but it calls computeWorldMatrix internally. And I find computeWorldMatrix will be very slow when scaling. https://playground.babylonjs.com/#BU5QQR#4 it's fast with out scaling. 234ms for my computer. https://playground.babylonjs.com/#BU5QQR#3 it's very slow when scaling. 2607ms . And when size change to 30, it will be timeout. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.