Jump to content

Instance which disappears


Dad72
 Share

Recommended Posts

Hi,
 
I try to paint the grass with the instance and pick system. When I pick the first time, my grass is displayed, but the second time, it disappears.
I have my number of active models increases but no grass showing on the scene.
 
What am I doing wrong?
 
I also get this error in the console:
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glDrawElementsInstancedANGLE: attempt to access out of range vertices in attribute 2
 

var currentPosition, that = this, pickInfo, this.instanceGrass = 0;		this._onBeforeRender = function () {            	if (!currentPosition) return;	var pickTerrain = that._ground.getScene(), posX = currentPosition.x , posY = currentPosition.y;		pickInfo = pickTerrain.pick(posX, posY);					switch(that.MODE_CONTROLE)	{		case WORLDCASTOR.ElevationControl.MODE_CONTROLE_GRASS:						if(pickInfo.pickedMesh == that._ground) {									if(that.instanceGrass == 0) {					that.Grass = BABYLON.Mesh.CreatePlane("grass", 0.4, scene);				that.Grass.position = new BABYLON.Vector3(pickInfo.pickedPoint.x, parseFloat(pickInfo.pickedPoint.y+0.31), pickInfo.pickedPoint.z);				that.Grass.material = that.materialGrass;				that.instanceGrass = 1;			} else {				var instance_Grass = that.Grass.createInstance("grass"+ that.instanceGrass);				instance_Grass.position = new BABYLON.Vector3(pickInfo.pickedPoint.x, parseFloat(pickInfo.pickedPoint.y+0.31), pickInfo.pickedPoint.z);				that.instanceGrass++;			}													}							break;		}			};

Thank you for help

Link to comment
Share on other sites

I is not number instance defined. it is a pick(), when I click on the stage.

 

As raise vertex on worlmonger, but here, I painted grass.

 

This does not pass through a loop for(), but loop onBeforeRender()

Link to comment
Share on other sites

OK. I used woldmonger and I add a button Grass.
 
Zoom in on the ground  (to see what happens) Select the button grass and click once, the grass appears for a while and disappears immediately.
 
I have the same error in the console. 

 

index.html

Link to comment
Share on other sites

Not this changes nothing.

 

have look you on my demo. look near the ground when you add from the grass, it appears correctly and disappears immediately. the problem isn't that the face is hide, it is that it is remove from the scene once add. 

 

If I comment the part instance, my grass is display and does not disappear.

Link to comment
Share on other sites

in fact it is not double, because I've put 7 plan on the ground and it displays me 148 active mesh.

and FPS are down with 7 plan displays.

 


[edited] in fact the displays are random. instances that create well but most are invisible on the stage.

So what you have fix, a partially solved the problem.


 

Even the screen:


Link to comment
Share on other sites

With your woldmonger demo. I put a day babylon with the previous correction.
 
index.html

 

Vous remarquerez que le nombre de modèle actif augmente ( a coté de FPS j'ai ajouter Active en haut a droite), mais pas le nombre visible sur la scène. ou en continuant de peindre de l'herbe, avec un gros temps de retard, il apparaisse, mais le nombre ne correspond pas.

 

Le seule fichier que j'ai modifier de plus important c’est dans "elevationControl.js" a partir de la ligne 71 et ainsi que dans le constructeur pour initialiser les materiaux.

Je charge le premier modeles a la ligne 74 et je créer les instance a la ligne 82. a la ligne 81 j'ai ajouter un petit sleep pour faire un petit temps de pause léger quand on peint l'herbes.

 

Voila j’espère que cela aide.

 

PS: j'ai pris la demo de worldmonger car c’est ce que j'utilise sur mon projet pour peindre de l'herbes.

 

 

Link to comment
Share on other sites

Voila je vous est fait une scène toute simple. :)

 

La camera est fixe mais orienter vers le sol pour que vous puissiez voir l'herbes que vous peignez. je vous est mis dans le title de la fenêtres les FPS et le nombres de mesh actif.

 

Vous avez juste a cliquer sur le sol pour peindre de l'herbes. le premier plan d'herbes pas de problème c'est instantanée, mais des que l'on arrive sur les instances, ça s'affiche avec un enorme temps de retard et le nombres afficher n'est pas celui du nombre actif. Il faut peindre de façons a arriver entre 30 et 40 mesh actif pour que enfin on en voie apparaître 10 a 20 plan d'un coup, mais une partie reste invisible ou en mémoire peut être et le nombre de non afficher est aléatoire.

 

index.html

 

Merci Deltakosh

Link to comment
Share on other sites

[edite] If this is fixed, this is what I used this:

 

if(scene._activeMeshes.length > 10) scene.createOrUpdateSelectionOctree();

 

I had to update octree that is displayed in real time with the same line each plan to create more on stage.
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...