Skip to content

Commit

Permalink
Added Pixel Canvas API scene
Browse files Browse the repository at this point in the history
  • Loading branch information
CansyLand committed Oct 3, 2023
1 parent 1f9b90f commit 012a8df
Show file tree
Hide file tree
Showing 25 changed files with 1,092 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Pixel-Canvas-API/.dclignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.*
bin/*.map
package-lock.json
yarn-lock.json
build.json
export
tsconfig.json
tslint.json
node_modules
*.ts
*.tsx
.vscode
Dockerfile
dist
README.md
*.blend
*.fbx
*.zip
*.rar
src
19 changes: 19 additions & 0 deletions Pixel-Canvas-API/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test-build

on:
push:
pull_request:

jobs:
lint-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: install dependencies
run: npm install
- name: npm run build
run: npm run build
9 changes: 9 additions & 0 deletions Pixel-Canvas-API/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package-lock.json
*.js
node_modules
bin/
.DS_Store
**/.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 3 additions & 0 deletions Pixel-Canvas-API/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["decentralandfoundation.decentraland-sdk7"]
}
17 changes: 17 additions & 0 deletions Pixel-Canvas-API/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use the Decentraland Editor extension of VSCode to debug the scene
// in chrome from VSCode
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug Decentraland in Chrome",
"url": "${command:decentraland-sdk7.commands.getDebugURL}",
"webRoot": "${workspaceFolder}/bin",
"sourceMapPathOverrides": {
"dcl:///*": "${workspaceFolder}/*"
}
}
]
}
72 changes: 72 additions & 0 deletions Pixel-Canvas-API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## Pixel Canvas API

A scene that fetches pixel color data from an API and displays it on a giant canvas. Set your own pixel on the canvas and sync it with an online database via API.



![](images/screenshot.jpg)


This scene shows you:

- How to call a REST API and parse a JSON response
- How to store data in an online databse
- How to detect if player points on an entity
- How to update scene via messageBus
- How to use components to manage entities



## Try it out

**Install the CLI**

Download and install the Decentraland CLI by running the following command:

```bash
npm i -g decentraland
```

**Previewing the scene**

1. Download this full repository from [sdk7-goerli-plaza](https://github.com/decentraland/sdk7-goerli-plaza/tree/main), including this and several other example scenes on SDK7.
2. Install the [Decentraland Editor](https://docs.decentraland.org/creator/development-guide/sdk7/editor/)
3. Open a Visual Studio Code window on this scene's root folder. Not on the root folder of the whole repo, but instead on this sub-folder that belongs to the scene.
4. Open the Decentraland Editor tab, and press **Run Scene**

Alternatively, you can use the command line. Inside this scene root directory run:

```bash

npm run start

```

## Scene Setup

1. Create an account on [restdb.io](https://restdb.io/)

2. Set up a table in the database with the required fields. Restdb.io will autogenerate a REST API for your table.

The table for this scene should have the following format:

```javascript
posX: number
posY: number
color: string
```

***CORS Configuration***
To allow access from a Decentraland scene:


1. Navigate to the API tab under settings on restdb.io.
2. Create a new "Web page API key (CORS)".
3. Replace the `apiKey` value in `api.ts` with your generated API key.




## Copyright info

This scene is protected with a standard Apache 2 licence. See the terms and conditions in the [LICENSE](/LICENSE) file.
Loading

0 comments on commit 012a8df

Please sign in to comment.