Dad72 Posted March 23, 2016 Share Posted March 23, 2016 Hi, I want a isLocked member , but it does not exist. I would lock an object to any changes even if an object is pickable. By locking an object, you can not change it, nor materials, nor select ... is there a similar function or member? or could it be possible to have a work like this in Babylon? Thank you Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 23, 2016 Share Posted March 23, 2016 Woot..That's not supported right now and unlikely to be supported in the future. Too much work. You can freeze the worldmatrix though Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 how to do it: freeze the WorldMatrix? Thanks DK Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 ok I found, mesh.freezeWorldMatrix(); and mesh.unfreezeWorldMatrix(); But it does not work. the object can still be select, move ... I'll try to hack something, then. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 23, 2016 Share Posted March 23, 2016 yep it only freeze the worldmatrix Quote Link to comment Share on other sites More sharing options...
jerome Posted March 23, 2016 Share Posted March 23, 2016 maybe this would help : http://doc.babylonjs.com/classes/2.3/AbstractMesh#ispickable-boolean Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 I know isPickable Jerome, I use it for 3 years now, this is one of the first thing I learned from Babylon. I just wish that even if isPickable is true, it may not be selectable, or modify the materials and other level. Basically, I want to lock an object of any changes to my editor. because all the objects are selectable. IsPickable also do not want the change on materials. isPickable is not a verous on objects. I must keep my pickable objects If users want avoid select an object or change by error, I wish he could add a Security locks that blocks any modification, selection, movement. Quote Link to comment Share on other sites More sharing options...
adam Posted March 23, 2016 Share Posted March 23, 2016 Have you tried Object.freeze(obj) ? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze I just tried it on Object.freeze(mesh.position) and it worked. I'm thinking you could easily create a function that freezes just the properties you want to freeze. Dad72 and JCPalmer 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 I'll try that. Thank you Adam. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 This works Adam. Object.freeze freezes perfectly the object. But I do not track unfreeze function to unlock. An idea to unlock? Quote Link to comment Share on other sites More sharing options...
adam Posted March 23, 2016 Share Posted March 23, 2016 I would try replacing the object with a new one. mesh.position = new BABYLON.Vector3(mesh.position.x, mesh.position.y, mesh.position.z); That didn't work. It actually does work. I had a bug in my code. Quote Link to comment Share on other sites More sharing options...
adam Posted March 23, 2016 Share Posted March 23, 2016 Check out lines 52, 53: http://www.babylonjs-playground.com/#21XUBV#16 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 Ok, so we have to recreate new property if I understand well. but if I freeze the whole object: Object.freeze (mesh). Is what I should freeze or a specific property? Quote Link to comment Share on other sites More sharing options...
adam Posted March 23, 2016 Share Posted March 23, 2016 I would just freeze specific properties. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2016 Author Share Posted March 23, 2016 Thank you for your help bring here. Here's what I did in the end if it can be useful to the other. I hope that Babylon soon get this kind of functionality. but in the meantime, I hope this can help. I managed to block the entire object and unlock it. In made, I simply create a clone of the subject and I add it visibility is false. This new object will be rendered visible when I unlock the freeze objects. The object freeze will be deleted then. This works well in 2 directions. lockObjet = function() { if(global.objetSelected) { var name = global.objetSelected.name; global.objectsFreeze[name] = global.objetSelected.clone(name); global.objectsFreeze[name].visibility = false; Object.freeze(global.objetSelected); } }; unlockObjet = function() { for(var i = 0; i < global.objets.length; i++) { if(global.objectsFreeze[global.objets.name]) { global.objectsFreeze[global.objets.name].visibility = true; global.objets.dispose(); global.objets = global.objectsFreeze[global.objets.name]; } } }; global.objetSelected corresponds to all my global variables contained in a json: var global = {objetSelected : null, objets: [], objectFreeze: [], othervariable: valueDefaut}; adam and GameMonetize 2 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.