You can read here about gui in world coordinates
About 3d it worked same, but you have new problems.
1)You need to fix distance field shader. Shader worked in pixels not in meters so df font will be blurry
varying lowp vec2 var_texcoord0;
varying lowp vec4 var_face_color;
varying lowp vec4 var_outline_color;
varying lowp vec4 var_sdf_params;
uniform mediump sampler2D texture_sampler;
void main()
{
lowp float distance = texture2D(texture_sampler, var_texcoord0).x;
lowp float sdf_edge = var_sdf_params.x;
lowp float sdf_outline = var_sdf_params.y;
lowp float sdf_smoothing = var_sdf_params.z/100.0;
lowp float alpha = smoothstep(sdf_edge - sdf_smoothing, sdf_edge + sdf_smoothing, distance);
lowp float outline_alpha = smoothstep(sdf_outline - sdf_smoothing, sdf_outline + sdf_smoothing, distance);
lowp vec4 color = mix(var_outline_color, var_face_color, alpha);
gl_FragColor = color * outline_alpha;
}
2)you need enable depth test for gui in your shader. To avoid gui rendered on top of models
3)you need to enable depth write for gui, or make your own sort of gui nodes. To avoid far gui rendered on top of near gui.
4)About look at camera. You need convert camera rotation quaternion to euler.
player.camera.rotation_euler.x, player.camera.rotation_euler.y, player.camera.rotation_euler.z = COMMON.LUME.quat_to_euler_degrees(player.camera.rotation)
--[[
https://android.googlesource.com/platform/external/jmonkeyengine/+/59b2e6871c65f58fdad78cd7229c292f6a177578/engine/src/core/com/jme3/math/Quaternion.java
Convert a quaternion into euler angles (roll, pitch, yaw)
roll is rotation around x in radians (counterclockwise)
pitch is rotation around y in radians (counterclockwise)
yaw is rotation around z in radians (counterclockwise)
--]]
function lume.quat_to_euler_degrees(q)
-- Extract the quaternion components
local x, y, z, w = q.x, q.y, q.z, q.w
local sqw = w * w;
local sqx = x * x;
local sqy = y * y;
local sqz = z * z;
-- normalized is one, otherwise is correction factor
local unit = sqx + sqy + sqz + sqw
local test = x * y + z * w;
local roll, pitch, yaw
-- singularity at north pole
if (test > 0.499 * unit) then
roll = 2 * MATH_ATAN2(x, w);
pitch = PI_HALF;
yaw = 0;
--// singularity at south pole
elseif (test < -0.499 * unit) then
roll = -2 * MATH_ATAN2(x, w);
pitch = -PI_HALF;
yaw = 0;
else
roll = MATH_ATAN2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); -- roll or heading
pitch = MATH_ASIN(2 * test / unit); -- pitch or attitude
yaw = MATH_ATAN2(2 * x * w - 2 * y * z, -sqx + sqy - sqz + sqw); -- yaw or bank
end
--something wrong with names
--return roll, pitch, yaw
return MATH_DEG(yaw), MATH_DEG(roll), MATH_DEG(pitch)
end