Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
eccc0541
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,发现更多精彩内容 >>
提交
eccc0541
编写于
3月 11, 2017
作者:
Y
yomotsu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CSS Renderer: supports IE10, 11
上级
6c7ef7e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
45 deletion
+38
-45
examples/js/renderers/CSS3DRenderer.js
examples/js/renderers/CSS3DRenderer.js
+38
-45
未找到文件。
examples/js/renderers/CSS3DRenderer.js
浏览文件 @
eccc0541
...
...
@@ -10,7 +10,7 @@ THREE.CSS3DObject = function ( element ) {
this
.
element
=
element
;
this
.
element
.
style
.
position
=
'
absolute
'
;
this
.
addEventListener
(
'
removed
'
,
function
()
{
this
.
addEventListener
(
'
removed
'
,
function
(
event
)
{
if
(
this
.
element
.
parentNode
!==
null
)
{
...
...
@@ -41,6 +41,7 @@ THREE.CSS3DRenderer = function () {
console
.
log
(
'
THREE.CSS3DRenderer
'
,
THREE
.
REVISION
);
var
_width
,
_height
;
var
_widthHalf
,
_heightHalf
;
var
matrix
=
new
THREE
.
Matrix4
();
...
...
@@ -52,19 +53,13 @@ THREE.CSS3DRenderer = function () {
var
domElement
=
document
.
createElement
(
'
div
'
);
domElement
.
style
.
overflow
=
'
hidden
'
;
domElement
.
style
.
WebkitTransformStyle
=
'
preserve-3d
'
;
domElement
.
style
.
MozTransformStyle
=
'
preserve-3d
'
;
domElement
.
style
.
oTransformStyle
=
'
preserve-3d
'
;
domElement
.
style
.
transformStyle
=
'
preserve-3d
'
;
this
.
domElement
=
domElement
;
var
cameraElement
=
document
.
createElement
(
'
div
'
);
cameraElement
.
style
.
position
=
'
absolute
'
;
cameraElement
.
style
.
left
=
'
50%
'
;
cameraElement
.
style
.
top
=
'
50%
'
;
// IE10 and 11 does not support 'preserve-3d'.
// Thus, z-order in 3D will not work.
// Should we calc z-order and set "CSS z-index" manually?
cameraElement
.
style
.
WebkitTransformStyle
=
'
preserve-3d
'
;
cameraElement
.
style
.
MozTransformStyle
=
'
preserve-3d
'
;
cameraElement
.
style
.
oTransformStyle
=
'
preserve-3d
'
;
...
...
@@ -74,7 +69,7 @@ THREE.CSS3DRenderer = function () {
this
.
setClearColor
=
function
()
{};
this
.
getSize
=
function
()
{
this
.
getSize
=
function
()
{
return
{
width
:
_width
,
...
...
@@ -88,18 +83,24 @@ THREE.CSS3DRenderer = function () {
_width
=
width
;
_height
=
height
;
_widthHalf
=
_width
/
2
;
_heightHalf
=
_height
/
2
;
domElement
.
style
.
width
=
width
+
'
px
'
;
domElement
.
style
.
height
=
height
+
'
px
'
;
cameraElement
.
style
.
width
=
width
+
'
px
'
;
cameraElement
.
style
.
height
=
height
+
'
px
'
;
};
function
epsilon
(
value
)
{
var
epsilon
=
function
(
value
)
{
return
Math
.
abs
(
value
)
<
Number
.
EPSILON
?
0
:
value
;
}
}
;
function
getCameraCSSMatrix
(
matrix
)
{
var
getCameraCSSMatrix
=
function
(
matrix
)
{
var
elements
=
matrix
.
elements
;
...
...
@@ -122,13 +123,13 @@ THREE.CSS3DRenderer = function () {
epsilon
(
elements
[
15
]
)
+
'
)
'
;
}
}
;
function
getObjectCSSMatrix
(
matrix
)
{
var
getObjectCSSMatrix
=
function
(
matrix
)
{
var
elements
=
matrix
.
elements
;
return
'
translate3d(-50%,-50%,0)
matrix3d(
'
+
return
'
matrix3d(
'
+
epsilon
(
elements
[
0
]
)
+
'
,
'
+
epsilon
(
elements
[
1
]
)
+
'
,
'
+
epsilon
(
elements
[
2
]
)
+
'
,
'
+
...
...
@@ -145,15 +146,15 @@ THREE.CSS3DRenderer = function () {
epsilon
(
elements
[
13
]
)
+
'
,
'
+
epsilon
(
elements
[
14
]
)
+
'
,
'
+
epsilon
(
elements
[
15
]
)
+
'
)
'
;
'
)
'
;
}
}
;
function
renderObject
(
object
,
camera
)
{
var
renderObject
=
function
(
object
,
camera
,
parentTransfrom
)
{
if
(
object
instanceof
THREE
.
CSS3DObject
)
{
var
style
;
var
style
;
if
(
object
instanceof
THREE
.
CSS3DObject
)
{
if
(
object
instanceof
THREE
.
CSS3DSprite
)
{
...
...
@@ -169,11 +170,11 @@ THREE.CSS3DRenderer = function () {
matrix
.
elements
[
11
]
=
0
;
matrix
.
elements
[
15
]
=
1
;
style
=
getObjectCSSMatrix
(
matrix
);
style
=
parentTransfrom
+
getObjectCSSMatrix
(
matrix
);
}
else
{
style
=
getObjectCSSMatrix
(
object
.
matrixWorld
);
style
=
parentTransfrom
+
getObjectCSSMatrix
(
object
.
matrixWorld
);
}
...
...
@@ -181,13 +182,13 @@ THREE.CSS3DRenderer = function () {
var
cachedStyle
=
cache
.
objects
[
object
.
id
];
if
(
cachedStyle
===
undefined
||
cachedStyle
!==
style
)
{
element
.
style
.
WebkitTransform
=
'
translate3d(-50%,-50%,0)
'
+
style
;
element
.
style
.
MozTransform
=
'
translate3d(-50%,-50%,0)
'
+
style
;
element
.
style
.
oTransform
=
'
translate3d(-50%,-50%,0)
'
+
style
;
element
.
style
.
transform
=
'
translate3d(-50%,-50%,0)
'
+
style
;
element
.
style
.
WebkitTransform
=
style
;
element
.
style
.
MozTransform
=
style
;
element
.
style
.
oTransform
=
style
;
element
.
style
.
transform
=
style
;
cache
.
objects
[
object
.
id
]
=
style
;
cache
.
objects
[
object
.
id
]
=
'
translate3d(-50%,-50%,0)
'
+
style
;
}
...
...
@@ -199,13 +200,15 @@ THREE.CSS3DRenderer = function () {
}
var
parentTransfrom
=
style
||
parentTransfrom
;
for
(
var
i
=
0
,
l
=
object
.
children
.
length
;
i
<
l
;
i
++
)
{
renderObject
(
object
.
children
[
i
],
camera
);
renderObject
(
object
.
children
[
i
],
camera
,
parentTransfrom
);
}
}
}
;
this
.
render
=
function
(
scene
,
camera
)
{
...
...
@@ -228,20 +231,10 @@ THREE.CSS3DRenderer = function () {
camera
.
matrixWorldInverse
.
getInverse
(
camera
.
matrixWorld
);
var
style
=
'
translateZ(
'
+
fov
+
'
px)
'
+
getCameraCSSMatrix
(
camera
.
matrixWorldInverse
);
if
(
cache
.
camera
.
style
!==
style
)
{
cameraElement
.
style
.
WebkitTransform
=
style
;
cameraElement
.
style
.
MozTransform
=
style
;
cameraElement
.
style
.
oTransform
=
style
;
cameraElement
.
style
.
transform
=
style
;
cache
.
camera
.
style
=
style
;
}
var
style
=
"
translate3d(
"
+
_widthHalf
+
"
px,
"
+
_heightHalf
+
"
px,
"
+
fov
+
"
px)
"
+
getCameraCSSMatrix
(
camera
.
matrixWorldInverse
);
renderObject
(
scene
,
camera
);
renderObject
(
scene
,
camera
,
style
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录