Why the gizmo can implement this effect ? And How Can I implement it ?
This is the relevant code from the Editor which does the gizmo scaling:
// scale to screen space
if (camera.camera.projection === pc.PROJECTION_PERSPECTIVE) {
var dot = vecA.copy(posGizmo).sub(posCamera).dot(camera.forward);
var denom = 1280 / (2 * Math.tan(camera.camera.fov * pc.math.DEG_TO_RAD / 2));
scale = Math.max(0.0001, (dot / denom) * 150) * GIZMO_SIZE;
} else {
scale = camera.camera.orthoHeight / 3 * GIZMO_SIZE;
}
gizmo.setLocalScale(scale, scale, scale);
You should be able to do something similar to this.
2 Likes
Oh I see, thank you, vaios!