Pryme8 Posted December 20, 2016 Share Posted December 20, 2016 http://www.babylonjs-playground.com/#R35AE#1 See attached playground for proof. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 20, 2016 Share Posted December 20, 2016 Can you provide a simpler repro? LIke this one: which is working (http://www.babylonjs-playground.com/#2E85FV) Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Author Share Posted December 20, 2016 Yea it works because it is just one, the demo demonstrates when instances break you have to do more then one of them. Whats happening is I make a base mesh this is the only real mesh called, I then clone it to make 3 versions of it that can have different materials, then I am randomly picking from those three clones and creating an instance from one of the three and just placing them in the scene. You will see the weird behavior the second a additional instance is made that is not the same as the first one created. If you see here is the working version with just 1 instance being used: http://www.babylonjs-playground.com/#R35AE#0, then the second you start using the other ones it breaks. This is the simplest PG I could think of to demonstrate. You will see the second a different color sphere is picked from the first one made (red blue or green) all others that are not the same one disappear and they all like jump around trying to decided whos who it looks like. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Author Share Posted December 20, 2016 http://www.babylonjs-playground.com/#R35AE#2 here i commented the code for you. Quote Link to comment Share on other sites More sharing options...
adam Posted December 20, 2016 Share Posted December 20, 2016 It's because you are making instances of clones. http://www.babylonjs-playground.com/#R35AE#3 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Author Share Posted December 20, 2016 Ok that's fine and dandy, but what about when I run into the situation where I need to create instances of clones? There is no reason why they should behave like this. The reason I say that is what if I have a custom shape I want to load for example my hex block, and it has 64 different texture variations, you would need to be able to make instances of a clone. and why would that break it? I mean thinking about it I guess its the same number of draw calls... but the behavior seems weird. so how would I create multiple copy's of the loaded obj without clone also?@adam, thanks by the way. Its coming into play with my scene I am working on where: lob.prototype._buildPresetHexs = function(){ var hexList = ['Rock', 'Rock2Dirt'] for(var p = 0; p<hexList.length; p++){ var ps = hexList[p]; this.presets[ps] = []; for (var i = 0; i<this.materials[ps].length; i++){ console.log(ps); var nP = this.presets['hex'].clone(ps+i); nP.material = this.materials[ps][i]; nP.setEnabled(0); this.presets[ps].push(nP); } } }; I am using clone to make fresh instances of the hex preset which was a loaded obj, is there a better way to do this? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 20, 2016 Share Posted December 20, 2016 Ok so: - Clones share the same geometry as their root - Instances share everything with their root (including material) - You can call CreateInstance on a clone but in this case all instances will have the initial geometry as root You can still use clones but you then have to make them unique (kind of de-cloning): http://www.babylonjs-playground.com/#R35AE#4 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Author Share Posted December 20, 2016 .makeGeometryUnique(); thats the ticket! I love you long time! One of these days Im gonna take the 8 hour trip and drive up to Seattle to buy you a beer! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 20, 2016 Share Posted December 20, 2016 Man! this could be really fun! You know that we thought about some kind of Babylonjs Con but as we are really all over the world this could be too complicated Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 20, 2016 Author Share Posted December 20, 2016 Id be in for sure! I bet if we built it and had some guest speakers people would come. 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.