I have Installed meshwriter package 1.1.1 from npm in the project.
Since its is angular, I cant import like this,
const typeURL = “https://host/path/meshwriter.min.js”;
jQuery.getScript(typeURL).then(startWriting)
code snippet:
import * as BABYLON from ‘babylonjs’;
import * as GUI from ‘babylonjs-gui’;
import * as MeshWriter from ‘meshwriter’;
export class TextDisplay {
private GUI2DText: GUI.TextBlock;
constructor(){
this.GUI2DText = new GUI.TextBlock();
}
public Display3DText ( scene?:any ): void{
let Writer = (BABYLON as any).MeshWriter(scene, {scale:0.5});
let text1 = new Writer(
"ABC",
{
"anchor": "center",
"letter-height": 50,
"color": "#1C3870",
"position": {
"z": 20
}
}
);
let text2 = new Writer(
"abcdefghijklmnopqrstuvwxyz",
{
"anchor": "center",
"letter-height": 50,
"color": "#70381C",
"position": {
"z": -20
}
}
);
let text3 = new Writer(
“$12,345-#67,890 = 100%++!”,
{
“anchor”: “left”, // The default value; this line has no effect
“letter-height”: 20,
“color”: “#70701C”,
“position”: {
“y”: 40,
“x”: 5
}
}
);
let text4 = new Writer(
“false||TRUE === 1 && 0.0??”,
{
“anchor”: “right”,
“letter-height”: 20,
“color”: “#70701C”,
“position”: {
“y”: 40,
“x”: -5
}
}
);
}
}
In this sample code, I have used GUI. Here GUI runs without any errors.
The error I get for meshwriter is
AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: babylonjs__WEBPACK_IMPORTED_MODULE_1__.MeshWriter is not a function
at TextDisplay.Display3DText (TextDisplay.ts:13)
at AppComponent.InitializeRendering (app.component.ts:38)
at AppComponent.ngAfterViewInit (app.component.ts:28)
at callProviderLifecycles (core.js:32328)
at callElementProvidersLifecycles (core.js:32293)
at callLifecycleHooksChildrenFirst (core.js:32275)
at checkAndUpdateView (core.js:44281)
at callWithDebugContext (core.js:45632)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:45194)
at ViewRef_.detectChanges (core.js:31126)
You can also refer the following links