Jump to content

Borders For More Primitives


Wingnut
 Share

Recommended Posts

Before answering your question, I just want to be sure that you're aware that due to event bubbling you may get an event triggered by the Text2D prim that is raised in the Rect2D prim, to know which Prim triggered the event you have to use the relatedTarget property in PrimitivePointerInfo object.

#1 this may related to what I just say above, Over/Out are bubbling, which means if you set an Observer on the Rect2D and the event occurs on the Text2D: you will be notified of Text2D related events. Enter/Leave are not bubbling, so in the same situation you won't be notified.

#2 Well in your case everything is pickable so isContainer's value doesn't matter.

#3 If you set isContainer = true and isPickable = false on the Rect2D, you won't have events for the Text2D, I will stop looking for event to raise as soon as I meet the Rect2D.

#3b no, isContainer is really a very specific case, one I couldn't ignore, I don't remember the use case exactly but MasterK really made his point when his expressed the need to have this behavior, so I developed it. But most of the time you can ignore it.

It's not mouse because these events are supposed to be raised is you have a touch screen or a screen compatible with a stylus.

Link to comment
Share on other sites

Ok, very good, thanks.  Good reminders (relatedTarget, isPickable, etc).  I forgot that Text2D is "generating" over/out events, even if I'm not observing any Text2D.  Its parental rect2D observer was hearing Text2d's bubblings... as you stated.  Yep, yep, yep.  New demo:

http://babylonjs-playground.com/#UAG5H#12

It's all working perfect, and just like you said it would.  New enhanced console loggings on this one... showing more info.

ONE minor thing... I thought I should mention.  Currently, (in the new demo) the left button Text2D is NOT producing bubbled overs and outs, and it is caused by line 13. Line 13 is a size setting on the rect2d.  You'll notice there is also a size setting on the Text2d in line 21, currently disabled.

ONLY when there is a sizer on the rect2d... does the text2D fail to bubble over/out events to rect2d.  Here's the truth table:

Line 13 active ONLY:  no Text2D over/out bubble to rect2d.
Line 13 & 21 active:  Text2D bubble - > rect2d okay
Line 21 active ONLY:  Text2D bubble - > rect2d okay
Line 13 & 21 disabled:  Text2D bubble - > rect2d okay

Okay, that's it.  I could be mistaken.  No big deal... just thought I'd tell you about this interesting sizing thing.

Again, good work. I'm having a blast torturing this.  It's pretty solid. I'm having difficulties making it screw-up.  :)  Don't drag that playground editor/canvas divider bar, though.  :)  I probably need to find a refreshAfterResize() or something. I should read the docs someday.  :/

Link to comment
Share on other sites

Okay, so, while I have your ear... um... :)

...the reason the playground slider and other canvas resizing... is screwing up the proportional placement of the buttons... is because none of the values... use percentages, correct?  (sizes, x, y, origins, etc)  Would that be a programmer-calculated thing?

For example, if I could place left button x: "5%" and right button x: "85%", then we could do a nicer canvas re-size/re-scale, and have it be cool, right?

Nockawa... is "allowing percentages" (and thus nicer canvas re-scales)... planned?  Is it part of the "primitives phase" of C2D dev?  Any thoughts?  Thx.  Sorry if you already told me and I forgot.

Link to comment
Share on other sites

you can't use percentage for x/y/pos. these area number based properties so it's in pixel.

but if you rely on positioning instead of absolute position, which means using alignment and marging, you should be able to express your offsets in percentage

another way to achieve something "responsive", would be to use the designSize when you create the canvas. you set a "ideal/design" size, then you rely on absolute position (x/y/pos) and size for your prim, then I will take care of "scaling everything" in order to keep the proportions you asked for... it may be a little hard to understand, but just create a canvas with a designSize of 500,500 then position everything according to this size, then run you PG and resize the window

Link to comment
Share on other sites

Thx.  http://babylonjs-playground.com/#UAG5H#13

Line 4.  Alright.  Something happened.  :)  Now I just need to wire the engine resize observer... to the Canvas.reconbobulate() method, and then... uhh... no.  :) 

.reconbobulate() is a GUI-lib layer thing, right?  :)  But yes, I understand.  When the super-scaler is coded... it will use .designSize as a factor.  So... folks should set one... to be ready for the future scaler?  *nod*  ?  *nod*  :)

Can .designSize do percentages?   (of window.innerWidth/innerHeight)  heh  *sigh*  Life is hard... when ya carry a Wingnut brain... it really is.  :)

Link to comment
Share on other sites

MasterK asked for the designSize feature, basically it allow him to do a game with a predefined screen/canvas resolution (the designSize) then the rendered canvas will adapt to the real canvas/screen's resolution. still no percentage.

With 2D Engine pixel is always the unit. when you start dealing with percentage it's more about GUI...

Link to comment
Share on other sites

Alright, thx.  Am I being annoying?  I hope not. 

Users can do their own percentages system... IF they can get a canvas size... when scene.executeWhenReady comes around.  (We probably need a canvas resize observer, too, for after-resize prim re-positioning and possible prim re-sizing).  Manual re-scale.  :)

http://babylonjs-playground.com/#UAG5H#14

In lines 108-114, I'm trying everything in the toolbox (to get a canvas size).  I tried every property on ssc2d that looked appropriate.  Couldn't get it.  Yet the browser object-inspector shows good numbers for all of those properties.  

I suppose I could measure the render canvas... if an explicit canvas size is not user-set.

I think executeWhenReady is executingBeforeReady.  Thoughts? 

Canvas2d system is a "late binding" thing, it seems.  (Wingy talking out his butt again.)  Am I driving down MasterK avenue, here?  Did he go looking for canvas size, too?  Bet so.  :)

Does ._notifDebugMode need an added 'y'... and _supprtInstancedArray need an added 'o'?  Just checking.  (Thx for putting up with me, eh?)

Link to comment
Share on other sites

you should use "actualSize", but it won't change the fact that you're right, if you query this property right away you won't get a proper value, the canvas has to be rendered at least once for the correct value to be fetched.

this is something that I should fix because it's no longer acceptable. in this case it should be "lazy evaluation" instead of "late binding" (which is not the more accurate term to use, well most accurate would be "real bugged" :D )

Link to comment
Share on other sites

Oh, you're right.  http://babylonjs-playground.com/#UAG5H#15

Just put a scene.render() in there (Line 108), and suddenly I have good numbers at the console.  Interesting!  I wonder if this is related to the old days... when we would see a prim2d appear in the lower left corner of the canvas... and a moment later... it got moved to its proper position.  hmm. 

Very good.  Demented manual scaling experiments... on the horizon.  :)  I'll have a drag-to-resize widget on the upper right corner of every ssc2d... by midnight tonight.  (yeeeeah).  (Patience, Wingy.  Patience.)  heh 

Speaking of patience... looks like "Loading assets...Please wait" is stuck ON... in that PG.  (Wingy tries "percussive calibration")  (banging on it)   Something is wrong with my .executeWhenReady().  Mister playground doesn't like it.

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