提交 4ce780c4 编写于 作者: M Mugen87

Curves: Added type property

上级 458d7845
...@@ -63,7 +63,7 @@ var curveObject = new THREE.Line( geometry, material ); ...@@ -63,7 +63,7 @@ var curveObject = new THREE.Line( geometry, material );
<h3>[property:Boolean closed]</h3> <h3>[property:Boolean closed]</h3>
<div>The curve will loop back onto itself when this is true. False by default</div> <div>The curve will loop back onto itself when this is true. False by default</div>
<h3>[property:String type]</h3> <h3>[property:String cureType]</h3>
<div>Possible values are `centripetal` (default), `chordal` and `catmullrom`.</div> <div>Possible values are `centripetal` (default), `chordal` and `catmullrom`.</div>
<h3>[property:float tension]</h3> <h3>[property:float tension]</h3>
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
new THREE.Vector3( 60, -100, -60 ) new THREE.Vector3( 60, -100, -60 )
] ); ] );
closedSpline.type = 'catmullrom'; closedSpline.curveType = 'catmullrom';
closedSpline.closed = true; closedSpline.closed = true;
var extrudeSettings = { var extrudeSettings = {
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
new THREE.Vector3( 0, -40, 40 ) new THREE.Vector3( 0, -40, 40 )
] ); ] );
sampleClosedSpline.type = 'catmullrom'; sampleClosedSpline.curveType = 'catmullrom';
sampleClosedSpline.closed = true; sampleClosedSpline.closed = true;
// Keep a dictionary of Curve instances // Keep a dictionary of Curve instances
......
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
} }
var curve = new THREE.CatmullRomCurve3( positions ); var curve = new THREE.CatmullRomCurve3( positions );
curve.type = 'catmullrom'; curve.curveType = 'catmullrom';
curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( { curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( {
color: 0xff0000, color: 0xff0000,
opacity: 0.35, opacity: 0.35,
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
splines.uniform = curve; splines.uniform = curve;
curve = new THREE.CatmullRomCurve3( positions ); curve = new THREE.CatmullRomCurve3( positions );
curve.type = 'centripetal'; curve.curveType = 'centripetal';
curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( { curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( {
color: 0x00ff00, color: 0x00ff00,
opacity: 0.35, opacity: 0.35,
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
splines.centripetal = curve; splines.centripetal = curve;
curve = new THREE.CatmullRomCurve3( positions ); curve = new THREE.CatmullRomCurve3( positions );
curve.type = 'chordal'; curve.curveType = 'chordal';
curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( { curve.mesh = new THREE.Line( geometry.clone(), new THREE.LineBasicMaterial( {
color: 0x0000ff, color: 0x0000ff,
opacity: 0.35, opacity: 0.35,
......
...@@ -39,6 +39,8 @@ import { Matrix4 } from '../../math/Matrix4.js'; ...@@ -39,6 +39,8 @@ import { Matrix4 } from '../../math/Matrix4.js';
function Curve() { function Curve() {
this.type = 'Curve';
this.arcLengthDivisions = 200; this.arcLengthDivisions = 200;
} }
......
...@@ -17,8 +17,9 @@ function CurvePath() { ...@@ -17,8 +17,9 @@ function CurvePath() {
Curve.call( this ); Curve.call( this );
this.curves = []; this.type = 'CurvePath';
this.curves = [];
this.autoClose = false; // Automatically closes the path this.autoClose = false; // Automatically closes the path
} }
......
...@@ -9,6 +9,8 @@ import { ShapePath } from './ShapePath.js'; ...@@ -9,6 +9,8 @@ import { ShapePath } from './ShapePath.js';
function Font( data ) { function Font( data ) {
this.type = 'Font';
this.data = data; this.data = data;
} }
......
...@@ -11,6 +11,9 @@ import { CurvePath } from './CurvePath.js'; ...@@ -11,6 +11,9 @@ import { CurvePath } from './CurvePath.js';
function Path( points ) { function Path( points ) {
CurvePath.call( this ); CurvePath.call( this );
this.type = 'Path';
this.currentPoint = new Vector2(); this.currentPoint = new Vector2();
if ( points ) { if ( points ) {
......
...@@ -16,6 +16,8 @@ function Shape() { ...@@ -16,6 +16,8 @@ function Shape() {
Path.apply( this, arguments ); Path.apply( this, arguments );
this.type = 'Shape';
this.holes = []; this.holes = [];
} }
......
...@@ -9,6 +9,8 @@ import { ShapeUtils } from '../ShapeUtils.js'; ...@@ -9,6 +9,8 @@ import { ShapeUtils } from '../ShapeUtils.js';
function ShapePath() { function ShapePath() {
this.type = 'ShapePath';
this.subPaths = []; this.subPaths = [];
this.currentPath = null; this.currentPath = null;
......
...@@ -5,6 +5,8 @@ function ArcCurve( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { ...@@ -5,6 +5,8 @@ function ArcCurve( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
this.type = 'ArcCurve';
} }
ArcCurve.prototype = Object.create( EllipseCurve.prototype ); ArcCurve.prototype = Object.create( EllipseCurve.prototype );
......
...@@ -87,10 +87,13 @@ function CatmullRomCurve3( points ) { ...@@ -87,10 +87,13 @@ function CatmullRomCurve3( points ) {
Curve.call( this ); Curve.call( this );
this.type = 'CatmullRomCurve3';
if ( points.length < 2 ) console.warn( 'THREE.CatmullRomCurve3: Points array needs at least two entries.' ); if ( points.length < 2 ) console.warn( 'THREE.CatmullRomCurve3: Points array needs at least two entries.' );
this.points = points || []; this.points = points || [];
this.closed = false; this.closed = false;
this.curveType = 'centripetal';
} }
...@@ -150,10 +153,10 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) { ...@@ -150,10 +153,10 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
} }
if ( this.type === undefined || this.type === 'centripetal' || this.type === 'chordal' ) { if ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) {
// init Centripetal / Chordal Catmull-Rom // init Centripetal / Chordal Catmull-Rom
var pow = this.type === 'chordal' ? 0.5 : 0.25; var pow = this.curveType === 'chordal' ? 0.5 : 0.25;
var dt0 = Math.pow( p0.distanceToSquared( p1 ), pow ); var dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );
var dt1 = Math.pow( p1.distanceToSquared( p2 ), pow ); var dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );
var dt2 = Math.pow( p2.distanceToSquared( p3 ), pow ); var dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );
...@@ -167,7 +170,7 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) { ...@@ -167,7 +170,7 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
py.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 ); py.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 );
pz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 ); pz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 );
} else if ( this.type === 'catmullrom' ) { } else if ( this.curveType === 'catmullrom' ) {
var tension = this.tension !== undefined ? this.tension : 0.5; var tension = this.tension !== undefined ? this.tension : 0.5;
px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, tension ); px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, tension );
......
...@@ -7,6 +7,8 @@ function CubicBezierCurve( v0, v1, v2, v3 ) { ...@@ -7,6 +7,8 @@ function CubicBezierCurve( v0, v1, v2, v3 ) {
Curve.call( this ); Curve.call( this );
this.type = 'CubicBezierCurve';
this.v0 = v0; this.v0 = v0;
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -7,6 +7,8 @@ function CubicBezierCurve3( v0, v1, v2, v3 ) { ...@@ -7,6 +7,8 @@ function CubicBezierCurve3( v0, v1, v2, v3 ) {
Curve.call( this ); Curve.call( this );
this.type = 'CubicBezierCurve3';
this.v0 = v0; this.v0 = v0;
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -6,6 +6,8 @@ function EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockw ...@@ -6,6 +6,8 @@ function EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockw
Curve.call( this ); Curve.call( this );
this.type = 'EllipseCurve';
this.aX = aX; this.aX = aX;
this.aY = aY; this.aY = aY;
......
...@@ -6,6 +6,8 @@ function LineCurve( v1, v2 ) { ...@@ -6,6 +6,8 @@ function LineCurve( v1, v2 ) {
Curve.call( this ); Curve.call( this );
this.type = 'LineCurve';
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -6,6 +6,8 @@ function LineCurve3( v1, v2 ) { ...@@ -6,6 +6,8 @@ function LineCurve3( v1, v2 ) {
Curve.call( this ); Curve.call( this );
this.type = 'LineCurve3';
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -7,6 +7,8 @@ function QuadraticBezierCurve( v0, v1, v2 ) { ...@@ -7,6 +7,8 @@ function QuadraticBezierCurve( v0, v1, v2 ) {
Curve.call( this ); Curve.call( this );
this.type = 'QuadraticBezierCurve';
this.v0 = v0; this.v0 = v0;
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -7,6 +7,8 @@ function QuadraticBezierCurve3( v0, v1, v2 ) { ...@@ -7,6 +7,8 @@ function QuadraticBezierCurve3( v0, v1, v2 ) {
Curve.call( this ); Curve.call( this );
this.type = 'QuadraticBezierCurve3';
this.v0 = v0; this.v0 = v0;
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
......
...@@ -7,6 +7,8 @@ function SplineCurve( points /* array of Vector2 */ ) { ...@@ -7,6 +7,8 @@ function SplineCurve( points /* array of Vector2 */ ) {
Curve.call( this ); Curve.call( this );
this.type = 'SplineCurve';
this.points = ( points === undefined ) ? [] : points; this.points = ( points === undefined ) ? [] : points;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册