Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
ec436427
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,发现更多精彩内容 >>
提交
ec436427
编写于
8月 14, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Core: Eagerly instantiate module scope variables.
上级
e785f126
变更
36
隐藏空白更改
内联
并排
Showing
36 changed file
with
229 addition
and
585 deletion
+229
-585
src/animation/PropertyBinding.js
src/animation/PropertyBinding.js
+32
-44
src/audio/AudioListener.js
src/audio/AudioListener.js
+4
-11
src/audio/PositionalAudio.js
src/audio/PositionalAudio.js
+4
-11
src/cameras/StereoCamera.js
src/cameras/StereoCamera.js
+2
-8
src/core/BufferGeometry.js
src/core/BufferGeometry.js
+7
-33
src/core/Geometry.js
src/core/Geometry.js
+3
-15
src/core/Object3D.js
src/core/Object3D.js
+14
-47
src/helpers/ArrowHelper.js
src/helpers/ArrowHelper.js
+7
-14
src/helpers/BoxHelper.js
src/helpers/BoxHelper.js
+1
-3
src/helpers/CameraHelper.js
src/helpers/CameraHelper.js
+2
-5
src/helpers/DirectionalLightHelper.js
src/helpers/DirectionalLightHelper.js
+3
-9
src/helpers/FaceNormalsHelper.js
src/helpers/FaceNormalsHelper.js
+3
-9
src/helpers/HemisphereLightHelper.js
src/helpers/HemisphereLightHelper.js
+3
-9
src/helpers/SkeletonHelper.js
src/helpers/SkeletonHelper.js
+3
-9
src/helpers/SpotLightHelper.js
src/helpers/SpotLightHelper.js
+1
-3
src/helpers/VertexNormalsHelper.js
src/helpers/VertexNormalsHelper.js
+4
-10
src/loaders/Loader.js
src/loaders/Loader.js
+12
-18
src/math/Box2.js
src/math/Box2.js
+1
-5
src/math/Box3.js
src/math/Box3.js
+29
-58
src/math/Euler.js
src/math/Euler.js
+2
-5
src/math/Frustum.js
src/math/Frustum.js
+2
-8
src/math/Line3.js
src/math/Line3.js
+2
-8
src/math/Matrix3.js
src/math/Matrix3.js
+1
-3
src/math/Matrix4.js
src/math/Matrix4.js
+8
-30
src/math/Plane.js
src/math/Plane.js
+3
-17
src/math/Ray.js
src/math/Ray.js
+9
-29
src/math/Sphere.js
src/math/Sphere.js
+2
-4
src/math/Triangle.js
src/math/Triangle.js
+11
-41
src/math/Vector3.js
src/math/Vector3.js
+2
-9
src/objects/LOD.js
src/objects/LOD.js
+2
-10
src/objects/Line.js
src/objects/Line.js
+5
-17
src/objects/LineSegments.js
src/objects/LineSegments.js
+2
-8
src/objects/Mesh.js
src/objects/Mesh.js
+22
-33
src/objects/Points.js
src/objects/Points.js
+4
-10
src/objects/Skeleton.js
src/objects/Skeleton.js
+2
-8
src/objects/Sprite.js
src/objects/Sprite.js
+15
-24
未找到文件。
src/animation/PropertyBinding.js
浏览文件 @
ec436427
...
...
@@ -10,9 +10,39 @@
// Characters [].:/ are reserved for track binding syntax.
var
_RESERVED_CHARS_RE
=
'
\\
[
\\
]
\\
.:
\\
/
'
;
var
_reservedRe
=
new
RegExp
(
'
[
'
+
_RESERVED_CHARS_RE
+
'
]
'
,
'
g
'
);
var
_reservedRe
;
var
_trackRe
,
_supportedObjectNames
;
// Attempts to allow node names from any language. ES5's `\w` regexp matches
// only latin characters, and the unicode \p{L} is not yet supported. So
// instead, we exclude reserved characters and match everything else.
var
_wordChar
=
'
[^
'
+
_RESERVED_CHARS_RE
+
'
]
'
;
var
_wordCharOrDot
=
'
[^
'
+
_RESERVED_CHARS_RE
.
replace
(
'
\\
.
'
,
''
)
+
'
]
'
;
// Parent directories, delimited by '/' or ':'. Currently unused, but must
// be matched to parse the rest of the track name.
var
_directoryRe
=
/
((?:
WC+
[\/
:
])
*
)
/
.
source
.
replace
(
'
WC
'
,
_wordChar
);
// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.
var
_nodeRe
=
/
(
WCOD+
)?
/
.
source
.
replace
(
'
WCOD
'
,
_wordCharOrDot
);
// Object on target node, and accessor. May not contain reserved
// characters. Accessor may contain any character except closing bracket.
var
_objectRe
=
/
(?:\.(
WC+
)(?:\[(
.+
)\])?)?
/
.
source
.
replace
(
'
WC
'
,
_wordChar
);
// Property and accessor. May not contain reserved characters. Accessor may
// contain any non-bracket characters.
var
_propertyRe
=
/
\.(
WC+
)(?:\[(
.+
)\])?
/
.
source
.
replace
(
'
WC
'
,
_wordChar
);
var
_trackRe
=
new
RegExp
(
''
+
'
^
'
+
_directoryRe
+
_nodeRe
+
_objectRe
+
_propertyRe
+
'
$
'
);
var
_supportedObjectNames
=
[
'
material
'
,
'
materials
'
,
'
bones
'
];
function
Composite
(
targetGroup
,
path
,
optionalParsedPath
)
{
...
...
@@ -114,54 +144,12 @@ Object.assign( PropertyBinding, {
*/
sanitizeNodeName
:
function
(
name
)
{
if
(
_reservedRe
===
undefined
)
{
_reservedRe
=
new
RegExp
(
'
[
'
+
_RESERVED_CHARS_RE
+
'
]
'
,
'
g
'
);
}
return
name
.
replace
(
/
\s
/g
,
'
_
'
).
replace
(
_reservedRe
,
''
);
},
parseTrackName
:
function
(
trackName
)
{
if
(
_supportedObjectNames
===
undefined
)
{
// Attempts to allow node names from any language. ES5's `\w` regexp matches
// only latin characters, and the unicode \p{L} is not yet supported. So
// instead, we exclude reserved characters and match everything else.
var
wordChar
=
'
[^
'
+
_RESERVED_CHARS_RE
+
'
]
'
;
var
wordCharOrDot
=
'
[^
'
+
_RESERVED_CHARS_RE
.
replace
(
'
\\
.
'
,
''
)
+
'
]
'
;
// Parent directories, delimited by '/' or ':'. Currently unused, but must
// be matched to parse the rest of the track name.
var
directoryRe
=
/
((?:
WC+
[\/
:
])
*
)
/
.
source
.
replace
(
'
WC
'
,
wordChar
);
// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.
var
nodeRe
=
/
(
WCOD+
)?
/
.
source
.
replace
(
'
WCOD
'
,
wordCharOrDot
);
// Object on target node, and accessor. May not contain reserved
// characters. Accessor may contain any character except closing bracket.
var
objectRe
=
/
(?:\.(
WC+
)(?:\[(
.+
)\])?)?
/
.
source
.
replace
(
'
WC
'
,
wordChar
);
// Property and accessor. May not contain reserved characters. Accessor may
// contain any non-bracket characters.
var
propertyRe
=
/
\.(
WC+
)(?:\[(
.+
)\])?
/
.
source
.
replace
(
'
WC
'
,
wordChar
);
_trackRe
=
new
RegExp
(
''
+
'
^
'
+
directoryRe
+
nodeRe
+
objectRe
+
propertyRe
+
'
$
'
);
_supportedObjectNames
=
[
'
material
'
,
'
materials
'
,
'
bones
'
];
}
var
matches
=
_trackRe
.
exec
(
trackName
);
if
(
!
matches
)
{
...
...
src/audio/AudioListener.js
浏览文件 @
ec436427
...
...
@@ -8,8 +8,10 @@ import { Clock } from '../core/Clock.js';
import
{
Object3D
}
from
'
../core/Object3D.js
'
;
import
{
AudioContext
}
from
'
./AudioContext.js
'
;
var
_position
,
_quaternion
,
_scale
;
var
_orientation
;
var
_position
=
new
Vector3
();
var
_quaternion
=
new
Quaternion
();
var
_scale
=
new
Vector3
();
var
_orientation
=
new
Vector3
();
function
AudioListener
()
{
...
...
@@ -102,15 +104,6 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), {
Object3D
.
prototype
.
updateMatrixWorld
.
call
(
this
,
force
);
if
(
_position
===
undefined
)
{
_position
=
new
Vector3
();
_quaternion
=
new
Quaternion
();
_scale
=
new
Vector3
();
_orientation
=
new
Vector3
();
}
var
listener
=
this
.
context
.
listener
;
var
up
=
this
.
up
;
...
...
src/audio/PositionalAudio.js
浏览文件 @
ec436427
...
...
@@ -7,8 +7,10 @@ import { Quaternion } from '../math/Quaternion.js';
import
{
Audio
}
from
'
./Audio.js
'
;
import
{
Object3D
}
from
'
../core/Object3D.js
'
;
var
_position
,
_quaternion
,
_scale
;
var
_orientation
;
var
_position
=
new
Vector3
();
var
_quaternion
=
new
Quaternion
();
var
_scale
=
new
Vector3
();
var
_orientation
=
new
Vector3
();
function
PositionalAudio
(
listener
)
{
...
...
@@ -100,15 +102,6 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
Object3D
.
prototype
.
updateMatrixWorld
.
call
(
this
,
force
);
if
(
_position
===
undefined
)
{
_position
=
new
Vector3
();
_quaternion
=
new
Quaternion
();
_scale
=
new
Vector3
();
_orientation
=
new
Vector3
();
}
if
(
this
.
hasPlaybackControl
===
true
&&
this
.
isPlaying
===
false
)
return
;
this
.
matrixWorld
.
decompose
(
_position
,
_quaternion
,
_scale
);
...
...
src/cameras/StereoCamera.js
浏览文件 @
ec436427
...
...
@@ -2,7 +2,8 @@ import { Matrix4 } from '../math/Matrix4.js';
import
{
_Math
}
from
'
../math/Math.js
'
;
import
{
PerspectiveCamera
}
from
'
./PerspectiveCamera.js
'
;
var
_eyeRight
,
_eyeLeft
;
var
_eyeRight
=
new
Matrix4
();
var
_eyeLeft
=
new
Matrix4
();
/**
* @author mrdoob / http://mrdoob.com/
...
...
@@ -40,13 +41,6 @@ Object.assign( StereoCamera.prototype, {
update
:
function
(
camera
)
{
if
(
_eyeRight
===
undefined
)
{
_eyeRight
=
new
Matrix4
();
_eyeLeft
=
new
Matrix4
();
}
var
cache
=
this
.
_cache
;
var
needsUpdate
=
cache
.
focus
!==
camera
.
focus
||
cache
.
fov
!==
camera
.
fov
||
...
...
src/core/BufferGeometry.js
浏览文件 @
ec436427
...
...
@@ -16,9 +16,13 @@ import { arrayMax } from '../utils.js';
*/
var
_bufferGeometryId
=
1
;
// BufferGeometry uses odd numbers as Id
var
_m1
,
_obj
,
_offset
;
var
_box
,
_boxMorphTargets
;
var
_vector
;
var
_m1
=
new
Matrix4
();
var
_obj
=
new
Object3D
();
var
_offset
=
new
Vector3
();
var
_box
=
new
Box3
();
var
_boxMorphTargets
=
new
Box3
();
var
_vector
=
new
Vector3
();
function
BufferGeometry
()
{
...
...
@@ -189,8 +193,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
// rotate geometry around world x-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationX
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -203,8 +205,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
// rotate geometry around world y-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationY
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -217,8 +217,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
// rotate geometry around world z-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationZ
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -231,8 +229,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
// translate geometry
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeTranslation
(
x
,
y
,
z
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -245,8 +241,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
// scale geometry
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeScale
(
x
,
y
,
z
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -257,8 +251,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
lookAt
:
function
(
vector
)
{
if
(
_obj
===
undefined
)
_obj
=
new
Object3D
();
_obj
.
lookAt
(
vector
);
_obj
.
updateMatrix
();
...
...
@@ -271,8 +263,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
center
:
function
()
{
if
(
_offset
===
undefined
)
_offset
=
new
Vector3
();
this
.
computeBoundingBox
();
this
.
boundingBox
.
getCenter
(
_offset
).
negate
();
...
...
@@ -578,12 +568,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
computeBoundingBox
:
function
()
{
if
(
_box
===
undefined
)
{
_box
=
new
Box3
();
}
if
(
this
.
boundingBox
===
null
)
{
this
.
boundingBox
=
new
Box3
();
...
...
@@ -629,14 +613,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
computeBoundingSphere
:
function
()
{
if
(
_boxMorphTargets
===
undefined
)
{
_box
=
new
Box3
();
_vector
=
new
Vector3
();
_boxMorphTargets
=
new
Box3
();
}
if
(
this
.
boundingSphere
===
null
)
{
this
.
boundingSphere
=
new
Sphere
();
...
...
@@ -877,8 +853,6 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
normalizeNormals
:
function
()
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
normals
=
this
.
attributes
.
normal
;
for
(
var
i
=
0
,
il
=
normals
.
count
;
i
<
il
;
i
++
)
{
...
...
src/core/Geometry.js
浏览文件 @
ec436427
...
...
@@ -20,7 +20,9 @@ import { _Math } from '../math/Math.js';
*/
var
_geometryId
=
0
;
// Geometry uses even numbers as Id
var
_m1
,
_obj
,
_offset
;
var
_m1
=
new
Matrix4
();
var
_obj
=
new
Object3D
();
var
_offset
=
new
Vector3
();
function
Geometry
()
{
...
...
@@ -112,8 +114,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// rotate geometry around world x-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationX
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -126,8 +126,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// rotate geometry around world y-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationY
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -140,8 +138,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// rotate geometry around world z-axis
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeRotationZ
(
angle
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -154,8 +150,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// translate geometry
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeTranslation
(
x
,
y
,
z
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -168,8 +162,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// scale geometry
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
_m1
.
makeScale
(
x
,
y
,
z
);
this
.
applyMatrix
(
_m1
);
...
...
@@ -180,8 +172,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
lookAt
:
function
(
vector
)
{
if
(
_obj
===
undefined
)
_obj
=
new
Object3D
();
_obj
.
lookAt
(
vector
);
_obj
.
updateMatrix
();
...
...
@@ -327,8 +317,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
center
:
function
()
{
if
(
_offset
===
undefined
)
_offset
=
new
Vector3
();
this
.
computeBoundingBox
();
this
.
boundingBox
.
getCenter
(
_offset
).
negate
();
...
...
src/core/Object3D.js
浏览文件 @
ec436427
...
...
@@ -17,9 +17,20 @@ import { TrianglesDrawMode } from '../constants.js';
*/
var
_object3DId
=
0
;
var
_m1
,
_q1
,
_v1
;
var
_xAxis
,
_yAxis
,
_zAxis
;
var
_target
,
_position
,
_scale
,
_quaternion
;
var
_v1
=
new
Vector3
();
var
_q1
=
new
Quaternion
();
var
_m1
=
new
Matrix4
();
var
_target
=
new
Vector3
();
var
_position
=
new
Vector3
();
var
_scale
=
new
Vector3
();
var
_quaternion
=
new
Quaternion
();
var
_xAxis
=
new
Vector3
(
1
,
0
,
0
);
var
_yAxis
=
new
Vector3
(
0
,
1
,
0
);
var
_zAxis
=
new
Vector3
(
0
,
0
,
1
);
var
_addedEvent
=
{
type
:
'
added
'
};
var
_removedEvent
=
{
type
:
'
removed
'
};
...
...
@@ -170,8 +181,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// rotate object on axis in object space
// axis is assumed to be normalized
if
(
_q1
===
undefined
)
_q1
=
new
Quaternion
();
_q1
.
setFromAxisAngle
(
axis
,
angle
);
this
.
quaternion
.
multiply
(
_q1
);
...
...
@@ -186,8 +195,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// axis is assumed to be normalized
// method assumes no rotated parent
if
(
_q1
===
undefined
)
_q1
=
new
Quaternion
();
_q1
.
setFromAxisAngle
(
axis
,
angle
);
this
.
quaternion
.
premultiply
(
_q1
);
...
...
@@ -198,24 +205,18 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
rotateX
:
function
(
angle
)
{
if
(
_xAxis
===
undefined
)
_xAxis
=
new
Vector3
(
1
,
0
,
0
);
return
this
.
rotateOnAxis
(
_xAxis
,
angle
);
},
rotateY
:
function
(
angle
)
{
if
(
_yAxis
===
undefined
)
_yAxis
=
new
Vector3
(
0
,
1
,
0
);
return
this
.
rotateOnAxis
(
_yAxis
,
angle
);
},
rotateZ
:
function
(
angle
)
{
if
(
_zAxis
===
undefined
)
_zAxis
=
new
Vector3
(
0
,
0
,
1
);
return
this
.
rotateOnAxis
(
_zAxis
,
angle
);
},
...
...
@@ -225,8 +226,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// translate object by distance along axis in object space
// axis is assumed to be normalized
if
(
_v1
===
undefined
)
_v1
=
new
Vector3
();
_v1
.
copy
(
axis
).
applyQuaternion
(
this
.
quaternion
);
this
.
position
.
add
(
_v1
.
multiplyScalar
(
distance
)
);
...
...
@@ -237,24 +236,18 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
translateX
:
function
(
distance
)
{
if
(
_xAxis
===
undefined
)
_xAxis
=
new
Vector3
(
1
,
0
,
0
);
return
this
.
translateOnAxis
(
_xAxis
,
distance
);
},
translateY
:
function
(
distance
)
{
if
(
_yAxis
===
undefined
)
_yAxis
=
new
Vector3
(
0
,
1
,
0
);
return
this
.
translateOnAxis
(
_yAxis
,
distance
);
},
translateZ
:
function
(
distance
)
{
if
(
_zAxis
===
undefined
)
_zAxis
=
new
Vector3
(
0
,
0
,
1
);
return
this
.
translateOnAxis
(
_zAxis
,
distance
);
},
...
...
@@ -267,8 +260,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
worldToLocal
:
function
(
vector
)
{
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
return
vector
.
applyMatrix4
(
_m1
.
getInverse
(
this
.
matrixWorld
)
);
},
...
...
@@ -277,15 +268,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// This method does not support objects having non-uniformly-scaled parent(s)
if
(
_target
===
undefined
)
{
_q1
=
new
Quaternion
();
_m1
=
new
Matrix4
();
_target
=
new
Vector3
();
_position
=
new
Vector3
();
}
if
(
x
.
isVector3
)
{
_target
.
copy
(
x
);
...
...
@@ -401,8 +383,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
// adds object as a child of this, while maintaining the object's world transform
if
(
_m1
===
undefined
)
_m1
=
new
Matrix4
();
this
.
updateWorldMatrix
(
true
,
false
);
_m1
.
getInverse
(
this
.
matrixWorld
);
...
...
@@ -475,13 +455,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
getWorldQuaternion
:
function
(
target
)
{
if
(
_scale
===
undefined
)
{
_position
=
new
Vector3
();
_scale
=
new
Vector3
();
}
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.Object3D: .getWorldQuaternion() target is now required
'
);
...
...
@@ -499,12 +472,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
getWorldScale
:
function
(
target
)
{
if
(
_quaternion
===
undefined
)
{
_position
=
new
Vector3
();
_quaternion
=
new
Quaternion
();
}
if
(
target
===
undefined
)
{
...
...
src/helpers/ArrowHelper.js
浏览文件 @
ec436427
...
...
@@ -24,8 +24,13 @@ import { Mesh } from '../objects/Mesh.js';
import
{
Line
}
from
'
../objects/Line.js
'
;
import
{
Vector3
}
from
'
../math/Vector3.js
'
;
var
_axis
;
var
_lineGeometry
,
_coneGeometry
;
var
_axis
=
new
Vector3
();
var
_lineGeometry
=
new
BufferGeometry
();
_lineGeometry
.
addAttribute
(
'
position
'
,
new
Float32BufferAttribute
(
[
0
,
0
,
0
,
0
,
1
,
0
],
3
)
);
var
_coneGeometry
=
new
CylinderBufferGeometry
(
0
,
0.5
,
1
,
5
,
1
);
_coneGeometry
.
translate
(
0
,
-
0.5
,
0
);
function
ArrowHelper
(
dir
,
origin
,
length
,
color
,
headLength
,
headWidth
)
{
...
...
@@ -40,16 +45,6 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
if
(
headLength
===
undefined
)
headLength
=
0.2
*
length
;
if
(
headWidth
===
undefined
)
headWidth
=
0.2
*
headLength
;
if
(
_lineGeometry
===
undefined
)
{
_lineGeometry
=
new
BufferGeometry
();
_lineGeometry
.
addAttribute
(
'
position
'
,
new
Float32BufferAttribute
(
[
0
,
0
,
0
,
0
,
1
,
0
],
3
)
);
_coneGeometry
=
new
CylinderBufferGeometry
(
0
,
0.5
,
1
,
5
,
1
);
_coneGeometry
.
translate
(
0
,
-
0.5
,
0
);
}
this
.
position
.
copy
(
origin
);
this
.
line
=
new
Line
(
_lineGeometry
,
new
LineBasicMaterial
(
{
color
:
color
}
)
);
...
...
@@ -70,8 +65,6 @@ ArrowHelper.prototype.constructor = ArrowHelper;
ArrowHelper
.
prototype
.
setDirection
=
function
(
dir
)
{
if
(
_axis
===
undefined
)
_axis
=
new
Vector3
();
// dir is assumed to be normalized
if
(
dir
.
y
>
0.99999
)
{
...
...
src/helpers/BoxHelper.js
浏览文件 @
ec436427
...
...
@@ -9,7 +9,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
import
{
BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
var
_box
;
var
_box
=
new
Box3
()
;
function
BoxHelper
(
object
,
color
)
{
...
...
@@ -37,8 +37,6 @@ BoxHelper.prototype.constructor = BoxHelper;
BoxHelper
.
prototype
.
update
=
function
(
object
)
{
if
(
_box
===
undefined
)
_box
=
new
Box3
();
if
(
object
!==
undefined
)
{
console
.
warn
(
'
THREE.BoxHelper: .update() has no longer arguments.
'
);
...
...
src/helpers/CameraHelper.js
浏览文件 @
ec436427
...
...
@@ -17,7 +17,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
var
_vector
,
_camera
;
var
_vector
=
new
Vector3
();
var
_camera
=
new
Camera
();
function
CameraHelper
(
camera
)
{
...
...
@@ -128,8 +129,6 @@ CameraHelper.prototype.constructor = CameraHelper;
CameraHelper
.
prototype
.
update
=
function
()
{
if
(
_camera
===
undefined
)
_camera
=
new
Camera
();
var
geometry
=
this
.
geometry
;
var
pointMap
=
this
.
pointMap
;
...
...
@@ -183,8 +182,6 @@ CameraHelper.prototype.update = function () {
function
setPoint
(
point
,
pointMap
,
geometry
,
camera
,
x
,
y
,
z
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
_vector
.
set
(
x
,
y
,
z
).
unproject
(
camera
);
var
points
=
pointMap
[
point
];
...
...
src/helpers/DirectionalLightHelper.js
浏览文件 @
ec436427
...
...
@@ -11,7 +11,9 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
import
{
LineBasicMaterial
}
from
'
../materials/LineBasicMaterial.js
'
;
var
_v1
,
_v2
,
_v3
;
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
var
_v3
=
new
Vector3
();
function
DirectionalLightHelper
(
light
,
size
,
color
)
{
...
...
@@ -65,14 +67,6 @@ DirectionalLightHelper.prototype.dispose = function () {
DirectionalLightHelper
.
prototype
.
update
=
function
()
{
if
(
_v3
===
undefined
)
{
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
_v3
=
new
Vector3
();
}
_v1
.
setFromMatrixPosition
(
this
.
light
.
matrixWorld
);
_v2
.
setFromMatrixPosition
(
this
.
light
.
target
.
matrixWorld
);
_v3
.
subVectors
(
_v2
,
_v1
);
...
...
src/helpers/FaceNormalsHelper.js
浏览文件 @
ec436427
...
...
@@ -10,7 +10,9 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
var
_v1
,
_v2
,
_normalMatrix
;
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
var
_normalMatrix
=
new
Matrix3
();
function
FaceNormalsHelper
(
object
,
size
,
hex
,
linewidth
)
{
...
...
@@ -62,14 +64,6 @@ FaceNormalsHelper.prototype.constructor = FaceNormalsHelper;
FaceNormalsHelper
.
prototype
.
update
=
function
()
{
if
(
_normalMatrix
===
undefined
)
{
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
_normalMatrix
=
new
Matrix3
();
}
this
.
object
.
updateMatrixWorld
(
true
);
_normalMatrix
.
getNormalMatrix
(
this
.
object
.
matrixWorld
);
...
...
src/helpers/HemisphereLightHelper.js
浏览文件 @
ec436427
...
...
@@ -13,7 +13,9 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
import
{
OctahedronBufferGeometry
}
from
'
../geometries/OctahedronGeometry.js
'
;
import
{
BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
var
_vector
,
_color1
,
_color2
;
var
_vector
=
new
Vector3
();
var
_color1
=
new
Color
();
var
_color2
=
new
Color
();
function
HemisphereLightHelper
(
light
,
size
,
color
)
{
...
...
@@ -56,14 +58,6 @@ HemisphereLightHelper.prototype.dispose = function () {
HemisphereLightHelper
.
prototype
.
update
=
function
()
{
if
(
_color2
===
undefined
)
{
_vector
=
new
Vector3
();
_color1
=
new
Color
();
_color2
=
new
Color
();
}
var
mesh
=
this
.
children
[
0
];
if
(
this
.
color
!==
undefined
)
{
...
...
src/helpers/SkeletonHelper.js
浏览文件 @
ec436427
...
...
@@ -16,7 +16,9 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
Object3D
}
from
'
../core/Object3D.js
'
;
var
_vector
,
_boneMatrix
,
_matrixWorldInv
;
var
_vector
=
new
Vector3
();
var
_boneMatrix
=
new
Matrix4
();
var
_matrixWorldInv
=
new
Matrix4
();
function
getBoneList
(
object
)
{
...
...
@@ -85,14 +87,6 @@ SkeletonHelper.prototype.constructor = SkeletonHelper;
SkeletonHelper
.
prototype
.
updateMatrixWorld
=
function
(
force
)
{
if
(
_matrixWorldInv
===
undefined
)
{
_vector
=
new
Vector3
();
_boneMatrix
=
new
Matrix4
();
_matrixWorldInv
=
new
Matrix4
();
}
var
bones
=
this
.
bones
;
var
geometry
=
this
.
geometry
;
...
...
src/helpers/SpotLightHelper.js
浏览文件 @
ec436427
...
...
@@ -11,7 +11,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
var
_vector
;
var
_vector
=
new
Vector3
()
;
function
SpotLightHelper
(
light
,
color
)
{
...
...
@@ -70,8 +70,6 @@ SpotLightHelper.prototype.dispose = function () {
SpotLightHelper
.
prototype
.
update
=
function
()
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
this
.
light
.
updateMatrixWorld
();
var
coneLength
=
this
.
light
.
distance
?
this
.
light
.
distance
:
1000
;
...
...
src/helpers/VertexNormalsHelper.js
浏览文件 @
ec436427
...
...
@@ -10,7 +10,10 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
import
{
Float32BufferAttribute
}
from
'
../core/BufferAttribute.js
'
;
import
{
BufferGeometry
}
from
'
../core/BufferGeometry.js
'
;
var
_v1
,
_v2
,
_normalMatrix
,
_keys
;
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
var
_normalMatrix
=
new
Matrix3
();
var
_keys
=
[
'
a
'
,
'
b
'
,
'
c
'
];
function
VertexNormalsHelper
(
object
,
size
,
hex
,
linewidth
)
{
...
...
@@ -61,15 +64,6 @@ VertexNormalsHelper.prototype.constructor = VertexNormalsHelper;
VertexNormalsHelper
.
prototype
.
update
=
function
()
{
if
(
_normalMatrix
===
undefined
)
{
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
_normalMatrix
=
new
Matrix3
();
_keys
=
[
'
a
'
,
'
b
'
,
'
c
'
];
}
this
.
object
.
updateMatrixWorld
(
true
);
_normalMatrix
.
getNormalMatrix
(
this
.
object
.
matrixWorld
);
...
...
src/loaders/Loader.js
浏览文件 @
ec436427
...
...
@@ -24,7 +24,18 @@ import { Color } from '../math/Color.js';
* @author alteredq / http://alteredqualia.com/
*/
var
_BlendingMode
,
_color
,
_textureLoader
,
_materialLoader
;
var
_BlendingMode
=
{
NoBlending
:
NoBlending
,
NormalBlending
:
NormalBlending
,
AdditiveBlending
:
AdditiveBlending
,
SubtractiveBlending
:
SubtractiveBlending
,
MultiplyBlending
:
MultiplyBlending
,
CustomBlending
:
CustomBlending
};
var
_color
=
new
Color
();
var
_textureLoader
=
new
TextureLoader
();
var
_materialLoader
=
new
MaterialLoader
();
function
Loader
()
{}
...
...
@@ -87,23 +98,6 @@ Object.assign( Loader.prototype, {
createMaterial
:
function
(
m
,
texturePath
,
crossOrigin
)
{
if
(
_materialLoader
===
undefined
)
{
_BlendingMode
=
{
NoBlending
:
NoBlending
,
NormalBlending
:
NormalBlending
,
AdditiveBlending
:
AdditiveBlending
,
SubtractiveBlending
:
SubtractiveBlending
,
MultiplyBlending
:
MultiplyBlending
,
CustomBlending
:
CustomBlending
};
_color
=
new
Color
();
_textureLoader
=
new
TextureLoader
();
_materialLoader
=
new
MaterialLoader
();
}
// convert from old material format
var
textures
=
{};
...
...
src/math/Box2.js
浏览文件 @
ec436427
...
...
@@ -4,7 +4,7 @@ import { Vector2 } from './Vector2.js';
* @author bhouston / http://clara.io
*/
var
_vector
;
var
_vector
=
new
Vector2
()
;
function
Box2
(
min
,
max
)
{
...
...
@@ -40,8 +40,6 @@ Object.assign( Box2.prototype, {
setFromCenterAndSize
:
function
(
center
,
size
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector2
();
var
halfSize
=
_vector
.
copy
(
size
).
multiplyScalar
(
0.5
);
this
.
min
.
copy
(
center
).
sub
(
halfSize
);
this
.
max
.
copy
(
center
).
add
(
halfSize
);
...
...
@@ -192,8 +190,6 @@ Object.assign( Box2.prototype, {
distanceToPoint
:
function
(
point
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector2
();
var
clampedPoint
=
_vector
.
copy
(
point
).
clamp
(
this
.
min
,
this
.
max
);
return
clampedPoint
.
sub
(
point
).
length
();
...
...
src/math/Box3.js
浏览文件 @
ec436427
import
{
Vector3
}
from
'
./Vector3.js
'
;
var
_points
=
[
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
()
];
var
_vector
=
new
Vector3
();
// triangle centered vertices
var
_v0
=
new
Vector3
();
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
// triangle edge vectors
var
_f0
=
new
Vector3
();
var
_f1
=
new
Vector3
();
var
_f2
=
new
Vector3
();
var
_center
=
new
Vector3
();
var
_extents
=
new
Vector3
();
var
_triangleNormal
=
new
Vector3
();
var
_testAxis
=
new
Vector3
();
/**
* @author bhouston / http://clara.io
* @author WestLangley / http://github.com/WestLangley
*/
var
_points
;
var
_vector
;
var
_v0
,
_v1
,
_v2
;
var
_f0
,
_f1
,
_f2
;
var
_center
;
var
_extents
;
var
_triangleNormal
;
function
Box3
(
min
,
max
)
{
this
.
min
=
(
min
!==
undefined
)
?
min
:
new
Vector3
(
+
Infinity
,
+
Infinity
,
+
Infinity
);
...
...
@@ -116,8 +136,6 @@ Object.assign( Box3.prototype, {
setFromCenterAndSize
:
function
(
center
,
size
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
halfSize
=
_vector
.
copy
(
size
).
multiplyScalar
(
0.5
);
this
.
min
.
copy
(
center
).
sub
(
halfSize
);
...
...
@@ -222,8 +240,6 @@ Object.assign( Box3.prototype, {
expandByObject
:
function
(
object
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
i
,
l
;
// Computes the world-axis-aligned bounding box of an object (including its children),
...
...
@@ -329,8 +345,6 @@ Object.assign( Box3.prototype, {
intersectsSphere
:
function
(
sphere
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
// Find the point on the AABB closest to the sphere center.
this
.
clampPoint
(
sphere
.
center
,
_vector
);
...
...
@@ -388,26 +402,6 @@ Object.assign( Box3.prototype, {
intersectsTriangle
:
function
(
triangle
)
{
if
(
_v0
===
undefined
)
{
// triangle centered vertices
_v0
=
new
Vector3
();
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
// triangle edge vectors
_f0
=
new
Vector3
();
_f1
=
new
Vector3
();
_f2
=
new
Vector3
();
_center
=
new
Vector3
();
_extents
=
new
Vector3
();
_triangleNormal
=
new
Vector3
();
}
if
(
this
.
isEmpty
()
)
{
return
false
;
...
...
@@ -474,8 +468,6 @@ Object.assign( Box3.prototype, {
distanceToPoint
:
function
(
point
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
clampedPoint
=
_vector
.
copy
(
point
).
clamp
(
this
.
min
,
this
.
max
);
return
clampedPoint
.
sub
(
point
).
length
();
...
...
@@ -484,8 +476,6 @@ Object.assign( Box3.prototype, {
getBoundingSphere
:
function
(
target
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
if
(
target
===
undefined
)
{
console
.
error
(
'
THREE.Box3: .getBoundingSphere() target is now required
'
);
...
...
@@ -524,21 +514,6 @@ Object.assign( Box3.prototype, {
applyMatrix4
:
function
(
matrix
)
{
if
(
_points
===
undefined
)
{
_points
=
[
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
(),
new
Vector3
()
];
}
// transform of empty box is an empty box.
if
(
this
.
isEmpty
()
)
return
this
;
...
...
@@ -575,12 +550,8 @@ Object.assign( Box3.prototype, {
}
);
var
_testAxis
;
function
satForAxes
(
axes
,
v0
,
v1
,
v2
,
extents
)
{
if
(
_testAxis
===
undefined
)
_testAxis
=
new
Vector3
();
var
i
,
j
;
for
(
i
=
0
,
j
=
axes
.
length
-
3
;
i
<=
j
;
i
+=
3
)
{
...
...
src/math/Euler.js
浏览文件 @
ec436427
...
...
@@ -9,7 +9,8 @@ import { _Math } from './Math.js';
* @author bhouston / http://clara.io
*/
var
_matrix
,
_quaternion
;
var
_matrix
=
new
Matrix4
();
var
_quaternion
=
new
Quaternion
();
function
Euler
(
x
,
y
,
z
,
order
)
{
...
...
@@ -257,8 +258,6 @@ Object.assign( Euler.prototype, {
setFromQuaternion
:
function
(
q
,
order
,
update
)
{
if
(
_matrix
===
undefined
)
_matrix
=
new
Matrix4
();
_matrix
.
makeRotationFromQuaternion
(
q
);
return
this
.
setFromRotationMatrix
(
_matrix
,
order
,
update
);
...
...
@@ -275,8 +274,6 @@ Object.assign( Euler.prototype, {
// WARNING: this discards revolution information -bhouston
if
(
_quaternion
===
undefined
)
_quaternion
=
new
Quaternion
();
_quaternion
.
setFromEuler
(
this
);
return
this
.
setFromQuaternion
(
_quaternion
,
newOrder
);
...
...
src/math/Frustum.js
浏览文件 @
ec436427
...
...
@@ -8,8 +8,8 @@ import { Plane } from './Plane.js';
* @author bhouston / http://clara.io
*/
var
_sphere
;
var
_vector
;
var
_sphere
=
new
Sphere
()
;
var
_vector
=
new
Vector3
()
;
function
Frustum
(
p0
,
p1
,
p2
,
p3
,
p4
,
p5
)
{
...
...
@@ -85,8 +85,6 @@ Object.assign( Frustum.prototype, {
intersectsObject
:
function
(
object
)
{
if
(
_sphere
===
undefined
)
_sphere
=
new
Sphere
();
var
geometry
=
object
.
geometry
;
if
(
geometry
.
boundingSphere
===
null
)
geometry
.
computeBoundingSphere
();
...
...
@@ -99,8 +97,6 @@ Object.assign( Frustum.prototype, {
intersectsSprite
:
function
(
sprite
)
{
if
(
_sphere
===
undefined
)
_sphere
=
new
Sphere
();
_sphere
.
center
.
set
(
0
,
0
,
0
);
_sphere
.
radius
=
0.7071067811865476
;
_sphere
.
applyMatrix4
(
sprite
.
matrixWorld
);
...
...
@@ -133,8 +129,6 @@ Object.assign( Frustum.prototype, {
intersectsBox
:
function
(
box
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
planes
=
this
.
planes
;
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
...
...
src/math/Line3.js
浏览文件 @
ec436427
...
...
@@ -5,7 +5,8 @@ import { _Math } from './Math.js';
* @author bhouston / http://clara.io
*/
var
_startP
,
_startEnd
;
var
_startP
=
new
Vector3
();
var
_startEnd
=
new
Vector3
();
function
Line3
(
start
,
end
)
{
...
...
@@ -93,13 +94,6 @@ Object.assign( Line3.prototype, {
closestPointToPointParameter
:
function
(
point
,
clampToLine
)
{
if
(
_startP
===
undefined
)
{
_startP
=
new
Vector3
();
_startEnd
=
new
Vector3
();
}
_startP
.
subVectors
(
point
,
this
.
start
);
_startEnd
.
subVectors
(
this
.
end
,
this
.
start
);
...
...
src/math/Matrix3.js
浏览文件 @
ec436427
...
...
@@ -7,7 +7,7 @@ import { Vector3 } from './Vector3.js';
* @author tschw
*/
var
_vector
;
var
_vector
=
new
Vector3
()
;
function
Matrix3
()
{
...
...
@@ -94,8 +94,6 @@ Object.assign( Matrix3.prototype, {
applyToBufferAttribute
:
function
(
attribute
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
for
(
var
i
=
0
,
l
=
attribute
.
count
;
i
<
l
;
i
++
)
{
_vector
.
x
=
attribute
.
getX
(
i
);
...
...
src/math/Matrix4.js
浏览文件 @
ec436427
import
{
Vector3
}
from
'
./Vector3.js
'
;
var
_v1
=
new
Vector3
();
var
_m1
=
new
Matrix4
();
var
_zero
=
new
Vector3
(
0
,
0
,
0
);
var
_one
=
new
Vector3
(
1
,
1
,
1
);
var
_x
=
new
Vector3
();
var
_y
=
new
Vector3
();
var
_z
=
new
Vector3
();
/**
* @author mrdoob / http://mrdoob.com/
* @author supereggbert / http://www.paulbrunt.co.uk/
...
...
@@ -13,10 +21,6 @@ import { Vector3 } from './Vector3.js';
* @author WestLangley / http://github.com/WestLangley
*/
var
_v1
,
_m1
;
var
_zero
,
_one
;
var
_x
,
_y
,
_z
;
function
Matrix4
()
{
this
.
elements
=
[
...
...
@@ -125,8 +129,6 @@ Object.assign( Matrix4.prototype, {
extractRotation
:
function
(
m
)
{
if
(
_v1
===
undefined
)
_v1
=
new
Vector3
();
// this method does not support reflection matrices
var
te
=
this
.
elements
;
...
...
@@ -290,27 +292,12 @@ Object.assign( Matrix4.prototype, {
makeRotationFromQuaternion
:
function
(
q
)
{
if
(
_zero
===
undefined
)
{
_zero
=
new
Vector3
(
0
,
0
,
0
);
_one
=
new
Vector3
(
1
,
1
,
1
);
}
return
this
.
compose
(
_zero
,
q
,
_one
);
},
lookAt
:
function
(
eye
,
target
,
up
)
{
if
(
_x
===
undefined
)
{
_x
=
new
Vector3
();
_y
=
new
Vector3
();
_z
=
new
Vector3
();
}
var
te
=
this
.
elements
;
_z
.
subVectors
(
eye
,
target
);
...
...
@@ -430,8 +417,6 @@ Object.assign( Matrix4.prototype, {
applyToBufferAttribute
:
function
(
attribute
)
{
if
(
_v1
===
undefined
)
_v1
=
new
Vector3
();
for
(
var
i
=
0
,
l
=
attribute
.
count
;
i
<
l
;
i
++
)
{
_v1
.
x
=
attribute
.
getX
(
i
);
...
...
@@ -782,13 +767,6 @@ Object.assign( Matrix4.prototype, {
decompose
:
function
(
position
,
quaternion
,
scale
)
{
if
(
_m1
===
undefined
)
{
_m1
=
new
Matrix4
();
_v1
=
new
Vector3
();
}
var
te
=
this
.
elements
;
var
sx
=
_v1
.
set
(
te
[
0
],
te
[
1
],
te
[
2
]
).
length
();
...
...
src/math/Plane.js
浏览文件 @
ec436427
...
...
@@ -5,7 +5,9 @@ import { Vector3 } from './Vector3.js';
* @author bhouston / http://clara.io
*/
var
_vector1
,
_vector2
,
_normalMatrix
;
var
_vector1
=
new
Vector3
();
var
_vector2
=
new
Vector3
();
var
_normalMatrix
=
new
Matrix3
();
function
Plane
(
normal
,
constant
)
{
...
...
@@ -49,13 +51,6 @@ Object.assign( Plane.prototype, {
setFromCoplanarPoints
:
function
(
a
,
b
,
c
)
{
if
(
_vector1
===
undefined
)
{
_vector1
=
new
Vector3
();
_vector2
=
new
Vector3
();
}
var
normal
=
_vector1
.
subVectors
(
c
,
b
).
cross
(
_vector2
.
subVectors
(
a
,
b
)
).
normalize
();
// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
...
...
@@ -129,8 +124,6 @@ Object.assign( Plane.prototype, {
intersectLine
:
function
(
line
,
target
)
{
if
(
_vector1
===
undefined
)
_vector1
=
new
Vector3
();
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.Plane: .intersectLine() target is now required
'
);
...
...
@@ -206,13 +199,6 @@ Object.assign( Plane.prototype, {
applyMatrix4
:
function
(
matrix
,
optionalNormalMatrix
)
{
if
(
_normalMatrix
===
undefined
)
{
_normalMatrix
=
new
Matrix3
();
_vector1
=
new
Vector3
();
}
var
normalMatrix
=
optionalNormalMatrix
||
_normalMatrix
.
getNormalMatrix
(
matrix
);
var
referencePoint
=
this
.
coplanarPoint
(
_vector1
).
applyMatrix4
(
matrix
);
...
...
src/math/Ray.js
浏览文件 @
ec436427
import
{
Vector3
}
from
'
./Vector3.js
'
;
var
_vector
=
new
Vector3
();
var
_segCenter
=
new
Vector3
();
var
_segDir
=
new
Vector3
();
var
_diff
=
new
Vector3
();
var
_edge1
=
new
Vector3
();
var
_edge2
=
new
Vector3
();
var
_normal
=
new
Vector3
();
/**
* @author bhouston / http://clara.io
*/
var
_vector
;
var
_segCenter
,
_segDir
,
_diff
;
var
_diff
,
_edge1
,
_edge2
,
_normal
;
function
Ray
(
origin
,
direction
)
{
this
.
origin
=
(
origin
!==
undefined
)
?
origin
:
new
Vector3
();
...
...
@@ -64,8 +69,6 @@ Object.assign( Ray.prototype, {
recast
:
function
(
t
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
this
.
origin
.
copy
(
this
.
at
(
t
,
_vector
)
);
return
this
;
...
...
@@ -103,8 +106,6 @@ Object.assign( Ray.prototype, {
distanceSqToPoint
:
function
(
point
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
var
directionDistance
=
_vector
.
subVectors
(
point
,
this
.
origin
).
dot
(
this
.
direction
);
// point behind the ray
...
...
@@ -123,14 +124,6 @@ Object.assign( Ray.prototype, {
distanceSqToSegment
:
function
(
v0
,
v1
,
optionalPointOnRay
,
optionalPointOnSegment
)
{
if
(
_segCenter
===
undefined
)
{
_segCenter
=
new
Vector3
();
_segDir
=
new
Vector3
();
_diff
=
new
Vector3
();
}
// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h
// It returns the min distance between the ray and the segment
// defined by v0 and v1
...
...
@@ -250,8 +243,6 @@ Object.assign( Ray.prototype, {
intersectSphere
:
function
(
sphere
,
target
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
_vector
.
subVectors
(
sphere
.
center
,
this
.
origin
);
var
tca
=
_vector
.
dot
(
this
.
direction
);
var
d2
=
_vector
.
dot
(
_vector
)
-
tca
*
tca
;
...
...
@@ -424,8 +415,6 @@ Object.assign( Ray.prototype, {
intersectsBox
:
function
(
box
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
return
this
.
intersectBox
(
box
,
_vector
)
!==
null
;
},
...
...
@@ -434,15 +423,6 @@ Object.assign( Ray.prototype, {
// Compute the offset origin, edges, and normal.
if
(
_diff
===
undefined
)
{
_diff
=
new
Vector3
();
_edge1
=
new
Vector3
();
_edge2
=
new
Vector3
();
_normal
=
new
Vector3
();
}
// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h
_edge1
.
subVectors
(
b
,
a
);
...
...
src/math/Sphere.js
浏览文件 @
ec436427
import
{
Box3
}
from
'
./Box3.js
'
;
import
{
Vector3
}
from
'
./Vector3.js
'
;
var
_box
=
new
Box3
();
/**
* @author bhouston / http://clara.io
* @author mrdoob / http://mrdoob.com/
*/
var
_box
;
function
Sphere
(
center
,
radius
)
{
this
.
center
=
(
center
!==
undefined
)
?
center
:
new
Vector3
();
...
...
@@ -28,8 +28,6 @@ Object.assign( Sphere.prototype, {
setFromPoints
:
function
(
points
,
optionalCenter
)
{
if
(
_box
===
undefined
)
_box
=
new
Box3
();
var
center
=
this
.
center
;
if
(
optionalCenter
!==
undefined
)
{
...
...
src/math/Triangle.js
浏览文件 @
ec436427
...
...
@@ -5,8 +5,17 @@ import { Vector3 } from './Vector3.js';
* @author mrdoob / http://mrdoob.com/
*/
var
_v0
,
_v1
,
_v2
,
_v3
;
var
_vab
,
_vac
,
_vbc
,
_vap
,
_vbp
,
_vcp
;
var
_v0
=
new
Vector3
();
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
var
_v3
=
new
Vector3
();
var
_vab
=
new
Vector3
();
var
_vac
=
new
Vector3
();
var
_vbc
=
new
Vector3
();
var
_vap
=
new
Vector3
();
var
_vbp
=
new
Vector3
();
var
_vcp
=
new
Vector3
();
function
Triangle
(
a
,
b
,
c
)
{
...
...
@@ -20,8 +29,6 @@ Object.assign( Triangle, {
getNormal
:
function
(
a
,
b
,
c
,
target
)
{
if
(
_v0
===
undefined
)
_v0
=
new
Vector3
();
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.Triangle: .getNormal() target is now required
'
);
...
...
@@ -48,14 +55,6 @@ Object.assign( Triangle, {
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
getBarycoord
:
function
(
point
,
a
,
b
,
c
,
target
)
{
if
(
_v2
===
undefined
)
{
_v0
=
new
Vector3
();
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
}
_v0
.
subVectors
(
c
,
a
);
_v1
.
subVectors
(
b
,
a
);
_v2
.
subVectors
(
point
,
a
);
...
...
@@ -95,8 +94,6 @@ Object.assign( Triangle, {
containsPoint
:
function
(
point
,
a
,
b
,
c
)
{
if
(
_v3
===
undefined
)
_v3
=
new
Vector3
();
Triangle
.
getBarycoord
(
point
,
a
,
b
,
c
,
_v3
);
return
(
_v3
.
x
>=
0
)
&&
(
_v3
.
y
>=
0
)
&&
(
(
_v3
.
x
+
_v3
.
y
)
<=
1
);
...
...
@@ -105,8 +102,6 @@ Object.assign( Triangle, {
getUV
:
function
(
point
,
p1
,
p2
,
p3
,
uv1
,
uv2
,
uv3
,
target
)
{
if
(
_v3
===
undefined
)
_v3
=
new
Vector3
();
this
.
getBarycoord
(
point
,
p1
,
p2
,
p3
,
_v3
);
target
.
set
(
0
,
0
);
...
...
@@ -120,13 +115,6 @@ Object.assign( Triangle, {
isFrontFacing
:
function
(
a
,
b
,
c
,
direction
)
{
if
(
_v1
===
undefined
)
{
_v0
=
new
Vector3
();
_v1
=
new
Vector3
();
}
_v0
.
subVectors
(
c
,
b
);
_v1
.
subVectors
(
a
,
b
);
...
...
@@ -177,13 +165,6 @@ Object.assign( Triangle.prototype, {
getArea
:
function
()
{
if
(
_v1
===
undefined
)
{
_v0
=
new
Vector3
();
_v1
=
new
Vector3
();
}
_v0
.
subVectors
(
this
.
c
,
this
.
b
);
_v1
.
subVectors
(
this
.
a
,
this
.
b
);
...
...
@@ -255,17 +236,6 @@ Object.assign( Triangle.prototype, {
closestPointToPoint
:
function
(
p
,
target
)
{
if
(
_vab
===
undefined
)
{
_vab
=
new
Vector3
();
_vac
=
new
Vector3
();
_vbc
=
new
Vector3
();
_vap
=
new
Vector3
();
_vbp
=
new
Vector3
();
_vcp
=
new
Vector3
();
}
if
(
target
===
undefined
)
{
console
.
warn
(
'
THREE.Triangle: .closestPointToPoint() target is now required
'
);
...
...
src/math/Vector3.js
浏览文件 @
ec436427
...
...
@@ -10,7 +10,8 @@ import { Quaternion } from './Quaternion.js';
* @author WestLangley / http://github.com/WestLangley
*/
var
_vector
,
_quaternion
;
var
_vector
=
new
Vector3
();
var
_quaternion
=
new
Quaternion
();
function
Vector3
(
x
,
y
,
z
)
{
...
...
@@ -235,8 +236,6 @@ Object.assign( Vector3.prototype, {
applyEuler
:
function
(
euler
)
{
if
(
_quaternion
===
undefined
)
_quaternion
=
new
Quaternion
();
if
(
!
(
euler
&&
euler
.
isEuler
)
)
{
console
.
error
(
'
THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.
'
);
...
...
@@ -249,8 +248,6 @@ Object.assign( Vector3.prototype, {
applyAxisAngle
:
function
(
axis
,
angle
)
{
if
(
_quaternion
===
undefined
)
_quaternion
=
new
Quaternion
();
return
this
.
applyQuaternion
(
_quaternion
.
setFromAxisAngle
(
axis
,
angle
)
);
},
...
...
@@ -539,8 +536,6 @@ Object.assign( Vector3.prototype, {
projectOnPlane
:
function
(
planeNormal
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
_vector
.
copy
(
this
).
projectOnVector
(
planeNormal
);
return
this
.
sub
(
_vector
);
...
...
@@ -549,8 +544,6 @@ Object.assign( Vector3.prototype, {
reflect
:
function
(
normal
)
{
if
(
_vector
===
undefined
)
_vector
=
new
Vector3
();
// reflect incident vector off plane orthogonal to normal
// normal is assumed to have unit length
...
...
src/objects/LOD.js
浏览文件 @
ec436427
...
...
@@ -7,7 +7,8 @@ import { Object3D } from '../core/Object3D.js';
* @author mrdoob / http://mrdoob.com/
*/
var
_v1
,
_v2
;
var
_v1
=
new
Vector3
();
var
_v2
=
new
Vector3
();
function
LOD
()
{
...
...
@@ -96,8 +97,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast
:
function
(
raycaster
,
intersects
)
{
if
(
_v1
===
undefined
)
_v1
=
new
Vector3
();
_v1
.
setFromMatrixPosition
(
this
.
matrixWorld
);
var
distance
=
raycaster
.
ray
.
origin
.
distanceTo
(
_v1
);
...
...
@@ -108,13 +107,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
update
:
function
(
camera
)
{
if
(
_v2
===
undefined
)
{
_v1
=
new
Vector3
();
_v2
=
new
Vector3
();
}
var
levels
=
this
.
levels
;
if
(
levels
.
length
>
1
)
{
...
...
src/objects/Line.js
浏览文件 @
ec436427
...
...
@@ -11,8 +11,11 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
* @author mrdoob / http://mrdoob.com/
*/
var
_start
,
_end
;
var
_inverseMatrix
,
_ray
,
_sphere
;
var
_start
=
new
Vector3
();
var
_end
=
new
Vector3
();
var
_inverseMatrix
=
new
Matrix4
();
var
_ray
=
new
Ray
();
var
_sphere
=
new
Sphere
();
function
Line
(
geometry
,
material
,
mode
)
{
...
...
@@ -39,13 +42,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
computeLineDistances
:
function
()
{
if
(
_end
===
undefined
)
{
_start
=
new
Vector3
();
_end
=
new
Vector3
();
}
var
geometry
=
this
.
geometry
;
if
(
geometry
.
isBufferGeometry
)
{
...
...
@@ -97,14 +93,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast
:
function
(
raycaster
,
intersects
)
{
if
(
_sphere
===
undefined
)
{
_inverseMatrix
=
new
Matrix4
();
_ray
=
new
Ray
();
_sphere
=
new
Sphere
();
}
var
precision
=
raycaster
.
linePrecision
;
var
geometry
=
this
.
geometry
;
...
...
src/objects/LineSegments.js
浏览文件 @
ec436427
...
...
@@ -6,7 +6,8 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
* @author mrdoob / http://mrdoob.com/
*/
var
_start
,
_end
;
var
_start
=
new
Vector3
();
var
_end
=
new
Vector3
();
function
LineSegments
(
geometry
,
material
)
{
...
...
@@ -24,13 +25,6 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), {
computeLineDistances
:
function
()
{
if
(
_end
===
undefined
)
{
_start
=
new
Vector3
();
_end
=
new
Vector3
();
}
var
geometry
=
this
.
geometry
;
if
(
geometry
.
isBufferGeometry
)
{
...
...
src/objects/Mesh.js
浏览文件 @
ec436427
...
...
@@ -17,12 +17,28 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
* @author jonobr1 / http://jonobr1.com/
*/
var
_inverseMatrix
,
_ray
,
_sphere
;
var
_vA
,
_vB
,
_vC
;
var
_tempA
,
_tempB
,
_tempC
;
var
_morphA
,
_morphB
,
_morphC
;
var
_uvA
,
_uvB
,
_uvC
;
var
_intersectionPoint
,
_intersectionPointWorld
;
var
_inverseMatrix
=
new
Matrix4
();
var
_ray
=
new
Ray
();
var
_sphere
=
new
Sphere
();
var
_vA
=
new
Vector3
();
var
_vB
=
new
Vector3
();
var
_vC
=
new
Vector3
();
var
_tempA
=
new
Vector3
();
var
_tempB
=
new
Vector3
();
var
_tempC
=
new
Vector3
();
var
_morphA
=
new
Vector3
();
var
_morphB
=
new
Vector3
();
var
_morphC
=
new
Vector3
();
var
_uvA
=
new
Vector2
();
var
_uvB
=
new
Vector2
();
var
_uvC
=
new
Vector2
();
var
_intersectionPoint
=
new
Vector3
();
var
_intersectionPointWorld
=
new
Vector3
();
function
Mesh
(
geometry
,
material
)
{
...
...
@@ -121,33 +137,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast
:
function
(
raycaster
,
intersects
)
{
if
(
_intersectionPointWorld
===
undefined
)
{
_inverseMatrix
=
new
Matrix4
();
_ray
=
new
Ray
();
_sphere
=
new
Sphere
();
_vA
=
new
Vector3
();
_vB
=
new
Vector3
();
_vC
=
new
Vector3
();
_tempA
=
new
Vector3
();
_tempB
=
new
Vector3
();
_tempC
=
new
Vector3
();
_morphA
=
new
Vector3
();
_morphB
=
new
Vector3
();
_morphC
=
new
Vector3
();
_uvA
=
new
Vector2
();
_uvB
=
new
Vector2
();
_uvC
=
new
Vector2
();
_intersectionPoint
=
new
Vector3
();
_intersectionPointWorld
=
new
Vector3
();
}
var
geometry
=
this
.
geometry
;
var
material
=
this
.
material
;
var
matrixWorld
=
this
.
matrixWorld
;
...
...
src/objects/Points.js
浏览文件 @
ec436427
...
...
@@ -10,7 +10,10 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
* @author alteredq / http://alteredqualia.com/
*/
var
_inverseMatrix
,
_ray
,
_sphere
,
_position
;
var
_inverseMatrix
=
new
Matrix4
();
var
_ray
=
new
Ray
();
var
_sphere
=
new
Sphere
();
var
_position
=
new
Vector3
();
function
Points
(
geometry
,
material
)
{
...
...
@@ -33,15 +36,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast
:
function
(
raycaster
,
intersects
)
{
if
(
_sphere
===
undefined
)
{
_inverseMatrix
=
new
Matrix4
();
_ray
=
new
Ray
();
_sphere
=
new
Sphere
();
_position
=
new
Vector3
();
}
var
geometry
=
this
.
geometry
;
var
matrixWorld
=
this
.
matrixWorld
;
var
threshold
=
raycaster
.
params
.
Points
.
threshold
;
...
...
src/objects/Skeleton.js
浏览文件 @
ec436427
...
...
@@ -7,7 +7,8 @@ import { Matrix4 } from '../math/Matrix4.js';
* @author ikerr / http://verold.com
*/
var
_offsetMatrix
,
_identityMatrix
;
var
_offsetMatrix
=
new
Matrix4
();
var
_identityMatrix
=
new
Matrix4
();
function
Skeleton
(
bones
,
boneInverses
)
{
...
...
@@ -117,13 +118,6 @@ Object.assign( Skeleton.prototype, {
update
:
function
()
{
if
(
_identityMatrix
===
undefined
)
{
_offsetMatrix
=
new
Matrix4
();
_identityMatrix
=
new
Matrix4
();
}
var
bones
=
this
.
bones
;
var
boneInverses
=
this
.
boneInverses
;
var
boneMatrices
=
this
.
boneMatrices
;
...
...
src/objects/Sprite.js
浏览文件 @
ec436427
...
...
@@ -15,10 +15,21 @@ import { SpriteMaterial } from '../materials/SpriteMaterial.js';
var
_geometry
;
var
_intersectPoint
,
_worldScale
,
_mvPosition
;
var
_alignedPosition
,
_rotatedPosition
,
_viewWorldMatrix
;
var
_vA
,
_vB
,
_vC
;
var
_uvA
,
_uvB
,
_uvC
;
var
_intersectPoint
=
new
Vector3
();
var
_worldScale
=
new
Vector3
();
var
_mvPosition
=
new
Vector3
();
var
_alignedPosition
=
new
Vector2
();
var
_rotatedPosition
=
new
Vector2
();
var
_viewWorldMatrix
=
new
Matrix4
();
var
_vA
=
new
Vector3
();
var
_vB
=
new
Vector3
();
var
_vC
=
new
Vector3
();
var
_uvA
=
new
Vector2
();
var
_uvB
=
new
Vector2
();
var
_uvC
=
new
Vector2
();
function
Sprite
(
material
)
{
...
...
@@ -60,26 +71,6 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast
:
function
(
raycaster
,
intersects
)
{
if
(
_uvC
===
undefined
)
{
_intersectPoint
=
new
Vector3
();
_worldScale
=
new
Vector3
();
_mvPosition
=
new
Vector3
();
_alignedPosition
=
new
Vector2
();
_rotatedPosition
=
new
Vector2
();
_viewWorldMatrix
=
new
Matrix4
();
_vA
=
new
Vector3
();
_vB
=
new
Vector3
();
_vC
=
new
Vector3
();
_uvA
=
new
Vector2
();
_uvB
=
new
Vector2
();
_uvC
=
new
Vector2
();
}
_worldScale
.
setFromMatrixScale
(
this
.
matrixWorld
);
_viewWorldMatrix
.
copy
(
raycaster
.
_camera
.
matrixWorld
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录