Skip to content

Commit c0344fd

Browse files
committed
voxter simple example
1 parent a3ce59f commit c0344fd

27 files changed

+618
-0
lines changed

SDK-simple/.dclignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.*
2+
package.json
3+
package-lock.json
4+
yarn-lock.json
5+
build.json
6+
export
7+
tsconfig.json
8+
tslint.json
9+
node_modules
10+
*.ts
11+
*.tsx
12+
Dockerfile
13+
dist
14+
README.md
15+
*.blend
16+
*.fbx
17+
*.zip
18+
*.rar

SDK-simple/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

SDK-simple/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:10
2+
3+
# Create app directory
4+
WORKDIR /usr/src/app
5+
6+
RUN npm install --global decentraland@next
7+
8+
# Install app dependencies
9+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
10+
# where available (npm@5+)
11+
COPY package*.json ./
12+
13+
RUN npm install
14+
# If you are building your code for production
15+
# RUN npm install --only=production
16+
17+
# Bundle app source
18+
COPY . .
19+
20+
EXPOSE 8000
21+
CMD [ "npm", "start", "--", "--ci" ]

SDK-simple/bin/game.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SDK-simple/bin/game.js.lib

+17
Large diffs are not rendered by default.

SDK-simple/images/sprites2048.png

751 KB
Loading

SDK-simple/models/.DS_Store

6 KB
Binary file not shown.

SDK-simple/models/CUBE.gltf

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"asset" : {
3+
"generator" : "Khronos glTF Blender I/O v1.1.45",
4+
"version" : "2.0"
5+
},
6+
"scene" : 0,
7+
"scenes" : [
8+
{
9+
"name" : "Scene",
10+
"nodes" : [
11+
0
12+
]
13+
}
14+
],
15+
"nodes" : [
16+
{
17+
"mesh" : 0,
18+
"name" : "Cube"
19+
}
20+
],
21+
"meshes" : [
22+
{
23+
"name" : "Cube",
24+
"primitives" : [
25+
{
26+
"attributes" : {
27+
"POSITION" : 0,
28+
"NORMAL" : 1,
29+
"TEXCOORD_0" : 2
30+
},
31+
"indices" : 3
32+
}
33+
]
34+
}
35+
],
36+
"accessors" : [
37+
{
38+
"bufferView" : 0,
39+
"componentType" : 5126,
40+
"count" : 24,
41+
"max" : [
42+
1,
43+
1,
44+
1
45+
],
46+
"min" : [
47+
-1,
48+
-1,
49+
-1
50+
],
51+
"type" : "VEC3"
52+
},
53+
{
54+
"bufferView" : 1,
55+
"componentType" : 5126,
56+
"count" : 24,
57+
"type" : "VEC3"
58+
},
59+
{
60+
"bufferView" : 2,
61+
"componentType" : 5126,
62+
"count" : 24,
63+
"type" : "VEC2"
64+
},
65+
{
66+
"bufferView" : 3,
67+
"componentType" : 5123,
68+
"count" : 36,
69+
"type" : "SCALAR"
70+
}
71+
],
72+
"bufferViews" : [
73+
{
74+
"buffer" : 0,
75+
"byteLength" : 288,
76+
"byteOffset" : 0
77+
},
78+
{
79+
"buffer" : 0,
80+
"byteLength" : 288,
81+
"byteOffset" : 288
82+
},
83+
{
84+
"buffer" : 0,
85+
"byteLength" : 192,
86+
"byteOffset" : 576
87+
},
88+
{
89+
"buffer" : 0,
90+
"byteLength" : 72,
91+
"byteOffset" : 768
92+
}
93+
],
94+
"buffers" : [
95+
{
96+
"byteLength" : 840,
97+
"uri" : "data:application/octet-stream;base64,AACAPwAAgD8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/AACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAgPwAAgD4AACA/AAAAPwAAYD8AAAA/AABgPwAAgD4AACA/AAAAAAAAwD4AAAAAAADAPgAAgD4AACA/AACAPgAAID8AAEA/AADAPgAAQD8AAMA+AACAPwAAID8AAIA/AAAAPgAAgD4AAAA+AAAAPwAAwD4AAAA/AADAPgAAgD4AACA/AACAPgAAwD4AAIA+AADAPgAAAD8AACA/AAAAPwAAID8AAAA/AADAPgAAAD8AAMA+AABAPwAAID8AAEA/AAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA"
98+
}
99+
]
100+
}

SDK-simple/models/accesories/acc1.glb

1.25 KB
Binary file not shown.

SDK-simple/models/accesories/acc2.glb

13.4 KB
Binary file not shown.

SDK-simple/models/accesories/acc3.glb

19.3 KB
Binary file not shown.

SDK-simple/models/accesories/acc4.glb

37.7 KB
Binary file not shown.

SDK-simple/models/accesories/acc5.glb

5.17 KB
Binary file not shown.

