JohnK Posted November 8, 2016 Share Posted November 8, 2016 When trying to achieve a task involving matrices I found I did not get the expected results on my mesh. Exploring further and checking out values using using the console I found I was getting integers not floating point values when displaying individual elements of a matrix. This is the same in Firefox and Chrome. If it is not some sort of console error then the use of individual elements for calculations within BJS could not be right (but BJS works?). Here is a PG example that shows what I mean http://www.babylonjs-playground.com/#1ST43U#13 After the matrix is computed the first four elements of the matrix are displayed, but always show as 1, 0, 0, 0 The matrix is displaced and the values in this matrix are floats as you would expect. However cloning the matrix (and matrix.clone() accesses individual matrix elements) and displaying the clone results in displaying the clone as the identity matrix. I have tries BJS2.3 and BJS2.4 and the results are the same. Everything I have read on Float32Array seems to suggest that accessing individual elements of such a matrix using array notation, eg [ ] should work An image of such a set of results is shown below. What is happening? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted November 8, 2016 Share Posted November 8, 2016 __proto__: TypedArray Binary Age - in WebGL2 you can type float a = 1; or vec2 (1,2.9); We are already their If you coming from other programming languages its been implemented since decades. Quote Link to comment Share on other sites More sharing options...
adam Posted November 8, 2016 Share Posted November 8, 2016 At the time of cloning, the array is identity. You have to force it to compute the world matrix. http://www.babylonjs-playground.com/#1ST43U#14 jerome and JohnK 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted November 8, 2016 Share Posted November 8, 2016 Actually, each mesh world matrix is computed from each mesh position, rotation/quaternionRotation and scaling properties only every call to scene.render(). At the time you logged it in the console, it wasn't called yet. JohnK 1 Quote Link to comment Share on other sites More sharing options...
adam Posted November 8, 2016 Share Posted November 8, 2016 Right, that's why when he inspected the world matrix in the console he could see that it had been updated. 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.