Closed saadfaisal closed 9 years ago
Unfortunately pattern handling is not supported currently, but you can set textured materials manually for each bodies. For example you can set a new material for the first body like this:
var modelAndMaterials = JSM.SvgToModel (svgObject, height, segmentLength);
var model = modelAndMaterials[0];
var materials = modelAndMaterials[1];
var newMaterialIndex = materials.AddMaterial (new JSM.Material ({
texture : 'texture.jpg',
textureWidth : 100.0,
textureHeight : 100.0
}));
model.GetBody (0).SetPolygonsMaterialIndex (newMaterialIndex);
Tried as you suggested but getting TypeError: l is undefined jsmodeler.js:196
Here is my code
var svgObject = document.getElementById ('svgid');
var modelAndMaterials = JSM.SvgToModel (svgObject, 35, 5);
// ---------------
var model = modelAndMaterials[0];
var materials = modelAndMaterials[1];
var newMaterialIndex = materials.AddMaterial (new JSM.Material ({
texture : 'img/egyptian_marble_128.jpg',
textureWidth : 128.0,
textureHeight : 128.0
}));
model.GetBody (0).SetPolygonsMaterialIndex (newMaterialIndex);
var meshes = JSM.ConvertModelToThreeMeshes (model, materials);
viewer.AddMeshes (meshes);
viewer.FitInWindow ();
viewer.Draw ();
Its strange. It works for me with the current version. Which version do you use? On which part of this code you get this error?
Using the latest version JSModeler 0.32.183. and the error is on the following line
var meshes = JSM.ConvertModelToThreeMeshes (model, materials);
I have no idea what went wrong. Maybe if you could send me the whole code...
Somehow the newMaterialIndex is coming out as undefined, very strange.
how can i send it to you ?
Ok, I think I figured out what is the problem. I have used the developer version where the AddMaterial returns the added index :) So I think you should modify your code:
materials.AddMaterial (new JSM.Material ({
texture : 'texture.jpg',
textureWidth : 128.0,
textureHeight : 128.0
}));
var newMaterialIndex = materials.Count () - 1;
Thanks , got it working.
I am using the SVG To 3D functionality and I have a pattern defined for my path , but unfortunately it doesnt get loaded and the object is displayed as black. Here are the details
Any ideas if Pattern are currently supported by JSModeler ?