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,161 +16,149 @@ THREE.CurvePath = function () {
};
THREE
.
CurvePath
.
prototype
=
Object
.
create
(
THREE
.
Curve
.
prototype
);
THREE
.
CurvePath
.
prototype
.
constructor
=
THREE
.
CurvePath
;
THREE
.
CurvePath
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Curve
.
prototype
),
{
THREE
.
CurvePath
.
prototype
.
add
=
function
(
curve
)
{
constructor
:
THREE
.
CurvePath
,
this
.
curves
.
push
(
curve
);
add
:
function
(
curve
)
{
};
/*
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
};
*/
this
.
curves
.
push
(
curve
);
THREE
.
CurvePath
.
prototype
.
closePath
=
function
()
{
},
// TODO Test
// and verify for vector3 (needs to implement equals)
// Add a line curve if start and end of lines are not connected
var
startPoint
=
this
.
curves
[
0
].
getPoint
(
0
);
var
endPoint
=
this
.
curves
[
this
.
curves
.
length
-
1
].
getPoint
(
1
);
closePath
:
function
()
{
if
(
!
startPoint
.
equals
(
endPoint
)
)
{
// TODO Test
// and verify for vector3 (needs to implement equals)
// Add a line curve if start and end of lines are not connected
var
startPoint
=
this
.
curves
[
0
].
getPoint
(
0
);
var
endPoint
=
this
.
curves
[
this
.
curves
.
length
-
1
].
getPoint
(
1
);
this
.
curves
.
push
(
new
THREE
.
LineCurve
(
endPoint
,
startPoint
)
);
if
(
!
startPoint
.
equals
(
endPoint
)
)
{
}
this
.
curves
.
push
(
new
THREE
.
LineCurve
(
endPoint
,
startPoint
)
);
};
}
// To get accurate point with reference to
// entire path distance at time t,
// following has to be done:
},
// 1. Length of each sub path have to be known
// 2. Locate and identify type of curve
// 3. Get t for the curve
// 4. Return curve.getPointAt(t')
// To get accurate point with reference to
// entire path distance at time t,
// following has to be done:
THREE
.
CurvePath
.
prototype
.
getPoint
=
function
(
t
)
{
// 1. Length of each sub path have to be known
// 2. Locate and identify type of curve
// 3. Get t for the curve
// 4. Return curve.getPointAt(t')
var
d
=
t
*
this
.
getLength
();
var
curveLengths
=
this
.
getCurveLengths
();
var
i
=
0
;
getPoint
:
function
(
t
)
{
// To think about boundaries points.
var
d
=
t
*
this
.
getLength
();
var
curveLengths
=
this
.
getCurveLengths
();
var
i
=
0
;
while
(
i
<
curveLengths
.
length
)
{
// To think about boundaries points.
if
(
curveLengths
[
i
]
>=
d
)
{
while
(
i
<
curveLengths
.
length
)
{
var
diff
=
curveLengths
[
i
]
-
d
;
var
curve
=
this
.
curves
[
i
];
if
(
curveLengths
[
i
]
>=
d
)
{
var
u
=
1
-
diff
/
curve
.
getLength
();
var
diff
=
curveLengths
[
i
]
-
d
;
var
curve
=
this
.
curves
[
i
];
return
curve
.
getPointAt
(
u
);
var
u
=
1
-
diff
/
curve
.
getLength
(
);
}
return
curve
.
getPointAt
(
u
);
i
++
;
}
}
i
++
;
return
null
;
}
// loop where sum != 0, sum > d , sum+1 <d
return
null
;
};
// 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
// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
// getPoint() depends on getLength
// We cannot use the default THREE.Curve getPoint() with getLength() because in
// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath
// getPoint() depends on getLength
THREE
.
CurvePath
.
prototype
.
getLength
=
function
()
{
getLength
:
function
()
{
var
lens
=
this
.
getCurveLengths
();
return
lens
[
lens
.
length
-
1
];
var
lens
=
this
.
getCurveLengths
();
return
lens
[
lens
.
length
-
1
];
};
},
// Compute lengths and cache them
// We cannot overwrite getLengths() because UtoT mapping uses it.
// Compute lengths and cache them
// 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
if
(
this
.
cacheLengths
&&
this
.
cacheLengths
.
length
===
this
.
curves
.
length
)
{
if
(
this
.
cacheLengths
&&
this
.
cacheLengths
.
length
===
this
.
curves
.
length
)
{
return
this
.
cacheLengths
;
return
this
.
cacheLengths
;
}
}
// Get length of sub-curve
// Push sums into cached array
// Get length of sub-curve
// Push sums into cached array
var
lengths
=
[],
sums
=
0
;
var
lengths
=
[],
sums
=
0
;
for
(
var
i
=
0
,
l
=
this
.
curves
.
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
this
.
curves
.
length
;
i
<
l
;
i
++
)
{
sums
+=
this
.
curves
[
i
].
getLength
();
lengths
.
push
(
sums
);
sums
+=
this
.
curves
[
i
].
getLength
();
lengths
.
push
(
sums
);
}
}
this
.
cacheLengths
=
lengths
;
this
.
cacheLengths
=
lengths
;
return
lengths
;
return
lengths
;
};
},
/**************************************************************
* Create Geometries Helpers
**************************************************************/
/// Generate geometry from path points (for Line or Points objects)
/**************************************************************
* Create Geometries Helpers
**************************************************************/
createPointsGeometry
:
function
(
divisions
)
{
/// Generate geometry from path points (for Line or Points objects)
var
pts
=
this
.
getPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
THREE
.
CurvePath
.
prototype
.
createPointsGeometry
=
function
(
divisions
)
{
},
var
pts
=
this
.
getPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
// Generate geometry from equidistant sampling along the path
};
createSpacedPointsGeometry
:
function
(
divisions
)
{
// Generate geometry from equidistant sampling along the path
var
pts
=
this
.
getSpacedPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
THREE
.
CurvePath
.
prototype
.
createSpacedPointsGeometry
=
function
(
divisions
)
{
},
var
pts
=
this
.
getSpacedPoints
(
divisions
);
return
this
.
createGeometry
(
pts
);
createGeometry
:
function
(
points
)
{
}
;
var
geometry
=
new
THREE
.
Geometry
()
;
THREE
.
CurvePath
.
prototype
.
createGeometry
=
function
(
points
)
{
for
(
var
i
=
0
,
l
=
points
.
length
;
i
<
l
;
i
++
)
{
var
geometry
=
new
THREE
.
Geometry
();
var
point
=
points
[
i
];
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
point
.
x
,
point
.
y
,
point
.
z
||
0
)
);
for
(
var
i
=
0
,
l
=
points
.
length
;
i
<
l
;
i
++
)
{
}
var
point
=
points
[
i
];
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
point
.
x
,
point
.
y
,
point
.
z
||
0
)
);
return
geometry
;
}
return
geometry
;
};
}
);
src/extras/core/Font.js
浏览文件 @
6b53488f
...
...
@@ -9,9 +9,7 @@ THREE.Font = function ( data ) {
};
THREE
.
Font
.
prototype
=
{
constructor
:
THREE
.
Font
,
Object
.
assign
(
THREE
.
Font
.
prototype
,
{
generateShapes
:
function
(
text
,
size
,
divisions
)
{
...
...
@@ -163,4 +161,4 @@ THREE.Font.prototype = {
}
};
}
)
;
src/extras/core/Path.js
浏览文件 @
6b53488f
此差异已折叠。
点击以展开。
src/extras/core/Shape.js
浏览文件 @
6b53488f
...
...
@@ -17,57 +17,57 @@ THREE.Shape = function () {
};
THREE
.
Shape
.
prototype
=
Object
.
create
(
THREE
.
Path
.
prototype
);
THREE
.
Shape
.
prototype
.
constructor
=
THREE
.
Shape
;
THREE
.
Shape
.
prototype
=
Object
.
assign
(
Object
.
create
(
THREE
.
Path
.
prototype
),
{
// Convenience method to return ExtrudeGeometry
constructor
:
THREE
.
Shape
,
THREE
.
Shape
.
prototype
.
extrude
=
function
(
options
)
{
// Convenience method to return ExtrudeGeometry
return
new
THREE
.
ExtrudeGeometry
(
this
,
options
);
extrude
:
function
(
options
)
{
}
;
return
new
THREE
.
ExtrudeGeometry
(
this
,
options
)
;
// Convenience method to return ShapeGeometry
},
THREE
.
Shape
.
prototype
.
makeGeometry
=
function
(
options
)
{
// Convenience method to return ShapeGeometry
return
new
THREE
.
ShapeGeometry
(
this
,
options
);
makeGeometry
:
function
(
options
)
{
}
;
return
new
THREE
.
ShapeGeometry
(
this
,
options
)
;
// Get points of holes
},
THREE
.
Shape
.
prototype
.
getPointsHoles
=
function
(
divisions
)
{
getPointsHoles
:
function
(
divisions
)
{
var
holesPts
=
[];
var
holesPts
=
[];
for
(
var
i
=
0
,
l
=
this
.
holes
.
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
this
.
holes
.
length
;
i
<
l
;
i
++
)
{
holesPts
[
i
]
=
this
.
holes
[
i
].
getPoints
(
divisions
);
holesPts
[
i
]
=
this
.
holes
[
i
].
getPoints
(
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)
extractAllPoints
:
function
(
divisions
)
{
THREE
.
Shape
.
prototype
.
extractAllPoints
=
function
(
divisions
)
{
return
{
return
{
shape
:
this
.
getPoints
(
divisions
),
holes
:
this
.
getPointsHoles
(
divisions
)
shape
:
this
.
getPoints
(
divisions
),
holes
:
this
.
getPointsHoles
(
divisions
)
};
}
;
}
,
};
extractPoints
:
function
(
divisions
)
{
THREE
.
Shape
.
prototype
.
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录