How to export SolidWorks/eDrawings file in WebGL? - html

With the launch of SolidWorks 2016, Dassault Systèmes has promoted a new web portal that enables the embedding of Edrawings models into web pages: 3dcontentcentral.com.
Their web 3D viewer uses WebGL to show model inside a browser window (here you can find a live example). Moreover, there is the possibility to embed an iframe with the viewer to embed it onto another web page, like the following:
<iframe scrolling='no' frameborder='0' allowfullscreen='true'
src='http://www.3dcontentcentral.com/external-site-embed.aspx?format=3D&catalogid=364&modelid=1254&width=250&height=250&edraw=true'
name='PreviewFrame3D' id='PreviewFrame3D' width='400' height='355'>
</iframe>
<br/>
<a href='http://www.3dcontentcentral.com/download-model.aspx?catalogid=364&id=1217'>
Download</a>
The final result is something like the following:
Full screen example
So, is there any chance to export a 3D model (part) in the same way and embed as a WebGL without uploading into 3D Content Central website? I have also access to the Edrawings/SolidWorks SDK (2015), if it could be helpful in any way.

How to convert a SolidWorks file into a WebGL JSON file
The best solution I came across is simply to use SolidWorks Visualize (formerly Bunkspeed) to export the geometry and the materials using a combination of OBJ and MTL files.
Then, you'll be able to import it into a WebGL scene using the Three.js/OBJLoader. A big problem that can arise is the dimension and the memory required to load the exported file. To solve this latency/memory problem you can then convert the exported OBJ files into Three.js JSON format using the three-obj and minifying them using the minify() method. After that you'll have to load the minified files using the Three.js/BinaryLoader.
Hope this can help someone else.

Have a look at the WebGL 3D model viewer using three.js guide at http://www.radiatedpixel.com/wordpress/2013/03/27/webgl-3d-model-viewer-using-three-js/
Export the obj file from SolidWorks.
It should be straight forward to add your own controls via JavaScript.

Related

How to add an HTML5 animation generated with Adobe Animate CC to a Ionic 2 project page?

