bytev-charts
Version:
基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;
60 lines (51 loc) • 2.28 kB
JavaScript
import _Object$create from "@babel/runtime-corejs2/core-js/object/create";
console.warn("THREE.NURBSCurve: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation.");
/**
* NURBS curve object
*
* Derives from Curve, overriding getPoint and getTangent.
*
* Implementation is based on (x, y [, z=0 [, w=1]]) control points with w=weight.
*
**/
THREE.NURBSCurve = function (degree, knots
/* array of reals */
, controlPoints
/* array of Vector(2|3|4) */
, startKnot
/* index in knots */
, endKnot
/* index in knots */
) {
THREE.Curve.call(this);
this.degree = degree;
this.knots = knots;
this.controlPoints = []; // Used by periodic NURBS to remove hidden spans
this.startKnot = startKnot || 0;
this.endKnot = endKnot || this.knots.length - 1;
for (var i = 0; i < controlPoints.length; ++i) {
// ensure Vector4 for control points
var point = controlPoints[i];
this.controlPoints[i] = new THREE.Vector4(point.x, point.y, point.z, point.w);
}
};
THREE.NURBSCurve.prototype = _Object$create(THREE.Curve.prototype);
THREE.NURBSCurve.prototype.constructor = THREE.NURBSCurve;
THREE.NURBSCurve.prototype.getPoint = function (t, optionalTarget) {
var point = optionalTarget || new THREE.Vector3();
var u = this.knots[this.startKnot] + t * (this.knots[this.endKnot] - this.knots[this.startKnot]); // linear mapping t->u
// following results in (wx, wy, wz, w) homogeneous point
var hpoint = THREE.NURBSUtils.calcBSplinePoint(this.degree, this.knots, this.controlPoints, u);
if (hpoint.w != 1.0) {
// project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
hpoint.divideScalar(hpoint.w);
}
return point.set(hpoint.x, hpoint.y, hpoint.z);
};
THREE.NURBSCurve.prototype.getTangent = function (t, optionalTarget) {
var tangent = optionalTarget || new THREE.Vector3();
var u = this.knots[0] + t * (this.knots[this.knots.length - 1] - this.knots[0]);
var ders = THREE.NURBSUtils.calcNURBSDerivatives(this.degree, this.knots, this.controlPoints, u, 1);
tangent.copy(ders[1]).normalize();
return tangent;
};