Jump to content

actionManager on mesh Instance get an error


al404
 Share

Recommended Posts

pixelThumbOver = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, testlog);
		
for (var p = 0; p < totLinked; p++) {
			
    var linkedPart = particella2.createInstance("minewp" + p);
	linkedPart.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL;
	linkedPart.actionManager.registerAction(pixelThumbOver);

}

I'm trying to add a mouse over event at some instances of my mesh but i get an error when code is executed, i signify the file so i guess u is my linkedPart

TypeError: undefined is not an object (evaluating 'u.actionManager.registerAction')

i looked at this playgroud and the only difference i note is that mine are instances and not real mesh

http://www.babylonjs-playground.com/#8ULNX#13

 

Link to comment
Share on other sites

Hi al404, good to see you again.  We need a better playground demo, perhaps. 

What is particella2?  Is it a plane?  (I assume so because of billboard).  If it is a particleSystem or particle, I'm not sure BJS allows actionManagers on those.  Neither are standard mesh. 

But, if a particleSystem is using a mesh for its fountain/emitter, that mesh can have an attached actionManager, I believe.  Still, not allowed on the particle or the particleSystem.  Standard particles may LOOK like planes, but they are not really so.  They are "quads" - each part of a single mesh.  They are like sections of a single subdivided ground grid, with some of the connecting lines (indices) between the squares... removed.

Link to comment
Share on other sites

HI :)

var particella2 = BABYLON.MeshBuilder.CreatePlane("model", {size: 0.16}, scene);

particella2 is a mesh

we choose a different approach, but the only thing that I can guess is that on an instance

I modify playground adding a clone of sphere2 at line 31 and setting him offset on X

If I disable ActionManager and sphere2 and add an ActionManager on instance nothing happen, line 69 - 77

http://www.babylonjs-playground.com/#8ULNX#33

If i enable ActionManager on sphere2 it will work on his stance too

http://www.babylonjs-playground.com/#8ULNX#34

Link to comment
Share on other sites

Yep, I see what you mean... thx for the playgrounds.  I thought I would try to put a full actionManager on sphere2 BEFORE I created the instance of it, named linkedPart.  I wanted to see if an actionManager was instanced-onto the instance.  It isn't.  Then I tried making new actions for linkedPart's actionManager (action 3/4)... that didn't work.

Yep, interesting find.  Might be normal.  The actionManager on linkedPart IS working (after adding it)... because I am seeing your "mouse over minewp" and "mouse out minewp" reports at the console.  But, I'd say the "action" is failing.  Perhaps... it is renderOutline = true that is NOT allowed on instances.

http://www.babylonjs-playground.com/#8ULNX#36

Here, I set the mouseOverUnit and mouseOutUnit to simply move the mesh to the right/left a bit on mouseover and mouseout.  It works.  LinkedPart has its own actionManager, and I added its own actions (lines 66-70 area).

http://www.babylonjs-playground.com/#8ULNX#37

Here... in the same area... line 68...  linkedPart.actionManager = sphere2.actionManager (adding no actions to linkedPart actionManager).  Instead, I am depending upon the two actions that have already been added to sphere2.actionManager.  It still works fine.

So, it is not the action manager on instances... that is the problem.  It is the action.  Outline rendering... on an instance ONLY... seems disallowed.  Position changing... IS allowed.  hmm.  I'm not sure if this is a bug or not.  The framework COULD need a little adjustment to the outline renderer... but not sure.

By the way, I moved all your stuff UPWARD... so we could get a fully stocked actionManager on sphere2 BEFORE we instanced linkedPart.  I wanted to see if the actionManager was put on linkedPart automatically... during the createInstance.  It wasn't.  :)   Interesting!  Very very interesting.  hmm.

Well, we know renderOutline is not working well on instances.  Let's try edgesRendering...

http://www.babylonjs-playground.com/#8ULNX#38

Working pretty good.  (Still using linkedPart.actionManager = sphere2.actionManager).  So, this is an issue with the outlineRenderer, I believe.  Line 12 there... is just scary.  I think we will need to wait for @Deltakosh or some other core programmer... to tell us if outlineRenderer should be allowed on instances themselves.  Interesting find... well done.  This might award you with a "I contributed to BJS core" badge.  :)

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...