Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Hubs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
Hubs
Commits
735acfa9
Commit
735acfa9
authored
6 years ago
by
Kevin Lee
Browse files
Options
Downloads
Patches
Plain Diff
enable color and radius to be changed mid-line, update networking to support that
parent
a560ecc4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/tools/networked-drawing.js
+20
-22
20 additions, 22 deletions
src/components/tools/networked-drawing.js
src/components/tools/pen.js
+1
-1
1 addition, 1 deletion
src/components/tools/pen.js
src/utils/mouse-events-handler.js
+1
-0
1 addition, 0 deletions
src/utils/mouse-events-handler.js
with
22 additions
and
23 deletions
src/components/tools/networked-drawing.js
+
20
−
22
View file @
735acfa9
...
@@ -11,10 +11,6 @@ const MSG_CONFIRM_CONNECT = 0;
...
@@ -11,10 +11,6 @@ const MSG_CONFIRM_CONNECT = 0;
const
MSG_BUFFER_DATA
=
1
;
const
MSG_BUFFER_DATA
=
1
;
const
MSG_BUFFER_DATA_FULL
=
2
;
const
MSG_BUFFER_DATA_FULL
=
2
;
function
round
(
x
)
{
return
Math
.
round
(
x
*
100000
)
/
100000
;
}
function
copyData
(
fromArray
,
toArray
,
fromIndex
,
toIndex
)
{
function
copyData
(
fromArray
,
toArray
,
fromIndex
,
toIndex
)
{
let
i
=
fromIndex
-
1
;
let
i
=
fromIndex
-
1
;
let
j
=
-
1
;
let
j
=
-
1
;
...
@@ -129,16 +125,14 @@ AFRAME.registerComponent("networked-drawing", {
...
@@ -129,16 +125,14 @@ AFRAME.registerComponent("networked-drawing", {
if
(
this
.
drawBuffer
.
length
>
0
&&
NAF
.
connection
.
isConnected
()
&&
this
.
networkedEl
)
{
if
(
this
.
drawBuffer
.
length
>
0
&&
NAF
.
connection
.
isConnected
()
&&
this
.
networkedEl
)
{
if
(
!
NAF
.
utils
.
isMine
(
this
.
networkedEl
))
{
if
(
!
NAF
.
utils
.
isMine
(
this
.
networkedEl
))
{
const
head
=
this
.
drawBuffer
[
0
];
const
head
=
this
.
drawBuffer
[
0
];
if
(
head
!==
null
&&
typeof
head
===
"
string
"
)
{
if
(
head
!=
null
&&
this
.
drawBuffer
.
length
>=
9
)
{
this
.
color
.
set
(
head
);
this
.
drawBuffer
.
shift
();
}
else
if
(
head
!=
null
&&
this
.
drawBuffer
.
length
>=
9
)
{
position
.
set
(
this
.
drawBuffer
[
0
],
this
.
drawBuffer
[
1
],
this
.
drawBuffer
[
2
]);
position
.
set
(
this
.
drawBuffer
[
0
],
this
.
drawBuffer
[
1
],
this
.
drawBuffer
[
2
]);
direction
.
set
(
this
.
drawBuffer
[
3
],
this
.
drawBuffer
[
4
],
this
.
drawBuffer
[
5
]);
direction
.
set
(
this
.
drawBuffer
[
3
],
this
.
drawBuffer
[
4
],
this
.
drawBuffer
[
5
]);
this
.
radius
=
direction
.
length
();
//radius is encoded as length of direction vector
this
.
radius
=
direction
.
length
();
//radius is encoded as length of direction vector
direction
.
normalize
();
direction
.
normalize
();
normal
.
set
(
this
.
drawBuffer
[
6
],
this
.
drawBuffer
[
7
],
this
.
drawBuffer
[
8
]);
normal
.
set
(
this
.
drawBuffer
[
6
],
this
.
drawBuffer
[
7
],
this
.
drawBuffer
[
8
]);
//TODO: maybe encode segments in normal vector?
this
.
color
.
setHex
(
Math
.
round
(
normal
.
length
())
-
1
);
//color is encoded as length of normal vector
normal
.
normalize
();
if
(
!
this
.
remoteLineStarted
)
{
if
(
!
this
.
remoteLineStarted
)
{
this
.
startDraw
(
position
,
direction
,
normal
);
this
.
startDraw
(
position
,
direction
,
normal
);
...
@@ -253,7 +247,7 @@ AFRAME.registerComponent("networked-drawing", {
...
@@ -253,7 +247,7 @@ AFRAME.registerComponent("networked-drawing", {
return
this
.
lastPoint
;
return
this
.
lastPoint
;
},
},
startDraw
(
position
,
direction
,
normal
,
color
,
radius
,
segments
)
{
startDraw
(
position
,
direction
,
normal
,
color
,
radius
)
{
if
(
!
NAF
.
connection
.
isConnected
())
{
if
(
!
NAF
.
connection
.
isConnected
())
{
return
;
return
;
}
}
...
@@ -262,21 +256,24 @@ AFRAME.registerComponent("networked-drawing", {
...
@@ -262,21 +256,24 @@ AFRAME.registerComponent("networked-drawing", {
if
(
color
)
{
if
(
color
)
{
this
.
color
.
set
(
color
);
this
.
color
.
set
(
color
);
this
.
pushToDrawBuffer
(
color
);
}
}
if
(
radius
)
this
.
radius
=
radius
;
if
(
radius
)
this
.
radius
=
radius
;
if
(
segments
)
this
.
segments
=
segments
;
this
.
lastPoint
.
copy
(
position
);
this
.
lastPoint
.
copy
(
position
);
this
.
addToDrawBuffer
(
position
,
direction
,
normal
);
this
.
addToDrawBuffer
(
position
,
direction
,
normal
);
this
.
lastDrawTime
=
Date
.
now
();
this
.
lastDrawTime
=
Date
.
now
();
},
},
draw
(
position
,
direction
,
normal
)
{
draw
(
position
,
direction
,
normal
,
color
,
radius
)
{
if
(
!
NAF
.
connection
.
isConnected
()
||
!
this
.
drawStarted
)
{
if
(
!
NAF
.
connection
.
isConnected
()
||
!
this
.
drawStarted
)
{
return
;
return
;
}
}
if
(
color
&&
color
!=
"
#
"
+
this
.
color
.
getHexString
().
toUpperCase
())
{
this
.
color
.
set
(
color
);
}
if
(
radius
)
this
.
radius
=
radius
;
this
.
doDraw
(
position
,
direction
,
normal
);
this
.
doDraw
(
position
,
direction
,
normal
);
this
.
addToDrawBuffer
(
position
,
direction
,
normal
);
this
.
addToDrawBuffer
(
position
,
direction
,
normal
);
...
@@ -369,16 +366,17 @@ AFRAME.registerComponent("networked-drawing", {
...
@@ -369,16 +366,17 @@ AFRAME.registerComponent("networked-drawing", {
addToDrawBuffer
(
position
,
direction
,
normal
)
{
addToDrawBuffer
(
position
,
direction
,
normal
)
{
if
(
this
.
networkedEl
&&
NAF
.
utils
.
isMine
(
this
.
networkedEl
))
{
if
(
this
.
networkedEl
&&
NAF
.
utils
.
isMine
(
this
.
networkedEl
))
{
++
this
.
currentPointCount
;
++
this
.
currentPointCount
;
this
.
pushToDrawBuffer
(
round
(
position
.
x
)
)
;
this
.
pushToDrawBuffer
(
position
.
x
);
this
.
pushToDrawBuffer
(
round
(
position
.
y
)
)
;
this
.
pushToDrawBuffer
(
position
.
y
);
this
.
pushToDrawBuffer
(
round
(
position
.
z
)
)
;
this
.
pushToDrawBuffer
(
position
.
z
);
direction
.
setLength
(
this
.
radius
);
//encode radius as length of direction vector
direction
.
setLength
(
this
.
radius
);
//encode radius as length of direction vector
this
.
pushToDrawBuffer
(
round
(
direction
.
x
));
this
.
pushToDrawBuffer
(
direction
.
x
);
this
.
pushToDrawBuffer
(
round
(
direction
.
y
));
this
.
pushToDrawBuffer
(
direction
.
y
);
this
.
pushToDrawBuffer
(
round
(
direction
.
z
));
this
.
pushToDrawBuffer
(
direction
.
z
);
this
.
pushToDrawBuffer
(
round
(
normal
.
x
));
normal
.
setLength
(
this
.
color
.
getHex
()
+
1
);
//encode color as length, add one in case color is black
this
.
pushToDrawBuffer
(
round
(
normal
.
y
));
this
.
pushToDrawBuffer
(
normal
.
x
);
this
.
pushToDrawBuffer
(
round
(
normal
.
z
));
this
.
pushToDrawBuffer
(
normal
.
y
);
this
.
pushToDrawBuffer
(
normal
.
z
);
}
}
},
},
...
...
This diff is collapsed.
Click to expand it.
src/components/tools/pen.js
+
1
−
1
View file @
735acfa9
...
@@ -83,7 +83,7 @@ AFRAME.registerComponent("pen", {
...
@@ -83,7 +83,7 @@ AFRAME.registerComponent("pen", {
this
.
currentDrawing
.
getLastPoint
().
distanceTo
(
this
.
worldPosition
)
>=
this
.
data
.
minDistanceBetweenPoints
this
.
currentDrawing
.
getLastPoint
().
distanceTo
(
this
.
worldPosition
)
>=
this
.
data
.
minDistanceBetweenPoints
)
{
)
{
this
.
getNormal
(
this
.
normal
,
this
.
worldPosition
,
this
.
direction
);
this
.
getNormal
(
this
.
normal
,
this
.
worldPosition
,
this
.
direction
);
this
.
currentDrawing
.
draw
(
this
.
worldPosition
,
this
.
direction
,
this
.
normal
);
this
.
currentDrawing
.
draw
(
this
.
worldPosition
,
this
.
direction
,
this
.
normal
,
this
.
data
.
color
,
this
.
data
.
radius
);
}
}
this
.
timeSinceLastDraw
=
time
%
this
.
data
.
drawFrequency
;
this
.
timeSinceLastDraw
=
time
%
this
.
data
.
drawFrequency
;
...
...
This diff is collapsed.
Click to expand it.
src/utils/mouse-events-handler.js
+
1
−
0
View file @
735acfa9
...
@@ -90,6 +90,7 @@ export default class MouseEventsHandler {
...
@@ -90,6 +90,7 @@ export default class MouseEventsHandler {
if
(
!
e
.
altKey
)
{
if
(
!
e
.
altKey
)
{
direction
=
this
.
cursor
.
changeDistanceMod
(
mod
);
direction
=
this
.
cursor
.
changeDistanceMod
(
mod
);
}
else
{
}
else
{
e
.
preventDefault
();
//prevent forward/back in firefox
direction
=
e
.
deltaY
;
direction
=
e
.
deltaY
;
}
}
if
(
if
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment