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
aa4f4508
Commit
aa4f4508
authored
Dec 17, 2015
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added links to smaller models
parent
6087f7ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
32 deletions
+59
-32
viewmodel.js
x3d_web_viewer/viewmodel.js
+59
-32
No files found.
x3d_web_viewer/viewmodel.js
View file @
aa4f4508
...
@@ -13,6 +13,7 @@ var elphel_wiki_prefix = "http://wiki.elphel.com/index.php?search="
...
@@ -13,6 +13,7 @@ var elphel_wiki_prefix = "http://wiki.elphel.com/index.php?search="
var
nobuttons
=
false
;
var
nobuttons
=
false
;
var
animate
=
false
;
var
animate
=
false
;
var
settings_file
=
"settings.xml"
;
var
settings_file
=
"settings.xml"
;
var
path
=
""
;
function
resize
(){
function
resize
(){
var
w
=
$
(
window
).
width
();
var
w
=
$
(
window
).
width
();
...
@@ -350,13 +351,22 @@ function showBOM(){
...
@@ -350,13 +351,22 @@ function showBOM(){
e
.
stopPropagation
();
e
.
stopPropagation
();
});
});
btn_link_to_wiki
=
$
(
"<a>"
,{
href
:
elphel_wiki_prefix
+
tmp_nsn
,
class
:
"btn btn-default btn-sm"
,
title
:
"Elphel Wiki docs"
}).
html
(
"<span class=
\"
glyphicon glyphicon-link
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
padding
:
"7px 13px 7px 13px"
,
margin
:
"6px"
});
btn_link_open
=
$
(
"<a>"
,{
href
:
"?model="
+
path
+
"/"
+
tmp_nsn
+
".x3d"
,
class
:
"btn btn-default btn-sm"
,
title
:
"Open in new window"
}).
html
(
"<span class=
\"
glyphicon glyphicon-open
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
padding
:
"7px 13px 7px 13px"
,
margin
:
"6px 0px 6px 6px"
});
btn_link_open
.
click
(
function
(
e
){
window
.
location
.
href
=
$
(
this
).
attr
(
'href'
);
});
btn_link_to_wiki
=
$
(
"<a>"
,{
href
:
elphel_wiki_prefix
+
tmp_nsn
,
class
:
"btn btn-default btn-sm"
,
title
:
"Elphel Wiki docs"
}).
html
(
"<span class=
\"
glyphicon glyphicon-book
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
padding
:
"7px 13px 7px 13px"
,
margin
:
"6px"
});
btn_link_to_wiki
.
click
(
function
(
e
){
btn_link_to_wiki
.
click
(
function
(
e
){
window
.
location
.
href
=
$
(
e
.
target
).
attr
(
'href'
);
window
.
location
.
href
=
$
(
this
).
attr
(
'href'
);
});
});
ele_ul
.
append
(
$
(
"<li>"
).
append
(
btn_subpart
.
css
({
display
:
"inline"
})).
append
(
btn_link_to_wiki
.
css
({
display
:
"inline"
})).
css
({
padding
:
"3px"
,
"min-width"
:
"100px"
,
width
:
"100px"
}));
ele_ul
.
append
(
$
(
"<li>"
).
append
(
btn_subpart
.
css
({
display
:
"inline"
}))
.
append
(
btn_link_open
.
css
({
display
:
"inline"
}))
.
append
(
btn_link_to_wiki
.
css
({
display
:
"inline"
}))
.
css
({
padding
:
"3px"
,
"min-width"
:
"100px"
,
width
:
"150px"
}));
//build a list for unique and multiple parts
//build a list for unique and multiple parts
for
(
var
j
=
0
;
j
<=
sublist
.
length
;
j
++
){
for
(
var
j
=
0
;
j
<=
sublist
.
length
;
j
++
){
...
@@ -484,14 +494,31 @@ function update_info(name,state,cmd){
...
@@ -484,14 +494,31 @@ function update_info(name,state,cmd){
case
"left-click"
:
case
"left-click"
:
if
(
state
==
"normal"
){
if
(
state
==
"normal"
){
var
pn
=
$
(
"<span>"
).
html
(
name
);
var
pn
=
$
(
"<span>"
).
html
(
name
);
var
hide_btn
=
$
(
"<button>"
,{
id
:
"info_hide"
,
title
:
"hide parts"
,
class
:
"btn btn-default btn-danger btn-sm nooutline"
}).
attr
(
"nsn"
,
name
).
html
(
"<span class=
\"
glyphicon glyphicon-remove
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
var
open_btn
=
$
(
"<a>"
,{
id
:
"info_open"
,
title
:
"open part in new window"
,
class
:
"btn btn-default btn-sm nooutline"
}).
attr
(
"nsn"
,
name
).
html
(
"<span class=
\"
glyphicon glyphicon-open
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
padding
:
"8px 11px 7px 11px"
,
margin
:
"0px 0px 0px 10px"
});
open_btn
.
attr
(
"href"
,
"?model="
+
path
+
"/"
+
name
+
".x3d"
);
var
hide_btn
=
$
(
"<button>"
,{
id
:
"info_hide"
,
title
:
"hide parts"
,
class
:
"btn btn-default btn-danger btn-sm nooutline"
}).
attr
(
"nsn"
,
name
).
html
(
"<span class=
\"
glyphicon glyphicon-remove
\"
aria-hidden=
\"
true
\"
></span>"
).
css
({
padding
:
"8px 11px 7px 11px"
,
padding
:
"8px 11px 7px 11px"
,
margin
:
"0px 0px 0px 10px"
margin
:
"0px 0px 0px 10px"
});
});
hide_btn
.
click
(
function
(){
hide_btn
.
click
(
function
(){
model_run_cmd
(
name
,
"info-hide-click"
);
model_run_cmd
(
name
,
"info-hide-click"
);
});
});
$
(
"#info"
).
append
(
pn
).
append
(
$
(
"<span>"
).
append
(
hide_btn
));
$
(
"#info"
).
append
(
pn
).
append
(
$
(
"<span>"
).
append
(
open_btn
)).
append
(
$
(
"<span>"
).
append
(
hide_btn
));
}
}
break
;
break
;
default
:
return
false
;
default
:
return
false
;
...
@@ -537,14 +564,7 @@ function model_run_cmd(name,cmd){
...
@@ -537,14 +564,7 @@ function model_run_cmd(name,cmd){
$
(
".btn-subpart[nsn="
+
name
+
"]"
).
addClass
(
"btn-success"
);
$
(
".btn-subpart[nsn="
+
name
+
"]"
).
addClass
(
"btn-success"
);
}
}
if
((
state
==
"selected"
)
||
(
state
==
"superselected"
)){
if
((
state
==
"selected"
)
||
(
state
==
"superselected"
)){
$
(
"Switch"
).
each
(
function
(){
model_run_cmd
(
name
,
"normalize"
);
$
(
this
).
find
(
"Material"
).
attr
(
"transparency"
,
0.1
);
if
((
$
(
this
).
attr
(
"state"
)
==
"selected"
)
||
(
$
(
this
).
attr
(
"state"
)
==
"superselected"
)){
$
(
this
).
attr
(
"state"
,
"normal"
);
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
addClass
(
"btn-success"
).
removeClass
(
"btn-primary"
);
}
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
css
({
opacity
:
"1.0"
});
});
}
}
break
;
break
;
case
"click-int-all"
:
case
"click-int-all"
:
...
@@ -626,16 +646,19 @@ function model_run_cmd(name,cmd){
...
@@ -626,16 +646,19 @@ function model_run_cmd(name,cmd){
}
}
break
;
break
;
case
"info-hide-click"
:
case
"info-hide-click"
:
$
(
"Switch"
).
each
(
function
(){
model_run_cmd
(
name
,
"normalize"
);
$
(
this
).
find
(
"Material"
).
attr
(
"transparency"
,
0.1
);
if
((
$
(
this
).
attr
(
"state"
)
==
"selected"
)
||
(
$
(
this
).
attr
(
"state"
)
==
"superselected"
)){
$
(
this
).
attr
(
"state"
,
"normal"
);
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
addClass
(
"btn-success"
).
removeClass
(
"btn-primary"
);
}
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
css
({
opacity
:
"1.0"
});
});
model_run_cmd
(
name
,
"right-click"
);
model_run_cmd
(
name
,
"right-click"
);
break
;
break
;
case
"normalize"
:
$
(
"Switch"
).
each
(
function
(){
$
(
this
).
find
(
"Material"
).
attr
(
"transparency"
,
0.1
);
if
((
$
(
this
).
attr
(
"state"
)
==
"selected"
)
||
(
$
(
this
).
attr
(
"state"
)
==
"superselected"
)){
$
(
this
).
attr
(
"state"
,
"normal"
);
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
addClass
(
"btn-success"
).
removeClass
(
"btn-primary"
);
}
$
(
".btn-part[nsn="
+
$
(
this
).
attr
(
"nsn"
)
+
"]"
).
css
({
opacity
:
"1.0"
});
});
break
;
default
:
default
:
return
false
;
return
false
;
}
}
...
@@ -691,16 +714,20 @@ function btn_subpart_enableAll(){
...
@@ -691,16 +714,20 @@ function btn_subpart_enableAll(){
}
}
function
parseURL
()
{
function
parseURL
()
{
var
parameters
=
location
.
href
.
replace
(
/
\?
/ig
,
"&"
).
split
(
"&"
);
var
parameters
=
location
.
href
.
replace
(
/
\?
/ig
,
"&"
).
split
(
"&"
);
for
(
var
i
=
0
;
i
<
parameters
.
length
;
i
++
)
parameters
[
i
]
=
parameters
[
i
].
split
(
"="
);
for
(
var
i
=
0
;
i
<
parameters
.
length
;
i
++
)
parameters
[
i
]
=
parameters
[
i
].
split
(
"="
);
for
(
var
i
=
1
;
i
<
parameters
.
length
;
i
++
)
{
for
(
var
i
=
1
;
i
<
parameters
.
length
;
i
++
)
{
switch
(
parameters
[
i
][
0
])
{
switch
(
parameters
[
i
][
0
])
{
case
"model"
:
model
=
parameters
[
i
][
1
];
break
;
case
"model"
:
model
=
parameters
[
i
][
1
];
break
;
case
"nobuttons"
:
nobuttons
=
true
;
break
;
case
"nobuttons"
:
nobuttons
=
true
;
break
;
case
"animate"
:
animate
=
true
;
break
;
case
"animate"
:
animate
=
true
;
break
;
//case "settings": settings_file = parameters[i][1];break;
//case "settings": settings_file = parameters[i][1];break;
}
}
var
index
=
model
.
lastIndexOf
(
"/"
);
if
(
index
>
0
){
path
=
model
.
substr
(
0
,
index
);
}
}
}
settings_file
=
model
.
slice
(
0
,
-
3
)
+
"xml"
;
settings_file
=
model
.
slice
(
0
,
-
3
)
+
"xml"
;
console
.
log
(
"Opening model: "
+
model
);
console
.
log
(
"Opening model: "
+
model
);
}
}
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