[EDIT : RELEASED !] What about a code generator for the Playground?

Honestly on my side I just save a PG as bookmark, and that’s it ^^ Why don’t you do so ?

Ah yes, sure ! Maybe not by default, in order to let the user free of triggering the autoformat at any moment, but for sure it would be nice ! And it will even be necessary on dev side, if we don’t want to have to deal with indentation levels in the code snippets, json-based… Best will be to code format-less, and add an auto-format on top if that

Ah I think there is a confusion here, sorry if it was not clear. I was not speaking about specifically the Playground in this post ^^ When I said :

I was really speaking about another project idea, a “template” as well as you can download some in Unity or Unreal… Could be a .zip or whatever. For sure it’s not a big matter to let a way to load the template in the Playground in order to have a quick test “for real”, but obviously I would never code a game inside the Playground :grin:


By the way, to be honest, most of the time when I run a test in the playground, I actually code in my code editor and paste it to playground… I’m so used to some shortcuts which are missing in the Playground editor that I miss them so much.

Examples of what I am missing most, and could be added to the Playground are :

  • Moving a line with auto indent, using CTRL+ARROW :

  • Create new cursors with CTRL+ALT+ARROW

Maybe one day in the Playground ? :grin:


Ahah. AI is fashion nowadays, I’m sure it will come sooner or later :stuck_out_tongue:

I started to do it, but it there was several reasons I gave up:
It requires to do the action manually.
You have to rebookmark if you create a newer version of the PG.
I ended up with hundreds of bookmarks in a chaotic order.

I think it should be on by default and I could turn it off and the PG would remember my choice.

Template repos on GitHub will be great for this.

This is another thing that should be solved. Easilly copy code with ES6 imports to BABYLON namepaced code and vice versa.

You bet on it :slight_smile:

Hmm, this is already supported :wink: Monaco is Monaci everywhere.

I admit it’s not practical ^^

Fair enough :+1:

Hooouuuhh yes it’s ALT instead of CTRL but indeed it works :smiley: Thanks :sunglasses:

1 Like

Want my opinion? For whatever it’s good for :sweat_smile: I think the AI is already here today. I use it. Many people use it. But I think, in essence, the AI needs to be looked at/treated like any (human) ‘team member’. You cannot let it take over and just relying 100% on it. Speaking about code and moreover a ‘code base’ that needs to be solid and might be depending on context, I wouldn’t let the AI take over. For sure, not today. And likely not tomorrow. I think there’s a certain level of ‘control’ we need to make sure we keep for ourselves. By delegating just everything to the AI, we are loosing track and thus, loosing ‘control’.

Anyway, on a side note, I very much enjoy this thread (and then, the project :heart_eyes:)… and the way everyone seem to engage into this. I think @Tricotou you are onto something here… something big :man_superhero: I’m not sure how much I can be of help, but know that you do have my full support and I’m eager to see what will come out of it :child: Meanwhile, keep up the good work and have a great sunday :sunglasses:

2 Likes

NO NO NO! :slight_smile: It’s a fact that our brain is shrinking already. However it seems it is inevitable that AI will do a lot of programming in the future.

I have my reasons to disagree (at least for now :sweat_smile:). This isn’t about ‘programming’ but here for my latest experience with the AI. Artifical Intelligence - #234 by mawa

Hey !

I could (finaly) take some time to put on the table a PR for this new feature :slight_smile:
@Deltakosh as discussed, I made it JSON-based in order to ease the edit later on

  • source code is the same than CTRL+SPACE menu (tools/playground/public/templates.json)
  • any new code block from this code generator is now as well available from the CTRL+SPACE menu :heavy_check_mark:
  • added a structure json in tools/playground/public/procedural.json which is used to build the drop down menu :heavy_check_mark:
  • the fetch("templates.json").then() has been move to the monaco constuctor since now it’s used from different places.
  • NB: the code generator is not “100%” based on the JSON (for now…?) since some conditions have been included outside, such as for example a shadowGenerator check (cannot be enabled on hemi light), etc.
  • NB: In the monaco editor I added a if (model.isDisposed()) check (see line 720 & 727), but I could not find exactly when the error Model is disposed! is triggered. Seems to be a bit random :thinking:

Demo :

Link available soon to give it a test, when bjsplat is done building the stuff (If it builds :grin: )

6 Likes

Do you know Emmet for VS Code?

I could imagine something similar in the PG.

Nope :slight_smile:

It seems that Emmet is already available for the Monaco Editor which powers the PG :stuck_out_tongue:

For example:

sphere#crsp.10.std.diff.1,0,0

const sphere = BABYLON.CreateSphere("sphere", { radius: 10 })
const sphereMaterial = new BABYLON.StandardMaterial("sphereMaterial")
sphereMaterial.diffuseColor = new BABYLON.Color3(1, 0, 0)

:heart_eyes_cat:

Hey !
@labris @Dad72 @Joe_Kerr @ericwood73 @brianzinn @mawa @jamessimo @roland
I’m happy to announce that the “1.0 version” has been released tonight, and it’s up and running on the official Playground !

Also, since it stores locally your params, it’s a nice way to setup your prefered “Playground Template” (for example, I prefere ArcRotate Camera by default), and then you just need to hit Run on a new playground to switch to your prefered params :slight_smile:

7 Likes

If I open the Playground and click on CAMERA → ArcRotated (Deg) I’ve got


Probably I am doing something wrong?

Hum :thinking: Weird. To me the problem here is that the code snipped loader returned nothing (ending in an empty code with no camera). It could happen only in the event of the JSON load not working. But here the JSON released is fine. Do you have any error in console ?

Also, does CTRL+SPACE in the editor open the new snippets ?

Screenshot from 2024-07-10 10-56-48

It is working now for me after force cache reload.

1 Like

Ah yes, the JSON file hasn’t changed its name, so default caching would indeed be the issue.
By the way thanks to your screenshot, I just noticed that I’m missing a linesep (\n) at the very beginning, before first comment :see_no_evil:

I’ll wait for first feedbacks (and eventually bugs), and concatenate all suggestions and fixes in a new PR :slight_smile:

2 Likes

This works well for me. I have no comment to make. Maybe over time, you could add a little more code.

I have some ideas for other code :

  • Lensflare
  • Audio
  • Sprites
  • Sequence Animations (maybe this one is less important)
  • SkyBox

Thank you for adding this feature to the playground.

1 Like

@RaananW it seems that this last PR has created a potential bug where loading a Custom Playground ID can lead to a “forever engine load UI”. This PR is a fix :

Also, I make profit of this PR to fix the potential cache issue spotted by @labris as well as the missing "\n" at beginning of generated code :slight_smile:

3 Likes

opening the discussion here (cc @PatrickRyan ). We discussed with @RaananW and I wonder if this would be easier for user to use it as a wizard so we can avoid the risk to remove user code?

I have set a Run Auto button on top of the DropDown menu, which somehow does the same than the Safe Mode param of the Playground. Indeed it’s set to true by default but we could change this to false (in that case the user must hit Run to replace the code)

Eventually, we could replace the word "RUN" by "REPLACE CODE" to make it clear…

What do you think ?

I would like to get @PatrickRyan thoughts. The risk of losing user data is quite important if the user comes back to the menu

1 Like