Hi everyone!
I’m trying to do a small addition to the codebase, but I cannot get new playgrounds to show up locally. Old ones do work. New ones give me Uncaught (in promise) SyntaxError: Unexpected token ‘:’ error. I’m not sure if I’m doing something wrong, since this is my first ever contribution attempt!
I just cloned the repo, then ran the “Playground development (Edge)” -task after npm install. I have been trying to read the contribution document as carefully as I can. I’ve run the playgrounds in the address http://localhost:1337/#123456, where 123456 is imaginary snippet url of course ![]()
In the code evaluation there seems to be different handling. The new playgrounds have an input like this:
New Playgrounds
“{“v”:2,“language”:“JS”,“entry”:“index.js”,“imports”:{},“files”:{“index.js”:“const createScene = () => {\n const scene = new BABYLON.Scene(engine);\n\n const camera = new BABYLON.ArcRotateCamera(“Camera”, - Math.PI / 2, Math.PI / 4, 10, BABYLON.Vector3.Zero());\n camera.attachControl(canvas, true);\n\t\n\tconst light1 = new BABYLON.DirectionalLight(“DirectionalLight”, new BABYLON.Vector3(0, -1, 1));\n const light2 = new BABYLON.HemisphericLight(“HemiLight”, new BABYLON.Vector3(0, 1, 0)); \n light1.intensity =0.75;\n light2.intensity =0.5;\n\n const box = BABYLON.MeshBuilder.CreateBox(“box”, {});\n box.position.x = 2;\n\n const frameRate = 10;\n\n const xSlide = new BABYLON.Animation(“xSlide”, “position.x”, frameRate, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);\n\n const keyFrames = ; \n\n keyFrames.push({\n frame: 0,\n value: 2\n });\n\n keyFrames.push({\n frame: frameRate,\n value: -2\n });\n\n keyFrames.push({\n frame: 2 * frameRate,\n value: 2\n });\n\n xSlide.setKeys(keyFrames);\n\n box.animations.push(xSlide);\n\n scene.beginAnimation(box, 0, 2 * frameRate, true);\n\n\treturn scene;\n};\nexport default createScene\n”}}”
And the older ones are like this:
Old Playgrounds
"var createScene = async function () {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera(“camera”, -Math.PI / 2, Math.PI / 3, 10, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, true);
camera.setTarget(new BABYLON.Vector3(0, 0.5, 0));
camera.wheelPrecision = 10;
camera.minZ = 0.1;
camera.maxZ = 30;
var light = new BABYLON.DirectionalLight(“dirLight”, new BABYLON.Vector3(1, -2, 1), scene);
light.intensity = 0.4;
light.shadowMinZ = 0.1;
light.shadowMaxZ = 30;
var light2 = new BABYLON.DirectionalLight(“dirLight2”, new BABYLON.Vector3(-2, -2, -1), scene);
light2.intensity = 0.4;
light2.shadowMinZ = 0.1;
light2.shadowMaxZ = 30;
// Our built-in ‘sphere’ shape. Params: name, options, scene
var sphere = BABYLON.MeshBuilder.CreateSphere(“sphere”, { diameter: 2, segments: 32 }, scene);
// Move the sphere upward 1/2 its height
sphere.position.x = -1;
sphere.position.y = 1;
// Our built-in ‘ground’ shape. Params: name, options, scene
var ground = BABYLON.MeshBuilder.CreateGround(“ground”, { width: 60, height: 60 }, scene);
const groundMat = new BABYLON.StandardMaterial(“mat”, scene);
ground.material = groundMat;
await BABYLON.AppendSceneAsync(“https://playground.babylonjs.com/scenes/Dude/dude.babylon”, scene);
scene.lights[2].dispose();
const hero = scene.getMeshByName(“him”);
hero.scaling.scaleInPlace(0.03);
scene.beginAnimation(scene.skeletons[0], 0, 100, true, 1.0);
hero.position.x = 1;
scene.meshes.forEach((m) => m.receiveShadows = true);
scene.cameraToUseForPointers = camera;
const nrg = await BABYLON.NodeRenderGraph.ParseFromSnippetAsync(“PSA9PS#161”, scene, {
autoFillExternalInputs: false,
debugTextures: true,
});
// Sets values to block inputs / configure blocks
const cameraBlock = nrg.getBlockByName(“Camera”);
cameraBlock.value = camera;
const lightBlock = nrg.getBlockByName(“ShadowLight”);
lightBlock.value = light;
const light2Block = nrg.getBlockByName(“ShadowLight2”);
light2Block.value = light2;
const objectListBlock = nrg.getBlockByName(“ObjectList”);
objectListBlock.value = { meshes: scene.meshes, particleSystems: };
const objectListShadowBlock = nrg.getBlockByName(“ObjectListShadow”);
objectListShadowBlock.value = { meshes: scene.meshes.slice(), particleSystems: };
objectListShadowBlock.value.meshes.splice(objectListShadowBlock.value.meshes.indexOf(ground), 1);
const guiBlock = nrg.getBlockByName(“GUI”);
const gui = guiBlock.gui;
const button = BABYLON.GUI.Button.CreateSimpleButton(“button”, “Edit Frame Graph”);
button.width = “200px”;
button.height = “60px”;
button.color = “white”;
button.fontSize = 20;
button.background = “green”;
button.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
button.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
button.onPointerClickObservable.add(() => {
nrg.edit({
nodeRenderGraphEditorConfig: {
hostScene: scene,
}
});
});
gui.addControl(button);
nrg.build();
await nrg.whenReadyAsync();
scene.frameGraph = nrg.frameGraph;
return scene;
};"
So if you could confirm if this is infact a bug
or me doing something silly, I would be grateful ![]()





