var createScene = function () { var scene = new BABYLON.Scene(engine); // Create camera and light var light = new BABYLON.PointLight("Point", new BABYLON.Vector3(5, 10, 5), scene); var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 0, -30), scene); // Attach the Controls to the canvas camera.attachControl(canvas, true); // Load the JSON file, for simplicity in this demonstration it is included inline. let atlasJSON = getJSONFile(); // Load the SpriteSheet Associated with the JSON Atlas. let spriteSheet = new BABYLON.Texture('./textures/spriteMap/none_trimmed/Legends_Level_A.png', scene, false, //NoMipMaps false, //InvertY usuaslly false if exported from TexturePacker 0, //Sampling Mode null, //Onload, you could spin up the sprite map in a function nested here null, //OnError null, //CustomBuffer false, //DeleteBuffer 5 //ImageFormageType RGBA ); spriteSheet.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE; spriteSheet.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE; //Or Wrap, its up to you... let backgroundSize = new BABYLON.Vector2(200,60); let background = new BABYLON.SpriteMap('background', atlasJSON, spriteSheet, { stageSize: backgroundSize, maxAnimationFrames:8, baseTile : 42, layerCount: 2, flipU: true, //Sometimes you gotta flip the depending on the sprite format. colorMultiply : new BABYLON.Vector3(0.3,0.3,0.3) }, scene); //Set all the available tiles to the top left corner of the background for Visual debugging, and refrence. for(var i = 0; i0; y--){ if(x%12 == 0){ tilePositions.push(new BABYLON.Vector2(x, y)) } } } background.changeTiles(1, tilePositions, 1) //Adding Sewer Drains to BG tilePositions = [] for(let x=15; x0; y--){ if((x+6)%12 == 0){ tilePositions.push(new BABYLON.Vector2(x, y)) } } } background.changeTiles(1, tilePositions, 1); tilePositions = []; //Random Array for placing variations of the torches animation. let pTiles = [48, 49, 50, 48, 49, 50, 48]; //Making the Base of the level let levelSize = new BABYLON.Vector2(80,40); let levelBase = new BABYLON.SpriteMap('base', atlasJSON, spriteSheet, { stageSize: levelSize, maxAnimationFrames:8, baseTile : 42, layerCount: 2, flipU: true, colorMultiply : new BABYLON.Vector3(0.6,0.6,0.6) }, scene); //Duplicating over the animation map from the background system. levelBase.animationMap = background.animationMap //Making a hole. tilePositions = [] for(let x=15; x15; y--){ tilePositions.push(new BABYLON.Vector2(x, y)) } } levelBase.changeTiles(0, tilePositions, 0) //Adding Columns tilePositions = [] for(let x=15; x16; y--){ if(x%6 == 0){ tilePositions.push(new BABYLON.Vector2(x, y)) } } } levelBase.changeTiles(0, tilePositions, 23) //Adding Torches for(let x=15; x{ return {"frames": [ { "filename": "blank.png", "frame": {"x":221,"y":221,"w":1,"h":1}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-0.png", "frame": {"x":1,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-1.png", "frame": {"x":1,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-2.png", "frame": {"x":1,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-3.png", "frame": {"x":1,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-4.png", "frame": {"x":1,"y":141,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-5.png", "frame": {"x":1,"y":176,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-6.png", "frame": {"x":1,"y":211,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Falling-Water-7.png", "frame": {"x":1,"y":246,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large-Column-Light-0.png", "frame": {"x":36,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large-Column-Light-1.png", "frame": {"x":71,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large-Column-Light-2.png", "frame": {"x":106,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large-Column-Light-3.png", "frame": {"x":141,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large_Column-0.png", "frame": {"x":176,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large_Column-1.png", "frame": {"x":211,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large_Column-2.png", "frame": {"x":246,"y":1,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Large_Column-3.png", "frame": {"x":36,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman-Column-0.png", "frame": {"x":36,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman-Column-1.png", "frame": {"x":36,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman-Column-2.png", "frame": {"x":36,"y":141,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman-Column-3.png", "frame": {"x":36,"y":176,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman_Column_Light-0.png", "frame": {"x":36,"y":211,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman_Column_Light-1.png", "frame": {"x":36,"y":246,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman_Column_Light-2.png", "frame": {"x":71,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Roman_Column_Light-3.png", "frame": {"x":106,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-0.png", "frame": {"x":141,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-1.png", "frame": {"x":176,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-2.png", "frame": {"x":211,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-3.png", "frame": {"x":246,"y":36,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-4.png", "frame": {"x":71,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-5.png", "frame": {"x":71,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-6.png", "frame": {"x":71,"y":141,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Sewer-Drain-7.png", "frame": {"x":71,"y":176,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-0.png", "frame": {"x":71,"y":211,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-1.png", "frame": {"x":71,"y":246,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-2.png", "frame": {"x":106,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-3.png", "frame": {"x":106,"y":141,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-4.png", "frame": {"x":106,"y":176,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-5.png", "frame": {"x":106,"y":211,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-6.png", "frame": {"x":106,"y":246,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-7.png", "frame": {"x":141,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-8.png", "frame": {"x":176,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-9.png", "frame": {"x":211,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-10.png", "frame": {"x":106,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-11.png", "frame": {"x":141,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-12.png", "frame": {"x":176,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-13.png", "frame": {"x":211,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Stone-Platform-14.png", "frame": {"x":246,"y":71,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Torch-A-0.png", "frame": {"x":246,"y":106,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Torch-A-1.png", "frame": {"x":141,"y":141,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Torch-A-2.png", "frame": {"x":141,"y":176,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }, { "filename": "Torch-A-3.png", "frame": {"x":141,"y":211,"w":32,"h":32}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":32,"h":32}, "sourceSize": {"w":32,"h":32} }], "meta": { "app": "https://www.codeandweb.com/texturepacker", "version": "1.0", "image": "Legends_Level_A.png", "format": "RGBA8888", "size": {"w":279,"h":279}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:a755ec93daaec56d1c8bcd801e167677:2e759c84cbaf9134b80c1a34b50e5c9c:9f820b9412efc8199e0407f80b8c0011$" } } }