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
- @param {Vector3} tbCenter The trackball center
Implementation
makeGizmos(tbCenter, tbRadius) {
var curve = new EllipseCurve(0, 0, tbRadius, tbRadius);
var points = curve.getPoints(this._curvePts);
//geometry
var curveGeometry = new BufferGeometry().setFromPoints(points);
//material
var curveMaterialX = new LineBasicMaterial(
{'color': 0xff8080, 'fog': false, 'transparent': true, 'opacity': 0.6});
var curveMaterialY = new LineBasicMaterial(
{'color': 0x80ff80, 'fog': false, 'transparent': true, 'opacity': 0.6});
var curveMaterialZ = new LineBasicMaterial(
{'color': 0x8080ff, 'fog': false, 'transparent': true, 'opacity': 0.6});
//line
var gizmoX = new Line(curveGeometry, curveMaterialX);
var gizmoY = new Line(curveGeometry, curveMaterialY);
var gizmoZ = new Line(curveGeometry, curveMaterialZ);
var rotation = Math.PI * 0.5;
gizmoX.rotation.x = rotation;
gizmoY.rotation.y = rotation;
//setting state
this
._gizmoMatrixState0
.identity()
.setPosition(tbCenter.x, tbCenter.y, tbCenter.z);
this._gizmoMatrixState.copy(this._gizmoMatrixState0);
if (this.camera.zoom != 1) {
//adapt gizmos size to camera zoom
var size = 1 / this.camera.zoom;
this._scaleMatrix.makeScale(size, size, size);
this
._translationMatrix
.makeTranslation(-tbCenter.x, -tbCenter.y, -tbCenter.z);
this
._gizmoMatrixState
.premultiply(this._translationMatrix)
.premultiply(this._scaleMatrix);
this
._translationMatrix
.makeTranslation(tbCenter.x, tbCenter.y, tbCenter.z);
this._gizmoMatrixState.premultiply(this._translationMatrix);
}
this._gizmoMatrixState.decompose(
this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);
this._gizmos.clear();
this._gizmos.add(gizmoX);
this._gizmos.add(gizmoY);
this._gizmos.add(gizmoZ);
}