Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
freecad_x3d
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
freecad_x3d
Commits
55768512
Commit
55768512
authored
Dec 25, 2015
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.mouseleave 2.&zoom=1 3.&screen_ratio=0.9
parent
16b33b0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
8 deletions
+78
-8
viewmodel.js
x3d_web_viewer/viewmodel.js
+78
-8
No files found.
x3d_web_viewer/viewmodel.js
View file @
55768512
...
@@ -12,26 +12,34 @@ var NSN = "m";
...
@@ -12,26 +12,34 @@ var NSN = "m";
var
elphel_wiki_prefix
=
"http://wiki.elphel.com/index.php?search="
var
elphel_wiki_prefix
=
"http://wiki.elphel.com/index.php?search="
var
nobuttons
=
false
;
var
nobuttons
=
false
;
var
nocontrols
=
false
;
var
nocontrols
=
false
;
var
notitle
=
false
;
var
nodocs
=
false
;
var
animate
=
false
;
var
animate
=
false
;
var
settings_file
=
"settings.xml"
;
var
settings_file
=
"settings.xml"
;
var
path
=
""
;
var
path
=
""
;
var
inherited_parameters
=
""
;
var
inherited_parameters
=
""
;
var
screen_ratio
=
1
;
//w/h
var
zoom
=
0.9
;
function
resize
(){
function
resize
(){
console
.
log
(
"resize"
);
console
.
log
(
"resize"
);
var
w
=
$
(
window
).
width
();
var
w
=
$
(
window
).
width
();
var
h
=
$
(
window
).
height
();
var
h
=
$
(
window
).
height
();
if
(
w
>
h
){
if
(
w
>
h
){
$
(
"#main"
).
css
({
width
:(
h
-
10
)
+
"px"
,
height
:(
h
-
10
)
+
"px"
});
$
(
"#main"
).
css
({
width
:(
Math
.
round
(
h
*
screen_ratio
)
-
10
)
+
"px"
,
height
:(
h
-
10
)
+
"px"
});
$
(
"#x3d_canvas"
).
css
({
width
:(
h
-
10
)
+
"px"
,
height
:(
h
-
10
)
+
"px"
});
$
(
"#x3d_canvas"
).
css
({
width
:(
Math
.
round
(
h
*
screen_ratio
)
-
10
)
+
"px"
,
height
:(
h
-
10
)
+
"px"
});
$
(
"#bom"
).
css
({
left
:(
h
)
+
"px"
});
$
(
"#bom"
).
css
({
left
:(
Math
.
round
(
h
*
screen_ratio
)
)
+
"px"
});
//$("#thrd").css({left:(h-107)+"px"});
//$("#thrd").css({left:(h-107)+"px"});
}
else
{
}
else
{
$
(
"#main"
).
css
({
width
:(
w
-
10
)
+
"px"
,
height
:(
w
-
10
)
+
"px"
});
$
(
"#main"
).
css
({
width
:(
w
-
10
)
+
"px"
,
height
:(
Math
.
round
(
w
/
screen_ratio
)
-
10
)
+
"px"
});
$
(
"#x3d_canvas"
).
css
({
width
:(
w
-
10
)
+
"px"
,
height
:(
w
-
10
)
+
"px"
});
$
(
"#x3d_canvas"
).
css
({
width
:(
w
-
10
)
+
"px"
,
height
:(
Math
.
round
(
w
/
screen_ratio
)
-
10
)
+
"px"
});
$
(
"#bom"
).
css
({
left
:(
w
)
+
"px"
});
$
(
"#bom"
).
css
({
left
:(
w
)
+
"px"
});
//$("#thrd").css({left:(w-107)+"px"});
//$("#thrd").css({left:(w-107)+"px"});
}
}
$
(
"#title"
).
css
({
left
:
(
$
(
"#main"
).
width
()
/
2
-
$
(
"#title"
).
width
()
/
2
)
+
"px"
,
});
}
}
var
resizeTimer
;
var
resizeTimer
;
...
@@ -328,6 +336,36 @@ function prerun(){
...
@@ -328,6 +336,36 @@ function prerun(){
$
(
"#thrd"
).
css
({
display
:
"none"
});
$
(
"#thrd"
).
css
({
display
:
"none"
});
}
}
var
index
=
model
.
lastIndexOf
(
"/"
);
/*
if (index<0){
index = 0;
}
*/
var
model_pn
=
model
.
substr
(
index
+
1
);
model_pn
=
model_pn
.
slice
(
0
,
-
4
);
var
pn_title
=
$
(
"<div>"
,{
id
:
"title"
}).
css
({
position
:
"absolute"
,
"border-radius"
:
"2px 2px 2px 2px"
,
border
:
"1px solid gray"
,
color
:
"white"
,
"font-size"
:
"1.2em"
,
padding
:
"10px 10px 10px 10px"
,
background
:
"rgba(50,50,50,0.9)"
}).
html
(
model_pn
);
$
(
"#main"
).
append
(
pn_title
);
pn_title
.
css
({
top
:
"0px"
,
left
:
(
$
(
"#main"
).
width
()
/
2
-
pn_title
.
width
()
/
2
)
+
"px"
,
});
if
(
notitle
){
pn_title
.
css
({
display
:
"none"
});
}
}
}
...
@@ -371,7 +409,7 @@ function place_camera(){
...
@@ -371,7 +409,7 @@ function place_camera(){
console
.
log
(
"field of view is "
+
fov
);
console
.
log
(
"field of view is "
+
fov
);
//(top_bboxsize[1]/2) / l = tg a/2
//(top_bboxsize[1]/2) / l = tg a/2
fov
=
fov
*
0.9
;
fov
=
fov
*
zoom
;
var
phi
=
-
0.7
;
var
phi
=
-
0.7
;
var
boxsize
;
var
boxsize
;
...
@@ -595,7 +633,9 @@ function unbindCanvas(){
...
@@ -595,7 +633,9 @@ function unbindCanvas(){
canvas
.
removeEventListener
(
"mousedown"
,
mousestarted
,
false
);
canvas
.
removeEventListener
(
"mousedown"
,
mousestarted
,
false
);
canvas
.
removeEventListener
(
"mousemove"
,
mousemoved
,
true
);
//does not work with false
canvas
.
removeEventListener
(
"mousemove"
,
mousemoved
,
true
);
//does not work with false
canvas
.
removeEventListener
(
"mouseup"
,
mouseended
,
true
);
canvas
.
removeEventListener
(
"mouseup"
,
mouseended
,
true
);
canvas
.
removeEventListener
(
"mouseleave"
,
mouseleft
,
false
);
canvas
.
removeEventListener
(
"touchend"
,
mouseended
,
false
);
canvas
.
removeEventListener
(
"touchend"
,
mouseended
,
false
);
canvas
.
removeEventListener
(
"touchcancel"
,
touchcanceled
,
false
);
}
}
function
bindCanvas
(){
function
bindCanvas
(){
...
@@ -628,8 +668,10 @@ function bindCanvas(){
...
@@ -628,8 +668,10 @@ function bindCanvas(){
canvas
.
addEventListener
(
"touchmove"
,
touchmoved
,
false
);
canvas
.
addEventListener
(
"touchmove"
,
touchmoved
,
false
);
canvas
.
addEventListener
(
"mousedown"
,
mousestarted
,
false
);
canvas
.
addEventListener
(
"mousedown"
,
mousestarted
,
false
);
canvas
.
addEventListener
(
"mousemove"
,
mousemoved
,
true
);
//does not work with false
canvas
.
addEventListener
(
"mousemove"
,
mousemoved
,
true
);
//does not work with false
canvas
.
addEventListener
(
"mouseleave"
,
mouseleft
,
false
);
canvas
.
addEventListener
(
"mouseup"
,
mouseended
,
true
);
canvas
.
addEventListener
(
"mouseup"
,
mouseended
,
true
);
canvas
.
addEventListener
(
"touchend"
,
mouseended
,
false
);
canvas
.
addEventListener
(
"touchend"
,
mouseended
,
false
);
canvas
.
addEventListener
(
"touchcancel"
,
touchcanceled
,
false
);
console
.
log
(
"Added event listeners"
);
console
.
log
(
"Added event listeners"
);
//click
//click
...
@@ -663,8 +705,24 @@ function bindCanvas(){
...
@@ -663,8 +705,24 @@ function bindCanvas(){
var
switch_click_time
=
0
;
var
switch_click_time
=
0
;
function
touchstarted
(){
function
mouseleft
(
e
){
console
.
log
(
"Mouseleft!"
);
mouseended
(
e
);
}
function
touchcanceled
(
e
){
console
.
log
(
"Touchcanceled"
);
mouseended
(
e
);
}
var
touched_element
;
function
touchstarted
(
event
){
stop_animation
();
stop_animation
();
/*
var touch = event.touches[0];
touched_element = document.elementFromPoint(touch.pageX,touch.pageY);
*/
blockclick
=
false
;
blockclick
=
false
;
dragging
=
false
;
dragging
=
false
;
moveTimeStamp
=
getTimeStamp
();
moveTimeStamp
=
getTimeStamp
();
...
@@ -673,6 +731,12 @@ function touchstarted(){
...
@@ -673,6 +731,12 @@ function touchstarted(){
}
}
function
touchmoved
(
event
){
function
touchmoved
(
event
){
/*
var touches = event.touches[0];
if (touched_element !== document.elementFromPoint(touch.pageX,touch.pageY)) {
mouseended(event);
}
*/
//blockclick = true;
//blockclick = true;
if
((
getTimeStamp
()
-
moveTimeStamp
)
>
100
){
if
((
getTimeStamp
()
-
moveTimeStamp
)
>
100
){
blockclick
=
true
;
blockclick
=
true
;
...
@@ -981,7 +1045,9 @@ function update_info(name,state,cmd){
...
@@ -981,7 +1045,9 @@ function update_info(name,state,cmd){
model_run_cmd
(
name
,
"info-hide-click"
);
model_run_cmd
(
name
,
"info-hide-click"
);
});
});
$
(
"#info"
).
append
(
pn
).
append
(
$
(
"<span>"
).
append
(
open_btn
)).
append
(
$
(
"<span>"
).
append
(
wiki_btn
)).
append
(
$
(
"<span>"
).
append
(
hide_btn
)).
css
({
display
:
""
});
$
(
"#info"
).
append
(
pn
).
append
(
$
(
"<span>"
).
append
(
open_btn
));
if
(
!
nodocs
)
$
(
"#info"
).
append
(
$
(
"<span>"
).
append
(
wiki_btn
));
$
(
"#info"
).
append
(
$
(
"<span>"
).
append
(
hide_btn
)).
css
({
display
:
""
});
}
}
break
;
break
;
case
"click-ext"
:
case
"click-ext"
:
...
@@ -1245,9 +1311,13 @@ function parseURL() {
...
@@ -1245,9 +1311,13 @@ function parseURL() {
case
"nobuttons"
:
nobuttons
=
true
;
break
;
case
"nobuttons"
:
nobuttons
=
true
;
break
;
case
"animate"
:
animate
=
true
;
break
;
case
"animate"
:
animate
=
true
;
break
;
case
"nocontrols"
:
nocontrols
=
true
;
break
;
case
"nocontrols"
:
nocontrols
=
true
;
break
;
case
"notitle"
:
notitle
=
true
;
break
;
case
"nodocs"
:
nodocs
=
true
;
break
;
case
"fraction"
:
fraction
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"fraction"
:
fraction
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"halflife"
:
halflife
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"halflife"
:
halflife
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"releasetimelimit"
:
moveReleaseTimeLimit
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"releasetimelimit"
:
moveReleaseTimeLimit
=
parseInt
(
parameters
[
i
][
1
]);
break
;
case
"screen_ratio"
:
screen_ratio
=
parseFloat
(
parameters
[
i
][
1
]);
break
;
case
"zoom"
:
zoom
=
parseFloat
(
parameters
[
i
][
1
]);
break
;
//case "settings": settings_file = parameters[i][1];break;
//case "settings": settings_file = parameters[i][1];break;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment