makeGizmos method
void
makeGizmos(
- dynamic tbCenter,
- dynamic tbRadius
- Creates the rotation gizmos matching trackball center and radius
tbCenterThe trackball centertbRadiusThe trackball radius
Implementation
void makeGizmos(tbCenter, tbRadius) {
final curve = EllipseCurve(0, 0, tbRadius, tbRadius);
final points = curve.getPoints(_curvePts);
//geometry
final curveGeometry = BufferGeometry().setFromPoints(points);
//material
final curveMaterialX = LineBasicMaterial.fromMap({'color': 0xff8080, 'fog': false, 'transparent': true, 'opacity': 0.6});
final curveMaterialY = LineBasicMaterial.fromMap({'color': 0x80ff80, 'fog': false, 'transparent': true, 'opacity': 0.6});
final curveMaterialZ = LineBasicMaterial.fromMap({'color': 0x8080ff, 'fog': false, 'transparent': true, 'opacity': 0.6});
//line
final gizmoX = Line(curveGeometry, curveMaterialX);
final gizmoY = Line(curveGeometry, curveMaterialY);
final gizmoZ = Line(curveGeometry, curveMaterialZ);
const rotation = math.pi * 0.5;
gizmoX.rotation.x = rotation;
gizmoY.rotation.y = rotation;
//setting state
_gizmoMatrixState0.identity().setPosition(tbCenter.x, tbCenter.y, tbCenter.z);
_gizmoMatrixState.setFrom(_gizmoMatrixState0);
if (camera.zoom != 1) {
//adapt gizmos size to camera zoom
final size = 1 / camera.zoom;
_scaleMatrix.makeScale(size, size, size);
_translationMatrix.makeTranslation(-tbCenter.x, -tbCenter.y, -tbCenter.z);
_gizmoMatrixState.premultiply(_translationMatrix).premultiply(_scaleMatrix);
_translationMatrix.makeTranslation(tbCenter.x, tbCenter.y, tbCenter.z);
_gizmoMatrixState.premultiply(_translationMatrix);
}
_gizmoMatrixState.decompose(
_gizmos.position, _gizmos.quaternion, _gizmos.scale);
_gizmos.clear();
_gizmos.add(gizmoX);
_gizmos.add(gizmoY);
_gizmos.add(gizmoZ);
}