Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8f0a1c50
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,发现更多精彩内容 >>
提交
8f0a1c50
编写于
1月 25, 2017
作者:
M
Mr.doob
提交者:
GitHub
1月 25, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10637 from TristanVALCKE/FixCircularReferences
Fix circular references
上级
b5d29b98
bf13d47c
变更
43
展开全部
隐藏空白更改
内联
并排
Showing
43 changed file
with
1136 addition
and
1153 deletion
+1136
-1153
src/animation/AnimationAction.js
src/animation/AnimationAction.js
+2
-2
src/animation/AnimationClip.js
src/animation/AnimationClip.js
+49
-53
src/animation/AnimationMixer.js
src/animation/AnimationMixer.js
+251
-258
src/animation/AnimationObjectGroup.js
src/animation/AnimationObjectGroup.js
+2
-3
src/animation/PropertyBinding.js
src/animation/PropertyBinding.js
+278
-275
src/animation/PropertyMixer.js
src/animation/PropertyMixer.js
+4
-4
src/core/BufferAttribute.js
src/core/BufferAttribute.js
+12
-2
src/core/BufferGeometry.js
src/core/BufferGeometry.js
+23
-36
src/core/Clock.js
src/core/Clock.js
+2
-2
src/core/EventDispatcher.js
src/core/EventDispatcher.js
+2
-2
src/core/Face3.js
src/core/Face3.js
+2
-2
src/core/Geometry.js
src/core/Geometry.js
+32
-45
src/core/InterleavedBuffer.js
src/core/InterleavedBuffer.js
+11
-7
src/core/InterleavedBufferAttribute.js
src/core/InterleavedBufferAttribute.js
+21
-10
src/core/Layers.js
src/core/Layers.js
+2
-2
src/core/Object3D.js
src/core/Object3D.js
+2
-3
src/core/Raycaster.js
src/core/Raycaster.js
+2
-4
src/extras/core/Curve.js
src/extras/core/Curve.js
+3
-2
src/extras/core/ShapePath.js
src/extras/core/ShapePath.js
+7
-7
src/loaders/Loader.js
src/loaders/Loader.js
+38
-40
src/materials/Material.js
src/materials/Material.js
+14
-11
src/materials/MultiMaterial.js
src/materials/MultiMaterial.js
+2
-2
src/math/Box2.js
src/math/Box2.js
+2
-2
src/math/Box3.js
src/math/Box3.js
+3
-5
src/math/Color.js
src/math/Color.js
+27
-27
src/math/Cylindrical.js
src/math/Cylindrical.js
+2
-2
src/math/Euler.js
src/math/Euler.js
+50
-32
src/math/Frustum.js
src/math/Frustum.js
+3
-4
src/math/Interpolant.js
src/math/Interpolant.js
+14
-14
src/math/Line3.js
src/math/Line3.js
+2
-2
src/math/Matrix3.js
src/math/Matrix3.js
+3
-5
src/math/Matrix4.js
src/math/Matrix4.js
+9
-25
src/math/Plane.js
src/math/Plane.js
+2
-2
src/math/Quaternion.js
src/math/Quaternion.js
+123
-102
src/math/Ray.js
src/math/Ray.js
+2
-4
src/math/Sphere.js
src/math/Sphere.js
+3
-5
src/math/Spherical.js
src/math/Spherical.js
+2
-2
src/math/Triangle.js
src/math/Triangle.js
+61
-63
src/math/Vector2.js
src/math/Vector2.js
+40
-36
src/math/Vector3.js
src/math/Vector3.js
+10
-28
src/math/Vector4.js
src/math/Vector4.js
+4
-10
src/renderers/WebGLRenderTarget.js
src/renderers/WebGLRenderTarget.js
+2
-3
src/textures/Texture.js
src/textures/Texture.js
+11
-8
未找到文件。
src/animation/AnimationAction.js
浏览文件 @
8f0a1c50
...
...
@@ -76,7 +76,7 @@ function AnimationAction( mixer, clip, localRoot ) {
}
AnimationAction
.
prototype
=
{
Object
.
assign
(
AnimationAction
.
prototype
,
{
constructor
:
AnimationAction
,
...
...
@@ -651,7 +651,7 @@ AnimationAction.prototype = {
}
};
}
)
;
export
{
AnimationAction
};
src/animation/AnimationClip.js
浏览文件 @
8f0a1c50
...
...
@@ -32,55 +32,6 @@ function AnimationClip( name, duration, tracks ) {
}
AnimationClip
.
prototype
=
{
constructor
:
AnimationClip
,
resetDuration
:
function
()
{
var
tracks
=
this
.
tracks
,
duration
=
0
;
for
(
var
i
=
0
,
n
=
tracks
.
length
;
i
!==
n
;
++
i
)
{
var
track
=
this
.
tracks
[
i
];
duration
=
Math
.
max
(
duration
,
track
.
times
[
track
.
times
.
length
-
1
]
);
}
this
.
duration
=
duration
;
},
trim
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
tracks
.
length
;
i
++
)
{
this
.
tracks
[
i
].
trim
(
0
,
this
.
duration
);
}
return
this
;
},
optimize
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
tracks
.
length
;
i
++
)
{
this
.
tracks
[
i
].
optimize
();
}
return
this
;
}
};
// Static methods:
Object
.
assign
(
AnimationClip
,
{
parse
:
function
(
json
)
{
...
...
@@ -98,8 +49,7 @@ Object.assign( AnimationClip, {
return
new
AnimationClip
(
json
.
name
,
json
.
duration
,
tracks
);
},
toJSON
:
function
(
clip
)
{
var
tracks
=
[],
...
...
@@ -122,8 +72,7 @@ Object.assign( AnimationClip, {
return
json
;
},
CreateFromMorphTargetSequence
:
function
(
name
,
morphTargetSequence
,
fps
,
noLoop
)
{
var
numMorphTargets
=
morphTargetSequence
.
length
;
...
...
@@ -359,5 +308,52 @@ Object.assign( AnimationClip, {
}
);
Object
.
assign
(
AnimationClip
.
prototype
,
{
constructor
:
AnimationClip
,
resetDuration
:
function
()
{
var
tracks
=
this
.
tracks
,
duration
=
0
;
for
(
var
i
=
0
,
n
=
tracks
.
length
;
i
!==
n
;
++
i
)
{
var
track
=
this
.
tracks
[
i
];
duration
=
Math
.
max
(
duration
,
track
.
times
[
track
.
times
.
length
-
1
]
);
}
this
.
duration
=
duration
;
},
trim
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
tracks
.
length
;
i
++
)
{
this
.
tracks
[
i
].
trim
(
0
,
this
.
duration
);
}
return
this
;
},
optimize
:
function
()
{
for
(
var
i
=
0
;
i
<
this
.
tracks
.
length
;
i
++
)
{
this
.
tracks
[
i
].
optimize
();
}
return
this
;
}
}
);
export
{
AnimationClip
};
src/animation/AnimationMixer.js
浏览文件 @
8f0a1c50
...
...
@@ -27,260 +27,10 @@ function AnimationMixer( root ) {
}
AnimationMixer
.
prototype
=
{
Object
.
assign
(
AnimationMixer
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
AnimationMixer
,
// return an action for a clip optionally using a custom root target
// object (this method allocates a lot of dynamic memory in case a
// previously unknown clip/root combination is specified)
clipAction
:
function
(
clip
,
optionalRoot
)
{
var
root
=
optionalRoot
||
this
.
_root
,
rootUuid
=
root
.
uuid
,
clipObject
=
typeof
clip
===
'
string
'
?
AnimationClip
.
findByName
(
root
,
clip
)
:
clip
,
clipUuid
=
clipObject
!==
null
?
clipObject
.
uuid
:
clip
,
actionsForClip
=
this
.
_actionsByClip
[
clipUuid
],
prototypeAction
=
null
;
if
(
actionsForClip
!==
undefined
)
{
var
existingAction
=
actionsForClip
.
actionByRoot
[
rootUuid
];
if
(
existingAction
!==
undefined
)
{
return
existingAction
;
}
// we know the clip, so we don't have to parse all
// the bindings again but can just copy
prototypeAction
=
actionsForClip
.
knownActions
[
0
];
// also, take the clip from the prototype action
if
(
clipObject
===
null
)
clipObject
=
prototypeAction
.
_clip
;
}
// clip must be known when specified via string
if
(
clipObject
===
null
)
return
null
;
// allocate all resources required to run it
var
newAction
=
new
AnimationAction
(
this
,
clipObject
,
optionalRoot
);
this
.
_bindAction
(
newAction
,
prototypeAction
);
// and make the action known to the memory manager
this
.
_addInactiveAction
(
newAction
,
clipUuid
,
rootUuid
);
return
newAction
;
},
// get an existing action
existingAction
:
function
(
clip
,
optionalRoot
)
{
var
root
=
optionalRoot
||
this
.
_root
,
rootUuid
=
root
.
uuid
,
clipObject
=
typeof
clip
===
'
string
'
?
AnimationClip
.
findByName
(
root
,
clip
)
:
clip
,
clipUuid
=
clipObject
?
clipObject
.
uuid
:
clip
,
actionsForClip
=
this
.
_actionsByClip
[
clipUuid
];
if
(
actionsForClip
!==
undefined
)
{
return
actionsForClip
.
actionByRoot
[
rootUuid
]
||
null
;
}
return
null
;
},
// deactivates all previously scheduled actions
stopAllAction
:
function
()
{
var
actions
=
this
.
_actions
,
nActions
=
this
.
_nActiveActions
,
bindings
=
this
.
_bindings
,
nBindings
=
this
.
_nActiveBindings
;
this
.
_nActiveActions
=
0
;
this
.
_nActiveBindings
=
0
;
for
(
var
i
=
0
;
i
!==
nActions
;
++
i
)
{
actions
[
i
].
reset
();
}
for
(
var
i
=
0
;
i
!==
nBindings
;
++
i
)
{
bindings
[
i
].
useCount
=
0
;
}
return
this
;
},
// advance the time and update apply the animation
update
:
function
(
deltaTime
)
{
deltaTime
*=
this
.
timeScale
;
var
actions
=
this
.
_actions
,
nActions
=
this
.
_nActiveActions
,
time
=
this
.
time
+=
deltaTime
,
timeDirection
=
Math
.
sign
(
deltaTime
),
accuIndex
=
this
.
_accuIndex
^=
1
;
// run active actions
for
(
var
i
=
0
;
i
!==
nActions
;
++
i
)
{
var
action
=
actions
[
i
];
if
(
action
.
enabled
)
{
action
.
_update
(
time
,
deltaTime
,
timeDirection
,
accuIndex
);
}
}
// update scene graph
var
bindings
=
this
.
_bindings
,
nBindings
=
this
.
_nActiveBindings
;
for
(
var
i
=
0
;
i
!==
nBindings
;
++
i
)
{
bindings
[
i
].
apply
(
accuIndex
);
}
return
this
;
},
// return this mixer's root target object
getRoot
:
function
()
{
return
this
.
_root
;
},
// free all resources specific to a particular clip
uncacheClip
:
function
(
clip
)
{
var
actions
=
this
.
_actions
,
clipUuid
=
clip
.
uuid
,
actionsByClip
=
this
.
_actionsByClip
,
actionsForClip
=
actionsByClip
[
clipUuid
];
if
(
actionsForClip
!==
undefined
)
{
// note: just calling _removeInactiveAction would mess up the
// iteration state and also require updating the state we can
// just throw away
var
actionsToRemove
=
actionsForClip
.
knownActions
;
for
(
var
i
=
0
,
n
=
actionsToRemove
.
length
;
i
!==
n
;
++
i
)
{
var
action
=
actionsToRemove
[
i
];
this
.
_deactivateAction
(
action
);
var
cacheIndex
=
action
.
_cacheIndex
,
lastInactiveAction
=
actions
[
actions
.
length
-
1
];
action
.
_cacheIndex
=
null
;
action
.
_byClipCacheIndex
=
null
;
lastInactiveAction
.
_cacheIndex
=
cacheIndex
;
actions
[
cacheIndex
]
=
lastInactiveAction
;
actions
.
pop
();
this
.
_removeInactiveBindingsForAction
(
action
);
}
delete
actionsByClip
[
clipUuid
];
}
},
// free all resources specific to a particular root target object
uncacheRoot
:
function
(
root
)
{
var
rootUuid
=
root
.
uuid
,
actionsByClip
=
this
.
_actionsByClip
;
for
(
var
clipUuid
in
actionsByClip
)
{
var
actionByRoot
=
actionsByClip
[
clipUuid
].
actionByRoot
,
action
=
actionByRoot
[
rootUuid
];
if
(
action
!==
undefined
)
{
this
.
_deactivateAction
(
action
);
this
.
_removeInactiveAction
(
action
);
}
}
var
bindingsByRoot
=
this
.
_bindingsByRootAndName
,
bindingByName
=
bindingsByRoot
[
rootUuid
];
if
(
bindingByName
!==
undefined
)
{
for
(
var
trackName
in
bindingByName
)
{
var
binding
=
bindingByName
[
trackName
];
binding
.
restoreOriginalState
();
this
.
_removeInactiveBinding
(
binding
);
}
}
},
// remove a targeted clip from the cache
uncacheAction
:
function
(
clip
,
optionalRoot
)
{
var
action
=
this
.
existingAction
(
clip
,
optionalRoot
);
if
(
action
!==
null
)
{
this
.
_deactivateAction
(
action
);
this
.
_removeInactiveAction
(
action
);
}
}
};
// Implementation details:
Object
.
assign
(
AnimationMixer
.
prototype
,
{
_bindAction
:
function
(
action
,
prototypeAction
)
{
var
root
=
action
.
_localRoot
||
this
.
_root
,
...
...
@@ -332,8 +82,8 @@ Object.assign( AnimationMixer.prototype, {
_propertyBindings
[
i
].
binding
.
parsedPath
;
binding
=
new
PropertyMixer
(
PropertyBinding
.
create
(
root
,
trackName
,
path
),
track
.
ValueTypeName
,
track
.
getValueSize
()
);
PropertyBinding
.
create
(
root
,
trackName
,
path
),
track
.
ValueTypeName
,
track
.
getValueSize
()
);
++
binding
.
referenceCount
;
this
.
_addInactiveBinding
(
binding
,
rootUuid
,
trackName
);
...
...
@@ -362,7 +112,7 @@ Object.assign( AnimationMixer.prototype, {
actionsForClip
=
this
.
_actionsByClip
[
clipUuid
];
this
.
_bindAction
(
action
,
actionsForClip
&&
actionsForClip
.
knownActions
[
0
]
);
actionsForClip
&&
actionsForClip
.
knownActions
[
0
]
);
this
.
_addInactiveAction
(
action
,
clipUuid
,
rootUuid
);
...
...
@@ -710,8 +460,8 @@ Object.assign( AnimationMixer.prototype, {
if
(
interpolant
===
undefined
)
{
interpolant
=
new
LinearInterpolant
(
new
Float32Array
(
2
),
new
Float32Array
(
2
),
1
,
this
.
_controlInterpolantsResultBuffer
);
new
Float32Array
(
2
),
new
Float32Array
(
2
),
1
,
this
.
_controlInterpolantsResultBuffer
);
interpolant
.
__cacheIndex
=
lastActiveIndex
;
interpolants
[
lastActiveIndex
]
=
interpolant
;
...
...
@@ -739,10 +489,253 @@ Object.assign( AnimationMixer.prototype, {
},
_controlInterpolantsResultBuffer
:
new
Float32Array
(
1
)
_controlInterpolantsResultBuffer
:
new
Float32Array
(
1
),
// return an action for a clip optionally using a custom root target
// object (this method allocates a lot of dynamic memory in case a
// previously unknown clip/root combination is specified)
clipAction
:
function
(
clip
,
optionalRoot
)
{
var
root
=
optionalRoot
||
this
.
_root
,
rootUuid
=
root
.
uuid
,
clipObject
=
typeof
clip
===
'
string
'
?
AnimationClip
.
findByName
(
root
,
clip
)
:
clip
,
clipUuid
=
clipObject
!==
null
?
clipObject
.
uuid
:
clip
,
actionsForClip
=
this
.
_actionsByClip
[
clipUuid
],
prototypeAction
=
null
;
if
(
actionsForClip
!==
undefined
)
{
var
existingAction
=
actionsForClip
.
actionByRoot
[
rootUuid
];
if
(
existingAction
!==
undefined
)
{
return
existingAction
;
}
// we know the clip, so we don't have to parse all
// the bindings again but can just copy
prototypeAction
=
actionsForClip
.
knownActions
[
0
];
// also, take the clip from the prototype action
if
(
clipObject
===
null
)
clipObject
=
prototypeAction
.
_clip
;
}
// clip must be known when specified via string
if
(
clipObject
===
null
)
return
null
;
// allocate all resources required to run it
var
newAction
=
new
AnimationAction
(
this
,
clipObject
,
optionalRoot
);
this
.
_bindAction
(
newAction
,
prototypeAction
);
// and make the action known to the memory manager
this
.
_addInactiveAction
(
newAction
,
clipUuid
,
rootUuid
);
return
newAction
;
},
// get an existing action
existingAction
:
function
(
clip
,
optionalRoot
)
{
var
root
=
optionalRoot
||
this
.
_root
,
rootUuid
=
root
.
uuid
,
clipObject
=
typeof
clip
===
'
string
'
?
AnimationClip
.
findByName
(
root
,
clip
)
:
clip
,
clipUuid
=
clipObject
?
clipObject
.
uuid
:
clip
,
actionsForClip
=
this
.
_actionsByClip
[
clipUuid
];
if
(
actionsForClip
!==
undefined
)
{
return
actionsForClip
.
actionByRoot
[
rootUuid
]
||
null
;
}
return
null
;
},
// deactivates all previously scheduled actions
stopAllAction
:
function
()
{
var
actions
=
this
.
_actions
,
nActions
=
this
.
_nActiveActions
,
bindings
=
this
.
_bindings
,
nBindings
=
this
.
_nActiveBindings
;
this
.
_nActiveActions
=
0
;
this
.
_nActiveBindings
=
0
;
for
(
var
i
=
0
;
i
!==
nActions
;
++
i
)
{
actions
[
i
].
reset
();
}
for
(
var
i
=
0
;
i
!==
nBindings
;
++
i
)
{
bindings
[
i
].
useCount
=
0
;
}
return
this
;
},
// advance the time and update apply the animation
update
:
function
(
deltaTime
)
{
deltaTime
*=
this
.
timeScale
;
var
actions
=
this
.
_actions
,
nActions
=
this
.
_nActiveActions
,
time
=
this
.
time
+=
deltaTime
,
timeDirection
=
Math
.
sign
(
deltaTime
),
accuIndex
=
this
.
_accuIndex
^=
1
;
// run active actions
for
(
var
i
=
0
;
i
!==
nActions
;
++
i
)
{
var
action
=
actions
[
i
];
if
(
action
.
enabled
)
{
action
.
_update
(
time
,
deltaTime
,
timeDirection
,
accuIndex
);
}
}
// update scene graph
var
bindings
=
this
.
_bindings
,
nBindings
=
this
.
_nActiveBindings
;
for
(
var
i
=
0
;
i
!==
nBindings
;
++
i
)
{
bindings
[
i
].
apply
(
accuIndex
);
}
return
this
;
},
// return this mixer's root target object
getRoot
:
function
()
{
return
this
.
_root
;
},
// free all resources specific to a particular clip
uncacheClip
:
function
(
clip
)
{
var
actions
=
this
.
_actions
,
clipUuid
=
clip
.
uuid
,
actionsByClip
=
this
.
_actionsByClip
,
actionsForClip
=
actionsByClip
[
clipUuid
];
if
(
actionsForClip
!==
undefined
)
{
// note: just calling _removeInactiveAction would mess up the
// iteration state and also require updating the state we can
// just throw away
var
actionsToRemove
=
actionsForClip
.
knownActions
;
for
(
var
i
=
0
,
n
=
actionsToRemove
.
length
;
i
!==
n
;
++
i
)
{
var
action
=
actionsToRemove
[
i
];
this
.
_deactivateAction
(
action
);
var
cacheIndex
=
action
.
_cacheIndex
,
lastInactiveAction
=
actions
[
actions
.
length
-
1
];
action
.
_cacheIndex
=
null
;
action
.
_byClipCacheIndex
=
null
;
lastInactiveAction
.
_cacheIndex
=
cacheIndex
;
actions
[
cacheIndex
]
=
lastInactiveAction
;
actions
.
pop
();
this
.
_removeInactiveBindingsForAction
(
action
);
}
delete
actionsByClip
[
clipUuid
];
}
},
// free all resources specific to a particular root target object
uncacheRoot
:
function
(
root
)
{
var
rootUuid
=
root
.
uuid
,
actionsByClip
=
this
.
_actionsByClip
;
for
(
var
clipUuid
in
actionsByClip
)
{
var
actionByRoot
=
actionsByClip
[
clipUuid
].
actionByRoot
,
action
=
actionByRoot
[
rootUuid
];
if
(
action
!==
undefined
)
{
this
.
_deactivateAction
(
action
);
this
.
_removeInactiveAction
(
action
);
}
}
var
bindingsByRoot
=
this
.
_bindingsByRootAndName
,
bindingByName
=
bindingsByRoot
[
rootUuid
];
if
(
bindingByName
!==
undefined
)
{
for
(
var
trackName
in
bindingByName
)
{
var
binding
=
bindingByName
[
trackName
];
binding
.
restoreOriginalState
();
this
.
_removeInactiveBinding
(
binding
);
}
}
},
// remove a targeted clip from the cache
uncacheAction
:
function
(
clip
,
optionalRoot
)
{
var
action
=
this
.
existingAction
(
clip
,
optionalRoot
);
if
(
action
!==
null
)
{
this
.
_deactivateAction
(
action
);
this
.
_removeInactiveAction
(
action
);
}
}
}
);
Object
.
assign
(
AnimationMixer
.
prototype
,
EventDispatcher
.
prototype
);
export
{
AnimationMixer
};
src/animation/AnimationObjectGroup.js
浏览文件 @
8f0a1c50
...
...
@@ -71,7 +71,7 @@ function AnimationObjectGroup( var_args ) {
}
AnimationObjectGroup
.
prototype
=
{
Object
.
assign
(
AnimationObjectGroup
.
prototype
,
{
constructor
:
AnimationObjectGroup
,
...
...
@@ -371,8 +371,7 @@ AnimationObjectGroup.prototype = {
}
};
}
);
export
{
AnimationObjectGroup
};
src/animation/PropertyBinding.js
浏览文件 @
8f0a1c50
此差异已折叠。
点击以展开。
src/animation/PropertyMixer.js
浏览文件 @
8f0a1c50
...
...
@@ -56,7 +56,7 @@ function PropertyMixer( binding, typeName, valueSize ) {
}
PropertyMixer
.
prototype
=
{
Object
.
assign
(
PropertyMixer
.
prototype
,
{
constructor
:
PropertyMixer
,
...
...
@@ -118,7 +118,7 @@ PropertyMixer.prototype = {
var
originalValueOffset
=
stride
*
3
;
this
.
_mixBufferRegion
(
buffer
,
offset
,
originalValueOffset
,
1
-
weight
,
stride
);
buffer
,
offset
,
originalValueOffset
,
1
-
weight
,
stride
);
}
...
...
@@ -188,7 +188,7 @@ PropertyMixer.prototype = {
_slerp
:
function
(
buffer
,
dstOffset
,
srcOffset
,
t
,
stride
)
{
Quaternion
.
slerpFlat
(
buffer
,
dstOffset
,
buffer
,
dstOffset
,
buffer
,
srcOffset
,
t
);
buffer
,
dstOffset
,
buffer
,
srcOffset
,
t
);
},
...
...
@@ -206,7 +206,7 @@ PropertyMixer.prototype = {
}
};
}
)
;
export
{
PropertyMixer
};
src/core/BufferAttribute.js
浏览文件 @
8f0a1c50
...
...
@@ -32,7 +32,17 @@ function BufferAttribute( array, itemSize, normalized ) {
}
BufferAttribute
.
prototype
=
{
Object
.
defineProperty
(
BufferAttribute
.
prototype
,
"
needsUpdate
"
,
{
set
:
function
(
value
)
{
if
(
value
===
true
)
this
.
version
++
;
}
});
Object
.
assign
(
BufferAttribute
.
prototype
,
{
constructor
:
BufferAttribute
,
...
...
@@ -335,7 +345,7 @@ BufferAttribute.prototype = {
}
};
}
)
;
//
...
...
src/core/BufferGeometry.js
浏览文件 @
8f0a1c50
...
...
@@ -39,7 +39,9 @@ function BufferGeometry() {
}
BufferGeometry
.
prototype
=
{
BufferGeometry
.
MaxIndex
=
65535
;
Object
.
assign
(
BufferGeometry
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
BufferGeometry
,
...
...
@@ -173,12 +175,10 @@ BufferGeometry.prototype = {
// rotate geometry around world x-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateX
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationX
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -193,12 +193,10 @@ BufferGeometry.prototype = {
// rotate geometry around world y-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateY
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationY
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -213,12 +211,10 @@ BufferGeometry.prototype = {
// rotate geometry around world z-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateZ
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationZ
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -233,12 +229,10 @@ BufferGeometry.prototype = {
// translate geometry
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
translate
(
x
,
y
,
z
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeTranslation
(
x
,
y
,
z
);
this
.
applyMatrix
(
m1
);
...
...
@@ -253,12 +247,10 @@ BufferGeometry.prototype = {
// scale geometry
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
scale
(
x
,
y
,
z
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeScale
(
x
,
y
,
z
);
this
.
applyMatrix
(
m1
);
...
...
@@ -271,12 +263,10 @@ BufferGeometry.prototype = {
lookAt
:
function
()
{
var
obj
;
var
obj
=
new
Object3D
()
;
return
function
lookAt
(
vector
)
{
if
(
obj
===
undefined
)
obj
=
new
Object3D
();
obj
.
lookAt
(
vector
);
obj
.
updateMatrix
();
...
...
@@ -979,28 +969,28 @@ BufferGeometry.prototype = {
clone
:
function
()
{
/*
// Handle primitives
// Handle primitives
var parameters = this.parameters;
var parameters = this.parameters;
if ( parameters !== undefined ) {
if ( parameters !== undefined ) {
var values = [];
var values = [];
for ( var key in parameters ) {
for ( var key in parameters ) {
values.push( parameters[ key ] );
values.push( parameters[ key ] );
}
}
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
}
}
return new this.constructor().copy( this );
*/
return new this.constructor().copy( this );
*/
return
new
BufferGeometry
().
copy
(
this
);
...
...
@@ -1109,10 +1099,7 @@ BufferGeometry.prototype = {
}
};
BufferGeometry
.
MaxIndex
=
65535
;
}
);
Object
.
assign
(
BufferGeometry
.
prototype
,
EventDispatcher
.
prototype
);
export
{
BufferGeometry
};
src/core/Clock.js
浏览文件 @
8f0a1c50
...
...
@@ -14,7 +14,7 @@ function Clock( autoStart ) {
}
Clock
.
prototype
=
{
Object
.
assign
(
Clock
.
prototype
,
{
constructor
:
Clock
,
...
...
@@ -67,7 +67,7 @@ Clock.prototype = {
}
};
}
)
;
export
{
Clock
};
src/core/EventDispatcher.js
浏览文件 @
8f0a1c50
...
...
@@ -4,7 +4,7 @@
function
EventDispatcher
()
{}
EventDispatcher
.
prototype
=
{
Object
.
assign
(
EventDispatcher
.
prototype
,
{
addEventListener
:
function
(
type
,
listener
)
{
...
...
@@ -87,7 +87,7 @@ EventDispatcher.prototype = {
}
};
}
)
;
export
{
EventDispatcher
};
src/core/Face3.js
浏览文件 @
8f0a1c50
...
...
@@ -22,7 +22,7 @@ function Face3( a, b, c, normal, color, materialIndex ) {
}
Face3
.
prototype
=
{
Object
.
assign
(
Face3
.
prototype
,
{
constructor
:
Face3
,
...
...
@@ -59,7 +59,7 @@ Face3.prototype = {
}
};
}
)
;
export
{
Face3
};
src/core/Geometry.js
浏览文件 @
8f0a1c50
...
...
@@ -59,7 +59,7 @@ function Geometry() {
}
Geometry
.
prototype
=
{
Object
.
assign
(
Geometry
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
Geometry
,
...
...
@@ -112,12 +112,10 @@ Geometry.prototype = {
// rotate geometry around world x-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateX
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationX
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -132,12 +130,10 @@ Geometry.prototype = {
// rotate geometry around world y-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateY
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationY
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -152,12 +148,10 @@ Geometry.prototype = {
// rotate geometry around world z-axis
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
rotateZ
(
angle
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeRotationZ
(
angle
);
this
.
applyMatrix
(
m1
);
...
...
@@ -172,12 +166,10 @@ Geometry.prototype = {
// translate geometry
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
translate
(
x
,
y
,
z
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeTranslation
(
x
,
y
,
z
);
this
.
applyMatrix
(
m1
);
...
...
@@ -192,12 +184,10 @@ Geometry.prototype = {
// scale geometry
var
m1
;
var
m1
=
new
Matrix4
()
;
return
function
scale
(
x
,
y
,
z
)
{
if
(
m1
===
undefined
)
m1
=
new
Matrix4
();
m1
.
makeScale
(
x
,
y
,
z
);
this
.
applyMatrix
(
m1
);
...
...
@@ -210,12 +200,10 @@ Geometry.prototype = {
lookAt
:
function
()
{
var
obj
;
var
obj
=
new
Object3D
()
;
return
function
lookAt
(
vector
)
{
if
(
obj
===
undefined
)
obj
=
new
Object3D
();
obj
.
lookAt
(
vector
);
obj
.
updateMatrix
();
...
...
@@ -714,15 +702,15 @@ Geometry.prototype = {
}
var
normalMatrix
,
vertexOffset
=
this
.
vertices
.
length
,
vertices1
=
this
.
vertices
,
vertices2
=
geometry
.
vertices
,
faces1
=
this
.
faces
,
faces2
=
geometry
.
faces
,
uvs1
=
this
.
faceVertexUvs
[
0
],
uvs2
=
geometry
.
faceVertexUvs
[
0
],
colors1
=
this
.
colors
,
colors2
=
geometry
.
colors
;
vertexOffset
=
this
.
vertices
.
length
,
vertices1
=
this
.
vertices
,
vertices2
=
geometry
.
vertices
,
faces1
=
this
.
faces
,
faces2
=
geometry
.
faces
,
uvs1
=
this
.
faceVertexUvs
[
0
],
uvs2
=
geometry
.
faceVertexUvs
[
0
],
colors1
=
this
.
colors
,
colors2
=
geometry
.
colors
;
if
(
materialIndexOffset
===
undefined
)
materialIndexOffset
=
0
;
...
...
@@ -759,8 +747,8 @@ Geometry.prototype = {
for
(
i
=
0
,
il
=
faces2
.
length
;
i
<
il
;
i
++
)
{
var
face
=
faces2
[
i
],
faceCopy
,
normal
,
color
,
faceVertexNormals
=
face
.
vertexNormals
,
faceVertexColors
=
face
.
vertexColors
;
faceVertexNormals
=
face
.
vertexNormals
,
faceVertexColors
=
face
.
vertexColors
;
faceCopy
=
new
Face3
(
face
.
a
+
vertexOffset
,
face
.
b
+
vertexOffset
,
face
.
c
+
vertexOffset
);
faceCopy
.
normal
.
copy
(
face
.
normal
);
...
...
@@ -1171,28 +1159,28 @@ Geometry.prototype = {
clone
:
function
()
{
/*
// Handle primitives
// Handle primitives
var parameters = this.parameters;
var parameters = this.parameters;
if ( parameters !== undefined ) {
if ( parameters !== undefined ) {
var values = [];
var values = [];
for ( var key in parameters ) {
for ( var key in parameters ) {
values.push( parameters[ key ] );
values.push( parameters[ key ] );
}
}
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
var geometry = Object.create( this.constructor.prototype );
this.constructor.apply( geometry, values );
return geometry;
}
}
return new this.constructor().copy( this );
*/
return new this.constructor().copy( this );
*/
return
new
Geometry
().
copy
(
this
);
...
...
@@ -1438,8 +1426,7 @@ Geometry.prototype = {
}
};
}
)
;
Object
.
assign
(
Geometry
.
prototype
,
EventDispatcher
.
prototype
);
export
{
GeometryIdCount
,
Geometry
};
src/core/InterleavedBuffer.js
浏览文件 @
8f0a1c50
...
...
@@ -21,17 +21,21 @@ function InterleavedBuffer( array, stride ) {
}
InterleavedBuffer
.
prototype
=
{
Object
.
defineProperty
(
InterleavedBuffer
.
prototype
,
"
needsUpdate
"
,
{
constructor
:
InterleavedBuffer
,
set
:
function
(
value
)
{
if
(
value
===
true
)
this
.
version
++
;
}
isInterleavedBuffer
:
true
,
});
set
needsUpdate
(
value
)
{
Object
.
assign
(
InterleavedBuffer
.
prototype
,
{
if
(
value
===
true
)
this
.
version
++
;
constructor
:
InterleavedBuffer
,
}
,
isInterleavedBuffer
:
true
,
setArray
:
function
(
array
)
{
...
...
@@ -104,7 +108,7 @@ InterleavedBuffer.prototype = {
}
};
}
)
;
export
{
InterleavedBuffer
};
src/core/InterleavedBufferAttribute.js
浏览文件 @
8f0a1c50
...
...
@@ -16,24 +16,35 @@ function InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normal
}
Object
.
defineProperties
(
InterleavedBufferAttribute
.
prototype
,
{
InterleavedBufferAttribute
.
prototype
=
{
"
count
"
:
{
constructor
:
InterleavedBufferAttribute
,
isInterleavedBufferAttribute
:
true
,
get
:
function
()
{
get
count
()
{
return
this
.
data
.
count
;
return
this
.
data
.
count
;
}
},
get
array
()
{
"
array
"
:
{
return
this
.
data
.
array
;
get
:
function
()
{
},
return
this
.
data
.
array
;
}
}
}
);
Object
.
assign
(
InterleavedBufferAttribute
.
prototype
,
{
constructor
:
InterleavedBufferAttribute
,
isInterleavedBufferAttribute
:
true
,
setX
:
function
(
index
,
x
)
{
...
...
@@ -127,7 +138,7 @@ InterleavedBufferAttribute.prototype = {
}
};
}
)
;
export
{
InterleavedBufferAttribute
};
src/core/Layers.js
浏览文件 @
8f0a1c50
...
...
@@ -8,7 +8,7 @@ function Layers() {
}
Layers
.
prototype
=
{
Object
.
assign
(
Layers
.
prototype
,
{
constructor
:
Layers
,
...
...
@@ -42,7 +42,7 @@ Layers.prototype = {
}
};
}
)
;
export
{
Layers
};
src/core/Object3D.js
浏览文件 @
8f0a1c50
...
...
@@ -101,7 +101,7 @@ function Object3D() {
Object3D
.
DefaultUp
=
new
Vector3
(
0
,
1
,
0
);
Object3D
.
DefaultMatrixAutoUpdate
=
true
;
Object
3D
.
prototype
=
{
Object
.
assign
(
Object3D
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
Object3D
,
...
...
@@ -730,8 +730,7 @@ Object3D.prototype = {
}
};
}
)
;
Object
.
assign
(
Object3D
.
prototype
,
EventDispatcher
.
prototype
);
export
{
Object3D
};
src/core/Raycaster.js
浏览文件 @
8f0a1c50
...
...
@@ -59,9 +59,7 @@ function intersectObject( object, raycaster, intersects, recursive ) {
}
//
Raycaster
.
prototype
=
{
Object
.
assign
(
Raycaster
.
prototype
,
{
constructor
:
Raycaster
,
...
...
@@ -130,7 +128,7 @@ Raycaster.prototype = {
}
};
}
)
;
export
{
Raycaster
};
src/extras/core/Curve.js
浏览文件 @
8f0a1c50
...
...
@@ -39,7 +39,7 @@ import { Matrix4 } from '../../math/Matrix4';
function
Curve
()
{}
Curve
.
prototype
=
{
Object
.
assign
(
Curve
.
prototype
,
{
constructor
:
Curve
,
...
...
@@ -382,6 +382,7 @@ Curve.prototype = {
}
};
}
);
export
{
Curve
};
src/extras/core/ShapePath.js
浏览文件 @
8f0a1c50
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* minimal class for proxing functions to Path. Replaces old "extractSubpaths()"
**/
import
{
Path
}
from
'
./Path
'
;
import
{
Shape
}
from
'
./Shape
'
;
import
{
ShapeUtils
}
from
'
../ShapeUtils
'
;
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* minimal class for proxing functions to Path. Replaces old "extractSubpaths()"
**/
function
ShapePath
()
{
...
...
@@ -15,7 +14,7 @@ function ShapePath() {
}
ShapePath
.
prototype
=
{
Object
.
assign
(
ShapePath
.
prototype
,
{
moveTo
:
function
(
x
,
y
)
{
...
...
@@ -276,6 +275,7 @@ ShapePath.prototype = {
}
};
}
);
export
{
ShapePath
};
src/loaders/Loader.js
浏览文件 @
8f0a1c50
...
...
@@ -32,7 +32,40 @@ function Loader() {
}
Loader
.
prototype
=
{
Loader
.
Handlers
=
{
handlers
:
[],
add
:
function
(
regex
,
loader
)
{
this
.
handlers
.
push
(
regex
,
loader
);
},
get
:
function
(
file
)
{
var
handlers
=
this
.
handlers
;
for
(
var
i
=
0
,
l
=
handlers
.
length
;
i
<
l
;
i
+=
2
)
{
var
regex
=
handlers
[
i
];
var
loader
=
handlers
[
i
+
1
];
if
(
regex
.
test
(
file
)
)
{
return
loader
;
}
}
return
null
;
}
};
Object
.
assign
(
Loader
.
prototype
,
{
constructor
:
Loader
,
...
...
@@ -75,14 +108,12 @@ Loader.prototype = {
CustomBlending
:
CustomBlending
};
var
color
,
textureLoader
,
materialLoader
;
var
color
=
new
Color
();
var
textureLoader
=
new
TextureLoader
();
var
materialLoader
=
new
MaterialLoader
();
return
function
createMaterial
(
m
,
texturePath
,
crossOrigin
)
{
if
(
color
===
undefined
)
color
=
new
Color
();
if
(
textureLoader
===
undefined
)
textureLoader
=
new
TextureLoader
();
if
(
materialLoader
===
undefined
)
materialLoader
=
new
MaterialLoader
();
// convert from old material format
var
textures
=
{};
...
...
@@ -320,40 +351,7 @@ Loader.prototype = {
}
)()
};
Loader
.
Handlers
=
{
handlers
:
[],
add
:
function
(
regex
,
loader
)
{
this
.
handlers
.
push
(
regex
,
loader
);
},
get
:
function
(
file
)
{
var
handlers
=
this
.
handlers
;
for
(
var
i
=
0
,
l
=
handlers
.
length
;
i
<
l
;
i
+=
2
)
{
var
regex
=
handlers
[
i
];
var
loader
=
handlers
[
i
+
1
];
if
(
regex
.
test
(
file
)
)
{
return
loader
;
}
}
return
null
;
}
};
}
);
export
{
Loader
};
src/materials/Material.js
浏览文件 @
8f0a1c50
...
...
@@ -63,24 +63,28 @@ function Material() {
}
Material
.
prototype
=
{
Object
.
defineProperty
(
Material
.
prototype
,
"
needsUpdate
"
,
{
constructor
:
Material
,
isMaterial
:
true
,
get
needsUpdate
()
{
get
:
function
()
{
return
this
.
_needsUpdate
;
},
set
needsUpdate
(
value
)
{
set
:
function
(
value
)
{
if
(
value
===
true
)
this
.
update
();
this
.
_needsUpdate
=
value
;
},
}
});
Object
.
assign
(
Material
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
Material
,
isMaterial
:
true
,
setValues
:
function
(
values
)
{
...
...
@@ -346,8 +350,7 @@ Material.prototype = {
}
};
}
)
;
Object
.
assign
(
Material
.
prototype
,
EventDispatcher
.
prototype
);
export
{
Material
};
src/materials/MultiMaterial.js
浏览文件 @
8f0a1c50
...
...
@@ -16,7 +16,7 @@ function MultiMaterial( materials ) {
}
MultiMaterial
.
prototype
=
{
Object
.
assign
(
MultiMaterial
.
prototype
,
{
constructor
:
MultiMaterial
,
...
...
@@ -68,7 +68,7 @@ MultiMaterial.prototype = {
}
};
}
)
;
export
{
MultiMaterial
};
src/math/Box2.js
浏览文件 @
8f0a1c50
...
...
@@ -11,7 +11,7 @@ function Box2( min, max ) {
}
Box2
.
prototype
=
{
Object
.
assign
(
Box2
.
prototype
,
{
constructor
:
Box2
,
...
...
@@ -216,7 +216,7 @@ Box2.prototype = {
}
};
}
)
;
export
{
Box2
};
src/math/Box3.js
浏览文件 @
8f0a1c50
...
...
@@ -13,7 +13,7 @@ function Box3( min, max ) {
}
Box3
.
prototype
=
{
Object
.
assign
(
Box3
.
prototype
,
{
constructor
:
Box3
,
...
...
@@ -310,12 +310,10 @@ Box3.prototype = {
intersectsSphere
:
(
function
()
{
var
closestPoint
;
var
closestPoint
=
new
Vector3
()
;
return
function
intersectsSphere
(
sphere
)
{
if
(
closestPoint
===
undefined
)
closestPoint
=
new
Vector3
();
// Find the point on the AABB closest to the sphere center.
this
.
clampPoint
(
sphere
.
center
,
closestPoint
);
...
...
@@ -483,7 +481,7 @@ Box3.prototype = {
}
};
}
)
;
export
{
Box3
};
src/math/Color.js
浏览文件 @
8f0a1c50
...
...
@@ -4,6 +4,31 @@ import { _Math } from './Math';
* @author mrdoob / http://mrdoob.com/
*/
var
ColorKeywords
=
{
'
aliceblue
'
:
0xF0F8FF
,
'
antiquewhite
'
:
0xFAEBD7
,
'
aqua
'
:
0x00FFFF
,
'
aquamarine
'
:
0x7FFFD4
,
'
azure
'
:
0xF0FFFF
,
'
beige
'
:
0xF5F5DC
,
'
bisque
'
:
0xFFE4C4
,
'
black
'
:
0x000000
,
'
blanchedalmond
'
:
0xFFEBCD
,
'
blue
'
:
0x0000FF
,
'
blueviolet
'
:
0x8A2BE2
,
'
brown
'
:
0xA52A2A
,
'
burlywood
'
:
0xDEB887
,
'
cadetblue
'
:
0x5F9EA0
,
'
chartreuse
'
:
0x7FFF00
,
'
chocolate
'
:
0xD2691E
,
'
coral
'
:
0xFF7F50
,
'
cornflowerblue
'
:
0x6495ED
,
'
cornsilk
'
:
0xFFF8DC
,
'
crimson
'
:
0xDC143C
,
'
cyan
'
:
0x00FFFF
,
'
darkblue
'
:
0x00008B
,
'
darkcyan
'
:
0x008B8B
,
'
darkgoldenrod
'
:
0xB8860B
,
'
darkgray
'
:
0xA9A9A9
,
'
darkgreen
'
:
0x006400
,
'
darkgrey
'
:
0xA9A9A9
,
'
darkkhaki
'
:
0xBDB76B
,
'
darkmagenta
'
:
0x8B008B
,
'
darkolivegreen
'
:
0x556B2F
,
'
darkorange
'
:
0xFF8C00
,
'
darkorchid
'
:
0x9932CC
,
'
darkred
'
:
0x8B0000
,
'
darksalmon
'
:
0xE9967A
,
'
darkseagreen
'
:
0x8FBC8F
,
'
darkslateblue
'
:
0x483D8B
,
'
darkslategray
'
:
0x2F4F4F
,
'
darkslategrey
'
:
0x2F4F4F
,
'
darkturquoise
'
:
0x00CED1
,
'
darkviolet
'
:
0x9400D3
,
'
deeppink
'
:
0xFF1493
,
'
deepskyblue
'
:
0x00BFFF
,
'
dimgray
'
:
0x696969
,
'
dimgrey
'
:
0x696969
,
'
dodgerblue
'
:
0x1E90FF
,
'
firebrick
'
:
0xB22222
,
'
floralwhite
'
:
0xFFFAF0
,
'
forestgreen
'
:
0x228B22
,
'
fuchsia
'
:
0xFF00FF
,
'
gainsboro
'
:
0xDCDCDC
,
'
ghostwhite
'
:
0xF8F8FF
,
'
gold
'
:
0xFFD700
,
'
goldenrod
'
:
0xDAA520
,
'
gray
'
:
0x808080
,
'
green
'
:
0x008000
,
'
greenyellow
'
:
0xADFF2F
,
'
grey
'
:
0x808080
,
'
honeydew
'
:
0xF0FFF0
,
'
hotpink
'
:
0xFF69B4
,
'
indianred
'
:
0xCD5C5C
,
'
indigo
'
:
0x4B0082
,
'
ivory
'
:
0xFFFFF0
,
'
khaki
'
:
0xF0E68C
,
'
lavender
'
:
0xE6E6FA
,
'
lavenderblush
'
:
0xFFF0F5
,
'
lawngreen
'
:
0x7CFC00
,
'
lemonchiffon
'
:
0xFFFACD
,
'
lightblue
'
:
0xADD8E6
,
'
lightcoral
'
:
0xF08080
,
'
lightcyan
'
:
0xE0FFFF
,
'
lightgoldenrodyellow
'
:
0xFAFAD2
,
'
lightgray
'
:
0xD3D3D3
,
'
lightgreen
'
:
0x90EE90
,
'
lightgrey
'
:
0xD3D3D3
,
'
lightpink
'
:
0xFFB6C1
,
'
lightsalmon
'
:
0xFFA07A
,
'
lightseagreen
'
:
0x20B2AA
,
'
lightskyblue
'
:
0x87CEFA
,
'
lightslategray
'
:
0x778899
,
'
lightslategrey
'
:
0x778899
,
'
lightsteelblue
'
:
0xB0C4DE
,
'
lightyellow
'
:
0xFFFFE0
,
'
lime
'
:
0x00FF00
,
'
limegreen
'
:
0x32CD32
,
'
linen
'
:
0xFAF0E6
,
'
magenta
'
:
0xFF00FF
,
'
maroon
'
:
0x800000
,
'
mediumaquamarine
'
:
0x66CDAA
,
'
mediumblue
'
:
0x0000CD
,
'
mediumorchid
'
:
0xBA55D3
,
'
mediumpurple
'
:
0x9370DB
,
'
mediumseagreen
'
:
0x3CB371
,
'
mediumslateblue
'
:
0x7B68EE
,
'
mediumspringgreen
'
:
0x00FA9A
,
'
mediumturquoise
'
:
0x48D1CC
,
'
mediumvioletred
'
:
0xC71585
,
'
midnightblue
'
:
0x191970
,
'
mintcream
'
:
0xF5FFFA
,
'
mistyrose
'
:
0xFFE4E1
,
'
moccasin
'
:
0xFFE4B5
,
'
navajowhite
'
:
0xFFDEAD
,
'
navy
'
:
0x000080
,
'
oldlace
'
:
0xFDF5E6
,
'
olive
'
:
0x808000
,
'
olivedrab
'
:
0x6B8E23
,
'
orange
'
:
0xFFA500
,
'
orangered
'
:
0xFF4500
,
'
orchid
'
:
0xDA70D6
,
'
palegoldenrod
'
:
0xEEE8AA
,
'
palegreen
'
:
0x98FB98
,
'
paleturquoise
'
:
0xAFEEEE
,
'
palevioletred
'
:
0xDB7093
,
'
papayawhip
'
:
0xFFEFD5
,
'
peachpuff
'
:
0xFFDAB9
,
'
peru
'
:
0xCD853F
,
'
pink
'
:
0xFFC0CB
,
'
plum
'
:
0xDDA0DD
,
'
powderblue
'
:
0xB0E0E6
,
'
purple
'
:
0x800080
,
'
red
'
:
0xFF0000
,
'
rosybrown
'
:
0xBC8F8F
,
'
royalblue
'
:
0x4169E1
,
'
saddlebrown
'
:
0x8B4513
,
'
salmon
'
:
0xFA8072
,
'
sandybrown
'
:
0xF4A460
,
'
seagreen
'
:
0x2E8B57
,
'
seashell
'
:
0xFFF5EE
,
'
sienna
'
:
0xA0522D
,
'
silver
'
:
0xC0C0C0
,
'
skyblue
'
:
0x87CEEB
,
'
slateblue
'
:
0x6A5ACD
,
'
slategray
'
:
0x708090
,
'
slategrey
'
:
0x708090
,
'
snow
'
:
0xFFFAFA
,
'
springgreen
'
:
0x00FF7F
,
'
steelblue
'
:
0x4682B4
,
'
tan
'
:
0xD2B48C
,
'
teal
'
:
0x008080
,
'
thistle
'
:
0xD8BFD8
,
'
tomato
'
:
0xFF6347
,
'
turquoise
'
:
0x40E0D0
,
'
violet
'
:
0xEE82EE
,
'
wheat
'
:
0xF5DEB3
,
'
white
'
:
0xFFFFFF
,
'
whitesmoke
'
:
0xF5F5F5
,
'
yellow
'
:
0xFFFF00
,
'
yellowgreen
'
:
0x9ACD32
};
function
Color
(
r
,
g
,
b
)
{
if
(
g
===
undefined
&&
b
===
undefined
)
{
...
...
@@ -17,7 +42,7 @@ function Color( r, g, b ) {
}
Color
.
prototype
=
{
Object
.
assign
(
Color
.
prototype
,
{
constructor
:
Color
,
...
...
@@ -494,32 +519,7 @@ Color.prototype = {
}
};
var
ColorKeywords
=
{
'
aliceblue
'
:
0xF0F8FF
,
'
antiquewhite
'
:
0xFAEBD7
,
'
aqua
'
:
0x00FFFF
,
'
aquamarine
'
:
0x7FFFD4
,
'
azure
'
:
0xF0FFFF
,
'
beige
'
:
0xF5F5DC
,
'
bisque
'
:
0xFFE4C4
,
'
black
'
:
0x000000
,
'
blanchedalmond
'
:
0xFFEBCD
,
'
blue
'
:
0x0000FF
,
'
blueviolet
'
:
0x8A2BE2
,
'
brown
'
:
0xA52A2A
,
'
burlywood
'
:
0xDEB887
,
'
cadetblue
'
:
0x5F9EA0
,
'
chartreuse
'
:
0x7FFF00
,
'
chocolate
'
:
0xD2691E
,
'
coral
'
:
0xFF7F50
,
'
cornflowerblue
'
:
0x6495ED
,
'
cornsilk
'
:
0xFFF8DC
,
'
crimson
'
:
0xDC143C
,
'
cyan
'
:
0x00FFFF
,
'
darkblue
'
:
0x00008B
,
'
darkcyan
'
:
0x008B8B
,
'
darkgoldenrod
'
:
0xB8860B
,
'
darkgray
'
:
0xA9A9A9
,
'
darkgreen
'
:
0x006400
,
'
darkgrey
'
:
0xA9A9A9
,
'
darkkhaki
'
:
0xBDB76B
,
'
darkmagenta
'
:
0x8B008B
,
'
darkolivegreen
'
:
0x556B2F
,
'
darkorange
'
:
0xFF8C00
,
'
darkorchid
'
:
0x9932CC
,
'
darkred
'
:
0x8B0000
,
'
darksalmon
'
:
0xE9967A
,
'
darkseagreen
'
:
0x8FBC8F
,
'
darkslateblue
'
:
0x483D8B
,
'
darkslategray
'
:
0x2F4F4F
,
'
darkslategrey
'
:
0x2F4F4F
,
'
darkturquoise
'
:
0x00CED1
,
'
darkviolet
'
:
0x9400D3
,
'
deeppink
'
:
0xFF1493
,
'
deepskyblue
'
:
0x00BFFF
,
'
dimgray
'
:
0x696969
,
'
dimgrey
'
:
0x696969
,
'
dodgerblue
'
:
0x1E90FF
,
'
firebrick
'
:
0xB22222
,
'
floralwhite
'
:
0xFFFAF0
,
'
forestgreen
'
:
0x228B22
,
'
fuchsia
'
:
0xFF00FF
,
'
gainsboro
'
:
0xDCDCDC
,
'
ghostwhite
'
:
0xF8F8FF
,
'
gold
'
:
0xFFD700
,
'
goldenrod
'
:
0xDAA520
,
'
gray
'
:
0x808080
,
'
green
'
:
0x008000
,
'
greenyellow
'
:
0xADFF2F
,
'
grey
'
:
0x808080
,
'
honeydew
'
:
0xF0FFF0
,
'
hotpink
'
:
0xFF69B4
,
'
indianred
'
:
0xCD5C5C
,
'
indigo
'
:
0x4B0082
,
'
ivory
'
:
0xFFFFF0
,
'
khaki
'
:
0xF0E68C
,
'
lavender
'
:
0xE6E6FA
,
'
lavenderblush
'
:
0xFFF0F5
,
'
lawngreen
'
:
0x7CFC00
,
'
lemonchiffon
'
:
0xFFFACD
,
'
lightblue
'
:
0xADD8E6
,
'
lightcoral
'
:
0xF08080
,
'
lightcyan
'
:
0xE0FFFF
,
'
lightgoldenrodyellow
'
:
0xFAFAD2
,
'
lightgray
'
:
0xD3D3D3
,
'
lightgreen
'
:
0x90EE90
,
'
lightgrey
'
:
0xD3D3D3
,
'
lightpink
'
:
0xFFB6C1
,
'
lightsalmon
'
:
0xFFA07A
,
'
lightseagreen
'
:
0x20B2AA
,
'
lightskyblue
'
:
0x87CEFA
,
'
lightslategray
'
:
0x778899
,
'
lightslategrey
'
:
0x778899
,
'
lightsteelblue
'
:
0xB0C4DE
,
'
lightyellow
'
:
0xFFFFE0
,
'
lime
'
:
0x00FF00
,
'
limegreen
'
:
0x32CD32
,
'
linen
'
:
0xFAF0E6
,
'
magenta
'
:
0xFF00FF
,
'
maroon
'
:
0x800000
,
'
mediumaquamarine
'
:
0x66CDAA
,
'
mediumblue
'
:
0x0000CD
,
'
mediumorchid
'
:
0xBA55D3
,
'
mediumpurple
'
:
0x9370DB
,
'
mediumseagreen
'
:
0x3CB371
,
'
mediumslateblue
'
:
0x7B68EE
,
'
mediumspringgreen
'
:
0x00FA9A
,
'
mediumturquoise
'
:
0x48D1CC
,
'
mediumvioletred
'
:
0xC71585
,
'
midnightblue
'
:
0x191970
,
'
mintcream
'
:
0xF5FFFA
,
'
mistyrose
'
:
0xFFE4E1
,
'
moccasin
'
:
0xFFE4B5
,
'
navajowhite
'
:
0xFFDEAD
,
'
navy
'
:
0x000080
,
'
oldlace
'
:
0xFDF5E6
,
'
olive
'
:
0x808000
,
'
olivedrab
'
:
0x6B8E23
,
'
orange
'
:
0xFFA500
,
'
orangered
'
:
0xFF4500
,
'
orchid
'
:
0xDA70D6
,
'
palegoldenrod
'
:
0xEEE8AA
,
'
palegreen
'
:
0x98FB98
,
'
paleturquoise
'
:
0xAFEEEE
,
'
palevioletred
'
:
0xDB7093
,
'
papayawhip
'
:
0xFFEFD5
,
'
peachpuff
'
:
0xFFDAB9
,
'
peru
'
:
0xCD853F
,
'
pink
'
:
0xFFC0CB
,
'
plum
'
:
0xDDA0DD
,
'
powderblue
'
:
0xB0E0E6
,
'
purple
'
:
0x800080
,
'
red
'
:
0xFF0000
,
'
rosybrown
'
:
0xBC8F8F
,
'
royalblue
'
:
0x4169E1
,
'
saddlebrown
'
:
0x8B4513
,
'
salmon
'
:
0xFA8072
,
'
sandybrown
'
:
0xF4A460
,
'
seagreen
'
:
0x2E8B57
,
'
seashell
'
:
0xFFF5EE
,
'
sienna
'
:
0xA0522D
,
'
silver
'
:
0xC0C0C0
,
'
skyblue
'
:
0x87CEEB
,
'
slateblue
'
:
0x6A5ACD
,
'
slategray
'
:
0x708090
,
'
slategrey
'
:
0x708090
,
'
snow
'
:
0xFFFAFA
,
'
springgreen
'
:
0x00FF7F
,
'
steelblue
'
:
0x4682B4
,
'
tan
'
:
0xD2B48C
,
'
teal
'
:
0x008080
,
'
thistle
'
:
0xD8BFD8
,
'
tomato
'
:
0xFF6347
,
'
turquoise
'
:
0x40E0D0
,
'
violet
'
:
0xEE82EE
,
'
wheat
'
:
0xF5DEB3
,
'
white
'
:
0xFFFFFF
,
'
whitesmoke
'
:
0xF5F5F5
,
'
yellow
'
:
0xFFFF00
,
'
yellowgreen
'
:
0x9ACD32
};
}
);
export
{
Color
};
src/math/Cylindrical.js
浏览文件 @
8f0a1c50
...
...
@@ -15,7 +15,7 @@ function Cylindrical( radius, theta, y ) {
}
Cylindrical
.
prototype
=
{
Object
.
assign
(
Cylindrical
.
prototype
,
{
constructor
:
Cylindrical
,
...
...
@@ -55,7 +55,7 @@ Cylindrical.prototype = {
}
};
}
)
;
export
{
Cylindrical
};
src/math/Euler.js
浏览文件 @
8f0a1c50
...
...
@@ -22,63 +22,83 @@ Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
Euler
.
DefaultOrder
=
'
XYZ
'
;
Euler
.
prototype
=
{
Object
.
defineProperties
(
Euler
.
prototype
,
{
constructor
:
Euler
,
"
x
"
:
{
isEuler
:
true
,
get
:
function
()
{
get
x
()
{
return
this
.
_x
;
return
this
.
_x
;
},
},
set
:
function
(
value
)
{
set
x
(
value
)
{
this
.
_x
=
value
;
this
.
onChangeCallback
();
this
.
_x
=
value
;
this
.
onChangeCallback
();
}
},
get
y
()
{
"
y
"
:
{
return
this
.
_y
;
get
:
function
()
{
},
return
this
.
_y
;
set
y
(
value
)
{
},
this
.
_y
=
value
;
this
.
onChangeCallback
();
set
:
function
(
value
)
{
this
.
_y
=
value
;
this
.
onChangeCallback
();
}
},
get
z
()
{
"
z
"
:
{
return
this
.
_z
;
get
:
function
()
{
},
return
this
.
_z
;
set
z
(
value
)
{
},
this
.
_z
=
value
;
this
.
onChangeCallback
();
set
:
function
(
value
)
{
this
.
_z
=
value
;
this
.
onChangeCallback
();
}
},
get
order
()
{
"
order
"
:
{
return
this
.
_order
;
get
:
function
()
{
},
return
this
.
_order
;
set
order
(
value
)
{
},
this
.
_order
=
value
;
this
.
onChangeCallback
();
set
:
function
(
value
)
{
},
this
.
_order
=
value
;
this
.
onChangeCallback
();
}
}
});
Object
.
assign
(
Euler
.
prototype
,
{
constructor
:
Euler
,
isEuler
:
true
,
set
:
function
(
x
,
y
,
z
,
order
)
{
...
...
@@ -237,12 +257,10 @@ Euler.prototype = {
setFromQuaternion
:
function
()
{
var
matrix
;
var
matrix
=
new
Matrix4
()
;
return
function
setFromQuaternion
(
q
,
order
,
update
)
{
if
(
matrix
===
undefined
)
matrix
=
new
Matrix4
();
matrix
.
makeRotationFromQuaternion
(
q
);
return
this
.
setFromRotationMatrix
(
matrix
,
order
,
update
);
...
...
@@ -330,7 +348,7 @@ Euler.prototype = {
onChangeCallback
:
function
()
{}
};
}
)
;
export
{
Euler
};
src/math/Frustum.js
浏览文件 @
8f0a1c50
...
...
@@ -23,7 +23,7 @@ function Frustum( p0, p1, p2, p3, p4, p5 ) {
}
Frustum
.
prototype
=
{
Object
.
assign
(
Frustum
.
prototype
,
{
constructor
:
Frustum
,
...
...
@@ -178,8 +178,7 @@ Frustum.prototype = {
};
}(),
containsPoint
:
function
(
point
)
{
var
planes
=
this
.
planes
;
...
...
@@ -198,7 +197,7 @@ Frustum.prototype = {
}
};
}
)
;
export
{
Frustum
};
src/math/Interpolant.js
浏览文件 @
8f0a1c50
...
...
@@ -20,8 +20,7 @@
* @author tschw
*/
function
Interpolant
(
parameterPositions
,
sampleValues
,
sampleSize
,
resultBuffer
)
{
function
Interpolant
(
parameterPositions
,
sampleValues
,
sampleSize
,
resultBuffer
)
{
this
.
parameterPositions
=
parameterPositions
;
this
.
_cachedIndex
=
0
;
...
...
@@ -33,7 +32,7 @@ function Interpolant(
}
Interpolant
.
prototype
=
{
Object
.
assign
(
Interpolant
.
prototype
,
{
constructor
:
Interpolant
,
...
...
@@ -52,10 +51,10 @@ Interpolant.prototype = {
var
right
;
linear_scan
:
{
//- See http://jsperf.com/comparison-to-undefined/3
//- slower code:
//-
//- if ( t >= t1 || t1 === undefined ) {
//- See http://jsperf.com/comparison-to-undefined/3
//- slower code:
//-
//- if ( t >= t1 || t1 === undefined ) {
forward_scan
:
if
(
!
(
t
<
t1
)
)
{
for
(
var
giveUpAt
=
i1
+
2
;
;)
{
...
...
@@ -92,8 +91,8 @@ Interpolant.prototype = {
}
//- slower code:
//- if ( t < t0 || t0 === undefined ) {
//- slower code:
//- if ( t < t0 || t0 === undefined ) {
if
(
!
(
t
>=
t0
)
)
{
// looping?
...
...
@@ -244,15 +243,16 @@ Interpolant.prototype = {
}
};
}
)
;
//!\ DECLARE ALIAS AFTER assign prototype !
Object
.
assign
(
Interpolant
.
prototype
,
{
beforeStart_
:
//( 0, t, t0 ), returns this.resultBuffer
Interpolant
.
prototype
.
copySampleValue_
,
//( 0, t, t0 ), returns this.resultBuffer
beforeStart_
:
Interpolant
.
prototype
.
copySampleValue_
,
afterEnd_
:
//( N-1, tN-1, t ), returns this.resultBuffer
Interpolant
.
prototype
.
copySampleValue_
//( N-1, tN-1, t ), returns this.resultBuffer
afterEnd_
:
Interpolant
.
prototype
.
copySampleValue_
,
}
);
...
...
src/math/Line3.js
浏览文件 @
8f0a1c50
...
...
@@ -12,7 +12,7 @@ function Line3( start, end ) {
}
Line3
.
prototype
=
{
Object
.
assign
(
Line3
.
prototype
,
{
constructor
:
Line3
,
...
...
@@ -126,7 +126,7 @@ Line3.prototype = {
}
};
}
)
;
export
{
Line3
};
src/math/Matrix3.js
浏览文件 @
8f0a1c50
...
...
@@ -25,7 +25,7 @@ function Matrix3() {
}
Matrix3
.
prototype
=
{
Object
.
assign
(
Matrix3
.
prototype
,
{
constructor
:
Matrix3
,
...
...
@@ -97,12 +97,10 @@ Matrix3.prototype = {
applyToBufferAttribute
:
function
()
{
var
v1
;
var
v1
=
new
Vector3
()
;
return
function
applyToBufferAttribute
(
attribute
)
{
if
(
v1
===
undefined
)
v1
=
new
Vector3
();
for
(
var
i
=
0
,
l
=
attribute
.
count
;
i
<
l
;
i
++
)
{
v1
.
x
=
attribute
.
getX
(
i
);
...
...
@@ -274,7 +272,7 @@ Matrix3.prototype = {
}
};
}
)
;
export
{
Matrix3
};
src/math/Matrix4.js
浏览文件 @
8f0a1c50
...
...
@@ -33,7 +33,7 @@ function Matrix4() {
}
Matrix4
.
prototype
=
{
Object
.
assign
(
Matrix4
.
prototype
,
{
constructor
:
Matrix4
,
...
...
@@ -119,12 +119,10 @@ Matrix4.prototype = {
extractRotation
:
function
()
{
var
v1
;
var
v1
=
new
Vector3
()
;
return
function
extractRotation
(
m
)
{
if
(
v1
===
undefined
)
v1
=
new
Vector3
();
var
te
=
this
.
elements
;
var
me
=
m
.
elements
;
...
...
@@ -317,18 +315,12 @@ Matrix4.prototype = {
lookAt
:
function
()
{
var
x
,
y
,
z
;
var
x
=
new
Vector3
();
var
y
=
new
Vector3
();
var
z
=
new
Vector3
();
return
function
lookAt
(
eye
,
target
,
up
)
{
if
(
x
===
undefined
)
{
x
=
new
Vector3
();
y
=
new
Vector3
();
z
=
new
Vector3
();
}
var
te
=
this
.
elements
;
z
.
subVectors
(
eye
,
target
).
normalize
();
...
...
@@ -450,12 +442,10 @@ Matrix4.prototype = {
applyToBufferAttribute
:
function
()
{
var
v1
;
var
v1
=
new
Vector3
()
;
return
function
applyToBufferAttribute
(
attribute
)
{
if
(
v1
===
undefined
)
v1
=
new
Vector3
();
for
(
var
i
=
0
,
l
=
attribute
.
count
;
i
<
l
;
i
++
)
{
v1
.
x
=
attribute
.
getX
(
i
);
...
...
@@ -772,17 +762,11 @@ Matrix4.prototype = {
decompose
:
function
()
{
var
vector
,
matrix
;
var
vector
=
new
Vector3
();
var
matrix
=
new
Matrix4
();
return
function
decompose
(
position
,
quaternion
,
scale
)
{
if
(
vector
===
undefined
)
{
vector
=
new
Vector3
();
matrix
=
new
Matrix4
();
}
var
te
=
this
.
elements
;
var
sx
=
vector
.
set
(
te
[
0
],
te
[
1
],
te
[
2
]
).
length
();
...
...
@@ -939,7 +923,7 @@ Matrix4.prototype = {
}
};
}
)
;
export
{
Matrix4
};
src/math/Plane.js
浏览文件 @
8f0a1c50
...
...
@@ -12,7 +12,7 @@ function Plane( normal, constant ) {
}
Plane
.
prototype
=
{
Object
.
assign
(
Plane
.
prototype
,
{
constructor
:
Plane
,
...
...
@@ -232,7 +232,7 @@ Plane.prototype = {
}
};
}
)
;
export
{
Plane
};
src/math/Quaternion.js
浏览文件 @
8f0a1c50
...
...
@@ -16,62 +16,155 @@ function Quaternion( x, y, z, w ) {
}
Quaternion
.
prototype
=
{
constructor
:
Quaternion
,
Object
.
assign
(
Quaternion
,
{
get
x
(
)
{
slerp
:
function
(
qa
,
qb
,
qm
,
t
)
{
return
this
.
_x
;
return
qm
.
copy
(
qa
).
slerp
(
qb
,
t
)
;
},
set
x
(
value
)
{
slerpFlat
:
function
(
dst
,
dstOffset
,
src0
,
srcOffset0
,
src1
,
srcOffset1
,
t
)
{
this
.
_x
=
value
;
this
.
onChangeCallback
();
// fuzz-free, array-based Quaternion SLERP operation
},
var
x0
=
src0
[
srcOffset0
+
0
],
y0
=
src0
[
srcOffset0
+
1
],
z0
=
src0
[
srcOffset0
+
2
],
w0
=
src0
[
srcOffset0
+
3
],
get
y
()
{
x1
=
src1
[
srcOffset1
+
0
],
y1
=
src1
[
srcOffset1
+
1
],
z1
=
src1
[
srcOffset1
+
2
],
w1
=
src1
[
srcOffset1
+
3
];
return
this
.
_y
;
if
(
w0
!==
w1
||
x0
!==
x1
||
y0
!==
y1
||
z0
!==
z1
)
{
}
,
var
s
=
1
-
t
,
set
y
(
value
)
{
cos
=
x0
*
x1
+
y0
*
y1
+
z0
*
z1
+
w0
*
w1
,
this
.
_y
=
value
;
this
.
onChangeCallback
()
;
dir
=
(
cos
>=
0
?
1
:
-
1
),
sqrSin
=
1
-
cos
*
cos
;
},
// Skip the Slerp for tiny steps to avoid numeric problems:
if
(
sqrSin
>
Number
.
EPSILON
)
{
get
z
()
{
var
sin
=
Math
.
sqrt
(
sqrSin
),
len
=
Math
.
atan2
(
sin
,
cos
*
dir
);
return
this
.
_z
;
s
=
Math
.
sin
(
s
*
len
)
/
sin
;
t
=
Math
.
sin
(
t
*
len
)
/
sin
;
},
}
set
z
(
value
)
{
var
tDir
=
t
*
dir
;
this
.
_z
=
value
;
this
.
onChangeCallback
();
x0
=
x0
*
s
+
x1
*
tDir
;
y0
=
y0
*
s
+
y1
*
tDir
;
z0
=
z0
*
s
+
z1
*
tDir
;
w0
=
w0
*
s
+
w1
*
tDir
;
// Normalize in case we just did a lerp:
if
(
s
===
1
-
t
)
{
var
f
=
1
/
Math
.
sqrt
(
x0
*
x0
+
y0
*
y0
+
z0
*
z0
+
w0
*
w0
);
x0
*=
f
;
y0
*=
f
;
z0
*=
f
;
w0
*=
f
;
}
}
dst
[
dstOffset
]
=
x0
;
dst
[
dstOffset
+
1
]
=
y0
;
dst
[
dstOffset
+
2
]
=
z0
;
dst
[
dstOffset
+
3
]
=
w0
;
}
}
);
Object
.
defineProperties
(
Quaternion
.
prototype
,
{
"
x
"
:
{
get
:
function
()
{
return
this
.
_x
;
},
set
:
function
(
value
)
{
this
.
_x
=
value
;
this
.
onChangeCallback
();
}
},
get
w
()
{
"
y
"
:
{
get
:
function
()
{
return
this
.
_y
;
},
set
:
function
(
value
)
{
return
this
.
_w
;
this
.
_y
=
value
;
this
.
onChangeCallback
();
}
},
set
w
(
value
)
{
"
z
"
:
{
this
.
_w
=
value
;
this
.
onChangeCallback
();
get
:
function
()
{
return
this
.
_z
;
},
set
:
function
(
value
)
{
this
.
_z
=
value
;
this
.
onChangeCallback
();
}
},
"
w
"
:
{
get
:
function
()
{
return
this
.
_w
;
},
set
:
function
(
value
)
{
this
.
_w
=
value
;
this
.
onChangeCallback
();
}
}
});
Object
.
assign
(
Quaternion
.
prototype
,
{
constructor
:
Quaternion
,
set
:
function
(
x
,
y
,
z
,
w
)
{
this
.
_x
=
x
;
...
...
@@ -259,7 +352,8 @@ Quaternion.prototype = {
// assumes direction vectors vFrom and vTo are normalized
var
v1
,
r
;
var
v1
=
new
Vector3
();
var
r
;
var
EPS
=
0.000001
;
...
...
@@ -453,7 +547,7 @@ Quaternion.prototype = {
var
halfTheta
=
Math
.
atan2
(
sinHalfTheta
,
cosHalfTheta
);
var
ratioA
=
Math
.
sin
(
(
1
-
t
)
*
halfTheta
)
/
sinHalfTheta
,
ratioB
=
Math
.
sin
(
t
*
halfTheta
)
/
sinHalfTheta
;
ratioB
=
Math
.
sin
(
t
*
halfTheta
)
/
sinHalfTheta
;
this
.
_w
=
(
w
*
ratioA
+
this
.
_w
*
ratioB
);
this
.
_x
=
(
x
*
ratioA
+
this
.
_x
*
ratioB
);
...
...
@@ -511,79 +605,6 @@ Quaternion.prototype = {
onChangeCallback
:
function
()
{}
};
Object
.
assign
(
Quaternion
,
{
slerp
:
function
(
qa
,
qb
,
qm
,
t
)
{
return
qm
.
copy
(
qa
).
slerp
(
qb
,
t
);
},
slerpFlat
:
function
(
dst
,
dstOffset
,
src0
,
srcOffset0
,
src1
,
srcOffset1
,
t
)
{
// fuzz-free, array-based Quaternion SLERP operation
var
x0
=
src0
[
srcOffset0
+
0
],
y0
=
src0
[
srcOffset0
+
1
],
z0
=
src0
[
srcOffset0
+
2
],
w0
=
src0
[
srcOffset0
+
3
],
x1
=
src1
[
srcOffset1
+
0
],
y1
=
src1
[
srcOffset1
+
1
],
z1
=
src1
[
srcOffset1
+
2
],
w1
=
src1
[
srcOffset1
+
3
];
if
(
w0
!==
w1
||
x0
!==
x1
||
y0
!==
y1
||
z0
!==
z1
)
{
var
s
=
1
-
t
,
cos
=
x0
*
x1
+
y0
*
y1
+
z0
*
z1
+
w0
*
w1
,
dir
=
(
cos
>=
0
?
1
:
-
1
),
sqrSin
=
1
-
cos
*
cos
;
// Skip the Slerp for tiny steps to avoid numeric problems:
if
(
sqrSin
>
Number
.
EPSILON
)
{
var
sin
=
Math
.
sqrt
(
sqrSin
),
len
=
Math
.
atan2
(
sin
,
cos
*
dir
);
s
=
Math
.
sin
(
s
*
len
)
/
sin
;
t
=
Math
.
sin
(
t
*
len
)
/
sin
;
}
var
tDir
=
t
*
dir
;
x0
=
x0
*
s
+
x1
*
tDir
;
y0
=
y0
*
s
+
y1
*
tDir
;
z0
=
z0
*
s
+
z1
*
tDir
;
w0
=
w0
*
s
+
w1
*
tDir
;
// Normalize in case we just did a lerp:
if
(
s
===
1
-
t
)
{
var
f
=
1
/
Math
.
sqrt
(
x0
*
x0
+
y0
*
y0
+
z0
*
z0
+
w0
*
w0
);
x0
*=
f
;
y0
*=
f
;
z0
*=
f
;
w0
*=
f
;
}
}
dst
[
dstOffset
]
=
x0
;
dst
[
dstOffset
+
1
]
=
y0
;
dst
[
dstOffset
+
2
]
=
z0
;
dst
[
dstOffset
+
3
]
=
w0
;
}
}
);
...
...
src/math/Ray.js
浏览文件 @
8f0a1c50
...
...
@@ -11,7 +11,7 @@ function Ray( origin, direction ) {
}
Ray
.
prototype
=
{
Object
.
assign
(
Ray
.
prototype
,
{
constructor
:
Ray
,
...
...
@@ -325,8 +325,6 @@ Ray.prototype = {
},
intersectsPlane
:
function
(
plane
)
{
// check if the ray lies on the plane first
...
...
@@ -534,7 +532,7 @@ Ray.prototype = {
}
};
}
)
;
export
{
Ray
};
src/math/Sphere.js
浏览文件 @
8f0a1c50
...
...
@@ -13,7 +13,7 @@ function Sphere( center, radius ) {
}
Sphere
.
prototype
=
{
Object
.
assign
(
Sphere
.
prototype
,
{
constructor
:
Sphere
,
...
...
@@ -28,12 +28,10 @@ Sphere.prototype = {
setFromPoints
:
function
()
{
var
box
;
var
box
=
new
Box3
()
;
return
function
setFromPoints
(
points
,
optionalCenter
)
{
if
(
box
===
undefined
)
box
=
new
Box3
();
// see #10547
var
center
=
this
.
center
;
if
(
optionalCenter
!==
undefined
)
{
...
...
@@ -176,7 +174,7 @@ Sphere.prototype = {
}
};
}
)
;
export
{
Sphere
};
src/math/Spherical.js
浏览文件 @
8f0a1c50
...
...
@@ -20,7 +20,7 @@ function Spherical( radius, phi, theta ) {
}
Spherical
.
prototype
=
{
Object
.
assign
(
Spherical
.
prototype
,
{
constructor
:
Spherical
,
...
...
@@ -80,7 +80,7 @@ Spherical.prototype = {
}
};
}
)
;
export
{
Spherical
};
src/math/Triangle.js
浏览文件 @
8f0a1c50
...
...
@@ -15,90 +15,94 @@ function Triangle( a, b, c ) {
}
Triangle
.
normal
=
function
()
{
Object
.
assign
(
Triangle
,
{
var
v0
=
new
Vector3
();
normal
:
function
()
{
return
function
normal
(
a
,
b
,
c
,
optionalTarget
)
{
var
v0
=
new
Vector3
();
var
result
=
optionalTarget
||
new
Vector3
();
return
function
normal
(
a
,
b
,
c
,
optionalTarget
)
{
result
.
subVectors
(
c
,
b
);
v0
.
subVectors
(
a
,
b
);
result
.
cross
(
v0
);
var
result
=
optionalTarget
||
new
Vector3
();
var
resultLengthSq
=
result
.
lengthSq
();
if
(
resultLengthSq
>
0
)
{
result
.
subVectors
(
c
,
b
);
v0
.
subVectors
(
a
,
b
);
result
.
cross
(
v0
);
return
result
.
multiplyScalar
(
1
/
Math
.
sqrt
(
resultLengthSq
)
);
var
resultLengthSq
=
result
.
lengthSq
();
if
(
resultLengthSq
>
0
)
{
}
return
result
.
multiplyScalar
(
1
/
Math
.
sqrt
(
resultLengthSq
)
);
return
result
.
set
(
0
,
0
,
0
);
}
}
;
return
result
.
set
(
0
,
0
,
0
)
;
}()
;
}
;
// static/instance method to calculate barycentric coordinates
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
Triangle
.
barycoordFromPoint
=
function
()
{
}(),
var
v0
=
new
Vector3
();
var
v1
=
new
Vector3
();
var
v2
=
new
Vector3
();
// static/instance method to calculate barycentric coordinates
// based on: http://www.blackpawn.com/texts/pointinpoly/default.html
barycoordFromPoint
:
function
()
{
return
function
barycoordFromPoint
(
point
,
a
,
b
,
c
,
optionalTarget
)
{
var
v0
=
new
Vector3
();
var
v1
=
new
Vector3
();
var
v2
=
new
Vector3
();
v0
.
subVectors
(
c
,
a
);
v1
.
subVectors
(
b
,
a
);
v2
.
subVectors
(
point
,
a
);
return
function
barycoordFromPoint
(
point
,
a
,
b
,
c
,
optionalTarget
)
{
var
dot00
=
v0
.
dot
(
v0
);
var
dot01
=
v0
.
dot
(
v1
);
var
dot02
=
v0
.
dot
(
v2
);
var
dot11
=
v1
.
dot
(
v1
);
var
dot12
=
v1
.
dot
(
v2
);
v0
.
subVectors
(
c
,
a
);
v1
.
subVectors
(
b
,
a
);
v2
.
subVectors
(
point
,
a
);
var
denom
=
(
dot00
*
dot11
-
dot01
*
dot01
);
var
dot00
=
v0
.
dot
(
v0
);
var
dot01
=
v0
.
dot
(
v1
);
var
dot02
=
v0
.
dot
(
v2
);
var
dot11
=
v1
.
dot
(
v1
);
var
dot12
=
v1
.
dot
(
v2
);
var
result
=
optionalTarget
||
new
Vector3
(
);
var
denom
=
(
dot00
*
dot11
-
dot01
*
dot01
);
// collinear or singular triangle
if
(
denom
===
0
)
{
var
result
=
optionalTarget
||
new
Vector3
();
// arbitrary location outside of triangle?
// not sure if this is the best idea, maybe should be returning undefined
return
result
.
set
(
-
2
,
-
1
,
-
1
);
// collinear or singular triangle
if
(
denom
===
0
)
{
}
// arbitrary location outside of triangle?
// not sure if this is the best idea, maybe should be returning undefined
return
result
.
set
(
-
2
,
-
1
,
-
1
);
var
invDenom
=
1
/
denom
;
var
u
=
(
dot11
*
dot02
-
dot01
*
dot12
)
*
invDenom
;
var
v
=
(
dot00
*
dot12
-
dot01
*
dot02
)
*
invDenom
;
}
// barycentric coordinates must always sum to 1
return
result
.
set
(
1
-
u
-
v
,
v
,
u
);
var
invDenom
=
1
/
denom
;
var
u
=
(
dot11
*
dot02
-
dot01
*
dot12
)
*
invDenom
;
var
v
=
(
dot00
*
dot12
-
dot01
*
dot02
)
*
invDenom
;
};
// barycentric coordinates must always sum to 1
return
result
.
set
(
1
-
u
-
v
,
v
,
u
);
}();
};
}(),
Triangle
.
containsPoint
=
function
()
{
containsPoint
:
function
()
{
var
v1
=
new
Vector3
();
var
v1
=
new
Vector3
();
return
function
containsPoint
(
point
,
a
,
b
,
c
)
{
return
function
containsPoint
(
point
,
a
,
b
,
c
)
{
var
result
=
Triangle
.
barycoordFromPoint
(
point
,
a
,
b
,
c
,
v1
);
var
result
=
Triangle
.
barycoordFromPoint
(
point
,
a
,
b
,
c
,
v
1
);
return
(
result
.
x
>=
0
)
&&
(
result
.
y
>=
0
)
&&
(
(
result
.
x
+
result
.
y
)
<=
1
);
return
(
result
.
x
>=
0
)
&&
(
result
.
y
>=
0
)
&&
(
(
result
.
x
+
result
.
y
)
<=
1
)
;
}
;
}
;
}
()
}
(
);
}
);
Triangle
.
prototype
=
{
Object
.
assign
(
Triangle
.
prototype
,
{
constructor
:
Triangle
,
...
...
@@ -189,19 +193,13 @@ Triangle.prototype = {
closestPointToPoint
:
function
()
{
var
plane
,
edgeList
,
projectedPoint
,
closestPoint
;
var
plane
=
new
Plane
();
var
edgeList
=
[
new
Line3
(),
new
Line3
(),
new
Line3
()
];
var
projectedPoint
=
new
Vector3
();
var
closestPoint
=
new
Vector3
();
return
function
closestPointToPoint
(
point
,
optionalTarget
)
{
if
(
plane
===
undefined
)
{
plane
=
new
Plane
();
edgeList
=
[
new
Line3
(),
new
Line3
(),
new
Line3
()
];
projectedPoint
=
new
Vector3
();
closestPoint
=
new
Vector3
();
}
var
result
=
optionalTarget
||
new
Vector3
();
var
minDistance
=
Infinity
;
...
...
@@ -256,7 +254,7 @@ Triangle.prototype = {
}
};
}
)
;
export
{
Triangle
};
src/math/Vector2.js
浏览文件 @
8f0a1c50
...
...
@@ -12,37 +12,47 @@ function Vector2( x, y ) {
}
Vector2
.
prototype
=
{
constructor
:
Vector2
,
isVector2
:
true
,
get
width
()
{
return
this
.
x
;
},
set
width
(
value
)
{
this
.
x
=
value
;
},
get
height
()
{
return
this
.
y
;
},
Object
.
defineProperties
(
Vector2
.
prototype
,
{
"
width
"
:
{
get
:
function
()
{
return
this
.
x
;
},
set
:
function
(
value
)
{
this
.
x
=
value
;
}
},
"
height
"
:
{
get
:
function
()
{
return
this
.
y
;
},
set
:
function
(
value
)
{
this
.
y
=
value
;
}
}
set
height
(
value
)
{
}
);
this
.
y
=
value
;
Object
.
assign
(
Vector2
.
prototype
,
{
}
,
constructor
:
Vector2
,
//
isVector2
:
true
,
set
:
function
(
x
,
y
)
{
...
...
@@ -269,17 +279,11 @@ Vector2.prototype = {
clampScalar
:
function
()
{
var
min
,
max
;
var
min
=
new
Vector2
();
var
max
=
new
Vector2
();
return
function
clampScalar
(
minVal
,
maxVal
)
{
if
(
min
===
undefined
)
{
min
=
new
Vector2
();
max
=
new
Vector2
();
}
min
.
set
(
minVal
,
minVal
);
max
.
set
(
maxVal
,
maxVal
);
...
...
@@ -482,7 +486,7 @@ Vector2.prototype = {
}
};
}
)
;
export
{
Vector2
};
src/math/Vector3.js
浏览文件 @
8f0a1c50
...
...
@@ -19,7 +19,7 @@ function Vector3( x, y, z ) {
}
Vector3
.
prototype
=
{
Object
.
assign
(
Vector3
.
prototype
,
{
constructor
:
Vector3
,
...
...
@@ -246,7 +246,7 @@ Vector3.prototype = {
applyEuler
:
function
()
{
var
quaternion
;
var
quaternion
=
new
Quaternion
()
;
return
function
applyEuler
(
euler
)
{
...
...
@@ -256,8 +256,6 @@ Vector3.prototype = {
}
if
(
quaternion
===
undefined
)
quaternion
=
new
Quaternion
();
return
this
.
applyQuaternion
(
quaternion
.
setFromEuler
(
euler
)
);
};
...
...
@@ -266,12 +264,10 @@ Vector3.prototype = {
applyAxisAngle
:
function
()
{
var
quaternion
;
var
quaternion
=
new
Quaternion
()
;
return
function
applyAxisAngle
(
axis
,
angle
)
{
if
(
quaternion
===
undefined
)
quaternion
=
new
Quaternion
();
return
this
.
applyQuaternion
(
quaternion
.
setFromAxisAngle
(
axis
,
angle
)
);
};
...
...
@@ -329,12 +325,10 @@ Vector3.prototype = {
project
:
function
()
{
var
matrix
;
var
matrix
=
new
Matrix4
()
;
return
function
project
(
camera
)
{
if
(
matrix
===
undefined
)
matrix
=
new
Matrix4
();
matrix
.
multiplyMatrices
(
camera
.
projectionMatrix
,
matrix
.
getInverse
(
camera
.
matrixWorld
)
);
return
this
.
applyMatrix4
(
matrix
);
...
...
@@ -344,12 +338,10 @@ Vector3.prototype = {
unproject
:
function
()
{
var
matrix
;
var
matrix
=
new
Matrix4
()
;
return
function
unproject
(
camera
)
{
if
(
matrix
===
undefined
)
matrix
=
new
Matrix4
();
matrix
.
multiplyMatrices
(
camera
.
matrixWorld
,
matrix
.
getInverse
(
camera
.
projectionMatrix
)
);
return
this
.
applyMatrix4
(
matrix
);
...
...
@@ -423,17 +415,11 @@ Vector3.prototype = {
clampScalar
:
function
()
{
var
min
,
max
;
var
min
=
new
Vector3
();
var
max
=
new
Vector3
();
return
function
clampScalar
(
minVal
,
maxVal
)
{
if
(
min
===
undefined
)
{
min
=
new
Vector3
();
max
=
new
Vector3
();
}
min
.
set
(
minVal
,
minVal
,
minVal
);
max
.
set
(
maxVal
,
maxVal
,
maxVal
);
...
...
@@ -595,12 +581,10 @@ Vector3.prototype = {
projectOnPlane
:
function
()
{
var
v1
;
var
v1
=
new
Vector3
()
;
return
function
projectOnPlane
(
planeNormal
)
{
if
(
v1
===
undefined
)
v1
=
new
Vector3
();
v1
.
copy
(
this
).
projectOnVector
(
planeNormal
);
return
this
.
sub
(
v1
);
...
...
@@ -614,12 +598,10 @@ Vector3.prototype = {
// reflect incident vector off plane orthogonal to normal
// normal is assumed to have unit length
var
v1
;
var
v1
=
new
Vector3
()
;
return
function
reflect
(
normal
)
{
if
(
v1
===
undefined
)
v1
=
new
Vector3
();
return
this
.
sub
(
v1
.
copy
(
normal
).
multiplyScalar
(
2
*
this
.
dot
(
normal
)
)
);
};
...
...
@@ -760,7 +742,7 @@ Vector3.prototype = {
}
};
}
)
;
export
{
Vector3
};
src/math/Vector4.js
浏览文件 @
8f0a1c50
...
...
@@ -15,7 +15,7 @@ function Vector4( x, y, z, w ) {
}
Vector4
.
prototype
=
{
Object
.
assign
(
Vector4
.
prototype
,
{
constructor
:
Vector4
,
...
...
@@ -450,17 +450,11 @@ Vector4.prototype = {
clampScalar
:
function
()
{
var
min
,
max
;
var
min
=
new
Vector4
();
var
max
=
new
Vector4
();
return
function
clampScalar
(
minVal
,
maxVal
)
{
if
(
min
===
undefined
)
{
min
=
new
Vector4
();
max
=
new
Vector4
();
}
min
.
set
(
minVal
,
minVal
,
minVal
,
minVal
);
max
.
set
(
maxVal
,
maxVal
,
maxVal
,
maxVal
);
...
...
@@ -628,7 +622,7 @@ Vector4.prototype = {
}
};
}
)
;
export
{
Vector4
};
src/renderers/WebGLRenderTarget.js
浏览文件 @
8f0a1c50
...
...
@@ -39,7 +39,7 @@ function WebGLRenderTarget( width, height, options ) {
}
WebGLRenderTarget
.
prototype
=
{
Object
.
assign
(
WebGLRenderTarget
.
prototype
,
EventDispatcher
.
prototype
,
{
constructor
:
WebGLRenderTarget
,
...
...
@@ -90,8 +90,7 @@ WebGLRenderTarget.prototype = {
}
};
}
)
;
Object
.
assign
(
WebGLRenderTarget
.
prototype
,
EventDispatcher
.
prototype
);
export
{
WebGLRenderTarget
};
src/textures/Texture.js
浏览文件 @
8f0a1c50
...
...
@@ -59,17 +59,21 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty
Texture
.
DEFAULT_IMAGE
=
undefined
;
Texture
.
DEFAULT_MAPPING
=
UVMapping
;
Texture
.
prototype
=
{
Object
.
defineProperty
(
Texture
.
prototype
,
"
needsUpdate
"
,
{
constructor
:
Texture
,
set
:
function
(
value
)
{
if
(
value
===
true
)
this
.
version
++
;
}
isTexture
:
true
,
});
set
needsUpdate
(
value
)
{
Object
.
assign
(
Texture
.
prototype
,
EventDispatcher
.
prototype
,
{
if
(
value
===
true
)
this
.
version
++
;
constructor
:
Texture
,
}
,
isTexture
:
true
,
clone
:
function
()
{
...
...
@@ -285,8 +289,7 @@ Texture.prototype = {
}
};
}
)
;
Object
.
assign
(
Texture
.
prototype
,
EventDispatcher
.
prototype
);
export
{
Texture
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录