BabylonJS / Babylon.js

Babylon.js is a powerful, beautiful, simple, and open game and rendering engine packed into a friendly JavaScript framework.
http://www.babylonjs.com
Apache License 2.0
23.26k stars 3.43k forks source link

scrollViewer #5458

Closed BabylonJSGuide closed 5 years ago

BabylonJSGuide commented 6 years ago

Feature request

http://www.html5gamedevs.com/topic/40142-can-we-customize-the-look-of-babylonjsgui/?do=findComment&comment=230694

http://www.html5gamedevs.com/topic/41012-scroll-textblock-gui/

as a starting basis. Some current fixed values would be turned to parameters.

I would be happy to give creating a PR for it over next few weeks.

Any further thought on how you see it working very welcome.

Edit with list of remaining task (for @deltakosh):

dad72 commented 6 years ago

:+1:

BabylonJSGuide commented 6 years ago

BUG

When switching from setting width etc. of controls found that if you set in pixels and swap to number then this does not register, ie https://www.babylonjs-playground.com/#DKQ89M

I think this can be solved in the fromString function in valueAndUnits.ts by changing

var sourceUnit = this.unit; to var sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;

and I will make this change in my development of a ScrollText control.

Can you check that this change will not have knock on effects with any other property

deltakosh commented 6 years ago

So we cannot do that as properties like Left or Top are pixel by default. But I will fix that by storing the original default unit per property. Stay tuned ;)

BabylonJSGuide commented 6 years ago

The current issue is getting a value for example in widthInPixels when value is set to a fraction. It appears that this._cachedParentMeasure is only ever set to Measure.Empty() and never updated to an non-zero Measure or I could just be missing something

This appears to happen with existing GUI controls.

After further investigation

In this PG to create a rectangle rect1https://www.babylonjs-playground.com/#XCPP9Y#677

in the console the output for rect1 contains the _cachedParentMeasure as non zero eg {height: 630, left: 0, top: 0, width: 263} but the output for just the property is zero? {height: 0, left: 0, top: 0, width: 0} and this is what is used to calculate widthInPixels

deltakosh commented 6 years ago

_cachedParentMeasure is only updated after a render (it is like the world matrix computation for regular meshes)

BabylonJSGuide commented 6 years ago

Just don't understand why ...... Oh I think I do, the console picks up the immediate value of the property and outputs that but then updates the object once the rendering has taken place before printing that. So the difference in apparent values is down to how the console operates.

deltakosh commented 6 years ago

Exactly. Let me try that: https://www.babylonjs-playground.com/#XCPP9Y#678

BabylonJSGuide commented 5 years ago

Only managed to create a specific scoller for text that was not future proof. Help still needed to produce scrollviewer for all controls

deltakosh commented 5 years ago

@BabylonJSGuide: Do not be worried by the tasks, I'll handle them :)

deltakosh commented 5 years ago

Done and merged., Thanks a lot @BabylonJSGuide