react-pixi-fiber 1.0.0-beta.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -3
- package/README.md +308 -34
- package/cjs/react-pixi-alias.development.js +31 -12
- package/cjs/react-pixi-alias.production.min.js +1 -1
- package/cjs/react-pixi-alias.production.min.js.map +1 -1
- package/cjs/react-pixi-fiber.development.js +18912 -18154
- package/cjs/react-pixi-fiber.production.min.js +3 -9
- package/cjs/react-pixi-fiber.production.min.js.map +1 -1
- package/es/react-pixi-alias.development.js +33 -0
- package/es/react-pixi-alias.production.min.js +2 -0
- package/es/react-pixi-alias.production.min.js.map +1 -0
- package/es/react-pixi-fiber.development.js +21953 -0
- package/es/react-pixi-fiber.production.min.js +10 -0
- package/es/react-pixi-fiber.production.min.js.map +1 -0
- package/index.d.ts +8 -9
- package/index.es.js +5 -0
- package/index.umd.js +5 -0
- package/package.json +19 -17
- package/src/PixiPropertyOperations.js +39 -5
- package/src/ReactPixiFiber.js +10 -45
- package/src/ReactPixiFiberComponent.js +1 -1
- package/src/ReactPixiFiberUnknownPropertyHook.js +2 -2
- package/src/Stage/common.js +5 -2
- package/src/Stage/hooks.js +9 -3
- package/src/hooks.js +7 -1
- package/src/utils.js +26 -0
- package/umd/react-pixi-alias.development.js +33 -14
- package/umd/react-pixi-alias.production.min.js +1 -1
- package/umd/react-pixi-alias.production.min.js.map +1 -1
- package/umd/react-pixi-fiber.development.js +18917 -18158
- package/umd/react-pixi-fiber.production.min.js +3 -9
- package/umd/react-pixi-fiber.production.min.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,20 +9,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
## [1.0.
|
|
12
|
+
## [1.0.1] - 2022-08-02
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Fixed peer dependencies ([#277])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [1.0.0] - 2022-07-19
|
|
13
19
|
|
|
14
20
|
### Added
|
|
15
21
|
- Added ReactDOM-like prop validation in development ([#47])
|
|
16
22
|
- Add ES format output
|
|
23
|
+
- Added missing `prop-types` dependency ([#221])
|
|
17
24
|
|
|
18
25
|
### Changed
|
|
19
26
|
- Updated build dependencies
|
|
20
27
|
- Updated dev dependencies
|
|
28
|
+
- Changed `Stage` class and function component types to be the same ([#225])
|
|
29
|
+
- Changed Stage to delay destroying PIXI.Application when unmounting
|
|
30
|
+
- Changed usePixiApp to throw an error when used outside of <Stage /> ([#227])
|
|
21
31
|
|
|
22
32
|
### Fixed
|
|
23
33
|
- Fixed type of `oldProps` sent to `customApplyProps` of `CustomPIXIComponent`
|
|
24
34
|
- Fixed hook-based `Stage` to render and rerender synchronously ([#204])
|
|
25
35
|
- Fixed type compatibility with PixiJS v6.0.0 ([#210])
|
|
36
|
+
- Fixed breaking change when undefined values were assigned to props with previously defined values
|
|
26
37
|
|
|
27
38
|
### Removed
|
|
28
39
|
- Removed `performance-now` dependency
|
|
@@ -401,8 +412,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
401
412
|
- Added `<TilingSprite />` component
|
|
402
413
|
|
|
403
414
|
|
|
404
|
-
[Unreleased]: https://github.com/michalochman/react-pixi-fiber/compare/v1.0.
|
|
405
|
-
[1.0.
|
|
415
|
+
[Unreleased]: https://github.com/michalochman/react-pixi-fiber/compare/v1.0.1...HEAD
|
|
416
|
+
[1.0.1]: https://github.com/michalochman/react-pixi-fiber/compare/v1.0.0...v1.0.1
|
|
417
|
+
[1.0.0]: https://github.com/michalochman/react-pixi-fiber/compare/v0.14.3...v1.0.0
|
|
406
418
|
[0.14.2]: https://github.com/michalochman/react-pixi-fiber/compare/v0.14.1...v0.14.2
|
|
407
419
|
[0.14.1]: https://github.com/michalochman/react-pixi-fiber/compare/v0.14.0...v0.14.1
|
|
408
420
|
[0.14.0]: https://github.com/michalochman/react-pixi-fiber/compare/v0.13.2...v0.14.0
|
|
@@ -449,6 +461,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
449
461
|
[0.2.0]: https://github.com/michalochman/react-pixi-fiber/compare/v0.1.1...v0.2.0
|
|
450
462
|
[0.1.1]: https://github.com/michalochman/react-pixi-fiber/compare/v0.1.0...v0.1.1
|
|
451
463
|
|
|
464
|
+
[#277]: https://github.com/michalochman/react-pixi-fiber/pull/277
|
|
465
|
+
[#227]: https://github.com/michalochman/react-pixi-fiber/issues/227
|
|
466
|
+
[#225]: https://github.com/michalochman/react-pixi-fiber/issues/225
|
|
467
|
+
[#221]: https://github.com/michalochman/react-pixi-fiber/issues/221
|
|
452
468
|
[#210]: https://github.com/michalochman/react-pixi-fiber/issues/210
|
|
453
469
|
[#204]: https://github.com/michalochman/react-pixi-fiber/issues/204
|
|
454
470
|
[#196]: https://github.com/michalochman/react-pixi-fiber/issues/196
|
package/README.md
CHANGED
|
@@ -1,23 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ReactPixiFiber is a JavaScript library for writing PixiJS applications using React declarative style in React 16 and
|
|
10
|
-
|
|
11
|
-
For React <16.0.0 see
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img alt="ReactPixiFiber" src="./react-pixi.svg" width="500" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h1>ReactPixiFiber – React Fiber renderer for PixiJS</h1>
|
|
7
|
+
|
|
8
|
+
<p>
|
|
9
|
+
ReactPixiFiber is a JavaScript library for writing <a href="https://pixijs.com/">PixiJS</a> applications using <a href="https://reactjs.org/">React</a> declarative style in React 16 and above.
|
|
10
|
+
<br />
|
|
11
|
+
For React <16.0.0 see <a href="https://github.com/Izzimach/react-pixi">react-pixi</a>.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<a href="https://npmjs.com/package/react-pixi-fiber">
|
|
15
|
+
<img alt="npm" src="https://img.shields.io/npm/v/react-pixi-fiber.svg" />
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/michalochman/react-pixi-fiber/blob/master/LICENSE">
|
|
18
|
+
<img alt="License" src="https://img.shields.io/github/license/michalochman/react-pixi-fiber.svg" />
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://circleci.com/gh/michalochman/react-pixi-fiber/tree/master">
|
|
21
|
+
<img alt="CircleCI" src="https://img.shields.io/circleci/project/github/michalochman/react-pixi-fiber/master.svg" />
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://codecov.io/gh/michalochman/react-pixi-fiber/branch/master">
|
|
24
|
+
<img alt="codecov" src="https://img.shields.io/codecov/c/github/michalochman/react-pixi-fiber/master.svg" />
|
|
25
|
+
</a>
|
|
26
|
+
<a href="
|
|
27
|
+
[![styled with prettier]()](">
|
|
28
|
+
<img alt="styled with prettier" src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" />
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://gitter.im/react-pixi-fiber/Lobby">
|
|
31
|
+
<img alt="gitter" src="https://img.shields.io/gitter/room/react-pixi-fiber/Lobby.svg" />
|
|
32
|
+
</a>
|
|
33
|
+
</div>
|
|
12
34
|
|
|
13
35
|
## Demo
|
|
14
36
|
|
|
15
37
|
See [Rotating Bunny](https://codesandbox.io/s/q7oj1p0jo6) demo.
|
|
16
38
|
|
|
39
|
+
Also, please explore our [CodeSandbox](https://codesandbox.io/) templates:
|
|
40
|
+
* [Hello world using JavaScript](https://codesandbox.io/s/react-pixi-fiber-template-ohk6z)
|
|
41
|
+
* [Hello world using TypeScript](https://codesandbox.io/s/react-pixi-fiber-typescript-template-613ly)
|
|
42
|
+
|
|
43
|
+
and examples:
|
|
44
|
+
* [Rotating Bunny](https://codesandbox.io/s/q7oj1p0jo6)
|
|
45
|
+
* [AnimatedSprite using CustomComponent](https://codesandbox.io/s/react-pixi-fiber-demo-animatedsprite-d6udu)
|
|
46
|
+
* [Aligning texts](https://codesandbox.io/s/react-pixi-fiber-text-alignment-th5eg)
|
|
47
|
+
* [Sharing Redux state](https://codesandbox.io/s/react-pixi-fiber-with-redux-g4k7n)
|
|
48
|
+
* [Using animated](https://codesandbox.io/s/9qyxrljyo)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## 🚀 Migrating from version `0.x.y`? 🚀
|
|
52
|
+
|
|
53
|
+
Read [migration guide](#migrating-from-react-pixi-fiber0xy-before-version-100).
|
|
54
|
+
|
|
55
|
+
## Installing
|
|
56
|
+
|
|
57
|
+
The current version assumes [React] >16.0.0 and [PixiJS] >4.4.0
|
|
58
|
+
|
|
59
|
+
yarn add react-pixi-fiber prop-types pixi.js
|
|
60
|
+
|
|
61
|
+
or
|
|
62
|
+
|
|
63
|
+
npm install react-pixi-fiber prop-types pixi.js --save
|
|
64
|
+
|
|
65
|
+
Refer to next sections to see usage examples.
|
|
66
|
+
|
|
67
|
+
This package works flawlessly with [Create React App](https://github.com/facebookincubator/create-react-app) – see examples below, they already use it.
|
|
17
68
|
|
|
18
69
|
## Usage
|
|
19
70
|
|
|
20
|
-
|
|
71
|
+
<details open>
|
|
72
|
+
<summary>
|
|
73
|
+
<strong>With ReactDOM (React 18 and above)</strong>
|
|
74
|
+
</summary>
|
|
75
|
+
|
|
76
|
+
```jsx harmony
|
|
77
|
+
import { createRoot } from "react-dom/client";
|
|
78
|
+
import { Sprite, Stage } from "react-pixi-fiber";
|
|
79
|
+
import bunny from "./bunny.png";
|
|
80
|
+
|
|
81
|
+
function Bunny (props) {
|
|
82
|
+
return <Sprite texture={PIXI.Texture.from(bunny)} {...props} />;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const container = document.getElementById("container");
|
|
86
|
+
const root = createRoot(container);
|
|
87
|
+
|
|
88
|
+
root.render(
|
|
89
|
+
<Stage options={{ backgroundColor: 0x10bb99, height: 600, width: 800 }}>
|
|
90
|
+
<Bunny x={200} y={200} />
|
|
91
|
+
</Stage>,
|
|
92
|
+
);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
This example will render [`PIXI.Sprite`] object into a [Root Container] of [`PIXI.Application`] on the page.
|
|
96
|
+
|
|
97
|
+
The HTML-like syntax; [called JSX](https://reactjs.org/docs/introducing-jsx.html) is not required to use with this renderer, but it makes code more readable. You can use [Babel](https://babeljs.io/) with a [React preset](https://babeljs.io/docs/plugins/preset-react/) to convert JSX into native JavaScript.
|
|
98
|
+
</details>
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
<details>
|
|
103
|
+
<summary>
|
|
104
|
+
<strong>With ReactDOM (React 16 and 17)</strong>
|
|
105
|
+
</summary>
|
|
21
106
|
|
|
22
107
|
```jsx harmony
|
|
23
108
|
import { render } from "react-dom";
|
|
@@ -28,20 +113,26 @@ function Bunny(props) {
|
|
|
28
113
|
return <Sprite texture={PIXI.Texture.from(bunny)} {...props} />;
|
|
29
114
|
}
|
|
30
115
|
|
|
116
|
+
const container = document.getElementById("container");
|
|
31
117
|
render(
|
|
32
118
|
<Stage options={{ backgroundColor: 0x10bb99, height: 600, width: 800 }}>
|
|
33
119
|
<Bunny x={200} y={200} />
|
|
34
120
|
</Stage>,
|
|
35
|
-
|
|
121
|
+
container
|
|
36
122
|
);
|
|
37
123
|
```
|
|
38
124
|
|
|
39
125
|
This example will render [`PIXI.Sprite`] object into a [Root Container] of [`PIXI.Application`] on the page.
|
|
40
126
|
|
|
41
127
|
The HTML-like syntax; [called JSX](https://reactjs.org/docs/introducing-jsx.html) is not required to use with this renderer, but it makes code more readable. You can use [Babel](https://babeljs.io/) with a [React preset](https://babeljs.io/docs/plugins/preset-react/) to convert JSX into native JavaScript.
|
|
128
|
+
</details>
|
|
42
129
|
|
|
130
|
+
---
|
|
43
131
|
|
|
44
|
-
|
|
132
|
+
<details>
|
|
133
|
+
<summary>
|
|
134
|
+
<strong>Without ReactDOM</strong>
|
|
135
|
+
</summary>
|
|
45
136
|
|
|
46
137
|
```jsx harmony
|
|
47
138
|
import { render, Text } from "react-pixi-fiber";
|
|
@@ -63,6 +154,7 @@ render(
|
|
|
63
154
|
```
|
|
64
155
|
|
|
65
156
|
This example will render [`PIXI.Text`] object into a [Root Container] of PIXI Application (created as `app`) inside the `<canvas id="container"></canvas>` element on the page.
|
|
157
|
+
</details>
|
|
66
158
|
|
|
67
159
|
|
|
68
160
|
## Running Examples
|
|
@@ -73,26 +165,188 @@ This example will render [`PIXI.Text`] object into a [Root Container] of PIXI Ap
|
|
|
73
165
|
4. Wait few seconds and browse examples that will open in new browser window.
|
|
74
166
|
|
|
75
167
|
|
|
76
|
-
##
|
|
168
|
+
## Migrating from `react-pixi-fiber@0.x.y` (before version `1.0.0`)
|
|
77
169
|
|
|
78
|
-
|
|
170
|
+
<details>
|
|
171
|
+
<summary>
|
|
172
|
+
<strong>Changed built-in <code>Stage</code> and the one returned by <code>createStageClass()</code> to have the same API</strong>
|
|
173
|
+
</summary>
|
|
79
174
|
|
|
80
|
-
|
|
175
|
+
It is now possible to get `ref` to built-in `Stage`.
|
|
81
176
|
|
|
82
|
-
|
|
177
|
+
Unless you are using class-based `Stage` component explicitly in your application, for example you are extending it, you should prefer to use built-in `Stage` instead of creating it with `createStageClass()`.
|
|
83
178
|
|
|
84
|
-
|
|
179
|
+
Data available on the `Stage` "instance":
|
|
180
|
+
* `_app` - PIXI.Application instance
|
|
181
|
+
* `_canvas` - HTMLCanvasElement instance
|
|
182
|
+
* `props` - props passed to Stage component
|
|
85
183
|
|
|
86
|
-
|
|
184
|
+
For example:
|
|
185
|
+
```js
|
|
186
|
+
import * as React from "react";
|
|
187
|
+
import { Stage, Text } from "react-pixi-fiber";
|
|
188
|
+
|
|
189
|
+
const width = 600;
|
|
190
|
+
const height = 400;
|
|
191
|
+
const options = {
|
|
192
|
+
backgroundColor: 0x56789a,
|
|
193
|
+
width: width,
|
|
194
|
+
height: height
|
|
195
|
+
};
|
|
196
|
+
const style = {
|
|
197
|
+
width: width,
|
|
198
|
+
height: height
|
|
199
|
+
};
|
|
87
200
|
|
|
201
|
+
function App() {
|
|
202
|
+
const stageRef = React.useRef()
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
// Access PIXI.Application instance
|
|
205
|
+
console.log(stageRef.current?._app.current)
|
|
206
|
+
// Access HTMLCanvasElement instance
|
|
207
|
+
console.log(stageRef.current?._canvas.current)
|
|
208
|
+
// Access props passed to Stage component
|
|
209
|
+
console.log(stageRef.current?.props)
|
|
210
|
+
}, [])
|
|
88
211
|
|
|
89
|
-
|
|
212
|
+
return (
|
|
213
|
+
<Stage options={options} style={style} ref={stageRef}>
|
|
214
|
+
<Text x={100} y={100} text="Hello world!" />
|
|
215
|
+
</Stage>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
</details>
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary>
|
|
225
|
+
<strong>Changed <code>PIXI.Application</code> exposed by <code>Stage</code> to be React <code>ref</code></strong>
|
|
226
|
+
</summary>
|
|
227
|
+
|
|
228
|
+
This is only relevant if you were using `createStageClass()` to create `Stage` component, as it was impossible to get `ref` when using built-in `Stage` as if was a function component, which triggered `Warning: Function components cannot be given refs` error.
|
|
229
|
+
|
|
230
|
+
For example:
|
|
231
|
+
```diff
|
|
232
|
+
import * as React from "react";
|
|
233
|
+
import { createStageClass, Text } from "react-pixi-fiber";
|
|
234
|
+
|
|
235
|
+
const Stage = createStageClass()
|
|
236
|
+
|
|
237
|
+
const width = 600;
|
|
238
|
+
const height = 400;
|
|
239
|
+
const options = {
|
|
240
|
+
backgroundColor: 0x56789a,
|
|
241
|
+
width: width,
|
|
242
|
+
height: height
|
|
243
|
+
};
|
|
244
|
+
const style = {
|
|
245
|
+
width: width,
|
|
246
|
+
height: height
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
function App() {
|
|
250
|
+
const stageRef = React.useRef()
|
|
251
|
+
React.useEffect(() => {
|
|
252
|
+
- console.log(stageRef.current?._app.renderer)
|
|
253
|
+
+ console.log(stageRef.current?._app.current.renderer)
|
|
254
|
+
}, [])
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<Stage options={options} style={style} ref={stageRef}>
|
|
258
|
+
<Text x={100} y={100} text="Hello world!" />
|
|
259
|
+
</Stage>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
</details>
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
<details>
|
|
268
|
+
<summary>
|
|
269
|
+
<strong>Changed <code>oldProps</code> in <code>customApplyProps</code> to not be initialised when the component is first rendered</strong>
|
|
270
|
+
</summary>
|
|
271
|
+
|
|
272
|
+
Make sure to check if `oldProps` is initialised before trying to read properties from it.
|
|
273
|
+
|
|
274
|
+
For example:
|
|
275
|
+
```diff
|
|
276
|
+
import { Container, CustomPIXIComponent } from "react-pixi-fiber"
|
|
277
|
+
|
|
278
|
+
const TYPE = "CustomContainer"
|
|
279
|
+
const behavior = {
|
|
280
|
+
customApplyProps: function (instance, oldProps, newProps) {
|
|
281
|
+
- const { customProp: oldCustomProp, ...otherOldProps } = oldProps
|
|
282
|
+
+ const { customProp: oldCustomProp, ...otherOldProps } = oldProps ?? {}
|
|
283
|
+
const { customProp, ...otherNewProps } = newProps
|
|
284
|
+
if (customProp !== oldCustomProp) {
|
|
285
|
+
// Do something when customProp value have changed
|
|
286
|
+
}
|
|
287
|
+
this.applyDisplayObjectProps(otherOldProps, otherNewProps)
|
|
288
|
+
},
|
|
289
|
+
customDisplayObject: function ({ customProp, ...props }) {
|
|
290
|
+
const container = new PIXI.Container(props)
|
|
291
|
+
if (customProp === "foo") {
|
|
292
|
+
// Do something when customProp is equal to "foo"
|
|
293
|
+
}
|
|
294
|
+
return container
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export default CustomPIXIComponent(behavior, TYPE)
|
|
299
|
+
```
|
|
300
|
+
</details>
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
<details>
|
|
305
|
+
<summary>
|
|
306
|
+
<strong>Changed <code>applyProps</code> to <code>applyDisplayObjectProps</code></strong>
|
|
307
|
+
</summary>
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
`react-pixi-fiber` now needs to know the type of component (e.g. `"Sprite"`) to properly apply the props.
|
|
311
|
+
|
|
312
|
+
For example:
|
|
313
|
+
```diff
|
|
314
|
+
-import { applyProps } from "react-pixi-fiber"
|
|
315
|
+
+import { applyDisplayObjectProps } from "react-pixi-fiber"
|
|
316
|
+
|
|
317
|
+
function ApplyAnimatedValues(instance, props) {
|
|
318
|
+
if (instance instanceof PIXI.DisplayObject) {
|
|
319
|
+
- applyProps(instance, {}, props)
|
|
320
|
+
+ // Component has custom way of applying props - use that
|
|
321
|
+
+ if (typeof instance._customApplyProps === "function") {
|
|
322
|
+
+ instance._customApplyProps(instance, {}, props)
|
|
323
|
+
+ }
|
|
324
|
+
+ // Component doesn't have custom way of applying props - use default way
|
|
325
|
+
+ else {
|
|
326
|
+
+ const type = instance.constructor.name
|
|
327
|
+
+ applyDisplayObjectProps(type, instance, {}, props)
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
return false
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Refer to the implementation, when in doubt:
|
|
336
|
+
* old `applyProps` -> https://github.com/michalochman/react-pixi-fiber/blob/64e8e9f991f51b407f3af108da732e186429454a/src/ReactPixiFiber.js#L43
|
|
337
|
+
* new `applyDisplayObjectProps` -> https://github.com/michalochman/react-pixi-fiber/blob/3a9b71b8d18180117bf70459dd6b4419c5ef1c21/src/ReactPixiFiberComponent.js#L161
|
|
338
|
+
</details>
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Migrating from `react-pixi`
|
|
90
343
|
|
|
91
344
|
It is possible to use React Pixi Fiber as a drop-in replacement for `react-pixi`.
|
|
92
345
|
|
|
93
346
|
There are two options:
|
|
94
347
|
|
|
95
|
-
|
|
348
|
+
<details>
|
|
349
|
+
<summary>Changing <code>import</code> or <code>require</code> statements</summary>
|
|
96
350
|
|
|
97
351
|
Change:
|
|
98
352
|
|
|
@@ -103,28 +357,35 @@ const ReactPIXI = require("react-pixi");
|
|
|
103
357
|
```
|
|
104
358
|
|
|
105
359
|
to:
|
|
106
|
-
|
|
360
|
+
|
|
107
361
|
```js
|
|
108
362
|
import ReactPIXI from "react-pixi-fiber/react-pixi-alias";
|
|
109
363
|
// or
|
|
110
364
|
const ReactPIXI = require("react-pixi-fiber/react-pixi-alias");
|
|
111
365
|
```
|
|
366
|
+
</details>
|
|
112
367
|
|
|
113
|
-
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
<details>
|
|
371
|
+
<summary>Using <code>webpack</code> resolve <code>alias</code></summary>
|
|
114
372
|
|
|
115
373
|
```js
|
|
116
374
|
resolve: {
|
|
117
375
|
alias: {
|
|
118
|
-
|
|
376
|
+
"react-pixi$": "react-pixi-fiber/react-pixi-alias"
|
|
119
377
|
}
|
|
120
378
|
}
|
|
121
379
|
```
|
|
380
|
+
</details>
|
|
381
|
+
|
|
382
|
+
---
|
|
122
383
|
|
|
123
384
|
## API
|
|
124
385
|
|
|
125
386
|
### Components
|
|
126
387
|
|
|
127
|
-
React Pixi Fiber currently supports following components:
|
|
388
|
+
React Pixi Fiber currently supports following components out of the box (but read [Custom Components](#custom-components) section if you need more):
|
|
128
389
|
|
|
129
390
|
#### `<Stage />`
|
|
130
391
|
|
|
@@ -144,7 +405,7 @@ Renders [`PIXI.Graphics`].
|
|
|
144
405
|
|
|
145
406
|
#### `<ParticleContainer />`
|
|
146
407
|
|
|
147
|
-
Renders [`PIXI.particles.ParticleContainer`].
|
|
408
|
+
Renders [`PIXI.ParticleContainer`] (or [`PIXI.particles.ParticleContainer`] if you're using PixiJS 4).
|
|
148
409
|
|
|
149
410
|
#### `<Sprite />`
|
|
150
411
|
|
|
@@ -152,7 +413,7 @@ Renders [`PIXI.Sprite`].
|
|
|
152
413
|
|
|
153
414
|
#### `<TilingSprite />`
|
|
154
415
|
|
|
155
|
-
Renders [`PIXI.extras.TilingSprite`].
|
|
416
|
+
Renders [`PIXI.TilingSprite`] (or [`PIXI.extras.TilingSprite`] if you're using PixiJS 4).
|
|
156
417
|
|
|
157
418
|
#### `<Text />`
|
|
158
419
|
|
|
@@ -160,7 +421,7 @@ Renders [`PIXI.Text`].
|
|
|
160
421
|
|
|
161
422
|
#### `<BitmapText />`
|
|
162
423
|
|
|
163
|
-
Renders [`PIXI.extras.BitmapText`].
|
|
424
|
+
Renders [`PIXI.BitmapText`] (or [`PIXI.extras.BitmapText`] if you're using PixiJS 4).
|
|
164
425
|
|
|
165
426
|
#### `<NineSlicePlane />`
|
|
166
427
|
|
|
@@ -295,6 +556,8 @@ render(
|
|
|
295
556
|
|
|
296
557
|
</details>
|
|
297
558
|
|
|
559
|
+
---
|
|
560
|
+
|
|
298
561
|
<details>
|
|
299
562
|
<summary>
|
|
300
563
|
<strong>Using New Context API directly (with React 16.3.0 and newer)</strong>
|
|
@@ -353,6 +616,8 @@ render(
|
|
|
353
616
|
|
|
354
617
|
</details>
|
|
355
618
|
|
|
619
|
+
---
|
|
620
|
+
|
|
356
621
|
<details>
|
|
357
622
|
<summary>
|
|
358
623
|
<strong>Using Legacy Context API directly (with React older than 16.3.0)</strong>
|
|
@@ -410,6 +675,8 @@ render(
|
|
|
410
675
|
|
|
411
676
|
</details>
|
|
412
677
|
|
|
678
|
+
---
|
|
679
|
+
|
|
413
680
|
### Custom Components
|
|
414
681
|
|
|
415
682
|
ReactPixiFiber can recognize your custom components using API compatible with `react-pixi`.
|
|
@@ -492,11 +759,15 @@ render(
|
|
|
492
759
|
|
|
493
760
|
### Is it production ready?
|
|
494
761
|
|
|
495
|
-
Yes!
|
|
762
|
+
Yes and it's awesome! It is battle tested and backed up by [Kalamba Games](https://kalambagames.com/games/) since the conception in the beginning of 2018 (after [migrating from `react-pixi`](#migrating-from-react-pixi)) and now also used by other game studios.
|
|
496
763
|
|
|
497
764
|
### What version of PixiJS I can use?
|
|
498
765
|
|
|
499
|
-
|
|
766
|
+
PixiJS v4, v5 and v6 are supported.
|
|
767
|
+
|
|
768
|
+
### Can I use it in my TypeScript project?
|
|
769
|
+
|
|
770
|
+
Sure thing! We've got you covered.
|
|
500
771
|
|
|
501
772
|
### Can I use already existing [`PIXI.Application`]?
|
|
502
773
|
|
|
@@ -562,15 +833,18 @@ For making an awesome project structure and documentation that is used in simila
|
|
|
562
833
|
[React]: https://github.com/facebook/react
|
|
563
834
|
[Root Container]: http://pixijs.download/release/docs/PIXI.Application.html#stage
|
|
564
835
|
[`PIXI.Application`]: http://pixijs.download/release/docs/PIXI.Application.html
|
|
836
|
+
[`PIXI.BitmapText`]: http://pixijs.download/release/docs/PIXI.BitmapText.html
|
|
565
837
|
[`PIXI.Container`]: http://pixijs.download/release/docs/PIXI.Container.html
|
|
566
838
|
[`PIXI.DisplayObject`]: http://pixijs.download/release/docs/PIXI.DisplayObject.html
|
|
567
|
-
[`PIXI.extras.BitmapText`]:
|
|
568
|
-
[`PIXI.extras.TilingSprite`]:
|
|
839
|
+
[`PIXI.extras.BitmapText`]: https://pixijs.download/v4.8.8/docs/PIXI.extras.BitmapText.html
|
|
840
|
+
[`PIXI.extras.TilingSprite`]: https://pixijs.download/v4.8.8/docs/PIXI.extras.TilingSprite.html
|
|
569
841
|
[`PIXI.Graphics`]: http://pixijs.download/release/docs/PIXI.Graphics.html
|
|
570
842
|
[`PIXI.NineSlicePlane`]: http://pixijs.download/release/docs/PIXI.NineSlicePlane.html
|
|
571
843
|
[`PIXI.ObservablePoint`]: http://pixijs.download/release/docs/PIXI.ObservablePoint.html
|
|
572
|
-
[`PIXI.
|
|
844
|
+
[`PIXI.ParticleContainer`]: http://pixijs.download/release/docs/PIXI.ParticleContainer.html
|
|
845
|
+
[`PIXI.particles.ParticleContainer`]: https://pixijs.download/v4.8.8/docs/PIXI.particles.ParticleContainer.html
|
|
573
846
|
[`PIXI.Point`]: http://pixijs.download/release/docs/PIXI.Point.html
|
|
574
847
|
[`PIXI.Sprite`]: http://pixijs.download/release/docs/PIXI.Sprite.html
|
|
575
848
|
[`PIXI.Text`]: http://pixijs.download/release/docs/PIXI.Text.html
|
|
849
|
+
[`PIXI.TilingSprite`]: http://pixijs.download/release/docs/PIXI.TilingSprite.html
|
|
576
850
|
[`react-pixi`]: https://github.com/Izzimach/react-pixi
|
|
@@ -7,21 +7,40 @@ var ReactPixiFiber = require('react-pixi-fiber');
|
|
|
7
7
|
|
|
8
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
9
|
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n["default"] = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
29
|
+
var ReactPixiFiber__namespace = /*#__PURE__*/_interopNamespace(ReactPixiFiber);
|
|
11
30
|
|
|
12
31
|
// Note: ReactPIXI.factories is not supported
|
|
13
32
|
|
|
14
|
-
var CustomPIXIComponent =
|
|
15
|
-
var render = ReactDOM__default[
|
|
16
|
-
var unmountComponentAtNode = ReactDOM__default[
|
|
17
|
-
var BitmapText =
|
|
18
|
-
var DisplayObjectContainer =
|
|
19
|
-
var Graphics =
|
|
20
|
-
var ParticleContainer =
|
|
21
|
-
var Sprite =
|
|
22
|
-
var Stage =
|
|
23
|
-
var Text =
|
|
24
|
-
var TilingSprite =
|
|
33
|
+
var CustomPIXIComponent = ReactPixiFiber__namespace.CustomPIXIComponent;
|
|
34
|
+
var render = ReactDOM__default["default"].render;
|
|
35
|
+
var unmountComponentAtNode = ReactDOM__default["default"].unmountComponentAtNode;
|
|
36
|
+
var BitmapText = ReactPixiFiber__namespace.BitmapText;
|
|
37
|
+
var DisplayObjectContainer = ReactPixiFiber__namespace.Container;
|
|
38
|
+
var Graphics = ReactPixiFiber__namespace.Graphics;
|
|
39
|
+
var ParticleContainer = ReactPixiFiber__namespace.ParticleContainer;
|
|
40
|
+
var Sprite = ReactPixiFiber__namespace.Sprite;
|
|
41
|
+
var Stage = ReactPixiFiber__namespace.Stage;
|
|
42
|
+
var Text = ReactPixiFiber__namespace.Text;
|
|
43
|
+
var TilingSprite = ReactPixiFiber__namespace.TilingSprite;
|
|
25
44
|
var ReactPIXI = {
|
|
26
45
|
// Render methods
|
|
27
46
|
CustomPIXIComponent: CustomPIXIComponent,
|
|
@@ -47,6 +66,6 @@ exports.Sprite = Sprite;
|
|
|
47
66
|
exports.Stage = Stage;
|
|
48
67
|
exports.Text = Text;
|
|
49
68
|
exports.TilingSprite = TilingSprite;
|
|
50
|
-
exports
|
|
69
|
+
exports["default"] = ReactPIXI;
|
|
51
70
|
exports.render = render;
|
|
52
71
|
exports.unmountComponentAtNode = unmountComponentAtNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react-dom"),t=require("react-pixi-fiber");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e),n=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react-dom"),t=require("react-pixi-fiber");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=r(e),i=n(t),p=i.CustomPIXIComponent,a=o.default.render,u=o.default.unmountComponentAtNode,s=i.BitmapText,c=i.Container,l=i.Graphics,x=i.ParticleContainer,f=i.Sprite,d=i.Stage,m=i.Text,C=i.TilingSprite,b={CustomPIXIComponent:p,render:a,unmountComponentAtNode:u,BitmapText:s,DisplayObjectContainer:c,Graphics:l,ParticleContainer:x,Sprite:f,Stage:d,Text:m,TilingSprite:C};exports.BitmapText=s,exports.CustomPIXIComponent=p,exports.DisplayObjectContainer=c,exports.Graphics=l,exports.ParticleContainer=x,exports.Sprite=f,exports.Stage=d,exports.Text=m,exports.TilingSprite=C,exports.default=b,exports.render=a,exports.unmountComponentAtNode=u;
|
|
2
2
|
//# sourceMappingURL=react-pixi-alias.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-pixi-alias.production.min.js","sources":["../src/react-pixi-alias/index.js"],"sourcesContent":["import ReactDOM from \"react-dom\";\nimport * as ReactPixiFiber from \"react-pixi-fiber\";\n\n// react-pixi like API\n// Note: ReactPIXI.factories is not supported\n\nexport const CustomPIXIComponent = ReactPixiFiber.CustomPIXIComponent;\nexport const render = ReactDOM.render;\nexport const unmountComponentAtNode = ReactDOM.unmountComponentAtNode;\nexport const BitmapText = ReactPixiFiber.BitmapText;\nexport const DisplayObjectContainer = ReactPixiFiber.Container;\nexport const Graphics = ReactPixiFiber.Graphics;\nexport const ParticleContainer = ReactPixiFiber.ParticleContainer;\nexport const Sprite = ReactPixiFiber.Sprite;\nexport const Stage = ReactPixiFiber.Stage;\nexport const Text = ReactPixiFiber.Text;\nexport const TilingSprite = ReactPixiFiber.TilingSprite;\n\nconst ReactPIXI = {\n // Render methods\n CustomPIXIComponent,\n render,\n unmountComponentAtNode,\n // Components\n BitmapText,\n DisplayObjectContainer,\n Graphics,\n ParticleContainer,\n Sprite,\n Stage,\n Text,\n TilingSprite,\n};\n\nexport default ReactPIXI;\n"],"names":["CustomPIXIComponent","ReactPixiFiber","render","ReactDOM","unmountComponentAtNode","BitmapText","DisplayObjectContainer","Graphics","ParticleContainer","Sprite","Stage","Text","TilingSprite","ReactPIXI"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-pixi-alias.production.min.js","sources":["../src/react-pixi-alias/index.js"],"sourcesContent":["import ReactDOM from \"react-dom\";\nimport * as ReactPixiFiber from \"react-pixi-fiber\";\n\n// react-pixi like API\n// Note: ReactPIXI.factories is not supported\n\nexport const CustomPIXIComponent = ReactPixiFiber.CustomPIXIComponent;\nexport const render = ReactDOM.render;\nexport const unmountComponentAtNode = ReactDOM.unmountComponentAtNode;\nexport const BitmapText = ReactPixiFiber.BitmapText;\nexport const DisplayObjectContainer = ReactPixiFiber.Container;\nexport const Graphics = ReactPixiFiber.Graphics;\nexport const ParticleContainer = ReactPixiFiber.ParticleContainer;\nexport const Sprite = ReactPixiFiber.Sprite;\nexport const Stage = ReactPixiFiber.Stage;\nexport const Text = ReactPixiFiber.Text;\nexport const TilingSprite = ReactPixiFiber.TilingSprite;\n\nconst ReactPIXI = {\n // Render methods\n CustomPIXIComponent,\n render,\n unmountComponentAtNode,\n // Components\n BitmapText,\n DisplayObjectContainer,\n Graphics,\n ParticleContainer,\n Sprite,\n Stage,\n Text,\n TilingSprite,\n};\n\nexport default ReactPIXI;\n"],"names":["CustomPIXIComponent","ReactPixiFiber","render","ReactDOM","unmountComponentAtNode","BitmapText","DisplayObjectContainer","Container","Graphics","ParticleContainer","Sprite","Stage","Text","TilingSprite","ReactPIXI"],"mappings":"sfAMaA,EAAsBC,EAAeD,oBACrCE,EAASC,EAAQ,QAACD,OAClBE,EAAyBD,EAAQ,QAACC,uBAClCC,EAAaJ,EAAeI,WAC5BC,EAAyBL,EAAeM,UACxCC,EAAWP,EAAeO,SAC1BC,EAAoBR,EAAeQ,kBACnCC,EAAST,EAAeS,OACxBC,EAAQV,EAAeU,MACvBC,EAAOX,EAAeW,KACtBC,EAAeZ,EAAeY,aAErCC,EAAY,CAEhBd,oBAAAA,EACAE,OAAAA,EACAE,uBAAAA,EAEAC,WAAAA,EACAC,uBAAAA,EACAE,SAAAA,EACAC,kBAAAA,EACAC,OAAAA,EACAC,MAAAA,EACAC,KAAAA,EACAC,aAAAA"}
|