SDK Release 4.1.0

Note: This version of the SDK is now deprecated. You can find the full documentation for this version in the legacy documentation

4.1.1

  • Fixed the method for signing using an ethereum address.
  • Performance improvements.
  • Ambient/sky improvements in preview.
  • Added joystick in mobile view.

4.1.0

  • A few packages have been rebranded:

    • metaverse-api is now decentraland-api
    • metaverse-rpc is now decentraland-rpc
    • metaverse-compiler is now decentraland-compiler

When migrating a scene to 4.1.0, keep in mind that the first lines of the file that import from metaverse-api must be changed to import from decentraland-api.

import * as DCL from "decentraland-api"
import { Vector3Component } from "decentraland-api"
  • The new onClick handler can be added to any entity to handle click events in the same way that React handles clicks. This can greatly simplify scene code, for example:

Old way

import * as DCL from "decentraland-api"

export default class InteractiveCubeScene extends DCL.ScriptableScene {
  state = {
    size: 1,
  }

  sceneDidMount() {
    this.eventSubscriber.on("interactiveBox_click", async () => {
      this.resizeBox()
    })
  }

  resizeBox = () => {
    this.setState({ size: Math.random() * 3 })
  }

  async render() {
    return (
      <scene>
        <box
          id="interactiveBox"
          withCollisions
          scale={this.state.size}
          position={{ x: 5, y: 1, z: 5 }}
        />
      </scene>
    )
  }
}

New way

import * as DCL from "decentraland-api"

export default class InteractiveCubeScene extends DCL.ScriptableScene {
  state = {
    size: 1,
  }

  resizeBox = () => {
    this.setState({ size: Math.random() * 3 })
  }

  async render() {
    return (
      <scene>
        <box
          onClick={this.resizeBox}
          withCollisions
          scale={this.state.size}
          position={{ x: 5, y: 1, z: 5 }}
        />
      </scene>
    )
  }
}

Note that the new way saves you from having to create and subscribe to a click event, and attaching and ID to every element that needs to handle a click. Using this handler, the entity doesn’t require an ID to be clicked. All you need to do is pass a function through an onClick JSX attribute and enjoy!

  • The parcel limits are now inclusive.

Before, entities couldn’t reach the border of the scene’s parcels, you needed to limit positions to something like { x: 9.9, y:1, z: 9.9} in a 1 parcel scene. Now you can position things up to the very limit of the parcels, so on a 1 parcel scene entities can reach { x: 10, y:1, z: 10}

  • Static scenes have better performance

  • A bug was fixed where an entity’s lookAt value couldn’t be the same as the value for position. This was problematic in scenarios where you need a character to move slowly towards a position (with a transition) and look in that direction as it does. Now this scenario is fully supported.

  • Preview scenes have a new lighting configuration. Previous lighting conditions were too bright and didn’t allow the geometry of certain shapes to be seen clearly.

Migrate a scene to 4.1.0

To migrate a scene built with an earlier version to 4.1.0, follow these steps:

  • Delete the file package-lock.json
  • Delete the folder node_modules
  • In scene.tsx, change all imports from metaverse-api to decentraland-api. For example:
import * as DCL from "decentraland-api"
  • Modify the package.json file to change the following:
    • Change metaverse-compiler into decentraland-compiler.
    • Change metaverse-api into decentraland-api.
    • Add "decentraland": "latest" in devDependencies. The file should look something like this:
{
  "name": "dcl-project",
  "version": "1.0.0",
  "description": "My new Decentraland project",
  "scripts": {
    "start": "dcl start",
    "build": "decentraland-compiler build.json",
    "watch": "decentraland-compiler build.json --watch"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "decentraland-api": "latest",
    "decentraland": "latest"
  }
}
  • Run npm install or dcl start to build new versions of package-lock.json and node_modules based on the dependencies of the new version.
  • If your scene included any special dependencies, like Babylon or Axios, install them again with npm.