How to use the decentraland-ecs/src.BoxShape function in decentraland-ecs

To help you get started, we’ve selected a few decentraland-ecs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github decentraland / explorer / kernel / public / test-scenes / 0.102.attachables / game.ts View on Github external
import { Entity, engine, Vector3, Transform, BoxShape, Material, Color3, Attachable } from 'decentraland-ecs/src'

// This entity will rotate with the camera, when in first person mode
const followTheCamera = new Entity()
followTheCamera.addComponent(new BoxShape())
followTheCamera.addComponent(new Transform({
  position: new Vector3(1, 0, 1),
  scale: new Vector3(0.5, 0.5, 2)
}))
engine.addEntity(followTheCamera)
followTheCamera.setParent(Attachable.PLAYER)

// This entity will follow the avatar, and remain unaffected by the camera rotation
const followAvatar = new Entity()
followAvatar.addComponent(new BoxShape())
followAvatar.addComponent(new Transform({
  position: new Vector3(0, 0, 0.5),
  scale: new Vector3(0.5, 0.5, 0.5)
}))
const material = new Material()
material.albedoColor = Color3.FromHexString('#FF00FF')
material.metallic = 0.2
material.roughness = 1.0
followAvatar.addComponent(material)
engine.addEntity(followAvatar)
followAvatar.setParent(Attachable.AVATAR_POSITION)
github decentraland / explorer / kernel / public / test-scenes / 0.21.audio-streaming / game.ts View on Github external
import { Entity, engine, Transform, Vector3, OnClick, BoxShape, AudioStream } from 'decentraland-ecs/src'

const cube = new Entity()
cube.addComponent(new BoxShape())
cube.addComponent(new Transform({ position: new Vector3(8, 1, 8) }))

const audioStream = new AudioStream('https://radiotopfm2.turadioonline.xyz/stream')
audioStream.playing = false
cube.addComponent(audioStream)

cube.addComponent(
  new OnClick(() => {
    audioStream.playing = !audioStream.playing
  })
)

engine.addEntity(cube)