Code Monkey home page Code Monkey logo

phaser3-protobuf-atlas's Introduction

Phaser 3 Protobuf Atlas

Encode and Load atlas JSON in more efficient binary format using Protobuf

Pros

  • Reduced file size -> improved load speed
  • Efficient encoding -> faster parse speed

Installation

  npm install phaser3-protobuf-atlas

Usage/Examples

library exposes 4 entries, each tailored to specific use and 1 cli command

atlas-loader

load texture atlas, similar to this.load.atlas

import "phaser3-protobuf-atlas/atlas-loader";

class extends Phaser.Scene {
  ...
  preload() {
    /**
     * Load Protobuf Atlas
     */
    this.load.protobufAtlas("atlas", "image.png", "atlas.bin");
  }
}

multi-atlas-loader

load multi texture atlas, similar to this.load.multiatlas

import "phaser3-protobuf-atlas/mulit-atlas-loader";

class extends Phaser.Scene {
  ...
  preload() {
    /**
     * Load Protobuf Atlas
     */
    this.load.protobufMultiAtlas("atlas", "atlas.bin");
  }
}

encode

encode Atlas JSON into binary protobuf format

import { Encode, EncodeFile } from "phaser3-protobuf-atlas/encode";

EncodeFile("atlas.json", "atlas.bin");
console.log("success!");

protobuf

decode binary data using super minimal protobuf type roots

import { Atlas } from "phaser3-protobuf-atlas/protobuf";

const atlasJSON = Atlas.decode(binaryData);
console.log(atlasJSON);

CLI

encode atlas.json into binary file using cli

encode-protobuf-atlas path/atlas.json path/output

or run with npm through package.json

{
  "scripts": {
    "build": "encode-protobuf-atlas path-to/atlas.json path-to/output"
  }
}

Related

Protobuf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.