MackeyK24 Posted January 8, 2018 Share Posted January 8, 2018 Yo @Deltakosh ... I know you said you dont wanna add any code to the engine specifically for my toolkit. But the last changes you made to metadata cloning is KILLING ME BRO... specifically the like in constructor babylon.mesh.ts: this.metadata = source.metadata; This is line is really setting a "POINTER" so to speak on the clone to the original metadata instead of making a COPY of the metadata. I had tons of code for "Prefabs" or mesh cloning where I would do something like this: mesh.metadata.clone = () => { return BABYLON.SceneManager.CloneMetadata(mesh.metadata); }; But somehow via the cloning framework, if you set: this.metadata = source.metadata ... that screws the whole thing up for me and a (almost) year worth of METADATA code I was using before that lone of code showed up. Can we at least add some kind of switch so those us who need CUSTOM METADATA CLONING ... not just simply setting a "REFERENCE" to the the original metadata in the clone. Something like this: if (!BABYLON.Mesh.CUSTOM_METADATA_CLONING) { this.metadata = source.metadata; } Then I could set that STATIC switch to true to use custom metadata cloning like this: // Setup metadata cloning mesh.metadata.clone = () => { return BABYLON.SceneManager.CloneMetadata(mesh.metadata); }; If not, then I will have to use Custom Builds of babylon.js in the Toolkit... Which not be a bad ideal so I can keep the toolkit working to a Custom Build of the current stable release... What do you think... I just thought I would ask Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 8, 2018 Share Posted January 8, 2018 I'm against custom builds mostly for an officially hosted toolkit like yours What if I do this: if (mesh.metadata.clone) { this.metadata = mesh.metadata.clone(); } else { this.metadata = mesh.metadata; } ? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 9, 2018 Author Share Posted January 9, 2018 2 hours ago, Deltakosh said: I'm against custom builds mostly for an officially hosted toolkit like yours What if I do this: if (mesh.metadata.clone) { this.metadata = mesh.metadata.clone(); } else { this.metadata = mesh.metadata; } ? This should work... trying is now in a custom build: in the babylon.mesh.ts constructor // Metadata if (source.metadata.clone) { this.metadata = source.metadata.clone(); } else { this.metadata = source.metadata; } Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 9, 2018 Author Share Posted January 9, 2018 Yo @Deltakosh ... it turns out we need to EXCLUDE metadata from Tools.DeepCopy if we are going to set this.metadata at all (even without the mod) so this works perfect: // Deep copy Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata"], ["_poseMatrix", "_source"]); // Metadata if (source.metadata.clone) { this.metadata = source.metadata.clone(); } else { this.metadata = source.metadata; } I am going to PR this... Please ACCEPT Quote Link to comment Share on other sites More sharing options...
brianzinn Posted January 9, 2018 Share Posted January 9, 2018 @Deltakosh I'm getting "TypeError: Cannot read property 'clone' of null". source.metadata is null. I'm using CSG toMesh(). Should it not be: if (source.metadata && source.metadata.clone) { this.metadata = source.metadata.clone(); } else { this.metadata = source.metadata; } edit: can confirm my game loads with that change. have done a PR. Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted January 9, 2018 Author Share Posted January 9, 2018 2 hours ago, brianzinn said: @Deltakosh I'm getting "TypeError: Cannot read property 'clone' of null". source.metadata is null. I'm using CSG toMesh(). Should it not be: if (source.metadata && source.metadata.clone) { this.metadata = source.metadata.clone(); } else { this.metadata = source.metadata; } edit: can confirm my game loads with that change. have done a PR. Good Catch Quote Link to comment Share on other sites More sharing options...
brianzinn Posted January 9, 2018 Share Posted January 9, 2018 10 minutes ago, MackeyK24 said: Good Catch Thanks - should work as long as nobody puts a clone property on the metadata! I normally check for typeof(source.metadata.clone) === 'function', but don't see that used much in the code 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.