I have made an animation with Adobe Animate CC as HTML 5 canvas item. I can publish the animation in several ways:
as html: 1 file html, 1 file js, several directory with included file. Pages are all inclusive (head, body, including libraries) and including it in a Ionic page means unpack the html (right?). I'm trying but it seems a bit complex.
as movie .mov, but it's a bit expensive in terms of file size
In both cases, i'm not sure how to include the published result in a Ionic page and I think I'm missing something.
So, how do I include a Adobe Animate CC animation in a Ionic 2 Framework page?
UPDATE: I tried to unpack the html. Tried publishing the animation as HTML5 animation, with the publish setting "Included javascript in HTML". This way all the necessary js is put inside the html file that the publish procedure outputs. Then I took that js (the one contained in
<script> some js here </script>
immediately after the import of the library createjs) and put it in a mylibrary.js file in /assets/js/mylibrary.js. This way, I was able to import it in the ts file of one ionic page like
import mylibrary from '../../assets/js/mylibrary'
and then try to initialize the animation like
ionViewDidLoad(){
mylibrary.init()
}
In the original file the init() function was called on body like
<body onload="init()">
Unfortunately it doesn't work. The error thrown is
cjs.Bitmap is not a constructor
that is not really important as error, if not to state that clearly the library createjs is not imported in the right way for it cannot associate its cjs variable of mylibrary.js that contains a function like
(function (lib, img, **cjs**, ss, an) {
… (all code here)
})(lib = lib||{}, images = images||{}, **createjs = createjs||{}**, ss = ss||{}, AdobeAn = AdobeAn||{});
to createjs variable of the library. I mean, commenting the cjs.Bitmap line, it starts complaining about the subsequent cjs.Rectangle that does not exixts.
So I tried to include the library, first taking the include from the Animate generated html
<script src="libs/createjs-2015.11.26.min.js"></script>
and put it in my main 'index.html' app file (copying in asset/js the directory lib containing the file). Did not work. Tried with the live version of the library
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
Did not work.
Tried even to add all the other (unecessary library linked to createjs like easejs etc https://code.createjs.com/). Did not work.
Then I tried adding the library in the ts file adding before the import of mylibrary
import createjs from '../../assets/js/createjs'
Did not work.
Even tried to npm install createjs, createjs-module and createjs-easeljs and import them.
import easeljs from 'createjs-easeljs';
import createjs-module from 'createjs-module';
import createjs from 'createjs';
Guess what? Did not work.
Any time I said "did not work" the problem was ever the same error "cjs.Bitmap is not a constructor". Presently I couldn't find a way to import an animation generate via Adobe Animate CC into Ionic.
Just for people passing by, not an elegant solution, but at least one.
You can save in Adobe Animate your animation as video ('mov' file) and optimize its size and format with Adobe Media Converter or whatever other program you like. I've converted it in mp4 in this case.
NB: When you publish the video, if there is an audio track, it will be included in the video only if beginning at the second frame of the animation. It is a little tricky to discover, so worthy to be said.
As soon as you have an 'mp4' file, add it to your app assets, and you could include it to a Ionic page in the classical html way. In my case, it was a video to play fullscreen so here it is my code:
<ion-content padding>
<div id="videocontainer">
<video fullscreen="fullscreen" autoplay="true" (ended)="onVideoEnded()">
<source src="assets/video/your_video_name.mp4" type="video/mp4">
</video>
</div>
</ion-content>

How does Google Swiffy implement clickTag for HTML5 banner ads?

First, I tried finding an option to prevent Swiffy from compressing/minifying all the data when doing an export to HTML5 from Adobe Flash Pro. But no dice.
Even if I was able to read the unminified Javascript that Swiffy exported, I don't think there would be a simple function call for the "clickTag".
It's likely defining the variable clickTag in the huge haystack of {index: #, type: #}, and then doing processing each operations to eventually call the window.open() method (or something similar).
This is how it currently outputs (minified)
Does anyone have any clue how Swiffy implements clickTag?
Or what would be the Javascript equivalent that does the same job?
Swiffy uses the core API of the environment where the ad is served. If it's a DoubleClick Rich Media ad, it does use Enabler.exit("url").
If you want to have a better control on your output file, I'd suggest having a look at Google Web Designer. The closest experience to flash development in the HTML5 - JS era.
Google instructions are here, for plain HTML5 (non-swiffy) click tags.
At the bottom of the file is a snippet of code like this:
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),
swiffyobject, {});
stage.start();
Add this right before stage.start(); to mimic previous flash behavior. Ensure you use the proper capitalization.
stage.setFlashVars("clickTAG=http://stackoverflow.com");
**Note: Ensure to use url encoding if there are parameters...doesn't seem to like it otherwise

How to load .dae object with texture, and material

I just started with Minko and trying to undestand this https://github.com/aerys/minko/blob/master/doc/tutorial/06-Loading_3D_files.md tutorial. I did some steps:
sceneManager->assets()->loader()
->queue(FIREAXE_D)
->queue(FIREAXE_N)
->queue(FIREAXE_S)
->queue(TEXTURE_FILENAME)
->queue("effect/Basic.effect")
->queue(OBJ_MODEL_FILENAME);
and now I am trying to use these three textures with my object and file .mtl -> material.
auto _ = sceneManager->assets()->loader()->complete()->connect([=](file::Loader::Ptr loader)
{
auto objModel = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);
objModel->component<Transform>()->matrix()->appendScale(0.01f);
objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
objModel->component<Texture>()->set(sceneManager->assets()->texture(FIREAXE_D));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_N));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_S));
root->addChild(objModel);
});
This won't work and what about .mtl file? How to attach it to my object?
However tutorials are still to tiny and buggy it is better to look for examples but I cann't find any with texture loading for object right now.
This won't work and what about .mtl file? How to attach it to my object?
Your question is about loading a Collada (*.dae) file. Collada files don't have *.mtl files, *.obj files do.
Still, it works the same for any dependency of any file: they are automatically loaded if they can actually be found at the provided path/URI.
You can add include/search paths using the file::Options::includePaths() property, or customize how URI are resolved by using the file::Options::uriFunction(). Many other properties of the file::Options class will help you customizing how assets are loaded.
However tutorials are still to tiny and buggy
If you find bugs please open an issue on github.
it is better to look for examples but I cann't find any with texture loading for object right now.
The following example loads a Collada file along with animations and textures:
https://github.com/aerys/minko/tree/master/example/assimp

