Jump to content

BABYLON.NullEngine material issue


Arte
 Share

Recommended Posts

Hi all,

On server side I'm creating scene.

Creating meshes -> applying materials (StandardMaterial) -> applying and rotating texture (diffuseTexture).

After all of this sending scene (SceneSerializer.Serialize) to client side and loading with assetsManager.

But all meshes have same material as last loaded mesh.

Do I need to reapply materials on client side or I'm doing something wrong? I never played with materials on server side.

Any suggestions are welcome and appreciated. :)

Link to comment
Share on other sites

@dbawel All scene created same as normal on client side.

// Apply materials

let mate = new BABYLON.StandardMaterial("material", scene);
mate.specularPower = 200;
mate.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
ob.material = mate;
ob.material.diffuseTexture = new BABYLON.Texture('some.url',scene);

// Send file

JSON.stringify(BABYLON.SceneSerializer.Serialize(scene));

// Load file 

let assetsManager = new BABYLON.AssetsManager(scene);
let mesh = assetsManager.addMeshTask("", "","","data:"+d.data);
assetsManager.load();
Link to comment
Share on other sites

@Arte

Are you cloning meshes? I assume you know the result of this. However, if you're loading a new and different geometry, then a little more code should help see what the issue is. So far, I don't see a problem, but don't know anything about the meshes.

It used to be that an array of meshes would take on the attributes of the first mesh if they were all contained in the same array.

DB

Link to comment
Share on other sites

No cloning, all meshes I'm creating from scratch.

Same code on client side working as expected. :huh:

let obPart = BABYLON.MeshBuilder.CreateBox("", {height: meta.param.z.val, width: meta.param.x.val, depth: meta.param.y.val,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
obPart.id=obPart.name=obPart.uniqueId;

obPart.setPivotPoint(new BABYLON.Vector3(meta.pivot.x,meta.pivot.y,meta.pivot.z));
obPart.position=new BABYLON.Vector3(meta.pos.x.val, meta.pos.z.val, meta.pos.y.val);
obPart.rotation=new BABYLON.Vector3(meta.rot.x.val*Math.PI/180,meta.rot.z.val*Math.PI/180,meta.rot.y.val*Math.PI/180);
let mate = new BABYLON.StandardMaterial("material", scene);
mate.specularPower = 200;
mate.specularColor = new BABYLON.Color3(0.5, 0.5, 0.5);
obPart.material = mate;

obPart.material.diffuseTexture = new BABYLON.Texture(meta.mat.url,scene);

Capture.PNG

Edited by Arte
added file
Link to comment
Share on other sites

Materials (texture) is sorted :rolleyes:

Changed order

ob.material = material;

ob.material.diffuseTexture = new BABYLON.Texture(url,scene);

To

ob.material.diffuseTexture = new BABYLON.Texture(url,scene);

ob.material = material;

 

But material.diffuseTexture.wAng is not working??? (all texture.wAng reading from first texture) :(

Link to comment
Share on other sites

@Arte

I'm not certain if there is a way to overcome this "optimization" within babylon. However, I know there is a solution that works; just don't want to say which method is the best since I haven't had to deal with this in some time. I've seen posts on Stackoverflow where @Deltakosh addresses this, so hopefully he'll see this and respond with the best method for your needs.

DB

Link to comment
Share on other sites

Can you create a PG with the client code? I will then try to fix it on server side (with nullengine) to understand why all textures are the same

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...