How to Embed a 3DXML Model in HTML / PHP

How to Embed a 3DXML Model in HTML / PHP

Since 2016, I’ve been having trouble getting 3DXML models to embed in HTML or PHP files on my website.  I’ve tried to use the Dassault Systemes recommended 3DXML integration code, but it doesn’t appear to work.  I’ve tested this on various HTML and PHP files on my website, with different security and settings, and haven’t had any luck.

Some background:  3DXML files are compressed 3D Models that are lightweight and great for web and video presentation.  Once a person installs the free 3DXML viewer on their machine, they can view, orbit, and pan embedded 3dXML models in their browsers.  It’s a great way for clients to examine a real 3D Model on their own machine, instead of just renderings or animations.

From the link, this portion of code should be able to embed a 3DXML file in the browser:

<object type='application/x-3dxmlplugin' id='3DXMLPluginId'>
<param name='DocumentFile'
value='http://www.3DVIA.com/mymodel.3dxml'>
</object>

However, if you insert that portion of code in your HTML body, it will give you a “This plugin is not supported” message when your page renders.

 

As you read further down the support page, they require a bit more infrastructure.

First off, if you plan to show your 3DXML models on your own website, you have to update your MIME types.  This is done on your server settings, and most hosting plans have a MIME Type Editor in your CPanel or web hosting account.  If not, just call your hosting provider and ask where you can change and edit MIME types for your server.

Basically every extension type uses a type of character stream to transfer from the server to the client.  There may already be many file types that require the “application/octet-stream” that 3DXML uses.

To add a user defined MIME type, just type in”application/octet-stream” for the type and “.3dxml” for the extension.

After setting this, I thought I was good to see my models on my site.

I still got the “not supported error.”

Then I tried the second part of the DS code, where it enables the javascript or vbscript code to set everything up. Here is the code that they request you put in the “Body” of the HTML page:

<HTML> 
<BODY> 
<SCRIPT LANGUAGE="Javascript"> 
var playerInstalled = 0; 
MSDetect = "false"; 
if (navigator.mimeTypes && navigator.mimeTypes.length)

{ 
x = navigator.mimeTypes['application/x-3dxmlplugin']; 
if (x && x.enabledPlugin) 
playerInstalled = 1; 
} 
else 
{ 
MSDetect = "true"; 
} 
</SCRIPT> 
<SCRIPT LANGUAGE="VBScript"> 
on error resume next 
If MSDetect = "true" Then 
If NOT (IsObject(CreateObject("3DXMLPlugin"))) Then 
playerInstalled = 0 
Else 
playerInstalled = 1 
End If 
End If 
</SCRIPT> 
<SCRIPT LANGUAGE="Javascript"> 
if (playerInstalled == 0) 
{ 
<!-- 3D XML Player is not installed - > 
} 
else 
{ 
<!-- 3D XML Player is installed - >
} 
</SCRIPT> 
</BODY> 
</HTML>

I don’t think I’ve seen vbscript on a webpage in ten years, so I’m getting a bit worried about the validity of this code.  Regardless, I installed this in my <head> and <body> just in case they got it wrong.   Both, either, and neither didn’t seem to impact the implementation of the 3Dxml model in my webpage.

Just for those of you trying to embed your 3DXML models in WordPress, here is the way I inserted the JS and VB script into my theme settings:

Go to Appearance > “_Your_” Theme Settings > Integration > “Add code to the <body>”  (see image:)

Copy and paste the Dassault Systemes HTML scripts into the body setting.  Save your settings and see if they have updated your website.

After all this, I figured I finally got it done.  Still, it doesn’t work, and it says the object is “undefined” when I hover over it.  I think this had some sort of Chrome browser restriction.

I tried to open the webpage in Internet Explorer.  The wild west of the internet.

To IE’s credit, it did open my page and try to load the model.  It prompted me with allowing the 3DXML Application object at the bottom of the page.  However, I got some odd error message though:

Text “3DXML Player – [*] Dassault Systemes – Incident Report Manager Me…” 

“Generating minidump…” and “Exiting Process…”

“[*] The Incident Report Manager is trying to get unexpected behavior context of the guarded application.  Please just wait, this operation may take a moment.”

 

Alright.  I was getting a bit frustrated.  According to DS’s own website, I have set this up correctly, but I’m still getting oddball result.   Time to check out StackOverflow.  I found what appears to be the only topic on embedding 3DXML in HTML after 2016 (titled “3DXML Catia files not showing“) and the change in browser settings.

