Use the camera recommended by the importer in case of no camera defined during embedding or self-hosting.
This commit is contained in:
parent
473da09052
commit
6d23481619
@ -1,5 +1,19 @@
|
||||
OV.Init3DViewerElements = function ()
|
||||
{
|
||||
function SetCamera (element, viewer, importResult)
|
||||
{
|
||||
let camera = null;
|
||||
let cameraParams = element.getAttribute ('camera');
|
||||
if (cameraParams) {
|
||||
camera = OV.UrlParamConverter.UrlParameterToCamera (cameraParams);
|
||||
}
|
||||
if (camera !== null) {
|
||||
viewer.SetCamera (camera);
|
||||
} else {
|
||||
viewer.SetUpVector (importResult.upVector, false);
|
||||
}
|
||||
}
|
||||
|
||||
function LoadElement (element)
|
||||
{
|
||||
let canvas = document.createElement ('canvas');
|
||||
@ -37,6 +51,7 @@ OV.Init3DViewerElements = function ()
|
||||
return true;
|
||||
});
|
||||
viewer.AdjustClippingPlanes (boundingSphere);
|
||||
SetCamera (element, viewer, importResult);
|
||||
viewer.FitToWindow (boundingSphere, false);
|
||||
},
|
||||
onTextureLoaded : function () {
|
||||
@ -57,14 +72,6 @@ OV.Init3DViewerElements = function ()
|
||||
return;
|
||||
}
|
||||
|
||||
let cameraParams = element.getAttribute ('camera');
|
||||
if (cameraParams) {
|
||||
let camera = OV.UrlParamConverter.UrlParameterToCamera (cameraParams);
|
||||
if (camera !== null) {
|
||||
viewer.SetCamera (camera);
|
||||
}
|
||||
}
|
||||
|
||||
loader.LoadFromUrlList (modelUrls);
|
||||
}
|
||||
|
||||
|
||||
@ -12,22 +12,27 @@
|
||||
<body>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/3ds/cube_four_instances.3ds,../test/testfiles/3ds/texture.png"
|
||||
width=400 height=300
|
||||
width=360 height=240
|
||||
style="border:1px solid #eeeeee;">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/hundred_cubes.obj,../test/testfiles/obj/hundred_cubes.mtl"
|
||||
width=360 height=240
|
||||
style="border:1px solid #eeeeee;">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/3ds/cube_four_instances.3ds,../test/testfiles/3ds/texture.png$camera=3.929421317669367,6.153966358575169,2.7076091223424714,1.5,1.5,0.5,0,0,1"
|
||||
width=400 height=300
|
||||
width=360 height=240
|
||||
style="border:1px solid #eeeeee;">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/hundred_cubes.obj,../test/testfiles/obj/hundred_cubes.mtl"
|
||||
width=400 height=300
|
||||
src="../../website/embed.html#model=../test/testfiles/obj/hundred_cubes.obj,../test/testfiles/obj/hundred_cubes.mtl$camera=1,1,1,0,0,0,0,0,1"
|
||||
width=360 height=240
|
||||
style="border:1px solid #eeeeee;">
|
||||
</iframe>
|
||||
<iframe
|
||||
src="../../website/embed.html#model=wrong.3ds"
|
||||
width=400 height=300
|
||||
width=360 height=240
|
||||
style="border:1px solid #eeeeee;">
|
||||
</iframe>
|
||||
</body>
|
||||
|
||||
@ -19,19 +19,35 @@
|
||||
div.online_3d_viewer
|
||||
{
|
||||
float: left;
|
||||
border: 1px solid #eeeeee;
|
||||
margin: 0px 4px 4px 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="online_3d_viewer" width="400" height="300" model="../../test/testfiles/3ds/cube_four_instances.3ds,../../test/testfiles/3ds/texture.png"></div>
|
||||
<div class="online_3d_viewer"
|
||||
width="400" height="300"
|
||||
model="../../test/testfiles/3ds/cube_four_instances.3ds,../../test/testfiles/3ds/texture.png"
|
||||
camera="-1.5,-3.0,2.0,0,0,0,0,0,1">
|
||||
width="360" height="240"
|
||||
model="../../test/testfiles/3ds/cube_four_instances.3ds,../../test/testfiles/3ds/texture.png">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
width="360" height="240"
|
||||
model="../../test/testfiles/obj/hundred_cubes.obj,../../test/testfiles/obj/hundred_cubes.mtl">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
width="360" height="240"
|
||||
model="../../test/testfiles/3ds/cube_four_instances.3ds,../../test/testfiles/3ds/texture.png"
|
||||
camera="3.929421317669367,6.153966358575169,2.7076091223424714,1.5,1.5,0.5,0,0,1">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
width="360" height="240"
|
||||
model="../../test/testfiles/obj/hundred_cubes.obj,../../test/testfiles/obj/hundred_cubes.mtl"
|
||||
camera="1,1,1,0,0,0,0,0,1">
|
||||
</div>
|
||||
<div class="online_3d_viewer"
|
||||
width="360" height="240"
|
||||
model="wrong.3ds">
|
||||
</div>
|
||||
<div class="online_3d_viewer" width="400" height="300" model="../../test/testfiles/obj/hundred_cubes.obj,../../test/testfiles/obj/hundred_cubes.mtl"></div>
|
||||
<div class="online_3d_viewer" width="400" height="300" model="wrong.3ds"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@ -20,10 +20,6 @@ OV.Embed = class
|
||||
if (urls === null) {
|
||||
return;
|
||||
}
|
||||
let camera = this.hashHandler.GetCameraFromHash ();
|
||||
if (camera !== null) {
|
||||
this.viewer.SetCamera (camera);
|
||||
}
|
||||
this.modelLoader.LoadFromUrlList (urls);
|
||||
let hashParameters = OV.CreateUrlParameters (urls, null);
|
||||
let websiteUrl = this.parameters.websiteLinkDiv.attr ('href') + '#' + hashParameters;
|
||||
@ -45,6 +41,12 @@ OV.Embed = class
|
||||
return true;
|
||||
});
|
||||
this.viewer.AdjustClippingPlanes (boundingSphere);
|
||||
let camera = this.hashHandler.GetCameraFromHash ();
|
||||
if (camera !== null) {
|
||||
this.viewer.SetCamera (camera);
|
||||
} else {
|
||||
this.viewer.SetUpVector (importResult.upVector, false);
|
||||
}
|
||||
this.viewer.FitToWindow (boundingSphere, false);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user