makeGizmos method
dynamic
makeGizmos(
- dynamic tbCenter,
- dynamic tbRadius
Creates the rotation gizmos matching trackball center and radius @param {Vector3} tbCenter The trackball center @param {number} tbRadius The trackball radius
Implementation
makeGizmos(tbCenter, tbRadius) {
var curve = EllipseCurve(0, 0, tbRadius, tbRadius);
var points = curve.getPoints(_curvePts);
//geometry
var curveGeometry = BufferGeometry().setFromPoints(points);
//material
var curveMaterialX = LineBasicMaterial({'color': 0xff8080, 'fog': false, 'transparent': true, 'opacity': 0.6});
var curveMaterialY = LineBasicMaterial({'color': 0x80ff80, 'fog': false, 'transparent': true, 'opacity': 0.6});
var curveMaterialZ = LineBasicMaterial({'color': 0x8080ff, 'fog': false, 'transparent': true, 'opacity': 0.6});
//line
var gizmoX = Line(curveGeometry, curveMaterialX);
var gizmoY = Line(curveGeometry, curveMaterialY);
var gizmoZ = Line(curveGeometry, curveMaterialZ);
var 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.copy(_gizmoMatrixState0);
if (camera.zoom != 1) {
//adapt gizmos size to camera zoom
var 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);
}