Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
6b53488f
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b53488f
编写于
5月 08, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
*Path: Implemented Object.assign(). See #8838.
上级
d330d5b6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
503 addition
and
533 deletion
+503
-533
src/extras/core/CurvePath.js
src/extras/core/CurvePath.js
+84
-96
src/extras/core/Font.js
src/extras/core/Font.js
+2
-4
src/extras/core/Path.js
src/extras/core/Path.js
+389
-405
src/extras/core/Shape.js
src/extras/core/Shape.js
+28
-28
未找到文件。
src/extras/core/CurvePath.js
浏览文件 @
6b53488f
...
@@ -16,24 +16,17 @@ THREE.CurvePath = function () {
...
@@ -16,24 +16,17 @@ THREE.CurvePath = function () {
};
};
THREE
.
CurvePath
.
prototype
=
Object
.
create
(
THREE
.
Curve
.
prototype
);
THREE
.
CurvePath
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Curve
.
prototype
),
{
THREE
.
CurvePath
.
prototype
.
constructor
=
THREE
.
CurvePath
;
THREE
.
CurvePath
.
prototype
.
add
=
function
(
curve
)
{
constructor
:
THREE
.
CurvePath
,
add
:
function
(
curve
)
{
this
.
curves
.
push
(
curve
);
this
.
curves
.
push
(
curve
);
};
},
/*
closePath
:
function
()
{
THREE.CurvePath.prototype.checkConnection = function() {
// TODO
// If the ending of curve is not connected to the starting
// or the next curve, then, this is not a real path
};
*/
THREE
.
CurvePath
.
prototype
.
closePath
=
function
()
{
// TODO Test
// TODO Test
// and verify for vector3 (needs to implement equals)
// and verify for vector3 (needs to implement equals)
...
@@ -47,18 +40,18 @@ THREE.CurvePath.prototype.closePath = function() {
...
@@ -47,18 +40,18 @@ THREE.CurvePath.prototype.closePath = function() {
}
}
};
},
// To get accurate point with reference to
// To get accurate point with reference to
// entire path distance at time t,
// entire path distance at time t,
// following has to be done:
// following has to be done:
// 1. Length of each sub path have to be known
// 1. Length of each sub path have to be known
// 2. Locate and identify type of curve
// 2. Locate and identify type of curve
// 3. Get t for the curve
// 3. Get t for the curve
// 4. Return curve.getPointAt(t')
// 4. Return curve.getPointAt(t')
THREE
.
CurvePath
.
prototype
.
getPoint
=
function
(
t
)
{
getPoint
:
function
(
t
)
{
var
d
=
t
*
this
.
getLength
();
var
d
=
t
*
this
.
getLength
();
var
curveLengths
=
this
.
getCurveLengths
();
var
curveLengths
=
this
.
getCurveLengths
();
...
@@ -87,28 +80,23 @@ THREE.CurvePath.prototype.getPoint = function( t ) {
...
@@ -87,28 +80,23 @@ THREE.CurvePath.prototype.getPoint = function( t ) {
// loop where sum != 0, sum > d , sum+1 <d
// loop where sum != 0, sum > d , sum+1 <d
};
},
/*
THREE.CurvePath.prototype.getTangent = function( t ) {
};
*/
// We cannot use the default THREE.Curve getPoint() with getLength() because in
// We cannot use the default THREE.Curve getPoint() with getLength() because in
// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
// getPoint() depends on getLength
// getPoint() depends on getLength
THREE
.
CurvePath
.
prototype
.
getLength
=
function
()
{
getLength
:
function
()
{
var
lens
=
this
.
getCurveLengths
();
var
lens
=
this
.
getCurveLengths
();
return
lens
[
lens
.
length
-
1
];
return
lens
[
lens
.
length
-
1
];
};
},
// Compute lengths and cache them
// Compute lengths and cache them
// We cannot overwrite getLengths() because UtoT mapping uses it.
// We cannot overwrite getLengths() because UtoT mapping uses it.
THREE
.
CurvePath
.
prototype
.
getCurveLengths
=
function
()
{
getCurveLengths
:
function
()
{
// We use cache values if curves and cache array are same length
// We use cache values if curves and cache array are same length
...
@@ -134,33 +122,31 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
...
@@ -134,33 +122,31 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
return
lengths
;
return
lengths
;
};
},
/**************************************************************
/**************************************************************
* Create Geometries Helpers
* Create Geometries Helpers
**************************************************************/
**************************************************************/
/// Generate geometry from path points (for Line or Points objects)
/// Generate geometry from path points (for Line or Points objects)
THREE
.
CurvePath
.
prototype
.
createPointsGeometry
=
function
(
divisions
)
{
createPointsGeometry
:
function
(
divisions
)
{
var
pts
=
this
.
getPoints
(
divisions
);
var
pts
=
this
.
getPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
return
this
.
createGeometry
(
pts
);
};
},
// Generate geometry from equidistant sampling along the path
// Generate geometry from equidistant sampling along the path
THREE
.
CurvePath
.
prototype
.
createSpacedPointsGeometry
=
function
(
divisions
)
{
createSpacedPointsGeometry
:
function
(
divisions
)
{
var
pts
=
this
.
getSpacedPoints
(
divisions
);
var
pts
=
this
.
getSpacedPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
return
this
.
createGeometry
(
pts
);
};
},
THREE
.
CurvePath
.
prototype
.
createGeometry
=
function
(
points
)
{
createGeometry
:
function
(
points
)
{
var
geometry
=
new
THREE
.
Geometry
();
var
geometry
=
new
THREE
.
Geometry
();
...
@@ -173,4 +159,6 @@ THREE.CurvePath.prototype.createGeometry = function( points ) {
...
@@ -173,4 +159,6 @@ THREE.CurvePath.prototype.createGeometry = function( points ) {
return
geometry
;
return
geometry
;
};
}
}
);
src/extras/core/Font.js
浏览文件 @
6b53488f
...
@@ -9,9 +9,7 @@ THREE.Font = function ( data ) {
...
@@ -9,9 +9,7 @@ THREE.Font = function ( data ) {
};
};
THREE
.
Font
.
prototype
=
{
Object
.
assign
(
THREE
.
Font
.
prototype
,
{
constructor
:
THREE
.
Font
,
generateShapes
:
function
(
text
,
size
,
divisions
)
{
generateShapes
:
function
(
text
,
size
,
divisions
)
{
...
@@ -163,4 +161,4 @@ THREE.Font.prototype = {
...
@@ -163,4 +161,4 @@ THREE.Font.prototype = {
}
}
};
}
)
;
src/extras/core/Path.js
浏览文件 @
6b53488f
...
@@ -18,15 +18,16 @@ THREE.Path = function ( points ) {
...
@@ -18,15 +18,16 @@ THREE.Path = function ( points ) {
};
};
THREE
.
Path
.
prototype
=
Object
.
create
(
THREE
.
CurvePath
.
prototype
);
THREE
.
Path
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
CurvePath
.
prototype
),
{
THREE
.
Path
.
prototype
.
constructor
=
THREE
.
Path
;
// TODO Clean up PATH API
constructor
:
THREE
.
Path
,
// Create path using straight lines to connect all points
// TODO Clean up PATH API
// - vectors: array of Vector2
THREE
.
Path
.
prototype
.
fromPoints
=
function
(
vectors
)
{
// Create path using straight lines to connect all points
// - vectors: array of Vector2
fromPoints
:
function
(
vectors
)
{
this
.
moveTo
(
vectors
[
0
].
x
,
vectors
[
0
].
y
);
this
.
moveTo
(
vectors
[
0
].
x
,
vectors
[
0
].
y
);
...
@@ -36,17 +37,15 @@ THREE.Path.prototype.fromPoints = function ( vectors ) {
...
@@ -36,17 +37,15 @@ THREE.Path.prototype.fromPoints = function ( vectors ) {
}
}
};
},
// startPath() endPath()?
THREE
.
Path
.
prototype
.
moveTo
=
function
(
x
,
y
)
{
moveTo
:
function
(
x
,
y
)
{
this
.
actions
.
push
(
{
action
:
'
moveTo
'
,
args
:
[
x
,
y
]
}
);
this
.
actions
.
push
(
{
action
:
'
moveTo
'
,
args
:
[
x
,
y
]
}
);
};
},
THREE
.
Path
.
prototype
.
lineTo
=
function
(
x
,
y
)
{
lineTo
:
function
(
x
,
y
)
{
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
...
@@ -58,9 +57,9 @@ THREE.Path.prototype.lineTo = function ( x, y ) {
...
@@ -58,9 +57,9 @@ THREE.Path.prototype.lineTo = function ( x, y ) {
this
.
actions
.
push
(
{
action
:
'
lineTo
'
,
args
:
[
x
,
y
]
}
);
this
.
actions
.
push
(
{
action
:
'
lineTo
'
,
args
:
[
x
,
y
]
}
);
};
},
THREE
.
Path
.
prototype
.
quadraticCurveTo
=
function
(
aCPx
,
aCPy
,
aX
,
aY
)
{
quadraticCurveTo
:
function
(
aCPx
,
aCPy
,
aX
,
aY
)
{
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
...
@@ -77,9 +76,9 @@ THREE.Path.prototype.quadraticCurveTo = function( aCPx, aCPy, aX, aY ) {
...
@@ -77,9 +76,9 @@ THREE.Path.prototype.quadraticCurveTo = function( aCPx, aCPy, aX, aY ) {
this
.
actions
.
push
(
{
action
:
'
quadraticCurveTo
'
,
args
:
[
aCPx
,
aCPy
,
aX
,
aY
]
}
);
this
.
actions
.
push
(
{
action
:
'
quadraticCurveTo
'
,
args
:
[
aCPx
,
aCPy
,
aX
,
aY
]
}
);
};
},
THREE
.
Path
.
prototype
.
bezierCurveTo
=
function
(
aCP1x
,
aCP1y
,
aCP2x
,
aCP2y
,
aX
,
aY
)
{
bezierCurveTo
:
function
(
aCP1x
,
aCP1y
,
aCP2x
,
aCP2y
,
aX
,
aY
)
{
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
...
@@ -97,9 +96,9 @@ THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y, aCP2x, aCP2y, aX, a
...
@@ -97,9 +96,9 @@ THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y, aCP2x, aCP2y, aX, a
this
.
actions
.
push
(
{
action
:
'
bezierCurveTo
'
,
args
:
[
aCP1x
,
aCP1y
,
aCP2x
,
aCP2y
,
aX
,
aY
]
}
);
this
.
actions
.
push
(
{
action
:
'
bezierCurveTo
'
,
args
:
[
aCP1x
,
aCP1y
,
aCP2x
,
aCP2y
,
aX
,
aY
]
}
);
};
},
THREE
.
Path
.
prototype
.
splineThru
=
function
(
pts
/*Array of Vector*/
)
{
splineThru
:
function
(
pts
/*Array of Vector*/
)
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
);
...
@@ -116,11 +115,9 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
...
@@ -116,11 +115,9 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
this
.
actions
.
push
(
{
action
:
'
splineThru
'
,
args
:
args
}
);
this
.
actions
.
push
(
{
action
:
'
splineThru
'
,
args
:
args
}
);
};
},
// FUTURE: Change the API or follow canvas API?
THREE
.
Path
.
prototype
.
arc
=
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
arc
:
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
x0
=
lastargs
[
lastargs
.
length
-
2
];
var
x0
=
lastargs
[
lastargs
.
length
-
2
];
...
@@ -129,15 +126,15 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, a
...
@@ -129,15 +126,15 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius, aStartAngle, aEndAngle, a
this
.
absarc
(
aX
+
x0
,
aY
+
y0
,
aRadius
,
this
.
absarc
(
aX
+
x0
,
aY
+
y0
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
aStartAngle
,
aEndAngle
,
aClockwise
);
};
},
THREE
.
Path
.
prototype
.
absarc
=
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
absarc
:
function
(
aX
,
aY
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
)
{
this
.
absellipse
(
aX
,
aY
,
aRadius
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
this
.
absellipse
(
aX
,
aY
,
aRadius
,
aRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
);
};
},
THREE
.
Path
.
prototype
.
ellipse
=
function
(
aX
,
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
)
{
ellipse
:
function
(
aX
,
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
)
{
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
lastargs
=
this
.
actions
[
this
.
actions
.
length
-
1
].
args
;
var
x0
=
lastargs
[
lastargs
.
length
-
2
];
var
x0
=
lastargs
[
lastargs
.
length
-
2
];
...
@@ -145,10 +142,9 @@ THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius, aStartAngle,
...
@@ -145,10 +142,9 @@ THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius, aStartAngle,
this
.
absellipse
(
aX
+
x0
,
aY
+
y0
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
);
this
.
absellipse
(
aX
+
x0
,
aY
+
y0
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
);
};
},
absellipse
:
function
(
aX
,
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
)
{
THREE
.
Path
.
prototype
.
absellipse
=
function
(
aX
,
aY
,
xRadius
,
yRadius
,
aStartAngle
,
aEndAngle
,
aClockwise
,
aRotation
)
{
var
args
=
[
var
args
=
[
aX
,
aY
,
aX
,
aY
,
...
@@ -167,9 +163,9 @@ THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius, aStartAng
...
@@ -167,9 +163,9 @@ THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius, aStartAng
this
.
actions
.
push
(
{
action
:
'
ellipse
'
,
args
:
args
}
);
this
.
actions
.
push
(
{
action
:
'
ellipse
'
,
args
:
args
}
);
};
},
THREE
.
Path
.
prototype
.
getSpacedPoints
=
function
(
divisions
)
{
getSpacedPoints
:
function
(
divisions
)
{
if
(
!
divisions
)
divisions
=
40
;
if
(
!
divisions
)
divisions
=
40
;
...
@@ -191,11 +187,9 @@ THREE.Path.prototype.getSpacedPoints = function ( divisions ) {
...
@@ -191,11 +187,9 @@ THREE.Path.prototype.getSpacedPoints = function ( divisions ) {
return
points
;
return
points
;
};
},
/* Return an array of vectors based on contour of the path */
THREE
.
Path
.
prototype
.
getPoints
=
function
(
divisions
)
{
getPoints
:
function
(
divisions
)
{
divisions
=
divisions
||
12
;
divisions
=
divisions
||
12
;
...
@@ -440,21 +434,9 @@ THREE.Path.prototype.getPoints = function( divisions ) {
...
@@ -440,21 +434,9 @@ THREE.Path.prototype.getPoints = function( divisions ) {
return
points
;
return
points
;
};
},
//
// Breaks path into shapes
//
// Assumptions (if parameter isCCW==true the opposite holds):
// - solid shapes are defined clockwise (CW)
// - holes are defined counterclockwise (CCW)
//
// If parameter noHoles==true:
// - all subPaths are regarded as solid shapes
// - definition order CW/CCW has no relevance
//
THREE
.
Path
.
prototype
.
toShapes
=
function
(
isCCW
,
noHoles
)
{
toShapes
:
function
(
isCCW
,
noHoles
)
{
function
extractSubpaths
(
inActions
)
{
function
extractSubpaths
(
inActions
)
{
...
@@ -722,4 +704,6 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
...
@@ -722,4 +704,6 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
return
shapes
;
return
shapes
;
};
}
}
);
src/extras/core/Shape.js
浏览文件 @
6b53488f
...
@@ -17,28 +17,27 @@ THREE.Shape = function () {
...
@@ -17,28 +17,27 @@ THREE.Shape = function () {
};
};
THREE
.
Shape
.
prototype
=
Object
.
create
(
THREE
.
Path
.
prototype
);
THREE
.
Shape
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Path
.
prototype
),
{
THREE
.
Shape
.
prototype
.
constructor
=
THREE
.
Shape
;
// Convenience method to return ExtrudeGeometry
constructor
:
THREE
.
Shape
,
THREE
.
Shape
.
prototype
.
extrude
=
function
(
options
)
{
// Convenience method to return ExtrudeGeometry
extrude
:
function
(
options
)
{
return
new
THREE
.
ExtrudeGeometry
(
this
,
options
);
return
new
THREE
.
ExtrudeGeometry
(
this
,
options
);
};
},
// Convenience method to return ShapeGeometry
// Convenience method to return ShapeGeometry
THREE
.
Shape
.
prototype
.
makeGeometry
=
function
(
options
)
{
makeGeometry
:
function
(
options
)
{
return
new
THREE
.
ShapeGeometry
(
this
,
options
);
return
new
THREE
.
ShapeGeometry
(
this
,
options
);
};
},
// Get points of holes
getPointsHoles
:
function
(
divisions
)
{
THREE
.
Shape
.
prototype
.
getPointsHoles
=
function
(
divisions
)
{
var
holesPts
=
[];
var
holesPts
=
[];
...
@@ -50,12 +49,11 @@ THREE.Shape.prototype.getPointsHoles = function ( divisions ) {
...
@@ -50,12 +49,11 @@ THREE.Shape.prototype.getPointsHoles = function ( divisions ) {
return
holesPts
;
return
holesPts
;
};
},
// Get points of shape and holes (keypoints based on segments parameter)
// Get points of shape and holes (keypoints based on segments parameter)
THREE
.
Shape
.
prototype
.
extractAllPoints
=
function
(
divisions
)
{
extractAllPoints
:
function
(
divisions
)
{
return
{
return
{
...
@@ -64,10 +62,12 @@ THREE.Shape.prototype.extractAllPoints = function ( divisions ) {
...
@@ -64,10 +62,12 @@ THREE.Shape.prototype.extractAllPoints = function ( divisions ) {
};
};
};
},
THREE
.
Shape
.
prototype
.
extractPoints
=
function
(
divisions
)
{
extractPoints
:
function
(
divisions
)
{
return
this
.
extractAllPoints
(
divisions
);
return
this
.
extractAllPoints
(
divisions
);
};
}
}
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录