Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: avatar shape test scene #22

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dcl-workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
{
"path": "scenes/5,90-scene-bounds-check"
},
{
"path": "scenes/4,20-avatar-shape"
},
{
"path": "scenes/30,20-pointer-events-feedback"
},
Expand Down
13 changes: 13 additions & 0 deletions scenes/4,20-avatar-shape/.dclignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.*
package.json
package-lock.json
yarn-lock.json
build.json
export
tsconfig.json
tslint.json
node_modules
*.ts
*.tsx
Dockerfile
dist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scenes/4,20-avatar-shape/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test scene shows how to configure avatar shapes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions scenes/4,20-avatar-shape/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "avatar-shapes-test",
"description": "ECS7 ",
"version": "1.0.0",
"dependencies": {
"@dcl/js-runtime": "7.6.5-11672040830.commit-680459b",
"@dcl/sdk": "^7.6.5-11672040830.commit-680459b"
},
"scripts": {
"build": "sdk-commands build --skip-install",
"deploy": "sdk-commands deploy",
"start": "sdk-commands start"
}
}
50 changes: 50 additions & 0 deletions scenes/4,20-avatar-shape/scene.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"ecs7": true,
"runtimeVersion": "7",
"display": {
"title": "avatar shapes test scene",
"description": "avatar shapes test scene",
"navmapThumbnail": "images/scene-thumbnail.png",
"favicon": "favicon_asset"
},
"owner": "",
"contact": {
"name": "sdk-team",
"email": ""
},
"main": "bin/game.js",
"tags": [],
"spawnPoints": [
{
"name": "spawn1",
"default": true,
"position": {
"x": [
0,
3
],
"y": [
0,
0
],
"z": [
0,
3
]
},
"cameraTarget": {
"x": 8,
"y": 1,
"z": 8
}
}
],
"featureToggles": {},
"scene": {
"base": "4,20",
"parcels": [
"4,20"
]
},
"name": "avatar shapes test scene"
}
66 changes: 66 additions & 0 deletions scenes/4,20-avatar-shape/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Vector3, Color4, Quaternion } from '@dcl/sdk/math'
import { engine, ColliderLayer, AvatarShape, Transform, MeshRenderer, MeshCollider, pointerEventsSystem, InputAction } from '@dcl/sdk/ecs'

const avatarShapeSpawner1 = engine.addEntity()
MeshRenderer.setBox(avatarShapeSpawner1)
MeshCollider.setBox(avatarShapeSpawner1, ColliderLayer.CL_POINTER)
Transform.create(avatarShapeSpawner1, { position: Vector3.create(7, 1, 4), scale: Vector3.create(0.5, 0.5, 0.5) })
pointerEventsSystem.onPointerDown(
{ entity: avatarShapeSpawner1, opts: { button: InputAction.IA_POINTER, hoverText: 'spawn avatar 1', maxDistance: 5 } },
() => {
const avatarShapeEntity1 = engine.addEntity()
Transform.create(avatarShapeEntity1, {
position: Vector3.create(7, 0.1, 8),
rotation: Quaternion.fromEulerDegrees(0, 180, 0)
})
AvatarShape.create(avatarShapeEntity1, {
wearables: [
"urn:decentraland:off-chain:base-avatars:eyebrows_00",
"urn:decentraland:off-chain:base-avatars:mouth_00",
"urn:decentraland:off-chain:base-avatars:eyes_00",
"urn:decentraland:off-chain:base-avatars:blue_tshirt",
"urn:decentraland:off-chain:base-avatars:brown_pants",
"urn:decentraland:off-chain:base-avatars:classic_shoes",
"urn:decentraland:off-chain:base-avatars:cornrows"
],
id: "dagon-id",
name: "Dagon",
bodyShape: "urn:decentraland:off-chain:base-avatars:BaseMale",
hairColor: { "r": 0.9281997, "g": 0.997558951, "b": 0.715044141 },
skinColor: { "r": 0.78, "g": 0.53, "b": 0.26 },
emotes: []
})
}
)

const avatarShapeSpawner2 = engine.addEntity()
MeshRenderer.setBox(avatarShapeSpawner2)
MeshCollider.setBox(avatarShapeSpawner2, ColliderLayer.CL_POINTER)
Transform.create(avatarShapeSpawner2, { position: Vector3.create(10, 1, 4), scale: Vector3.create(0.5, 0.5, 0.5) })
pointerEventsSystem.onPointerDown(
{ entity: avatarShapeSpawner2, opts: { button: InputAction.IA_POINTER, hoverText: 'spawn avatar 2', maxDistance: 5 } },
() => {
const avatarShapeEntity2 = engine.addEntity()
Transform.create(avatarShapeEntity2, {
position: Vector3.create(10, 0.1, 8),
rotation: Quaternion.fromEulerDegrees(0, 180, 0)
})
AvatarShape.create(avatarShapeEntity2, {
wearables: [
"urn:decentraland:off-chain:base-avatars:eyebrows_00",
"urn:decentraland:off-chain:base-avatars:mouth_00",
"urn:decentraland:off-chain:base-avatars:eyes_00",
"urn:decentraland:ethereum:collections-v1:xmas_2019:santa_facial_hair",
"urn:decentraland:matic:collections-v2:0x4334a820f556a54845a35f8aad5986aecdf07d43:1",
"urn:decentraland:matic:collections-v2:0x3a53afcd4f3a40953fa1217a56265909bb2f6309:0",
"urn:decentraland:ethereum:collections-v1:sugarclub_yumi:yumi_retro_shades_eyewear",
"urn:decentraland:matic:collections-v2:0x4334a820f556a54845a35f8aad5986aecdf07d43:0"
],
id: "cthulhu-id",
name: "Cthulhu",
hairColor: Color4.Red(),
skinColor: Color4.Green(),
emotes: []
})
}
)
11 changes: 11 additions & 0 deletions scenes/4,20-avatar-shape/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"allowJs": true,
"strict": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"extends": "@dcl/sdk/types/tsconfig.ecs7.json"
}
Loading