Allow default line color parameter when embedding.
This commit is contained in:
parent
ac1a0e5b9d
commit
9e5ddaead7
@ -112,6 +112,14 @@
|
||||
<div class="parameter_description">Default color of the model. It has effect only if the imported model doesn't specify any color.</div>
|
||||
</div>
|
||||
<div class="parameter_header">
|
||||
<span class="parameter_name">defaultLineColor</span>
|
||||
<span class="type parameter_type"><a href="Class_RGBColor.html" target="_self">RGBColor</a></span>
|
||||
<span class="parameter_attributes">(optional)</span>
|
||||
</div>
|
||||
<div class="parameter_main">
|
||||
<div class="parameter_description">Default line color of the model. It has effect only if the imported model doesn't specify any color.</div>
|
||||
</div>
|
||||
<div class="parameter_header">
|
||||
<span class="parameter_name">edgeSettings</span>
|
||||
<span class="type parameter_type"><a href="Class_EdgeSettings.html" target="_self">EdgeSettings</a></span>
|
||||
<span class="parameter_attributes">(optional)</span>
|
||||
|
||||
61
sandbox/embed_lines.html
Normal file
61
sandbox/embed_lines.html
Normal file
@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
|
||||
<title>Online 3D Viewer</title>
|
||||
|
||||
<script type="text/javascript" src="../build/engine_dev/o3dv.min.js"></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
window.addEventListener ('load', () => {
|
||||
OV.Init3DViewerElements ();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
iframe, div.online_3d_viewer
|
||||
{
|
||||
float: left;
|
||||
border: 1px solid #eeeeee;
|
||||
margin: 0px 4px 4px 0px;
|
||||
width: 360px;
|
||||
height: 240px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/cube_with_edges.obj">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/cube_with_edges.obj$defaultcolor=0,200,0$defaultlinecolor=0,100,0">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/cube_with_edges.obj,../test/testfiles/obj/cube_with_edges.mtl">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/cube_with_edges.obj,../test/testfiles/obj/cube_with_edges.mtl$defaultcolor=0,200,0$defaultlinecolor=0,100,0">
|
||||
</iframe>
|
||||
<div class="online_3d_viewer"
|
||||
model="../test/testfiles/obj/cube_with_edges.obj">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
model="../test/testfiles/obj/cube_with_edges.obj"
|
||||
defaultcolor="0,200,0"
|
||||
defaultlinecolor="0,100,0">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
model="../test/testfiles/obj/cube_with_edges.obj,../test/testfiles/obj/cube_with_edges.mtl">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
model="../test/testfiles/obj/cube_with_edges.obj,../test/testfiles/obj/cube_with_edges.mtl"
|
||||
defaultcolor="0,200,0"
|
||||
defaultlinecolor="0,100,0">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -269,6 +269,12 @@ export class ParameterListBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
AddDefaultLineColor (color)
|
||||
{
|
||||
this.AddUrlPart ('defaultlinecolor', ParameterConverter.RGBColorToString (color));
|
||||
return this;
|
||||
}
|
||||
|
||||
AddEdgeSettings (edgeSettings)
|
||||
{
|
||||
this.AddUrlPart ('edgesettings', ParameterConverter.EdgeSettingsToString (edgeSettings));
|
||||
@ -344,6 +350,12 @@ export class ParameterListParser
|
||||
return ParameterConverter.StringToRGBColor (colorParams);
|
||||
}
|
||||
|
||||
GetDefaultLineColor ()
|
||||
{
|
||||
let colorParams = this.GetKeywordParams ('defaultlinecolor');
|
||||
return ParameterConverter.StringToRGBColor (colorParams);
|
||||
}
|
||||
|
||||
GetEdgeSettings ()
|
||||
{
|
||||
let edgeSettingsParams = this.GetKeywordParams ('edgesettings');
|
||||
|
||||
@ -24,6 +24,8 @@ export class EmbeddedViewer
|
||||
* @param {RGBAColor} [parameters.backgroundColor] Background color of the canvas.
|
||||
* @param {RGBColor} [parameters.defaultColor] Default color of the model. It has effect only
|
||||
* if the imported model doesn't specify any color.
|
||||
* @param {RGBColor} [parameters.defaultLineColor] Default line color of the model. It has effect only
|
||||
* if the imported model doesn't specify any color.
|
||||
* @param {EdgeSettings} [parameters.edgeSettings] Edge settings.
|
||||
* @param {EnvironmentSettings} [parameters.environmentSettings] Environment settings.
|
||||
* @param {function} [parameters.onModelLoaded] Callback that is called when the model with all
|
||||
@ -109,10 +111,12 @@ export class EmbeddedViewer
|
||||
|
||||
this.viewer.Clear ();
|
||||
let settings = new ImportSettings ();
|
||||
console.log (this.parameters);
|
||||
if (this.parameters.defaultColor) {
|
||||
settings.defaultColor = this.parameters.defaultColor;
|
||||
}
|
||||
if (this.parameters.defaultLineColor) {
|
||||
settings.defaultLineColor = this.parameters.defaultLineColor;
|
||||
}
|
||||
|
||||
this.model = null;
|
||||
let progressDiv = null;
|
||||
@ -276,6 +280,12 @@ export function Init3DViewerElements (onReady)
|
||||
defaultColor = ParameterConverter.StringToRGBColor (defaultColorParams);
|
||||
}
|
||||
|
||||
let defaultLineColor = null;
|
||||
let defaultLineColorParams = element.getAttribute ('defaultlinecolor');
|
||||
if (defaultLineColorParams) {
|
||||
defaultLineColor = ParameterConverter.StringToRGBColor (defaultLineColorParams);
|
||||
}
|
||||
|
||||
let edgeSettings = null;
|
||||
let edgeSettingsParams = element.getAttribute ('edgesettings');
|
||||
if (edgeSettingsParams) {
|
||||
@ -306,6 +316,7 @@ export function Init3DViewerElements (onReady)
|
||||
camera : camera,
|
||||
projectionMode : projectionMode,
|
||||
backgroundColor : backgroundColor,
|
||||
defaultLineColor : defaultLineColor,
|
||||
defaultColor : defaultColor,
|
||||
edgeSettings : edgeSettings,
|
||||
environmentSettings : environmentSettings
|
||||
|
||||
@ -68,6 +68,10 @@ export class Embed
|
||||
if (defaultColor !== null) {
|
||||
settings.defaultColor = defaultColor;
|
||||
}
|
||||
let defaultLineColor = this.hashHandler.GetDefaultLineColorFromHash ();
|
||||
if (defaultLineColor !== null) {
|
||||
settings.defaultLineColor = defaultLineColor;
|
||||
}
|
||||
let inputFiles = InputFilesFromUrls (urls);
|
||||
this.modelLoaderUI.LoadModel (inputFiles, settings, {
|
||||
onStart : () =>
|
||||
|
||||
@ -72,6 +72,12 @@ export class HashHandler
|
||||
return parser.GetDefaultColor ();
|
||||
}
|
||||
|
||||
GetDefaultLineColorFromHash ()
|
||||
{
|
||||
let parser = CreateUrlParser (this.GetHash ());
|
||||
return parser.GetDefaultLineColor ();
|
||||
}
|
||||
|
||||
GetEdgeSettingsFromHash ()
|
||||
{
|
||||
let parser = CreateUrlParser (this.GetHash ());
|
||||
|
||||
@ -71,6 +71,7 @@ export function ShowSharingDialog (fileList, settings, viewer)
|
||||
builder.AddEnvironmentSettings (environmentSettings);
|
||||
builder.AddBackgroundColor (settings.backgroundColor);
|
||||
builder.AddDefaultColor (settings.defaultColor);
|
||||
builder.AddDefaultLineColor (settings.defaultLineColor);
|
||||
builder.AddEdgeSettings (settings.edgeSettings);
|
||||
}
|
||||
let hashParameters = builder.GetParameterList ();
|
||||
|
||||
@ -3,11 +3,6 @@ Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.800000 0.000000 0.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
|
||||
newmtl Green
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.000000 0.800000 0.000000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
|
||||
newmtl Blue
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.000000 0.000000 0.800000
|
||||
|
||||
@ -29,16 +29,12 @@ f 1/1/6 4/2/6 3/3/6 2/4/6
|
||||
f 2/1/1 3/2/1 7/3/1 6/4/1
|
||||
f 4/1/2 1/2/2 5/3/2 8/4/2
|
||||
f 5/1/5 6/2/5 7/3/5 8/4/5
|
||||
|
||||
l 1 4 2 3 6 7 5 8
|
||||
|
||||
usemtl Red
|
||||
f 3/1/3 4/2/3 8/3/3 7/4/3
|
||||
l 1 2 2 6 6 5 5 1
|
||||
|
||||
usemtl Blue
|
||||
f 1/1/4 2/2/4 6/3/4 5/4/4
|
||||
|
||||
usemtl Green
|
||||
l 3 4 4 8 8 7 7 3
|
||||
l 1 2 2 6 6 5 5 1
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ describe ('Parameter List', function () {
|
||||
);
|
||||
let background = new OV.RGBAColor (4, 5, 6, 7);
|
||||
let color = new OV.RGBColor (1, 2, 3);
|
||||
let color2 = new OV.RGBColor (4, 5, 6);
|
||||
{
|
||||
let urlParams = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).GetParameterList ();
|
||||
assert.strictEqual (urlParams, 'model=a.txt,b.txt');
|
||||
@ -36,6 +37,10 @@ describe ('Parameter List', function () {
|
||||
let urlParams = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).AddBackgroundColor (background).AddDefaultColor (color).GetParameterList ();
|
||||
assert.strictEqual (urlParams, 'model=a.txt,b.txt$camera=1.00000,1.00000,1.00000,0.00000,0.00000,0.00000,0.00000,0.00000,1.00000,45.00000$backgroundcolor=4,5,6,7$defaultcolor=1,2,3');
|
||||
}
|
||||
{
|
||||
let urlParams = OV.CreateUrlBuilder ().AddModelUrls (modelUrls).AddCamera (camera).AddBackgroundColor (background).AddDefaultColor (color).AddDefaultLineColor (color2).GetParameterList ();
|
||||
assert.strictEqual (urlParams, 'model=a.txt,b.txt$camera=1.00000,1.00000,1.00000,0.00000,0.00000,0.00000,0.00000,0.00000,1.00000,45.00000$backgroundcolor=4,5,6,7$defaultcolor=1,2,3$defaultlinecolor=4,5,6');
|
||||
}
|
||||
{
|
||||
let urlParams = OV.CreateUrlBuilder ().AddEdgeSettings (new EdgeSettings (
|
||||
true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user