Embed DWG file in HTML

I want to ask how to embed DWG file in HTML Page.
I have tried using tag with Volo Viewer but this solution run only in IE not in Firefox and Chrome.
Dwgview-x can do that, but it will need to be installed as a plug-in on client computers so that anyone can view the dwg file that you embed online.
There may be third party ActiveX controls that you could use, but I think ultimately you will find that it's not practical for drawing files of even average complexity. I recommend to create DWF (if you need vector format) or PNG files on demand (using e.g. the free DWG TrueView from http://usa.autodesk.com/design-review/ ) and embed those instead.
I use DWG Browser. Its a stand alone program that is used for reporting and categorizing drawings with previews. It saves exports in html too.
They have a free demo download available.
http://www.graytechnical.com/software/dwg-browser/
You'll find what I think is the latest information on Autodesk's labs site here: http://labs.blogs.com/its_alive_in_the_lab/2014/01/share-your-autodesk-360-designs-on-company-web-sites.html
It looks like a DWG can be embeded there is an example on this page, but clearly DWF is the way to go.
You can embed DWG file's content in an HTML page by rendering the file's pages as HTML pages or images. If you find it an attractive solution then you can do it using GroupDocs.Viewer API that allows you to render the document pages as HTML pages, images, or a PDF document as a whole. You can then include the rendered HTML/image pages or whole PDF document in your HTML page.
Using C#
ViewerConfig config = new ViewerConfig();
config.StoragePath = "D:\\storage\\";
// Create HTML handler (or ViewerImageHandler for rendering document as image)
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Guid implies that unique document name
string guid = "sample.dwg";
// Get document pages in html form
List<PageHtml> pages = htmlHandler.GetPages(guid);
// Or Get document pages in image form using image handler
//List<PageImage> pages = imageHandler.GetPages(guid);
foreach (PageHtml page in pages)
{
// Get HTML content of each page using page.HtmlContent
}
Using Java
// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
// Set storage path
config.setStoragePath("D:\\storage\\");
// Create HTML handler (or ViewerImageHandler for rendering document as image)
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "Sample.dwg"
// Get document pages in HTML form
List<PageHtml> pages = htmlHandler.getPages(guid);
for (PageHtml page : pages) {
// Get HTML content of each page using page.getHtmlContent
}
Disclosure: I work as a Developer Evangelist at GroupDocs.

Abour ResourceBundle in AS3

I creadet a class that has more ResourceBundles in it. My app is multilanguage so I will need many ".properties" files.
here is a sample code
[ResourceBundle("LocalizedStrings_en_US")]
[ResourceBundle("LocalizedStrings_fr_FR")]
...
public class LocaleLoader
{
...
}
My question is if I add many ResourceBunlde lines in this class, will the file size of the main swf increase drastically or not?
Should use separata class files to load separate ResourceBundles for each language?
The [ResourceBundle] annotation itself won't have any effect on the file size. It's the -locale compile option of the mxmlc that matters.
-locale=en_US means to embed only the US-locale in the SWF
-locale=en_US, ja_JP means to embed both the US-locale and the Japan-locale
If you don't embed the Japan-locale you can load it at runtime with resourceManager.loadResourceModule(...).
To address completely the topic of Flex Localization Support please refer to the Slides & Samples in the Flex Localization Support article I wrote in the Obecto Training Portal.