How to load parasolid (.x_t) file in three js - three.js

can anyone please suggest how to load parasolid file in three js?
like
var loader=New THREE.ObjectLoader();
loader.load('path',callback);
is there any loader available for parasolid?

Related

Chart.js-to-image in Laravel

does someone use Chart.js-to-image in his laravel application?
i render a chart.js chart in my application and i will save it as a img in my public folder to use it later to render a pdf with dompdf. but im not able to implement the chartjs-to-image in my project. i have a error with
const fs = require('fs')
i also try it with base64 image but there is the problem that my chart is not the same bevor and after base64img ( peak bevore goes up to 30 after only to 20).

Is it possible to create MatInput (all material Components Dynamically) in typescript?

We have DOM object to create dynamic html input and elements.
For eg: var child = document.createElement(input);
child.type="text";
child.id="inputId";
var parent = document.getElementByTagName('body');
parent.appendChild(child);
as usual we used to create element by dom object for HTML. But how to create material components using dom object in typescript.
is there options to create dynamic way like that above for material components
for eg: var child = document.createElement(mat-form-field);
This question am asking bcz we have planned to create custom module. so which can use it in any project in future.
For my question the answer is
https://material.angular.io/guide/creating-a-custom-form-field-control
With the help of custom form field control,I think, we can create dynamic angular material.
Let me try it and post regards about it further. Thanks

Reloading JSON fails to render correctly in canvas with Fabric.js

I have a bit of an issue with Fabric.js. I'm loading a JSON string in to the canvas and then at some time in the future I want to load more JSON in again (possibly the same JSON). The first load seems to work fine but the second load has an issue: the foreground path object doesn't appear, even though its bounding box is clickable. I'm not sure if this is a problem relating to the backgroundImage, or the way I'm clearing the canvas before I load the JSON again, or the actual way I'm loading JSON (or all three).
I've put a simple fiddle here.
var j = { ... }; //json object (see fiddle)
var c = new fabric.Canvas( document.getElementById("c") );
c.loadFromJSON(j, function(objects, options) {
c.renderAll();
setTimeout(function(){
c.backgroundImage=0;
c.clear();
c.renderAll();
setTimeout(function(){
c.loadFromJSON(j, function(objects, options) {
c.renderAll();
c.setActiveObject(c.item(0));
});
},3000);
},3000);
});
I create the initial canvas view from the JSON object, then clear it out after 3 seconds, then load it in again after another 3 seconds (this is just to simulate clicking a button or whatever in a real app).
Would appreciate any help on this and apologies if this has been dealt with before.
Cheers
[EDIT] I've noticed that if I copy the JSON object in to a second variable so that i'm initialising two objects with the same content, and load that in the second loop, it will load again properly. Could the original JSON variable be getting modified or cached and that's causing the issue? (fiddle for this here
i checked the objects that you product and i see that when you load the svg for the second time, all the 'paths' object is missing.
you can see it too, by adding a console.log before the first load and another one just before the 2nd load.
like this:
console.log(JSON.stringify(j));
anyway, to the point,
you just need to stringify your object before you try to load it, in that way you keep all the object as one ,
i added a line that converts you svg object to json string and pass it on a temp variable
tmp = JSON.stringify( j );
take a look ,i update your code,on the fiddle: https://jsfiddle.net/5j7ejLmk/2/
if you find my answer correct please mark it as so.
good luck

How can I have a custom default scene in the three.js editor?

I'm trying to use the Three.js editor to have the population participate in the town planning process. For that, I would like the editor to load with a 3D Version of the town, without the user having to load it manually. Clicking on "New" should also load that default model again.
I already copied the code on our server, it works. Which part of that code should I modify to do have the town model already loaded on startup?
The source code for the threejs editor is available here , you can just download it from it here, add your code to display the default model at appropriate place and host it.
Update 1: Adding a custom model in the Editor's Scene
After reviewing the code of the Editor.js I found that you can add custom objects in the scenevariable defined in the Editor using the addObject() function
I am assuming that you need to add an object which is exported out of blender in .obj format, but using this addObject() function you can add any object/mesh into the editor.
So in index.html add the following lines of code to add a model manually.
var manager = new THREE.LoadingManager();
var loader = new THREE.OBJLoader( manager );
loader.load( '../obj/male02/male02.obj', function ( object ) {
object.position.y =0;
editor.addObject( object );// THIS WAY YOU CAN MANUALLY ADD ANY MESH/OBJECT3D IN THE EDITOR
});
I have made and hosted an example here you can visit it and look around line 123 to see the custom code.

Embedded font from dynamically loaded swf not recognised

I am working on an application which needs to load fonts dynamically based upon the fonts used in a given document that the user opens. The fonts are used in a RichEditableTextControl so need to be CFF format.
If I add the code:
[Embed(source="/assets/fonts/AvenirLTStd Book.otf",
fontFamily="EmbedAvenir LT Std 45 Book",
mimeType="application/x-font",
embedAsCFF="true")]
public const embeddedFont:Class;
to the main SWF then the text displays correctly with the embedded font but moving the code to a separate file and adding a loader as per the information I found at the following link does not load the font - http://www.scottgmorgan.com/blog/index.php/2007/06/18/runtime-font-embedding-in-as3-there-is-no-need-to-embed-the-entire-fontset-anymore/
The loader code is:
private function loadFont(url:String):void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontLoaded);
loader.load(new URLRequest(url));
}
private function fontLoaded(event:Event):void {
var FontLibrary:Class = event.target.applicationDomain.getDefinition("FontAvenirLTStd") as Class;
Font.registerFont(FontLibrary.embeddedFont);
}
There is an error thrown at the Font.registerFont line to say that the parameter being passed cannot be null. I have checked in debug mode and the issue seems to be that the class exists but does not have any content. The FontLibrary class is instantiated but the only child entry in the debugger is _prototype so trying to access the embeddedFont property does return undefined.
At the moment the font SWF is in the assets folder of the main project so I don't believe there should be any security restrictions and, as I said, the SWF loading part appears to work.
One thing which is hampering my diagnostics is that I am not sure if the problem is the font SWF not being created correctly and having no content or if the main app is unable to load it. Any help on at least being able to narrow that down would be appreciated.
I would appreciate all the help I can get on this as I have been stuck at this problem for some time and it is a key part of the application.
Thanks in advance to everyone.
Just a quick note for anyone who ends up here from Google, the problem was that I had managed to lose the static keyword from the embeddedFont constant definition in the top block. It should have been public static const embeddedFont:Class;
Hope this helps someone.

Resources