Arte Posted October 15, 2018 Share Posted October 15, 2018 Hi All, I have strange behaviour in NullEngine using setPivotPoint with CSG Same Code, different results? (Blue background in Playground, grey background NULL ENGINE) https://www.babylonjs-playground.com/#8PIKRZ @Deltakosh do you have any idea? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 15, 2018 Share Posted October 15, 2018 wait..how do you get render from NullEngine? Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 Logic on server side, render on client side. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2018 Share Posted October 16, 2018 woot This is kind of interesting use! Can you provide a repro? This should work as CSG is pure javascript code Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 16, 2018 Share Posted October 16, 2018 If you are performing logic on the server side and passing only data such as position to the client you might run into errors because the way the pivot works, changing the pivot may not update the position. I would recommend using a parent object instead of the pivot, see first paragraph here https://doc.babylonjs.com/how_to/pivots and this PG: https://www.babylonjs-playground.com/#GH4N1R#1 Arte and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 38 minutes ago, trevordev said: If you are performing logic on the server side and passing only data such as position to the client you might run into errors because the way the pivot works, changing the pivot may not update the position. I would recommend using a parent object instead of the pivot, see first paragraph here https://doc.babylonjs.com/how_to/pivots and this PG: https://www.babylonjs-playground.com/#GH4N1R#1 That's exactly what's happening now. I like what you suggested, but. I think NullEngine should mach client side . Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 16, 2018 Share Posted October 16, 2018 My guess is they are the same in data. Like if you print out the positions, they should be the same if the logic was done in the exact same order in the client vs the server's null engine. If you have a repro where numbers printed out by null vs non-null engine are different please do share. Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 I'm using same code from https://www.babylonjs-playground.com/#8PIKRZ (for NullEngine and Client Side). This is happening if I'm using CSG. I think BABYLON.CSG.FromMesh creating a problem (loosing information about pivot). I'm not that clever to check it . Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 1 hour ago, trevordev said: My guess is they are the same in data. Like if you print out the positions, they should be the same if the logic was done in the exact same order in the client vs the server's null engine. If you have a repro where numbers printed out by null vs non-null engine are different please do share. All numbers a same. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2018 Share Posted October 16, 2018 So all numbers are the same but you still get different positioning? Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 Ooo yes Quote Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2018 Share Posted October 16, 2018 this looooks suspicious Are you sure of your code? Quote Link to comment Share on other sites More sharing options...
Arte Posted October 16, 2018 Author Share Posted October 16, 2018 100% Same as in PlayGround /////////////////////////////// // CODE FROM NULL ENGINE var parent = BABYLON.MeshBuilder.CreateBox("Parent", {height: 3.2, width: 2.2, depth: 1.2,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene); var mat = new BABYLON.StandardMaterial("material", scene); mat.alpha = 0.3; parent.material = mat; var part = BABYLON.MeshBuilder.CreateBox("Part", {height: 3, width: 2, depth: 1,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene); part.setPivotPoint(new BABYLON.Vector3(0,1,0)); part.position.x = 1; // part.rotation.x = -1; part.parent = parent; var tool = BABYLON.MeshBuilder.CreateBox("Tool", {height: 1, width: 2, depth: 2,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene); tool.material = mat; tool.setPivotPoint(new BABYLON.Vector3(5,-1,0)); tool.position.x = 1; tool.rotation.x = -1; // tool.parent = parent; var partCSG = BABYLON.CSG.FromMesh(part); var toolCSG = BABYLON.CSG.FromMesh(tool); var newPartCSG = partCSG.subtract(toolCSG); var newPart = newPartCSG.toMesh("csg", part.material, scene); // tool.dispose(); part.dispose(); // CODE FROM NULL ENGINE /////////////////////////////// Quote Link to comment Share on other sites More sharing options...
Guest Posted October 17, 2018 Share Posted October 17, 2018 OK can you repro on a page with the NullEngine (using Babylon.max.js) I will try to debug it. Also (I am traveling and I don't have too much free time this week), perhaps you could try to do a per mesh comparison between engine and NullEngine regarding properties like world matrix (is this matrix the same on all meshes between both engine) Can you also try to force a mesh.computeWorldMatrix(true) on all meshes before doing csg? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 17, 2018 Share Posted October 17, 2018 Also how do you render on client side when using NullEngine? Are you sure your local renderer interpret the pivot like Babylon.js? Quote Link to comment Share on other sites More sharing options...
Arte Posted October 17, 2018 Author Share Posted October 17, 2018 40 minutes ago, Deltakosh said: OK can you repro on a page with the NullEngine (using Babylon.max.js) I will try to debug it. Also (I am traveling and I don't have too much free time this week), perhaps you could try to do a per mesh comparison between engine and NullEngine regarding properties like world matrix (is this matrix the same on all meshes between both engine) Can you also try to force a mesh.computeWorldMatrix(true) on all meshes before doing csg? Okay 38 minutes ago, Deltakosh said: Also how do you render on client side when using NullEngine? Are you sure your local renderer interpret the pivot like Babylon.js? I'm creating everything on server side and passing data through assetsManager.addMeshTask. Does that make sense? Thank you for your time. Quote Link to comment Share on other sites More sharing options...
Arte Posted October 17, 2018 Author Share Posted October 17, 2018 @Deltakosh Shared files: index.html // create and download (serialised scene) serializedScene.json // downloaded json file (serialised scene) Loader.html // load serialised scene https://github.com/Gal-Arte/BabylonTest/tree/master/NULL ENGINE using setPivotPoint and CSG Playground to compare https://www.babylonjs-playground.com/#8PIKRZ#1 Lets hope for the best Quote Link to comment Share on other sites More sharing options...
Guest Posted October 18, 2018 Share Posted October 18, 2018 Can I ask you something else? Can you serialized the scene from a regular PG and reload it? I'm pretty sure this comes from the serializer which does not take the pivot correctly in account Quote Link to comment Share on other sites More sharing options...
Arte Posted October 18, 2018 Author Share Posted October 18, 2018 @Deltakosh Regular PG results Serializer!!! Quote Link to comment Share on other sites More sharing options...
Guest Posted October 19, 2018 Share Posted October 19, 2018 Ok so I think I can fix it Can you share the PG where you serialized and reload it? I will use it to fix the serializer Arte 1 Quote Link to comment Share on other sites More sharing options...
Arte Posted October 19, 2018 Author Share Posted October 19, 2018 https://www.babylonjs-playground.com/#8PIKRZ#2 If you comment out line 55. Original part position - Out. Or comment out lines 67-79, to see original view. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 22, 2018 Share Posted October 22, 2018 Fixed: https://github.com/BabylonJS/Babylon.js/commit/1e37e3b9d1c7cb5e6eb8a63557b278e65f0d393b Arte 1 Quote Link to comment Share on other sites More sharing options...
Arte Posted October 22, 2018 Author Share Posted October 22, 2018 Now I can go-ahead with my project "Parametric Cabinet". Thank you and ?. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 23, 2018 Share Posted October 23, 2018 Good luck Quote Link to comment Share on other sites More sharing options...
Arte Posted October 28, 2018 Author Share Posted October 28, 2018 @Deltakosh I updated npm babylonjs "Babylon.js null engine (v3.3.0)" , but for some reason I have same results as before. On PG is working perfect. ? ***EDITED*** I tried what @trevordev suggested "I would recommend using a parent object instead of the pivot" Results: https://www.babylonjs-playground.com/#8PIKRZ#3 BABYLON.CSG ignoring not just pivot but parenting as well??? My bad. I forgot sphere.computeWorldMatrix(true); https://www.babylonjs-playground.com/#8PIKRZ#4 But npm babylonjs still issue. 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.