Ciao, I have this function
public addCube() {
const material = new BABYLON.StandardMaterial("defaultMaterial", this.scene!);
material.alpha = 1;
material.diffuseColor = new BABYLON.Color3(1.0, 0, 0);
material.alpha = 0.8;
const obj1 = BABYLON.SceneLoader.Append("https://dl.dropbox.com/s/kum4ztqput0l3gx/", "demo20%bar.stl", this.scene, () => {
const mesh = this.scene?.getMeshByName("stlmesh");
if (mesh != null) {
mesh.material = material;
}
const pointerDragBehavior = new BABYLON.PointerDragBehavior({ dragAxis: new BABYLON.Vector3(1, 0, 0) });
pointerDragBehavior.useObjectOrientationForDragging = false;
mesh!.addBehavior(pointerDragBehavior, true);
});
const obj2 = BABYLON.SceneLoader.Append("https://dl.dropbox.com/s/kum4ztqput0l3gx/", "demo20%bar.stl", this.scene, () => {
const mesh = this.scene?.getMeshByName("stlmesh");
if (mesh != null) {
mesh.material = material;
}
const pointerDragBehavior = new BABYLON.PointerDragBehavior({ dragAxis: new BABYLON.Vector3(1, 0, 0) });
pointerDragBehavior.useObjectOrientationForDragging = false;
mesh!.addBehavior(pointerDragBehavior, true);
});
}
I see both of the objects imported, but the first one has the correct material and the correct behaviour, the second one is visible but with a gray material and is not draggable. What am I doing wrong?
Thank you
Toni