adam Posted October 21, 2016 Share Posted October 21, 2016 Shouldn't the lookAt function rotate the mesh so that the z axis points to the lookAt point? It appears to make the mesh look away from the target point. http://www.babylonjs-playground.com/#1CSVHO#9 http://www.babylonjs-playground.com/#1CSVHO#13 Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Author Share Posted October 21, 2016 I changed this line: targetPoint.subtractToRef(pos, dv); in AbstractMesh.lookAt to: pos.subtractToRef(targetPoint, dv); and it seems to work as I would expect it to: http://www.babylonjs-playground.com/#1CSVHO#11 Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Author Share Posted October 21, 2016 This works too (and makes more sense): http://www.babylonjs-playground.com/#1CSVHO#12 Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 21, 2016 Share Posted October 21, 2016 Hmmm! Maybe it depends which face is doing the look at. In this PG the pointy end points where expected. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted October 21, 2016 Share Posted October 21, 2016 Hm. I think LookAt is a very basic WegGL function, i should work straight away, i think the error is in the debuglayer, can you go back an color each face of the mesh, to proof the concept is working. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted October 21, 2016 Share Posted October 21, 2016 http://www.babylonjs-playground.com/#1CSVHO#15 Quote Link to comment Share on other sites More sharing options...
adam Posted October 21, 2016 Author Share Posted October 21, 2016 I don't think this is a bug. I just wasn't thinking of the default orientation of most models. Models almost always default to looking toward the negative Z (or negative Y in Blender). Quote Link to comment Share on other sites More sharing options...
Nabroski Posted October 21, 2016 Share Posted October 21, 2016 I think becourse your are counting the box.position in the loop it courses an strange behavior. the axis flip at some point. http://www.babylonjs-playground.com/#1CSVHO#16 http://www.babylonjs-playground.com/#1CSVHO#17 Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 22, 2017 Share Posted September 22, 2017 On 10/21/2016 at 8:51 AM, adam said: Shouldn't the lookAt function rotate the mesh so that the z axis points to the lookAt point? It appears to make the mesh look away from the target point. http://www.babylonjs-playground.com/#1CSVHO#9 http://www.babylonjs-playground.com/#1CSVHO#13 I am getting the too... Is this by Design or is the fix or workaround ??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 22, 2017 Share Posted September 22, 2017 Yo @adam how did you work this out... For now I just use a 'Parent Holder' and rotate that 180 on the Y... then I put my object (for me its a camera) inside that and it works perfect... Note I stick the camera inside a empty and move that around to stay in the spirit of Unity... There is no separate movement like cameraDirection and stuff... EVERYTHING in unity has a TRANSFORM... they always just move or rotate a transform whether that transform is on a camera or mesh does not matter... So for me (toolkit users) a transform is always a MESH. So when I want to get FUNKY with the camera... like a default third person camera controller I am writing I just treat the camera (or its holder to be more precise) just like a regular mesh and use the regular 'Transform' movement coding techniques I am learning from Unity type Game development... Quote Link to comment Share on other sites More sharing options...
adam Posted September 22, 2017 Author Share Posted September 22, 2017 I think I set yawCor to Math.PI when calling lookAt. https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1437 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.