|
| 1 | +## Description |
| 2 | + |
| 3 | +This project is an additional drawing target to Pixi.js (pixijs.com) that adds pxscene drawing in addition to WebGL and Canvas2D. |
| 4 | + |
| 5 | + |
| 6 | +Pixi.js Patch apply |
| 7 | +============== |
| 8 | +### Build pixi |
| 9 | + |
| 10 | +(1) Clone the pixi project |
| 11 | +``` |
| 12 | +git clone https://github.com/pixijs/pixi.js.git |
| 13 | +cd pixi.js |
| 14 | +git checkout bed84b9ff04cf98c536401d36841d447b74917fe |
| 15 | +``` |
| 16 | + |
| 17 | +(2) Copy /pxscene_pixi.patch into the repository folder (pixi.js) and patch |
| 18 | +``` |
| 19 | +git apply pxscene_pixi.patch |
| 20 | +``` |
| 21 | + |
| 22 | +(3) Install dependencies and build pixi |
| 23 | +``` |
| 24 | +npm i |
| 25 | +npm run dist -- --exclude deprecation |
| 26 | +``` |
| 27 | + |
| 28 | +The pixi will be built and generated in pixi.js/dist |
| 29 | + |
| 30 | +## Install pxscene |
| 31 | + |
| 32 | +pxscene can be downloaded from http://pxscene.org |
| 33 | + |
| 34 | +## Deployment |
| 35 | + |
| 36 | +Two separate projects are available: |
| 37 | +- pxPixi: for hosting pixi.js and assets (https://github.com/topcoderinc/pxPixi) |
| 38 | +- pxPixi-examples: the other for hosting examples (https://github.com/topcoderinc/pxPixi-examples) |
| 39 | + |
| 40 | +The deployment instructions are easy, switch to just type the following command: |
| 41 | +``` |
| 42 | +git init |
| 43 | +git add . |
| 44 | +git commit -m "init" |
| 45 | +heroku create |
| 46 | +git push heroku master |
| 47 | +``` |
| 48 | + |
| 49 | +**Note**: |
| 50 | +(1) If you modified and built pixi.js, please copy pixi.js/dist/* to /pixi-server/dist/pixi and update it on Heroku. |
| 51 | +(2) When you have deployed <submission>/pixi-server to Heroku, you should replace `ASSET_URL` in /example-server/dist/.js (all the example files) to the host URL of pixi-server. And also note that use the protocol to `http://` instead of `https://`. |
| 52 | + |
| 53 | + |
| 54 | +## Heroku examples |
| 55 | + |
| 56 | +- Basic: http://pxscene-pixi-examples.herokuapp.com//basic.js |
| 57 | +- Container: http://pxscene-pixi-examples.herokuapp.com/container.js |
| 58 | +- Container Pivot: http://pxscene-pixi-examples.herokuapp.com/container-pivot.js |
| 59 | +- Spritesheet Animation: http://pxscene-pixi-examples.herokuapp.com/spritesheet.js |
| 60 | +- Click: http://pxscene-pixi-examples.herokuapp.com/click.js |
| 61 | +- Tiling Sprite: http://pxscene-pixi-examples.herokuapp.com/tiling-sprite.js |
| 62 | +- Text: http://pxscene-pixi-examples.herokuapp.com/text.js |
| 63 | + |
| 64 | +Local example files are located in /example-server/dist/ |
| 65 | + |
| 66 | +Open pxscene and enter the URL of each example to the input box and press return, you will see the results. |
| 67 | + |
| 68 | +## Limitations |
| 69 | + |
| 70 | +(1) When hover on clickable object, the cursor cannot be changed in pxscene. |
| 71 | +(2) Pxscene text doesn't support stroke and gradient color. The shadow doesn't support blue effect. |
| 72 | +(3) Pxscene text doesn't support to use font family name directly. Instead, we need to design a font URL to it. So we cannot assign `BOLD` or `ITALIC` style to the text. |
| 73 | + |
| 74 | +For complying with the given text usage, I added a map to mapping fontFamily names to the font URL. Please check the pixi.js/text/TextV8.js |
| 75 | + |
| 76 | +``` |
| 77 | +// Map: font family name -> fontUrl |
| 78 | +// Set key lowercase |
| 79 | +const fontFamilyUrlMap = { |
| 80 | + dejavusans: 'http://www.pxscene.org/examples/px-reference/fonts/DejaVuSans.ttf', |
| 81 | + arial: 'http://www.pxscene.org/examples/px-reference/fonts/DejaVuSans.ttf', |
| 82 | +}; |
| 83 | +``` |
| 84 | +Currently, it only supports Arial and DejaVuSans. |
| 85 | + |
| 86 | + |
| 87 | +## Remarks |
| 88 | +(1) If you use the example in Heroku, you may need to wait several seconds for the resource downloading. |
| 89 | +(2) For showing text, you may still need to wait several seconds because the font URL is remote. |
| 90 | +(3) The updated pixi.js supports both browsers and pxscene. |
0 commit comments