One person responded to basically all the same issues that I encountered, and provided an enigmatic bit of code to resolve this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><head>
<title>3DXML embeded page</title>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"></HEAD>
<BODY>
<DIV class=copy>You will see a 3DXML file opened from DS website only if you 
have installed the free 3DXML player from Dassault Systemes (link <A 
href="http://www.3ds.com/products/3dvia/3d-xml/1/">http://www.3ds.com/products/3dvia/3d-xml/1/</A>&nbsp;).</DIV>
<DIV class=copy>To see how to embed a 3DXML file&nbsp;in a web page just view 
this page source code.</DIV>
<DIV class=copy>© 2010 Dassault Systemes - All rights reserved.</DIV>
<OBJECT id=viewer border=1 
codeBase="http://www.3ds.com/fileadmin/PRODUCTS/3DVIA/3DXML/3dxml/3DXMLPlayerOnlineInstaller.exe" 
classid=clsid:5ABD296B-F8A0-436C-B2F7-B19170C43D28 width=800 height=600> <PARAM NAME="_cx" VALUE="21166"><PARAM NAME="_cy" VALUE="15875"><PARAM NAME="DocumentFile" VALUE="http://a3.media.3ds.com/fileadmin/PRODUCTS/3DVIA/3DXML/gallery/3dxml_models/press_rink_axe_fta.3dxml"><PARAM NAME="Data" VALUE=""> 
</OBJECT>
<DIV></DIV>
</BODY>
</html>

The author claims the key to all this is to “get the right ‘classID,'” whatever that means.  I’m still not sure if that pertains to the classID of 3dxml file, the web site, HTML file, or scripts.  I left a reply, but as of a few days, there hasn’t been a response.

So, I’m getting an “unsupported” and “undefined” error from Chrome, and some kind of plugin error from IE.  I’m assuming Firefox would have similar issues.

I was at my wits end, and felt compelled to contact Dassault directly.  Here are my correspondences:

Hello,


I’m working on embedding a 3DXML model in some html or php.  It’s a rather simple setup, but I’ve tried three different ways and all of them either are blank or show that the plug-in is not supported.  

I’m using the sample code provided here:  https://www.3ds.com/fileadmin/PRODUCTS-SERVICES/3DVIA/3DXML/dircopy_official/PlrUserMap/plr-t-tu-PlayerEmbed-InWebBrowser.htm

I’ve also tried this:  https://stackoverflow.com/questions/35395444/3dxml-catia-files-not-showing   The problem I’m having is I don’t think I have the proper ClassID.  I don’t know for sure, but how would I find that?

Do you have any functioning code that will show a 3dxml in html? 

Thanks,

Nick

They sent a quick, but disappointing response:

Hi Nick,

We are unable to see your email address in our system.

Would you be able to provide us with the company you’re working for and/or the email log in you use?

Thanks in regards,

Dassault System Technical Support

I didn’t really need any major support staff on this, I’m more just trying to find out the validity of their sample codes and if they are still supported.  I responded:

Sorry that i’m not in the system. I’m not really looking for extensive support, but rather confirmation that the 3DXML-HTML embed code in your link is still supported.  

If it’s not supported, do you have a link to some newer embed code for 3DXML?
Thanks, -Nick

Their response:

Hi Nick,

Thank you for contacting DASSAULT SYSTEMES technical support.

Unfortunately, you are not a supported costumer; therefore, we cannot help you with your issue.

Thanks in regards,

Dassault System Technical Support

Just great.  You’d think a freeware viewer would have some basic cursory support for these types of things.  At the very least, they could tell us if the thing works or not anymore.

Thanks for the quick response.  Sorry to hear that.  I really appreciate your company and I would love to showcase some 3DXML’s I have on a website.  I know the 3DXML viewer is available to everyone, so I was hoping that you could help me out with a little thing.  Can you at least confirm that the link is still supported?  I can figure out the rest, I just need to know I’m not going down a dead end.  
Thanks, -Nick

They responded:

Hi Nick,

Sorry for the inconvenience, we work as a dispatch center.

We are not specialized and do not have the answer to this question.

If the link was found on our website it should be correct.

Thanks in regards,

Dassault System Technical Support

 

So that’s where I’m at.  If you know how to embed 3DXML files in wordpress, HTML, or PHP files on the web, please comment below.  I would love to figure this out.   Anything that I figure out or anything that is suggested will become integrated into the body of this article.

 

About the Author

Nicholas Pisca: Founder 0001d LLC; Former Technical Manager Gehry Technologies; Former Lecturer/Adviser/Faculty UCSB MAT/USC/SCIarc; Author YSYT; Editor 0001d BLAST;