Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
10e1b75f
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,发现更多精彩内容 >>
未验证
提交
10e1b75f
编写于
8月 03, 2018
作者:
M
Mr.doob
提交者:
GitHub
8月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14620 from Mugen87/dev18
PaintViveController: Moved to BufferGeometry.
上级
141c3d2b
7674c3d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
24 deletion
+43
-24
examples/js/vr/PaintViveController.js
examples/js/vr/PaintViveController.js
+43
-24
未找到文件。
examples/js/vr/PaintViveController.js
浏览文件 @
10e1b75f
...
...
@@ -32,7 +32,7 @@ THREE.PaintViveController = function ( id ) {
var
x
=
(
(
j
%
256
)
/
256
)
-
0.5
;
var
y
=
(
Math
.
floor
(
j
/
256
)
/
256
)
-
0.5
;
swatchColor
.
setHSL
(
Math
.
atan2
(
y
,
x
)
/
PI2
,
1
,(
0.5
-
Math
.
sqrt
(
x
*
x
+
y
*
y
)
)
*
2.0
);
swatchColor
.
setHSL
(
Math
.
atan2
(
y
,
x
)
/
PI2
,
1
,
(
0.5
-
Math
.
sqrt
(
x
*
x
+
y
*
y
)
)
*
2.0
);
data
[
i
+
0
]
=
swatchColor
.
r
*
256
;
data
[
i
+
1
]
=
swatchColor
.
g
*
256
;
...
...
@@ -49,7 +49,7 @@ THREE.PaintViveController = function ( id ) {
// COLOR UI
var
geometry
=
new
THREE
.
CircleGeometry
(
1
,
32
);
var
geometry
=
new
THREE
.
Circle
Buffer
Geometry
(
1
,
32
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
generateHueTexture
()
}
);
var
colorUI
=
new
THREE
.
Mesh
(
geometry
,
material
);
colorUI
.
position
.
set
(
0
,
0.005
,
0.0495
);
...
...
@@ -57,7 +57,7 @@ THREE.PaintViveController = function ( id ) {
colorUI
.
scale
.
setScalar
(
0.02
);
this
.
add
(
colorUI
);
var
geometry
=
new
THREE
.
IcosahedronGeometry
(
0.1
,
2
);
var
geometry
=
new
THREE
.
Icosahedron
Buffer
Geometry
(
0.1
,
2
);
var
material
=
new
THREE
.
MeshBasicMaterial
();
material
.
color
=
color
;
var
ball
=
new
THREE
.
Mesh
(
geometry
,
material
);
...
...
@@ -72,23 +72,23 @@ THREE.PaintViveController = function ( id ) {
this
.
add
(
sizeUI
);
var
triangleShape
=
new
THREE
.
Shape
();
triangleShape
.
moveTo
(
0
,
-
1
);
triangleShape
.
moveTo
(
0
,
-
1
);
triangleShape
.
lineTo
(
1
,
1
);
triangleShape
.
lineTo
(
-
1
,
1
);
triangleShape
.
lineTo
(
-
1
,
1
);
var
geometry
=
new
THREE
.
ShapeGeometry
(
triangleShape
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x222222
,
wireframe
:
true
}
);
var
sizeUIOutline
=
new
THREE
.
Mesh
(
geometry
,
material
)
;
var
geometry
=
new
THREE
.
Shape
Buffer
Geometry
(
triangleShape
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
0x222222
,
wireframe
:
true
}
);
var
sizeUIOutline
=
new
THREE
.
Mesh
(
geometry
,
material
);
sizeUIOutline
.
position
.
z
=
0.001
;
resizeTriangleGeometry
(
sizeUIOutline
.
geometry
,
1.0
);
resizeTriangleGeometry
(
sizeUIOutline
.
geometry
,
1.0
);
sizeUI
.
add
(
sizeUIOutline
);
var
geometry
=
new
THREE
.
ShapeGeometry
(
triangleShape
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
side
:
THREE
.
DoubleSide
}
);
var
geometry
=
new
THREE
.
Shape
Buffer
Geometry
(
triangleShape
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
side
:
THREE
.
DoubleSide
}
);
material
.
color
=
color
;
var
sizeUIFill
=
new
THREE
.
Mesh
(
geometry
,
material
)
;
var
sizeUIFill
=
new
THREE
.
Mesh
(
geometry
,
material
);
sizeUIFill
.
position
.
z
=
0.0011
;
resizeTriangleGeometry
(
sizeUIFill
.
geometry
,
0.5
);
resizeTriangleGeometry
(
sizeUIFill
.
geometry
,
0.5
);
sizeUI
.
add
(
sizeUIFill
);
sizeUI
.
visible
=
false
;
...
...
@@ -103,21 +103,25 @@ THREE.PaintViveController = function ( id ) {
var
y
=
-
event
.
axes
[
1
]
/
2.0
;
if
(
mode
===
MODES
.
COLOR
)
{
color
.
setHSL
(
Math
.
atan2
(
y
,
x
)
/
PI2
,
1
,
(
0.5
-
Math
.
sqrt
(
x
*
x
+
y
*
y
)
)
*
2.0
);
ball
.
position
.
set
(
event
.
axes
[
0
],
event
.
axes
[
1
],
0
);
ball
.
position
.
set
(
event
.
axes
[
0
],
event
.
axes
[
1
],
0
);
}
if
(
mode
===
MODES
.
SIZE
)
{
var
ratio
=
(
0.5
-
y
);
var
ratio
=
0.5
-
y
;
size
=
ratio
*
2
;
resizeTriangleGeometry
(
sizeUIFill
.
geometry
,
ratio
);
resizeTriangleGeometry
(
sizeUIFill
.
geometry
,
ratio
);
}
}
function
resizeTriangleGeometry
(
geometry
,
ratio
)
{
function
resizeTriangleGeometry
(
geometry
,
ratio
)
{
var
x
=
0
,
y
=
0
;
var
fullWidth
=
0.75
,
fullHeight
=
1.5
;
...
...
@@ -127,34 +131,49 @@ THREE.PaintViveController = function ( id ) {
var
height
=
fullHeight
*
ratio
;
var
width
=
(
Math
.
tan
(
angle
)
*
height
)
*
2
;
geometry
.
vertices
[
0
].
set
(
x
,
bottomY
,
0
);
geometry
.
vertices
[
1
].
set
(
x
+
width
/
2
,
bottomY
+
height
,
0
);
geometry
.
vertices
[
2
].
set
(
x
-
width
/
2
,
bottomY
+
height
,
0
);
var
position
=
geometry
.
attributes
.
position
;
geometry
.
verticesNeedUpdate
=
true
;
position
.
setXYZ
(
0
,
x
,
bottomY
,
0
);
position
.
setXYZ
(
1
,
x
+
width
/
2
,
bottomY
+
height
,
0
);
position
.
setXYZ
(
2
,
x
-
width
/
2
,
bottomY
+
height
,
0
);
position
.
needsUpdate
=
true
;
}
function
onGripsDown
(
event
)
{
function
onGripsDown
()
{
if
(
mode
===
MODES
.
COLOR
)
{
mode
=
MODES
.
SIZE
;
colorUI
.
visible
=
false
;
sizeUI
.
visible
=
true
;
return
;
}
if
(
mode
===
MODES
.
SIZE
)
{
mode
=
MODES
.
COLOR
;
colorUI
.
visible
=
true
;
sizeUI
.
visible
=
false
;
return
;
}
}
this
.
getColor
=
function
()
{
return
color
;
};
this
.
getSize
=
function
()
{
return
size
;
};
this
.
getColor
=
function
()
{
return
color
;
};
this
.
getSize
=
function
()
{
return
size
;
};
this
.
addEventListener
(
'
axischanged
'
,
onAxisChanged
);
this
.
addEventListener
(
'
gripsdown
'
,
onGripsDown
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录