Arte Posted July 7, 2018 Share Posted July 7, 2018 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. Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 7, 2018 Share Posted July 7, 2018 @Arte Do you have sample code or more specifics so everyone can fully understand how the code is sequenced? DB Quote Link to comment Share on other sites More sharing options...
Arte Posted July 7, 2018 Author Share Posted July 7, 2018 @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(); Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 7, 2018 Share Posted July 7, 2018 @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 Quote Link to comment Share on other sites More sharing options...
Arte Posted July 7, 2018 Author Share Posted July 7, 2018 (edited) No cloning, all meshes I'm creating from scratch. Same code on client side working as expected. 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); Edited July 7, 2018 by Arte added file Quote Link to comment Share on other sites More sharing options...
Arte Posted July 7, 2018 Author Share Posted July 7, 2018 @dbawel "@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." That is exactly what happening. How I can go around this? Quote Link to comment Share on other sites More sharing options...
Arte Posted July 7, 2018 Author Share Posted July 7, 2018 Materials (texture) is sorted 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) Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 7, 2018 Share Posted July 7, 2018 @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 Arte 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
Arte Posted July 9, 2018 Author Share Posted July 9, 2018 @Deltakosh https://www.babylonjs-playground.com/#FVWA7W For some reason BABYLON.SceneSerializer.SerializeMesh not working. Line 97-100 Added Client side code, Line 106-121 https://www.babylonjs-playground.com/#FVWA7W#2 Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 For the SerializedMesh: the code cannot work as the position is not a Vector3 (line #18): https://www.babylonjs-playground.com/#BN19JI I'll check why it does not work with nullengine Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 Are you sure the PG is correct? I cannot get an export with textures even in the PG Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 Ok found why: https://www.babylonjs-playground.com/#BN19JI#1 I also found the issue will be fixed by next nightly :) Arte 1 Quote Link to comment Share on other sites More sharing options...
Arte Posted July 9, 2018 Author Share Posted July 9, 2018 @Deltakosh You're a Superstar. ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.