Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
99c76921
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
99c76921
编写于
12月 30, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'vectormultiplymatrix' into dev
上级
3fa6cd47
127c0f24
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
163 addition
and
147 deletion
+163
-147
examples/canvas_interactive_voxelpainter.html
examples/canvas_interactive_voxelpainter.html
+8
-3
examples/js/controls/TrackballControls.js
examples/js/controls/TrackballControls.js
+4
-4
examples/js/loaders/ColladaLoader.js
examples/js/loaders/ColladaLoader.js
+6
-4
examples/js/renderers/WebGLDeferredRenderer.js
examples/js/renderers/WebGLDeferredRenderer.js
+6
-4
examples/webgl_interactive_voxelpainter.html
examples/webgl_interactive_voxelpainter.html
+2
-1
examples/webgl_lights_deferred_arealights.html
examples/webgl_lights_deferred_arealights.html
+3
-2
src/core/Geometry.js
src/core/Geometry.js
+5
-9
src/core/Object3D.js
src/core/Object3D.js
+2
-2
src/core/Projector.js
src/core/Projector.js
+16
-20
src/extras/GeometryUtils.js
src/extras/GeometryUtils.js
+4
-4
src/extras/geometries/LatheGeometry.js
src/extras/geometries/LatheGeometry.js
+1
-1
src/extras/geometries/TubeGeometry.js
src/extras/geometries/TubeGeometry.js
+2
-2
src/extras/renderers/plugins/LensFlarePlugin.js
src/extras/renderers/plugins/LensFlarePlugin.js
+3
-3
src/extras/renderers/plugins/ShadowMapPlugin.js
src/extras/renderers/plugins/ShadowMapPlugin.js
+1
-1
src/math/Box3.js
src/math/Box3.js
+10
-9
src/math/Matrix3.js
src/math/Matrix3.js
+0
-14
src/math/Matrix4.js
src/math/Matrix4.js
+0
-29
src/math/Plane.js
src/math/Plane.js
+4
-4
src/math/Quaternion.js
src/math/Quaternion.js
+0
-24
src/math/Ray.js
src/math/Ray.js
+3
-3
src/math/Sphere.js
src/math/Sphere.js
+2
-2
src/math/Vector3.js
src/math/Vector3.js
+61
-0
src/math/Vector4.js
src/math/Vector4.js
+18
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+2
-2
未找到文件。
examples/canvas_interactive_voxelpainter.html
浏览文件 @
99c76921
...
...
@@ -160,17 +160,22 @@
if
(
intersects
.
length
>
0
)
{
var
interect
=
intersects
[
0
];
if
(
isCtrlDown
)
{
if
(
inter
sects
[
0
]
.
object
!=
plane
)
{
if
(
inter
ect
.
object
!=
plane
)
{
scene
.
remove
(
inter
sects
[
0
]
.
object
);
scene
.
remove
(
inter
ect
.
object
);
}
}
else
{
var
position
=
new
THREE
.
Vector3
().
add
(
intersects
[
0
].
point
,
intersects
[
0
].
object
.
matrixRotationWorld
.
multiplyVector3
(
intersects
[
0
].
face
.
normal
.
clone
()
)
);
var
normal
=
interect
.
face
.
normal
.
clone
();
normal
.
multiplyMatrix4
(
interect
.
object
.
matrixRotationWorld
);
var
position
=
new
THREE
.
Vector3
().
add
(
interect
.
point
,
normal
);
var
geometry
=
new
THREE
.
CubeGeometry
(
50
,
50
,
50
);
...
...
examples/js/controls/TrackballControls.js
浏览文件 @
99c76921
...
...
@@ -135,10 +135,10 @@ THREE.TrackballControls = function ( object, domElement ) {
quaternion
.
setFromAxisAngle
(
axis
,
-
angle
);
quaternion
.
multiplyVector3
(
_eye
);
quaternion
.
multiplyVector3
(
_this
.
object
.
up
);
_eye
.
multiplyQuaternion
(
quaternion
);
_this
.
object
.
up
.
multiplyQuaternion
(
quaternion
);
quaternion
.
multiplyVector3
(
_rotateEnd
);
_rotateEnd
.
multiplyQuaternion
(
quaternion
);
if
(
_this
.
staticMoving
)
{
...
...
@@ -147,7 +147,7 @@ THREE.TrackballControls = function ( object, domElement ) {
}
else
{
quaternion
.
setFromAxisAngle
(
axis
,
angle
*
(
_this
.
dynamicDampingFactor
-
1.0
)
);
quaternion
.
multiplyVector3
(
_rotateStart
);
_rotateStart
.
multiplyQuaternion
(
quaternion
);
}
...
...
examples/js/loaders/ColladaLoader.js
浏览文件 @
99c76921
...
...
@@ -444,7 +444,7 @@ THREE.ColladaLoader = function () {
for
(
var
i
=
0
;
i
<
geometry
.
vertices
.
length
;
i
++
)
{
skin
.
bindShapeMatrix
.
multiplyVector3
(
geometry
.
vertices
[
i
]
);
geometry
.
vertices
[
i
].
multiplyMatrix4
(
skin
.
bindShapeMatrix
);
}
...
...
@@ -575,7 +575,7 @@ THREE.ColladaLoader = function () {
for
(
i
=
0
;
i
<
geometry
.
vertices
.
length
;
i
++
)
{
skinController
.
skin
.
bindShapeMatrix
.
multiplyVector3
(
geometry
.
vertices
[
i
]
);
geometry
.
vertices
[
i
].
multiplyMatrix4
(
skinController
.
skin
.
bindShapeMatrix
);
}
...
...
@@ -619,7 +619,7 @@ THREE.ColladaLoader = function () {
v
.
y
=
o
.
y
;
v
.
z
=
o
.
z
;
bones
[
i
].
skinningMatrix
.
multiplyVector3
(
v
);
v
.
multiplyMatrix4
(
bones
[
i
].
skinningMatrix
);
s
.
x
+=
(
v
.
x
*
weight
);
s
.
y
+=
(
v
.
y
*
weight
);
...
...
@@ -849,7 +849,9 @@ THREE.ColladaLoader = function () {
if
(
options
.
centerGeometry
&&
obj
.
geometry
)
{
var
delta
=
THREE
.
GeometryUtils
.
center
(
obj
.
geometry
);
obj
.
quaternion
.
multiplyVector3
(
delta
.
multiplySelf
(
obj
.
scale
)
);
delta
.
multiplySelf
(
obj
.
scale
);
delta
.
multiplyQuaternion
(
obj
.
quaternion
);
obj
.
position
.
subSelf
(
delta
);
}
...
...
examples/js/renderers/WebGLDeferredRenderer.js
浏览文件 @
99c76921
...
...
@@ -330,7 +330,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
uniforms
[
"
lightRadius
"
].
value
=
distance
;
positionVS
.
copy
(
light
.
matrixWorld
.
getPosition
()
);
camera
.
matrixWorldInverse
.
multiplyVector3
(
positionVS
);
positionVS
.
multiplyMatrix4
(
camera
.
matrixWorldInverse
);
uniforms
[
"
lightPositionVS
"
].
value
.
copy
(
positionVS
);
lightProxy
.
position
.
copy
(
light
.
matrixWorld
.
getPosition
()
);
...
...
@@ -421,7 +422,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var
modelMatrix
=
light
.
matrixWorld
;
positionVS
.
copy
(
modelMatrix
.
getPosition
()
);
viewMatrix
.
multiplyVector3
(
positionVS
);
positionVS
.
multiplyMatrix4
(
viewMatrix
);
directionVS
.
copy
(
modelMatrix
.
getPosition
()
);
directionVS
.
subSelf
(
light
.
target
.
matrixWorld
.
getPosition
()
);
...
...
@@ -629,7 +630,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
var
viewMatrix
=
camera
.
matrixWorldInverse
;
positionVS
.
copy
(
modelMatrix
.
getPosition
()
);
viewMatrix
.
multiplyVector3
(
positionVS
);
positionVS
.
multiplyMatrix4
(
viewMatrix
);
uniforms
[
"
lightPositionVS
"
].
value
.
copy
(
positionVS
);
rightVS
.
copy
(
light
.
right
);
...
...
@@ -1144,4 +1146,4 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
createRenderTargets
();
};
\ No newline at end of file
};
examples/webgl_interactive_voxelpainter.html
浏览文件 @
99c76921
...
...
@@ -174,8 +174,9 @@
function
setVoxelPosition
(
intersector
)
{
tmpVec
.
copy
(
intersector
.
face
.
normal
);
tmpVec
.
multiplyMatrix4
(
intersector
.
object
.
matrixRotationWorld
);
voxelPosition
.
add
(
intersector
.
point
,
intersector
.
object
.
matrixRotationWorld
.
multiplyVector3
(
tmpVec
)
);
voxelPosition
.
add
(
intersector
.
point
,
tmpVec
);
voxelPosition
.
x
=
Math
.
floor
(
voxelPosition
.
x
/
50
)
*
50
+
25
;
voxelPosition
.
y
=
Math
.
floor
(
voxelPosition
.
y
/
50
)
*
50
+
25
;
...
...
examples/webgl_lights_deferred_arealights.html
浏览文件 @
99c76921
...
...
@@ -174,8 +174,9 @@
light
.
right
.
set
(
1
,
0
,
0
);
light
.
normal
.
set
(
0
,
-
1
,
0
);
light
.
right
=
matrix
.
multiplyVector3
(
light
.
right
);
light
.
normal
=
matrix
.
multiplyVector3
(
light
.
normal
);
light
.
right
.
multiplyMatrix4
(
matrix
);
light
.
normal
.
multiplyMatrix4
(
matrix
);
}
...
...
src/core/Geometry.js
浏览文件 @
99c76921
...
...
@@ -60,31 +60,27 @@ THREE.Geometry.prototype = {
applyMatrix
:
function
(
matrix
)
{
var
normalMatrix
=
new
THREE
.
Matrix3
();
normalMatrix
.
getInverse
(
matrix
).
transpose
();
var
normalMatrix
=
new
THREE
.
Matrix3
().
getInverse
(
matrix
).
transpose
();
for
(
var
i
=
0
,
il
=
this
.
vertices
.
length
;
i
<
il
;
i
++
)
{
var
vertex
=
this
.
vertices
[
i
];
matrix
.
multiplyVector3
(
vertex
);
vertex
.
multiplyMatrix4
(
matrix
);
}
for
(
var
i
=
0
,
il
=
this
.
faces
.
length
;
i
<
il
;
i
++
)
{
var
face
=
this
.
faces
[
i
];
normalMatrix
.
multiplyVector3
(
face
.
normal
).
normalize
();
face
.
normal
.
multiplyMatrix3
(
normalMatrix
).
normalize
();
for
(
var
j
=
0
,
jl
=
face
.
vertexNormals
.
length
;
j
<
jl
;
j
++
)
{
normalMatrix
.
multiplyVector3
(
face
.
vertexNormals
[
j
]
).
normalize
();
face
.
vertexNormals
[
j
].
multiplyMatrix3
(
normalMatrix
).
normalize
();
}
matrix
.
multiplyVector3
(
face
.
centroid
);
face
.
centroid
.
multiplyMatrix4
(
matrix
);
}
...
...
src/core/Object3D.js
浏览文件 @
99c76921
...
...
@@ -91,13 +91,13 @@ THREE.Object3D.prototype = {
localToWorld
:
function
(
vector
)
{
return
this
.
matrixWorld
.
multiplyVector3
(
vector
);
return
vector
.
multiplyMatrix4
(
this
.
matrixWorld
);
},
worldToLocal
:
function
(
vector
)
{
return
THREE
.
Object3D
.
__m1
.
getInverse
(
this
.
matrixWorld
).
multiplyVector3
(
vector
);
return
vector
.
multiplyMatrix4
(
THREE
.
Object3D
.
__m1
.
getInverse
(
this
.
matrixWorld
)
);
},
...
...
src/core/Projector.js
浏览文件 @
99c76921
...
...
@@ -41,9 +41,8 @@ THREE.Projector = function() {
camera
.
matrixWorldInverse
.
getInverse
(
camera
.
matrixWorld
);
_viewProjectionMatrix
.
multiply
(
camera
.
projectionMatrix
,
camera
.
matrixWorldInverse
);
_viewProjectionMatrix
.
multiplyVector3
(
vector
);
return
vector
;
return
vector
.
multiplyMatrix4
(
_viewProjectionMatrix
)
;
};
...
...
@@ -52,9 +51,8 @@ THREE.Projector = function() {
camera
.
projectionMatrixInverse
.
getInverse
(
camera
.
projectionMatrix
);
_viewProjectionMatrix
.
multiply
(
camera
.
matrixWorld
,
camera
.
projectionMatrixInverse
);
_viewProjectionMatrix
.
multiplyVector3
(
vector
);
return
vector
;
return
vector
.
multiplyMatrix4
(
_viewProjectionMatrix
)
;
};
...
...
@@ -108,7 +106,7 @@ THREE.Projector = function() {
}
else
{
_vector3
.
copy
(
object
.
matrixWorld
.
getPosition
()
);
_v
iewProjectionMatrix
.
multiplyVector3
(
_vector3
);
_v
ector3
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_object
.
z
=
_vector3
.
z
;
}
...
...
@@ -131,7 +129,7 @@ THREE.Projector = function() {
}
else
{
_vector3
.
copy
(
object
.
matrixWorld
.
getPosition
()
);
_v
iewProjectionMatrix
.
multiplyVector3
(
_vector3
);
_v
ector3
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_object
.
z
=
_vector3
.
z
;
}
...
...
@@ -150,7 +148,7 @@ THREE.Projector = function() {
}
else
{
_vector3
.
copy
(
object
.
matrixWorld
.
getPosition
()
);
_v
iewProjectionMatrix
.
multiplyVector3
(
_vector3
);
_v
ector3
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_object
.
z
=
_vector3
.
z
;
}
...
...
@@ -229,10 +227,10 @@ THREE.Projector = function() {
_vertex
=
getNextVertexInPool
();
_vertex
.
positionWorld
.
copy
(
vertices
[
v
]
);
_
modelMatrix
.
multiplyVector3
(
_vertex
.
positionWorld
);
_
vertex
.
positionWorld
.
multiplyMatrix4
(
_modelMatrix
);
_vertex
.
positionScreen
.
copy
(
_vertex
.
positionWorld
);
_v
iewProjectionMatrix
.
multiplyVector4
(
_vertex
.
positionScreen
);
_v
ertex
.
positionScreen
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_vertex
.
positionScreen
.
x
/=
_vertex
.
positionScreen
.
w
;
_vertex
.
positionScreen
.
y
/=
_vertex
.
positionScreen
.
w
;
...
...
@@ -330,14 +328,14 @@ THREE.Projector = function() {
}
_
normalMatrix
.
multiplyVector3
(
_face
.
normalModel
);
_
face
.
normalModel
.
multiplyMatrix3
(
_normalMatrix
);
_face
.
normalModel
.
normalize
();
_face
.
normalModelView
.
copy
(
_face
.
normalModel
);
_
normalViewMatrix
.
multiplyVector3
(
_face
.
normalModelView
);
_
face
.
normalModelView
.
multiplyMatrix3
(
_normalViewMatrix
);
_face
.
centroidModel
.
copy
(
face
.
centroid
);
_
modelMatrix
.
multiplyVector3
(
_face
.
centroidModel
);
_
face
.
centroidModel
.
multiplyMatrix4
(
_modelMatrix
);
faceVertexNormals
=
face
.
vertexNormals
;
...
...
@@ -352,12 +350,12 @@ THREE.Projector = function() {
}
_normalMatrix
.
multiplyVector3
(
normalModel
)
normalModel
.
multiplyMatrix3
(
_normalMatrix
);
normalModel
.
normalize
();
var
normalModelView
=
_face
.
vertexNormalsModelView
[
n
];
normalModelView
.
copy
(
normalModel
);
_normalViewMatrix
.
multiplyVector3
(
normalModelView
)
normalModelView
.
multiplyMatrix3
(
_normalViewMatrix
);
}
...
...
@@ -381,7 +379,7 @@ THREE.Projector = function() {
_face
.
material
=
material
;
_centroid
.
copy
(
_face
.
centroidModel
)
_
viewProjectionMatrix
.
multiplyVector3
(
_centroid
);
_
centroid
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_face
.
z
=
_centroid
.
z
;
...
...
@@ -397,8 +395,7 @@ THREE.Projector = function() {
v1
=
getNextVertexInPool
();
v1
.
positionScreen
.
copy
(
vertices
[
0
]
);
_modelViewProjectionMatrix
.
multiplyVector4
(
v1
.
positionScreen
);
v1
.
positionScreen
.
multiplyMatrix4
(
_modelViewProjectionMatrix
);
// Handle LineStrip and LinePieces
var
step
=
object
.
type
===
THREE
.
LinePieces
?
2
:
1
;
...
...
@@ -407,8 +404,7 @@ THREE.Projector = function() {
v1
=
getNextVertexInPool
();
v1
.
positionScreen
.
copy
(
vertices
[
v
]
);
_modelViewProjectionMatrix
.
multiplyVector4
(
v1
.
positionScreen
);
v1
.
positionScreen
.
multiplyMatrix4
(
_modelViewProjectionMatrix
);
if
(
(
v
+
1
)
%
step
>
0
)
continue
;
...
...
@@ -450,7 +446,7 @@ THREE.Projector = function() {
if
(
object
instanceof
THREE
.
Particle
)
{
_vector4
.
set
(
_modelMatrix
.
elements
[
12
],
_modelMatrix
.
elements
[
13
],
_modelMatrix
.
elements
[
14
],
1
);
_v
iewProjectionMatrix
.
multiplyVector4
(
_vector4
);
_v
ector4
.
multiplyMatrix4
(
_viewProjectionMatrix
);
_vector4
.
z
/=
_vector4
.
w
;
...
...
src/extras/GeometryUtils.js
浏览文件 @
99c76921
...
...
@@ -38,7 +38,7 @@ THREE.GeometryUtils = {
var
vertexCopy
=
vertex
.
clone
();
if
(
matrix
)
matrix
.
multiplyVector3
(
vertexCopy
);
if
(
matrix
)
vertexCopy
.
multiplyMatrix4
(
matrix
);
vertices1
.
push
(
vertexCopy
);
...
...
@@ -64,13 +64,13 @@ THREE.GeometryUtils = {
faceCopy
.
normal
.
copy
(
face
.
normal
);
if
(
matrixRotation
)
matrixRotation
.
multiplyVector3
(
faceCopy
.
normal
);
if
(
matrixRotation
)
faceCopy
.
normal
.
multiplyMatrix4
(
matrixRotation
);
for
(
var
j
=
0
,
jl
=
faceVertexNormals
.
length
;
j
<
jl
;
j
++
)
{
normal
=
faceVertexNormals
[
j
].
clone
();
if
(
matrixRotation
)
matrixRotation
.
multiplyVector3
(
normal
);
if
(
matrixRotation
)
normal
.
multiplyMatrix4
(
matrixRotation
);
faceCopy
.
vertexNormals
.
push
(
normal
);
...
...
@@ -88,7 +88,7 @@ THREE.GeometryUtils = {
faceCopy
.
materialIndex
=
face
.
materialIndex
;
faceCopy
.
centroid
.
copy
(
face
.
centroid
);
if
(
matrix
)
matrix
.
multiplyVector3
(
faceCopy
.
centroid
);
if
(
matrix
)
faceCopy
.
centroid
.
multiplyMatrix4
(
matrix
);
faces1
.
push
(
faceCopy
);
...
...
src/extras/geometries/LatheGeometry.js
浏览文件 @
99c76921
...
...
@@ -26,7 +26,7 @@ THREE.LatheGeometry = function ( points, steps, angle ) {
for
(
var
j
=
0
;
j
<
_newV
.
length
;
j
++
)
{
_newV
[
j
]
=
_
matrix
.
multiplyVector3
(
_newV
[
j
].
clone
()
);
_newV
[
j
]
=
_
newV
[
j
].
clone
().
multiplyMatrix4
(
_matrix
);
this
.
vertices
.
push
(
_newV
[
j
]
);
}
...
...
src/extras/geometries/TubeGeometry.js
浏览文件 @
99c76921
...
...
@@ -246,7 +246,7 @@ THREE.TubeGeometry.FrenetFrames = function(path, segments, closed) {
theta
=
Math
.
acos
(
tangents
[
i
-
1
].
dot
(
tangents
[
i
]
)
);
mat
.
makeRotationAxis
(
vec
,
theta
).
multiplyVector3
(
normals
[
i
]
);
normals
[
i
].
multiplyMatrix4
(
mat
.
makeRotationAxis
(
vec
,
theta
)
);
}
...
...
@@ -271,7 +271,7 @@ THREE.TubeGeometry.FrenetFrames = function(path, segments, closed) {
for
(
i
=
1
;
i
<
numpoints
;
i
++
)
{
// twist a little...
mat
.
makeRotationAxis
(
tangents
[
i
],
theta
*
i
).
multiplyVector3
(
normals
[
i
]
);
normals
[
i
].
multiplyMatrix4
(
mat
.
makeRotationAxis
(
tangents
[
i
],
theta
*
i
)
);
binormals
[
i
].
cross
(
tangents
[
i
],
normals
[
i
]
);
}
...
...
src/extras/renderers/plugins/LensFlarePlugin.js
浏览文件 @
99c76921
...
...
@@ -160,8 +160,8 @@ THREE.LensFlarePlugin = function ( ) {
tempPosition
.
set
(
flare
.
matrixWorld
.
elements
[
12
],
flare
.
matrixWorld
.
elements
[
13
],
flare
.
matrixWorld
.
elements
[
14
]
);
camera
.
matrixWorldInverse
.
multiplyVector3
(
tempPosition
);
camera
.
projectionMatrix
.
multiplyVector3
(
tempPosition
);
tempPosition
.
multiplyMatrix4
(
camera
.
matrixWorldInverse
);
tempPosition
.
multiplyMatrix4
(
camera
.
projectionMatrix
);
// setup arrays for gl programs
...
...
@@ -300,4 +300,4 @@ THREE.LensFlarePlugin = function ( ) {
};
};
\ No newline at end of file
};
src/extras/renderers/plugins/ShadowMapPlugin.js
浏览文件 @
99c76921
...
...
@@ -451,7 +451,7 @@ THREE.ShadowMapPlugin = function ( ) {
p
.
copy
(
pointsFrustum
[
i
]
);
THREE
.
ShadowMapPlugin
.
__projector
.
unprojectVector
(
p
,
camera
);
shadowCamera
.
matrixWorldInverse
.
multiplyVector3
(
p
);
p
.
multiplyMatrix4
(
shadowCamera
.
matrixWorldInverse
);
if
(
p
.
x
<
_min
.
x
)
_min
.
x
=
p
.
x
;
if
(
p
.
x
>
_max
.
x
)
_max
.
x
=
p
.
x
;
...
...
src/math/Box3.js
浏览文件 @
99c76921
...
...
@@ -256,17 +256,18 @@ THREE.Box3.prototype = {
},
transform
:
function
(
matrix
)
{
// NOTE: I am using a binary pattern to specify all 2^3 combinations below
var
newPoints
=
[
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v0
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
min
.
z
)
),
// 000
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v1
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
max
.
z
)
),
// 001
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v2
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
min
.
z
)
),
// 010
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v3
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
max
.
z
)
),
// 011
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v4
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
min
.
z
)
),
// 100
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v5
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
max
.
z
)
),
// 101
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v6
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
min
.
z
)
),
// 110
matrix
.
multiplyVector3
(
THREE
.
Box3
.
__v7
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
max
.
z
)
)
// 111
THREE
.
Box3
.
__v0
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
min
.
z
).
multiplyMatrix4
(
matrix
),
THREE
.
Box3
.
__v0
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
min
.
z
).
multiplyMatrix4
(
matrix
),
// 000
THREE
.
Box3
.
__v1
.
set
(
this
.
min
.
x
,
this
.
min
.
y
,
this
.
max
.
z
).
multiplyMatrix4
(
matrix
),
// 001
THREE
.
Box3
.
__v2
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
min
.
z
).
multiplyMatrix4
(
matrix
),
// 010
THREE
.
Box3
.
__v3
.
set
(
this
.
min
.
x
,
this
.
max
.
y
,
this
.
max
.
z
).
multiplyMatrix4
(
matrix
),
// 011
THREE
.
Box3
.
__v4
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
min
.
z
).
multiplyMatrix4
(
matrix
),
// 100
THREE
.
Box3
.
__v5
.
set
(
this
.
max
.
x
,
this
.
min
.
y
,
this
.
max
.
z
).
multiplyMatrix4
(
matrix
),
// 101
THREE
.
Box3
.
__v6
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
min
.
z
).
multiplyMatrix4
(
matrix
),
// 110
THREE
.
Box3
.
__v7
.
set
(
this
.
max
.
x
,
this
.
max
.
y
,
this
.
max
.
z
).
multiplyMatrix4
(
matrix
)
// 111
];
this
.
makeEmpty
();
...
...
src/math/Matrix3.js
浏览文件 @
99c76921
...
...
@@ -63,20 +63,6 @@ THREE.Matrix3.prototype = {
},
multiplyVector3
:
function
(
v
)
{
var
te
=
this
.
elements
;
var
vx
=
v
.
x
,
vy
=
v
.
y
,
vz
=
v
.
z
;
v
.
x
=
te
[
0
]
*
vx
+
te
[
3
]
*
vy
+
te
[
6
]
*
vz
;
v
.
y
=
te
[
1
]
*
vx
+
te
[
4
]
*
vy
+
te
[
7
]
*
vz
;
v
.
z
=
te
[
2
]
*
vx
+
te
[
5
]
*
vy
+
te
[
8
]
*
vz
;
return
v
;
},
multiplyVector3Array
:
function
(
a
)
{
var
tmp
=
THREE
.
Matrix3
.
__v1
;
...
...
src/math/Matrix4.js
浏览文件 @
99c76921
...
...
@@ -322,35 +322,6 @@ THREE.Matrix4.prototype = {
},
multiplyVector3
:
function
(
v
)
{
var
te
=
this
.
elements
;
var
vx
=
v
.
x
,
vy
=
v
.
y
,
vz
=
v
.
z
;
var
d
=
1
/
(
te
[
3
]
*
vx
+
te
[
7
]
*
vy
+
te
[
11
]
*
vz
+
te
[
15
]
);
v
.
x
=
(
te
[
0
]
*
vx
+
te
[
4
]
*
vy
+
te
[
8
]
*
vz
+
te
[
12
]
)
*
d
;
v
.
y
=
(
te
[
1
]
*
vx
+
te
[
5
]
*
vy
+
te
[
9
]
*
vz
+
te
[
13
]
)
*
d
;
v
.
z
=
(
te
[
2
]
*
vx
+
te
[
6
]
*
vy
+
te
[
10
]
*
vz
+
te
[
14
]
)
*
d
;
return
v
;
},
multiplyVector4
:
function
(
v
)
{
var
te
=
this
.
elements
;
var
vx
=
v
.
x
,
vy
=
v
.
y
,
vz
=
v
.
z
,
vw
=
v
.
w
;
v
.
x
=
te
[
0
]
*
vx
+
te
[
4
]
*
vy
+
te
[
8
]
*
vz
+
te
[
12
]
*
vw
;
v
.
y
=
te
[
1
]
*
vx
+
te
[
5
]
*
vy
+
te
[
9
]
*
vz
+
te
[
13
]
*
vw
;
v
.
z
=
te
[
2
]
*
vx
+
te
[
6
]
*
vy
+
te
[
10
]
*
vz
+
te
[
14
]
*
vw
;
v
.
w
=
te
[
3
]
*
vx
+
te
[
7
]
*
vy
+
te
[
11
]
*
vz
+
te
[
15
]
*
vw
;
return
v
;
},
multiplyVector3Array
:
function
(
a
)
{
var
tmp
=
THREE
.
Matrix4
.
__v1
;
...
...
src/math/Plane.js
浏览文件 @
99c76921
...
...
@@ -153,22 +153,22 @@ THREE.Plane.prototype = {
},
transform
:
function
(
matrix
,
optionalNormalMatrix
)
{
transform
:
function
(
matrix
,
optionalNormalMatrix
)
{
var
newNormal
=
THREE
.
Plane
.
__v1
,
newCoplanarPoint
=
THREE
.
Plane
.
__v2
;
// compute new normal based on theory here:
// http://www.songho.ca/opengl/gl_normaltransform.html
optionalNormalMatrix
=
optionalNormalMatrix
||
new
THREE
.
Matrix3
().
getInverse
(
matrix
).
transpose
();
newNormal
=
optionalNormalMatrix
.
multiplyVector3
(
newNormal
.
copy
(
this
.
normal
)
);
newNormal
.
copy
(
this
.
normal
).
multiplyMatrix3
(
optionalNormalMatrix
);
newCoplanarPoint
=
this
.
coplanarPoint
(
newCoplanarPoint
);
newCoplanarPoint
=
matrix
.
multiplyVector3
(
newCoplanarPoint
);
newCoplanarPoint
.
multiplyMatrix4
(
matrix
);
this
.
setFromNormalAndCoplanarPoint
(
newNormal
,
newCoplanarPoint
);
return
this
;
},
translate
:
function
(
offset
)
{
...
...
src/math/Quaternion.js
浏览文件 @
99c76921
...
...
@@ -253,30 +253,6 @@ THREE.Quaternion.prototype = {
},
multiplyVector3
:
function
(
vector
,
dest
)
{
if
(
!
dest
)
{
dest
=
vector
;
}
var
x
=
vector
.
x
,
y
=
vector
.
y
,
z
=
vector
.
z
,
qx
=
this
.
x
,
qy
=
this
.
y
,
qz
=
this
.
z
,
qw
=
this
.
w
;
// calculate quat * vector
var
ix
=
qw
*
x
+
qy
*
z
-
qz
*
y
,
iy
=
qw
*
y
+
qz
*
x
-
qx
*
z
,
iz
=
qw
*
z
+
qx
*
y
-
qy
*
x
,
iw
=
-
qx
*
x
-
qy
*
y
-
qz
*
z
;
// calculate result * inverse quat
dest
.
x
=
ix
*
qw
+
iw
*
-
qx
+
iy
*
-
qz
-
iz
*
-
qy
;
dest
.
y
=
iy
*
qw
+
iw
*
-
qy
+
iz
*
-
qx
-
ix
*
-
qz
;
dest
.
z
=
iz
*
qw
+
iw
*
-
qz
+
ix
*
-
qy
-
iy
*
-
qx
;
return
dest
;
},
slerpSelf
:
function
(
qb
,
t
)
{
var
x
=
this
.
x
,
y
=
this
.
y
,
z
=
this
.
z
,
w
=
this
.
w
;
...
...
src/math/Ray.js
浏览文件 @
99c76921
...
...
@@ -133,8 +133,8 @@ THREE.Ray.prototype = {
transform
:
function
(
matrix4
)
{
this
.
direction
=
matrix4
.
multiplyVector3
(
this
.
direction
.
addSelf
(
this
.
origin
)
);
this
.
origin
=
matrix4
.
multiplyVector3
(
this
.
origin
);
this
.
direction
.
addSelf
(
this
.
origin
).
multiplyMatrix4
(
matrix4
);
this
.
origin
.
multiplyMatrix4
(
matrix4
);
this
.
direction
.
subSelf
(
this
.
origin
);
return
this
;
...
...
@@ -155,4 +155,4 @@ THREE.Ray.prototype = {
};
THREE
.
Ray
.
__v1
=
new
THREE
.
Vector3
();
THREE
.
Ray
.
__v2
=
new
THREE
.
Vector3
();
\ No newline at end of file
THREE
.
Ray
.
__v2
=
new
THREE
.
Vector3
();
src/math/Sphere.js
浏览文件 @
99c76921
...
...
@@ -97,8 +97,8 @@ THREE.Sphere.prototype = {
},
transform
:
function
(
matrix
)
{
this
.
center
=
matrix
.
multiplyVector3
(
this
.
center
);
this
.
center
.
multiplyMatrix4
(
matrix
);
this
.
radius
=
this
.
radius
*
matrix
.
getMaxScaleOnAxis
();
return
this
;
...
...
src/math/Vector3.js
浏览文件 @
99c76921
...
...
@@ -170,6 +170,67 @@ THREE.Vector3.prototype = {
},
multiplyMatrix3
:
function
(
m
)
{
var
x
=
this
.
x
;
var
y
=
this
.
y
;
var
z
=
this
.
z
;
var
e
=
m
.
elements
;
this
.
x
=
e
[
0
]
*
x
+
e
[
3
]
*
y
+
e
[
6
]
*
z
;
this
.
y
=
e
[
1
]
*
x
+
e
[
4
]
*
y
+
e
[
7
]
*
z
;
this
.
z
=
e
[
2
]
*
x
+
e
[
5
]
*
y
+
e
[
8
]
*
z
;
return
this
;
},
multiplyMatrix4
:
function
(
m
)
{
var
x
=
this
.
x
;
var
y
=
this
.
y
;
var
z
=
this
.
z
;
var
e
=
m
.
elements
;
var
d
=
1
/
(
e
[
3
]
*
x
+
e
[
7
]
*
y
+
e
[
11
]
*
z
+
e
[
15
]
);
this
.
x
=
(
e
[
0
]
*
x
+
e
[
4
]
*
y
+
e
[
8
]
*
z
+
e
[
12
]
)
*
d
;
this
.
y
=
(
e
[
1
]
*
x
+
e
[
5
]
*
y
+
e
[
9
]
*
z
+
e
[
13
]
)
*
d
;
this
.
z
=
(
e
[
2
]
*
x
+
e
[
6
]
*
y
+
e
[
10
]
*
z
+
e
[
14
]
)
*
d
;
return
this
;
},
multiplyQuaternion
:
function
(
q
)
{
var
x
=
this
.
x
;
var
y
=
this
.
y
;
var
z
=
this
.
z
;
var
qx
=
q
.
x
;
var
qy
=
q
.
y
;
var
qz
=
q
.
z
;
var
qw
=
q
.
w
;
// calculate quat * vector
var
ix
=
qw
*
x
+
qy
*
z
-
qz
*
y
;
var
iy
=
qw
*
y
+
qz
*
x
-
qx
*
z
;
var
iz
=
qw
*
z
+
qx
*
y
-
qy
*
x
;
var
iw
=
-
qx
*
x
-
qy
*
y
-
qz
*
z
;
// calculate result * inverse quat
this
.
x
=
ix
*
qw
+
iw
*
-
qx
+
iy
*
-
qz
-
iz
*
-
qy
;
this
.
y
=
iy
*
qw
+
iw
*
-
qy
+
iz
*
-
qx
-
ix
*
-
qz
;
this
.
z
=
iz
*
qw
+
iw
*
-
qz
+
ix
*
-
qy
-
iy
*
-
qx
;
return
this
;
},
divideSelf
:
function
(
v
)
{
this
.
x
/=
v
.
x
;
...
...
src/math/Vector4.js
浏览文件 @
99c76921
...
...
@@ -167,6 +167,24 @@ THREE.Vector4.prototype = {
},
multiplyMatrix4
:
function
(
m
)
{
var
x
=
this
.
x
;
var
y
=
this
.
y
;
var
z
=
this
.
z
;
var
w
=
this
.
w
;
var
e
=
m
.
elements
;
this
.
x
=
e
[
0
]
*
x
+
e
[
4
]
*
y
+
e
[
8
]
*
z
+
e
[
12
]
*
w
;
this
.
y
=
e
[
1
]
*
x
+
e
[
5
]
*
y
+
e
[
9
]
*
z
+
e
[
13
]
*
w
;
this
.
z
=
e
[
2
]
*
x
+
e
[
6
]
*
y
+
e
[
10
]
*
z
+
e
[
14
]
*
w
;
this
.
w
=
e
[
3
]
*
x
+
e
[
7
]
*
y
+
e
[
11
]
*
z
+
e
[
15
]
*
w
;
return
this
;
},
divideScalar
:
function
(
s
)
{
if
(
s
!==
0
)
{
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
99c76921
...
...
@@ -1158,7 +1158,7 @@ THREE.WebGLRenderer = function ( parameters ) {
vertex
=
vertices
[
v
];
_vector3
.
copy
(
vertex
);
_
projScreenMatrixPS
.
multiplyVector3
(
_vector3
);
_
vector3
.
multiplyMatrix4
(
_projScreenMatrixPS
);
sortArray
[
v
]
=
[
_vector3
.
z
,
v
];
...
...
@@ -4124,7 +4124,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
else
{
_vector3
.
copy
(
object
.
matrixWorld
.
getPosition
()
);
_
projScreenMatrix
.
multiplyVector3
(
_vector3
);
_
vector3
.
multiplyMatrix4
(
_projScreenMatrix
);
webglObject
.
z
=
_vector3
.
z
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录