SDK-simple/models/accesories/acc6.glb

6.66 KB
Binary file not shown.

SDK-simple/models/accesories/acc7.glb

5.32 KB
Binary file not shown.

SDK-simple/models/accesories/acc8.glb

7.37 KB
Binary file not shown.

SDK-simple/models/house.glb

10 KB
Binary file not shown.

SDK-simple/package-lock.json

+78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SDK-simple/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "dcl-project",
3+
"version": "1.0.0",
4+
"description": "My new Decentraland project",
5+
"scripts": {
6+
"start": "dcl start",
7+
"build": "build-ecs",
8+
"watch": "build-ecs --watch",
9+
"deploy:now": "dcl export && now export",
10+
"ecs:install": "npm install --save-dev decentraland-ecs@latest",
11+
"ecs:install-next": "npm install --save-dev decentraland-ecs@next"
12+
},
13+
"devDependencies": {
14+
"decentraland-ecs": "^6.6.5-20210514214922.commit-9e3ae89"
15+
}
16+
}

SDK-simple/scene.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"display": {
3+
"title": "Voxter",
4+
"favicon": "favicon_asset"
5+
},
6+
"contact": {
7+
"name": "Pablo.dcl.eth",
8+
"email": ""
9+
},
10+
"owner": "pablo.dcl.eth",
11+
"scene": {
12+
"parcels": [
13+
"0,0"
14+
],
15+
"base": "0,0"
16+
},
17+
"communications": {
18+
"type": "webrtc",
19+
"signalling": "https://signalling-01.decentraland.org"
20+
},
21+
"policy": {
22+
"contentRating": "E",
23+
"fly": true,
24+
"voiceEnabled": true,
25+
"blacklist": []
26+
},
27+
"requiredPermissions": [],
28+
"main": "bin/game.js",
29+
"tags": [],
30+
"spawnPoints": [
31+
{
32+
"name": "spawn1",
33+
"default": true,
34+
"position": {
35+
"x": 0,
36+
"y": 0,
37+
"z": 0
38+
},
39+
"cameraTarget": {
40+
"x": 8,
41+
"y": 1,
42+
"z": 8
43+
}
44+
}
45+
]
46+
}

SDK-simple/src/game.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {createVoxter} from "../../common/voxter/voxter";
2+
3+
const root = new Entity();
4+
engine.addEntity(root);
5+
6+
const voxter = createVoxter({
7+
position:new Vector3(8,1,8),
8+
rotation:Quaternion.Zero(),
9+
dna:0
10+
});
11+
12+
voxter.setParent(root);

SDK-simple/tsconfig.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"outFile": "./bin/game.js",
4+
"allowJs": true,
5+
"strict": true,
6+
"moduleResolution": "node"
7+
},
8+
"transpileOnly":true,
9+
"include": ["src/game.ts"],
10+
"extends": "./node_modules/decentraland-ecs/types/tsconfig.json"
11+
}

common/lib/decoder.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
export const propertySizes = [64, 64, 7, 9];
2+
export const properties = [
3+
"eye", "mouth", "eye_color", "head"
4+
];
5+
6+
7+
export enum COLOR {
8+
RED,
9+
PINK,
10+
YELLOW,
11+
WHITE,
12+
GREEN,
13+
TURQUOISE,
14+
BLUE
15+
};
16+
17+
export function decode(dna, propertySizes){
18+
const results = [];
19+
20+
let i = 0;
21+
let factor = 1;
22+
while(i < propertySizes.length){
23+
results.push( Math.floor(dna/factor)%propertySizes[i] );
24+
factor = factor * propertySizes[i];
25+
26+
i++;
27+
}
28+
29+
return results;
30+
}
31+
32+
export function maximumNumber(propertySizes){
33+
let i = 0;
34+
let factor = 1;
35+
while(i < propertySizes.length){
36+
factor *= propertySizes[i];
37+
i++
38+
}
39+
return factor-1;
40+
}
41+
42+
export function getDna({eyeIndex, mouthIndex, eyeColorIndex, headIndex}){
43+
return encode(propertySizes, [eyeIndex, mouthIndex, eyeColorIndex, headIndex])
44+
}
45+
46+
export function encode(propertySizes, propertyValues){
47+
let i = 0;
48+
let dna = 0;
49+
let factor = 1;
50+
while(i < propertySizes.length){
51+
dna = dna + ( propertyValues[i] * factor );
52+
factor *= propertySizes[i];
53+
54+
i++;
55+
}
56+
return dna;
57+
}
58+
59+
export function getEncoder(properties, propertySizes){
60+
return function(dna){
61+
const decoded = decode(dna, propertySizes);
62+
return properties.reduce((acc, current, index)=>{
63+
acc[current] = decoded[index];
64+
return acc;
65+
},{});
66+
}
67+
}
68+
69+
//TODO add metadata

0 commit comments

Comments
 (0)