How to use the decentraland-ecs.Transform 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 / public / test-scenes / -100.234-injected-mappings / game.ts View on Github external
import { engine, Entity, GLTFShape, Transform } from 'decentraland-ecs'

const shape = new GLTFShape('AnimatedCube.gltf')

const gltf = new Entity()
const transform = new Transform()

transform.position.set(5, 1, 5)

gltf.addComponent(transform)
gltf.addComponent(shape)

engine.addEntity(gltf)
github decentraland / builder / src / ecsScene / scene.ts View on Github external
function createComponent(component: AnyComponent, scene: Scene) {
  const { id, type, data } = component

  if (!getComponentById(id)) {
    switch (type) {
      case ComponentType.GLTFShape: {
        const { assetId } = data as ComponentData[ComponentType.GLTFShape]
        const asset = scene.assets[assetId]
        const url = `${assetId}/${asset.model}`
        editorComponents[id] = new GLTFShape(url)
        editorComponents[id].isPickable = true
        break
      }
      case ComponentType.Transform:
        editorComponents[id] = new Transform()
        break
      case ComponentType.NFTShape:
        editorComponents[id] = new NFTShape((data as ComponentData[ComponentType.NFTShape]).url)
        editorComponents[id].isPickable = true
        break
      case ComponentType.Script: {
        const { assetId, values } = data as ComponentData[ComponentType.Script]
        const asset = scene.assets[assetId]
        const src = asset.contents[asset.script!]
        editorComponents[id] = new Script(assetId, src, values)
        if (!scriptPromises.has(assetId)) {
          const url = `${scriptBaseUrl}/${src}`
          const promise = fetch(url).then(resp => resp.text())
          scriptPromises.set(assetId, promise)
        }
        break