https://github.com/wonderlandengine/api
Wonderland Engine's JavaScript API.
https://github.com/wonderlandengine/api
Last synced: about 1 year ago
JSON representation
Wonderland Engine's JavaScript API.
- Host: GitHub
- URL: https://github.com/wonderlandengine/api
- Owner: WonderlandEngine
- License: mit
- Created: 2021-05-15T13:48:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T15:59:56.000Z (over 1 year ago)
- Last Synced: 2025-04-09T19:02:04.327Z (about 1 year ago)
- Language: TypeScript
- Size: 949 KB
- Stars: 10
- Watchers: 3
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Wonderland Engine API
The bindings between Wonderland Engine's WebAssembly runtime and custom JavaScript
or TypeScript components.
Learn more about Wonderland Engine at [https://wonderlandengine.com](https://wonderlandengine.com).
> 💡 The Wonderland Engine Runtime is compatible on all patch versions of the API, but the
> major and minor versions are required to match.
>
> **Example:** You will be able to use Wonderland Editor 1.0.4 with API
> version 1.0.0 or 1.0.9 for example, but not with API 1.1.0. 💡
## Usage
Wonderland Engine projects usually come with this package pre-installed.
Install via `npm` or `yarn`:
```sh
npm i --save @wonderlandengine/api
# or:
yarn add @wonderlandengine/api
```
To update the API to the latest version use
```
npm i --save @wonderlandengine/api@latest
```
### Writing a Custom Component
**JavaScript**
```js
import {Component, Property} from '@wonderlandengine/api';
class Forward extends Component {
static TypeName = 'forward';
static Properties = {
speed: Property.float(1.5)
};
_forward = new Float32Array(3);
update(dt) {
this.object.getForward(this._forward);
this._forward[0] *= this.speed*dt;
this._forward[1] *= this.speed*dt;
this._forward[2] *= this.speed*dt;
this.object.translateLocal(this._forward);
}
}
```
**TypeScript**
```ts
import {Component} from '@wonderlandengine/api';
import {Component} from '@wonderlandengine/api/decorators.js';
class Forward extends Component {
static TypeName = 'forward';
@property.float(1.5)
speed!: number;
private _forward = new Float32Array(3);
update(dt) {
this.object.getForward(this._forward);
this._forward[0] *= this.speed*dt;
this._forward[1] *= this.speed*dt;
this._forward[2] *= this.speed*dt;
this.object.translateLocal(this._forward);
}
}
```
For more information, please refer to the [JavaScript Quick Start Guide](https://wonderlandengine.com/getting-started/quick-start-js).
### For Library Maintainers
To ensure the user of your library can use a range of API versions with your library,
use `"peerDependencies"` in your `package.json`:
```json
"peerDependencies": {
"@wonderlandengine/api": ">= 1.0.0 < 2"
},
```
Which signals that your package works with any API version `>= 1.0.0`
(choose the lowest version that provides all features you need) until `2.0.0`.
Also see the [Writing JavaScript Libraries Tutorial](https://wonderlandengine.com/tutorials/writing-js-library/).
## Contributing
* [API code](./packages/api): The `@wonderlandengine/api` source code
* [End2End tests](./packages/test-e2e): User-land testing for the `@wonderlandengine/api` package
### Installation
Make sure to install dependencies first:
```sh
npm i
```
### Build
To build the TypeScript code, use one of:
```sh
cd api
npm run build
npm run build:watch
```
### End-to-End Test
For information about how to run the end-to-end tests, have a look at the
`packages/test-e2e` [README.md](./test/README.md)
## License
Wonderland Engine API TypeScript and JavaScript code is released under MIT license.
The runtime and editor are licensed under the [Wonderland Engine EULA](https://wonderlandengine.com/eula).