0.5.9 • Published 2 years ago

@oasis-engine/tool-atlas v0.5.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

tool-atlas

Atlas tool for oasis engine

Usage in terminal

1、Install

npm i @oasis-engine/tool-atlas -g

2、Use command in terminal

2.1、pack or p

Pack images to atlas

// Pack images to atlas.
oasis-tool-atlas p ./atlas-test/111 -f oasis -o outputName -p 2

// Option help.
oasis-tool-atlas p -h

Options detail

optioninstruction
f/formatthe format for atlas (default: "oasis")
o/outputoutput atlas filename (default: "oasis")
a/algorithmthe algorithm for pack (default: "maxrects")
ar/allowRotatemark whether image allow rotate when pack (default: false)
p/paddingbetween images (default: 1)
mw/maxWidththe texture max width (default: 1024)
mh/maxHeightthe texture max height (default: 1024)
s/squarethe texture size forced square (default: false)
potthe texture size forced power of 2 (default: false)

2.2、formatConversion or fc

Convert other atlas formats to oasis atlas

// Convert other atlas formats to oasis atlas.
oasis-tool-atlas fc -t texture-packer -o oasis-atlas

// Option help.
oasis-tool-atlas fc -h

Options detail

optioninstruction
t/typeatlas format (default: "texture-packer")
o/outputthe name of output (default: "oasis-atlas")

Usage in node project

1、Install

npm i @oasis-engine/tool-atlas --save

2、Call api

const core = require("@oasis-engine/tool-atlas");

// Pack images to atlas.
const imageFiles = [ // the images to pack
  "./",
  "./test.png",
  "https://test/test.png"
];
core.pack(imageFiles, {
  format: 'oasis', // the format for atlas (default: "oasis")
  output: 'oasis', // output atlas filename (default: "oasis")
  algorithm: 'maxrects', // the algorithm for pack (default: "maxrects")
  allowRotate: false, // mark whether image allow rotate when pack (default: false)
  padding: 1, // between images (default: 1)
  maxWidth: 1024, // the texture max width (default: 1024)
  maxHeight: 1024, // the texture max height (default: 1024)
  square: false, // the texture size forced square (default: false)
  pot: false, // the texture size forced power of 2 (default: false)
}).then((ret) => {
  /*
  ret = {
    "code": 0, // return 0 if success
    "msg": '', // if code not 0, msg is the error info
    "info": {
      "imageFile": "", // the absolute path of the image file
      "atlasFile": "", // the absolute path of the atlas file
    }
  }
  */
});

// Convert other atlas formats to oasis atlas.
const filePath = "./test.json"; // the file exported by texture packer
core.formatConversion(filePath, {
  "type": texture-packer, // atlas format
  "output": oasis-atlas // the name of output
});
0.5.9

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.6-alpha.0

3 years ago

0.5.6

3 years ago

0.5.4

3 years ago

0.5.5

3 years ago

0.5.3-alpha.0

3 years ago

0.5.3

3 years ago

0.5.3-alpha.1

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago