@swf2es/player 0.1.0 → 0.1.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.
Files changed (277) hide show
  1. package/package.json +7 -7
  2. package/dist/audio.d.ts +0 -22
  3. package/dist/audio.d.ts.map +0 -1
  4. package/dist/audio.js +0 -106
  5. package/dist/audio.js.map +0 -1
  6. package/dist/bitmap-filters.d.ts +0 -29
  7. package/dist/bitmap-filters.d.ts.map +0 -1
  8. package/dist/bitmap-filters.js +0 -906
  9. package/dist/bitmap-filters.js.map +0 -1
  10. package/dist/bitmap-ops.d.ts +0 -113
  11. package/dist/bitmap-ops.d.ts.map +0 -1
  12. package/dist/bitmap-ops.js +0 -725
  13. package/dist/bitmap-ops.js.map +0 -1
  14. package/dist/bitmap.d.ts +0 -98
  15. package/dist/bitmap.d.ts.map +0 -1
  16. package/dist/bitmap.js +0 -314
  17. package/dist/bitmap.js.map +0 -1
  18. package/dist/bounds.d.ts +0 -26
  19. package/dist/bounds.d.ts.map +0 -1
  20. package/dist/bounds.js +0 -300
  21. package/dist/bounds.js.map +0 -1
  22. package/dist/color.d.ts +0 -7
  23. package/dist/color.d.ts.map +0 -1
  24. package/dist/color.js +0 -42
  25. package/dist/color.js.map +0 -1
  26. package/dist/display.d.ts +0 -425
  27. package/dist/display.d.ts.map +0 -1
  28. package/dist/display.js +0 -1274
  29. package/dist/display.js.map +0 -1
  30. package/dist/drawing.d.ts +0 -52
  31. package/dist/drawing.d.ts.map +0 -1
  32. package/dist/drawing.js +0 -204
  33. package/dist/drawing.js.map +0 -1
  34. package/dist/filters.d.ts +0 -54
  35. package/dist/filters.d.ts.map +0 -1
  36. package/dist/filters.js +0 -155
  37. package/dist/filters.js.map +0 -1
  38. package/dist/fonts.d.ts +0 -23
  39. package/dist/fonts.d.ts.map +0 -1
  40. package/dist/fonts.js +0 -91
  41. package/dist/fonts.js.map +0 -1
  42. package/dist/geometry.d.ts +0 -21
  43. package/dist/geometry.d.ts.map +0 -1
  44. package/dist/geometry.js +0 -76
  45. package/dist/geometry.js.map +0 -1
  46. package/dist/gradients.d.ts +0 -29
  47. package/dist/gradients.d.ts.map +0 -1
  48. package/dist/gradients.js +0 -116
  49. package/dist/gradients.js.map +0 -1
  50. package/dist/images.d.ts +0 -22
  51. package/dist/images.d.ts.map +0 -1
  52. package/dist/images.js +0 -147
  53. package/dist/images.js.map +0 -1
  54. package/dist/input.d.ts +0 -79
  55. package/dist/input.d.ts.map +0 -1
  56. package/dist/input.js +0 -366
  57. package/dist/input.js.map +0 -1
  58. package/dist/keyboard.d.ts +0 -97
  59. package/dist/keyboard.d.ts.map +0 -1
  60. package/dist/keyboard.js +0 -583
  61. package/dist/keyboard.js.map +0 -1
  62. package/dist/morph.d.ts +0 -17
  63. package/dist/morph.d.ts.map +0 -1
  64. package/dist/morph.js +0 -218
  65. package/dist/morph.js.map +0 -1
  66. package/dist/pixi-blend.d.ts +0 -7
  67. package/dist/pixi-blend.d.ts.map +0 -1
  68. package/dist/pixi-blend.js +0 -253
  69. package/dist/pixi-blend.js.map +0 -1
  70. package/dist/pixi-color.d.ts +0 -54
  71. package/dist/pixi-color.d.ts.map +0 -1
  72. package/dist/pixi-color.js +0 -336
  73. package/dist/pixi-color.js.map +0 -1
  74. package/dist/pixi-filters.d.ts +0 -40
  75. package/dist/pixi-filters.d.ts.map +0 -1
  76. package/dist/pixi-filters.js +0 -953
  77. package/dist/pixi-filters.js.map +0 -1
  78. package/dist/pixi-resolve.d.ts +0 -4
  79. package/dist/pixi-resolve.d.ts.map +0 -1
  80. package/dist/pixi-resolve.js +0 -76
  81. package/dist/pixi-resolve.js.map +0 -1
  82. package/dist/pixi.d.ts +0 -219
  83. package/dist/pixi.d.ts.map +0 -1
  84. package/dist/pixi.js +0 -2169
  85. package/dist/pixi.js.map +0 -1
  86. package/dist/playerglobal/flash/filters/filters.d.ts +0 -26
  87. package/dist/playerglobal/flash/filters/filters.d.ts.map +0 -1
  88. package/dist/playerglobal/flash/filters/filters.js +0 -287
  89. package/dist/playerglobal/flash/filters/filters.js.map +0 -1
  90. package/dist/playerglobal/flash/system/FSCommand.d.ts +0 -4
  91. package/dist/playerglobal/flash/system/FSCommand.d.ts.map +0 -1
  92. package/dist/playerglobal/flash/system/FSCommand.js +0 -18
  93. package/dist/playerglobal/flash/system/FSCommand.js.map +0 -1
  94. package/dist/playerglobal/natives.d.ts +0 -10
  95. package/dist/playerglobal/natives.d.ts.map +0 -1
  96. package/dist/playerglobal/natives.js +0 -53
  97. package/dist/playerglobal/natives.js.map +0 -1
  98. package/dist/png.d.ts +0 -4
  99. package/dist/png.d.ts.map +0 -1
  100. package/dist/png.js +0 -140
  101. package/dist/png.js.map +0 -1
  102. package/dist/render/art.d.ts +0 -148
  103. package/dist/render/art.d.ts.map +0 -1
  104. package/dist/render/art.js +0 -575
  105. package/dist/render/art.js.map +0 -1
  106. package/dist/render/batchers.d.ts +0 -23
  107. package/dist/render/batchers.d.ts.map +0 -1
  108. package/dist/render/batchers.js +0 -52
  109. package/dist/render/batchers.js.map +0 -1
  110. package/dist/render/bitmaps.d.ts +0 -117
  111. package/dist/render/bitmaps.d.ts.map +0 -1
  112. package/dist/render/bitmaps.js +0 -422
  113. package/dist/render/bitmaps.js.map +0 -1
  114. package/dist/render/blend.d.ts +0 -37
  115. package/dist/render/blend.d.ts.map +0 -1
  116. package/dist/render/blend.js +0 -195
  117. package/dist/render/blend.js.map +0 -1
  118. package/dist/render/color.d.ts +0 -111
  119. package/dist/render/color.d.ts.map +0 -1
  120. package/dist/render/color.js +0 -533
  121. package/dist/render/color.js.map +0 -1
  122. package/dist/render/compositing.d.ts +0 -77
  123. package/dist/render/compositing.d.ts.map +0 -1
  124. package/dist/render/compositing.js +0 -188
  125. package/dist/render/compositing.js.map +0 -1
  126. package/dist/render/filters.d.ts +0 -98
  127. package/dist/render/filters.d.ts.map +0 -1
  128. package/dist/render/filters.js +0 -1326
  129. package/dist/render/filters.js.map +0 -1
  130. package/dist/render/hooks.d.ts +0 -4
  131. package/dist/render/hooks.d.ts.map +0 -1
  132. package/dist/render/hooks.js +0 -48
  133. package/dist/render/hooks.js.map +0 -1
  134. package/dist/render/node.d.ts +0 -139
  135. package/dist/render/node.d.ts.map +0 -1
  136. package/dist/render/node.js +0 -59
  137. package/dist/render/node.js.map +0 -1
  138. package/dist/render/patches.d.ts +0 -54
  139. package/dist/render/patches.d.ts.map +0 -1
  140. package/dist/render/patches.js +0 -154
  141. package/dist/render/patches.js.map +0 -1
  142. package/dist/render/planes.d.ts +0 -74
  143. package/dist/render/planes.d.ts.map +0 -1
  144. package/dist/render/planes.js +0 -267
  145. package/dist/render/planes.js.map +0 -1
  146. package/dist/render/pointer.d.ts +0 -5
  147. package/dist/render/pointer.d.ts.map +0 -1
  148. package/dist/render/pointer.js +0 -279
  149. package/dist/render/pointer.js.map +0 -1
  150. package/dist/render/pools.d.ts +0 -122
  151. package/dist/render/pools.d.ts.map +0 -1
  152. package/dist/render/pools.js +0 -238
  153. package/dist/render/pools.js.map +0 -1
  154. package/dist/render/resolve.d.ts +0 -4
  155. package/dist/render/resolve.d.ts.map +0 -1
  156. package/dist/render/resolve.js +0 -76
  157. package/dist/render/resolve.js.map +0 -1
  158. package/dist/render/saffron.d.ts +0 -135
  159. package/dist/render/saffron.d.ts.map +0 -1
  160. package/dist/render/saffron.js +0 -725
  161. package/dist/render/saffron.js.map +0 -1
  162. package/dist/render/settle.d.ts +0 -60
  163. package/dist/render/settle.d.ts.map +0 -1
  164. package/dist/render/settle.js +0 -128
  165. package/dist/render/settle.js.map +0 -1
  166. package/dist/render/shared.d.ts +0 -25
  167. package/dist/render/shared.d.ts.map +0 -1
  168. package/dist/render/shared.js +0 -33
  169. package/dist/render/shared.js.map +0 -1
  170. package/dist/render/snapshot.d.ts +0 -21
  171. package/dist/render/snapshot.d.ts.map +0 -1
  172. package/dist/render/snapshot.js +0 -91
  173. package/dist/render/snapshot.js.map +0 -1
  174. package/dist/render/spares.d.ts +0 -56
  175. package/dist/render/spares.d.ts.map +0 -1
  176. package/dist/render/spares.js +0 -160
  177. package/dist/render/spares.js.map +0 -1
  178. package/dist/render/strokes.d.ts +0 -107
  179. package/dist/render/strokes.d.ts.map +0 -1
  180. package/dist/render/strokes.js +0 -448
  181. package/dist/render/strokes.js.map +0 -1
  182. package/dist/render/table.d.ts +0 -213
  183. package/dist/render/table.d.ts.map +0 -1
  184. package/dist/render/table.js +0 -795
  185. package/dist/render/table.js.map +0 -1
  186. package/dist/render/tessellate.d.ts +0 -89
  187. package/dist/render/tessellate.d.ts.map +0 -1
  188. package/dist/render/tessellate.js +0 -386
  189. package/dist/render/tessellate.js.map +0 -1
  190. package/dist/render/text.d.ts +0 -40
  191. package/dist/render/text.d.ts.map +0 -1
  192. package/dist/render/text.js +0 -309
  193. package/dist/render/text.js.map +0 -1
  194. package/dist/render/three.d.ts +0 -83
  195. package/dist/render/three.d.ts.map +0 -1
  196. package/dist/render/three.js +0 -511
  197. package/dist/render/three.js.map +0 -1
  198. package/dist/render/triangles.d.ts +0 -28
  199. package/dist/render/triangles.d.ts.map +0 -1
  200. package/dist/render/triangles.js +0 -189
  201. package/dist/render/triangles.js.map +0 -1
  202. package/dist/render/view.d.ts +0 -238
  203. package/dist/render/view.d.ts.map +0 -1
  204. package/dist/render/view.js +0 -1173
  205. package/dist/render/view.js.map +0 -1
  206. package/dist/render/worker/bitmaps.d.ts +0 -43
  207. package/dist/render/worker/bitmaps.d.ts.map +0 -1
  208. package/dist/render/worker/bitmaps.js +0 -151
  209. package/dist/render/worker/bitmaps.js.map +0 -1
  210. package/dist/render/worker/drawing.d.ts +0 -21
  211. package/dist/render/worker/drawing.d.ts.map +0 -1
  212. package/dist/render/worker/drawing.js +0 -356
  213. package/dist/render/worker/drawing.js.map +0 -1
  214. package/dist/render/worker/filters.d.ts +0 -7
  215. package/dist/render/worker/filters.d.ts.map +0 -1
  216. package/dist/render/worker/filters.js +0 -125
  217. package/dist/render/worker/filters.js.map +0 -1
  218. package/dist/render/worker/frames.d.ts +0 -32
  219. package/dist/render/worker/frames.d.ts.map +0 -1
  220. package/dist/render/worker/frames.js +0 -124
  221. package/dist/render/worker/frames.js.map +0 -1
  222. package/dist/render/worker/host.d.ts +0 -60
  223. package/dist/render/worker/host.d.ts.map +0 -1
  224. package/dist/render/worker/host.js +0 -297
  225. package/dist/render/worker/host.js.map +0 -1
  226. package/dist/render/worker/libraries.d.ts +0 -36
  227. package/dist/render/worker/libraries.d.ts.map +0 -1
  228. package/dist/render/worker/libraries.js +0 -153
  229. package/dist/render/worker/libraries.js.map +0 -1
  230. package/dist/render/worker/presentation.d.ts +0 -18
  231. package/dist/render/worker/presentation.d.ts.map +0 -1
  232. package/dist/render/worker/presentation.js +0 -47
  233. package/dist/render/worker/presentation.js.map +0 -1
  234. package/dist/render/worker/renderer.d.ts +0 -4
  235. package/dist/render/worker/renderer.d.ts.map +0 -1
  236. package/dist/render/worker/renderer.js +0 -21
  237. package/dist/render/worker/renderer.js.map +0 -1
  238. package/dist/render/worker/scene.d.ts +0 -32
  239. package/dist/render/worker/scene.d.ts.map +0 -1
  240. package/dist/render/worker/scene.js +0 -611
  241. package/dist/render/worker/scene.js.map +0 -1
  242. package/dist/render/worker/text.d.ts +0 -47
  243. package/dist/render/worker/text.d.ts.map +0 -1
  244. package/dist/render/worker/text.js +0 -261
  245. package/dist/render/worker/text.js.map +0 -1
  246. package/dist/render/worker/thread.d.ts +0 -23
  247. package/dist/render/worker/thread.d.ts.map +0 -1
  248. package/dist/render/worker/thread.js +0 -107
  249. package/dist/render/worker/thread.js.map +0 -1
  250. package/dist/render/worker/values.d.ts +0 -18
  251. package/dist/render/worker/values.d.ts.map +0 -1
  252. package/dist/render/worker/values.js +0 -64
  253. package/dist/render/worker/values.js.map +0 -1
  254. package/dist/sha256.d.ts +0 -5
  255. package/dist/sha256.d.ts.map +0 -1
  256. package/dist/sha256.js +0 -96
  257. package/dist/sha256.js.map +0 -1
  258. package/dist/shapes.d.ts +0 -71
  259. package/dist/shapes.d.ts.map +0 -1
  260. package/dist/shapes.js +0 -340
  261. package/dist/shapes.js.map +0 -1
  262. package/dist/static-text.d.ts +0 -33
  263. package/dist/static-text.d.ts.map +0 -1
  264. package/dist/static-text.js +0 -105
  265. package/dist/static-text.js.map +0 -1
  266. package/dist/text-layout.d.ts +0 -66
  267. package/dist/text-layout.d.ts.map +0 -1
  268. package/dist/text-layout.js +0 -315
  269. package/dist/text-layout.js.map +0 -1
  270. package/dist/text.d.ts +0 -67
  271. package/dist/text.d.ts.map +0 -1
  272. package/dist/text.js +0 -383
  273. package/dist/text.js.map +0 -1
  274. package/dist/timeline.d.ts +0 -150
  275. package/dist/timeline.d.ts.map +0 -1
  276. package/dist/timeline.js +0 -266
  277. package/dist/timeline.js.map +0 -1
@@ -1,74 +0,0 @@
1
- import type { Container as PixiContainer, Renderer } from "pixi.js";
2
- import type { DisplayObject } from "../display/display.js";
3
- import type { Node } from "./node.js";
4
- import { Plane } from "./three.js";
5
- /** The view's 3D objects: their planes, and the outside masks they let go of. */
6
- export declare class Planes {
7
- private readonly renderer;
8
- /** The view's nodes by their objects, and by their containers. */
9
- private readonly objectNodes;
10
- private readonly containerNodes;
11
- /**
12
- * `o` synced again at its plane's units, for one drawn at other units than its content was
13
- * made for: its lines and filters made again for them.
14
- */
15
- private readonly resync;
16
- /** The nodes of 3D objects, each drawn into its bitmap before the stage is drawn (`render`). */
17
- private readonly nodes;
18
- /**
19
- * The outside masks planes let go of in this sync (`letGo`), which Pixi puts back in the
20
- * build: those still another's mask are taken out again after it (`rebuildMasks`).
21
- */
22
- private readonly droppedMasks;
23
- /** render's scratch, the 3D objects to draw, deepest first. */
24
- private readonly order;
25
- constructor(renderer: Renderer,
26
- /** The view's nodes by their objects, and by their containers. */
27
- objectNodes: WeakMap<DisplayObject, Node>, containerNodes: WeakMap<PixiContainer, Node>,
28
- /**
29
- * `o` synced again at its plane's units, for one drawn at other units than its content was
30
- * made for: its lines and filters made again for them.
31
- */
32
- resync: (o: DisplayObject, node: Node) => void);
33
- /** Whether there are no 3D objects to draw. */
34
- get empty(): boolean;
35
- /** Every plane let go of, as a fresh view is disposed of. */
36
- dropAll(): void;
37
- /**
38
- * What a 3D object is drawn by in its parent, its quad, which takes its
39
- * container's place, the container going into the plane's holder; and
40
- * the container again for one no longer drawn in 3D. A mask set on it
41
- * clips its content in its bitmap (Plane.maskWith).
42
- */
43
- of(o: DisplayObject, node: Node, three: boolean, redrawn: boolean): PixiContainer;
44
- /**
45
- * A 3D object's blend mode put on its quad, which Flash composites with what is behind it, not
46
- * on its content within its bitmap: the blend's filters, or the GPU's own blending, from the
47
- * node's state, as compositing.ts may change them outside a sync. Its filters' chain draws
48
- * their result into the bitmap as it is, the quad blending it (`three-d-filter-blend`).
49
- */
50
- blendQuad(node: Node, plane: Plane): void;
51
- /** A 3D object's plane let go of, its container on no list. */
52
- drop(node: Node): void;
53
- /** `mask`, a plane's outside mask before a change, noted where the plane has let go of it. */
54
- private letGo;
55
- /**
56
- * The masks planes let go of in this sync kept out of the build where they still mask
57
- * another object: Pixi puts a mask back as any that held it lets go, which may come after
58
- * the next holder took it, as when a mask goes from one 3D object to another before it in
59
- * the list (`three-d-mask-handover`).
60
- */
61
- rebuildMasks(): void;
62
- /**
63
- * Each 3D object's quad placed by its plane in perspective, which moves
64
- * as anything above it does, and its bitmap drawn again where it may
65
- * have changed: those in another first, as the other's bitmap draws
66
- * their quads. One with a corner behind the eye is not drawn.
67
- */
68
- render(onStage: number): void;
69
- /** The units of the bitmap of the nearest 3D object above `o`, which its quad is drawn into. */
70
- private unitsAbove;
71
- /** The bitmap of the nearest 3D object above `o` marked to be drawn again. */
72
- private restaleAbove;
73
- }
74
- //# sourceMappingURL=planes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planes.d.ts","sourceRoot":"","sources":["../../src/render/planes.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAe,SAAS,IAAI,aAAa,EAAE,QAAQ,EAAE,MAAM,SA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,8FAA8F;IAC9F,OAAO,CAAC,KAAK;IAMb;;;;;OAKG;IACH,YAAY,IAAI,IAAI,CAQnB;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CA0E5B;IAED,gGAAgG;IAChG,OAAO,CAAC,UAAU;IAUlB,8EAA8E;IAC9E,OAAO,CAAC,YAAY;CAYrB"}
@@ -1,267 +0,0 @@
1
- import { filterRect } from "../bitmap/filters.js";
2
- import { bounds, toStage } from "../display/bounds.js";
3
- import { apply, concat } from "../display/geometry.js";
4
- import { blendFilters } from "./blend.js";
5
- import { FilterChain } from "./filters.js";
6
- import { Plane, SAMPLES } from "./three.js";
7
- /**
8
- * The map from the space of `mask`, a 2D mask outside the 3D object `o`, to
9
- * `o`'s, as Flash clips the bitmap it draws `o` into: the mask is placed by
10
- * its matrices up to the nearest 3D object above it (or the stage), and then
11
- * moved as if the bitmap's corner, `o`'s bounds' top left in its own space,
12
- * were where `o`'s bounds' top left is on the stage. So a mask over a turned
13
- * card clips a part of the card that is not under it (the `three-d-mask` case).
14
- */
15
- function outsideMaskMap(o, mask) {
16
- let m = mask.placed;
17
- for (let p = mask.parent; p && !p.space; p = p.parent) {
18
- m = concat(m, p.placed);
19
- }
20
- const own = bounds(o, true) ?? { xMin: 0, yMin: 0, xMax: 0, yMax: 0 };
21
- const up = toStage(o, null);
22
- let left = Number.POSITIVE_INFINITY;
23
- let top = Number.POSITIVE_INFINITY;
24
- for (let i = 0; i < 4; i++) {
25
- const [x, y] = apply(up, i & 1 ? own.xMax : own.xMin, i & 2 ? own.yMax : own.yMin);
26
- left = Math.min(left, x);
27
- top = Math.min(top, y);
28
- }
29
- return {
30
- a: m.a,
31
- b: m.b,
32
- c: m.c,
33
- d: m.d,
34
- tx: m.tx + own.xMin - Math.round(left),
35
- ty: m.ty + own.yMin - Math.round(top),
36
- };
37
- }
38
- /** The view's 3D objects: their planes, and the outside masks they let go of. */
39
- export class Planes {
40
- renderer;
41
- objectNodes;
42
- containerNodes;
43
- resync;
44
- /** The nodes of 3D objects, each drawn into its bitmap before the stage is drawn (`render`). */
45
- nodes = new Set();
46
- /**
47
- * The outside masks planes let go of in this sync (`letGo`), which Pixi puts back in the
48
- * build: those still another's mask are taken out again after it (`rebuildMasks`).
49
- */
50
- droppedMasks = [];
51
- /** render's scratch, the 3D objects to draw, deepest first. */
52
- order = [];
53
- constructor(renderer,
54
- /** The view's nodes by their objects, and by their containers. */
55
- objectNodes, containerNodes,
56
- /**
57
- * `o` synced again at its plane's units, for one drawn at other units than its content was
58
- * made for: its lines and filters made again for them.
59
- */
60
- resync) {
61
- this.renderer = renderer;
62
- this.objectNodes = objectNodes;
63
- this.containerNodes = containerNodes;
64
- this.resync = resync;
65
- }
66
- /** Whether there are no 3D objects to draw. */
67
- get empty() {
68
- return this.nodes.size === 0;
69
- }
70
- /** Every plane let go of, as a fresh view is disposed of. */
71
- dropAll() {
72
- for (const node of this.nodes) {
73
- this.drop(node);
74
- }
75
- }
76
- /**
77
- * What a 3D object is drawn by in its parent, its quad, which takes its
78
- * container's place, the container going into the plane's holder; and
79
- * the container again for one no longer drawn in 3D. A mask set on it
80
- * clips its content in its bitmap (Plane.maskWith).
81
- */
82
- of(o, node, three, redrawn) {
83
- const { container } = node;
84
- let plane = node.plane;
85
- if (!three) {
86
- const quad = plane?.quad;
87
- const parent = quad?.parent;
88
- if (quad && parent) {
89
- parent.addChildAt(container, parent.getChildIndex(quad));
90
- }
91
- this.drop(node);
92
- // Its chain blends it again, as a 2D object's does.
93
- const chain = node.filters[0];
94
- if (chain instanceof FilterChain) {
95
- chain.blendOver(node.directBlend ?? "normal");
96
- }
97
- return container;
98
- }
99
- if (!plane) {
100
- plane = new Plane();
101
- node.plane = plane;
102
- this.nodes.add(node);
103
- }
104
- const quad = plane.quad;
105
- if (container.parent !== plane.holder) {
106
- const parent = container.parent;
107
- if (parent) {
108
- parent.addChildAt(quad, parent.getChildIndex(container));
109
- }
110
- plane.holder.addChild(container);
111
- }
112
- this.blendQuad(node, plane);
113
- // A 2D mask in the object clips its content in its bitmap, as on a 2D object; one outside it
114
- // clips the bitmap too, put there by Flash's rule (`render`). The view's clip() has just set
115
- // the mask's container on the object's, where it set one.
116
- const set = container.mask;
117
- if (set !== plane.maskCopy) {
118
- const before = plane.outsideMask;
119
- plane.maskWith(container, set && o.mask && !o.encloses(o.mask) ? set : null);
120
- this.letGo(before, plane);
121
- }
122
- plane.stale ||= redrawn;
123
- return quad;
124
- }
125
- /**
126
- * A 3D object's blend mode put on its quad, which Flash composites with what is behind it, not
127
- * on its content within its bitmap: the blend's filters, or the GPU's own blending, from the
128
- * node's state, as compositing.ts may change them outside a sync. Its filters' chain draws
129
- * their result into the bitmap as it is, the quad blending it (`three-d-filter-blend`).
130
- */
131
- blendQuad(node, plane) {
132
- const { container } = node;
133
- const filters = container.filters;
134
- if (filters && filters.length > node.filters.length) {
135
- container.filters = node.filters.length > 0 ? node.filters : null;
136
- }
137
- const chain = node.filters[0];
138
- if (chain instanceof FilterChain) {
139
- chain.blendOver("normal");
140
- }
141
- const blending = node.directBlend === null ? blendFilters(node.blend) : null;
142
- if (blending !== plane.blending) {
143
- plane.blending = blending;
144
- plane.quad.filters = blending;
145
- }
146
- plane.quad.blendMode = node.directBlend ?? "inherit";
147
- container.blendMode = "inherit";
148
- }
149
- /** A 3D object's plane let go of, its container on no list. */
150
- drop(node) {
151
- const plane = node.plane;
152
- if (!plane) {
153
- return;
154
- }
155
- const before = plane.outsideMask;
156
- plane.destroy(node.container);
157
- this.letGo(before, plane);
158
- node.plane = null;
159
- this.nodes.delete(node);
160
- }
161
- /** `mask`, a plane's outside mask before a change, noted where the plane has let go of it. */
162
- letGo(mask, plane) {
163
- if (mask && plane.outsideMask !== mask) {
164
- this.droppedMasks.push(mask);
165
- }
166
- }
167
- /**
168
- * The masks planes let go of in this sync kept out of the build where they still mask
169
- * another object: Pixi puts a mask back as any that held it lets go, which may come after
170
- * the next holder took it, as when a mask goes from one 3D object to another before it in
171
- * the list (`three-d-mask-handover`).
172
- */
173
- rebuildMasks() {
174
- for (const mask of this.droppedMasks) {
175
- if (this.containerNodes.get(mask)?.owner.deref()?.maskOf) {
176
- mask.includeInBuild = false;
177
- }
178
- }
179
- this.droppedMasks.length = 0;
180
- }
181
- /**
182
- * Each 3D object's quad placed by its plane in perspective, which moves
183
- * as anything above it does, and its bitmap drawn again where it may
184
- * have changed: those in another first, as the other's bitmap draws
185
- * their quads. One with a corner behind the eye is not drawn.
186
- */
187
- render(onStage) {
188
- const drawn = this.order;
189
- drawn.length = 0;
190
- for (const node of this.nodes) {
191
- const o = node.owner.deref();
192
- if (!o || !node.plane) {
193
- this.drop(node);
194
- continue;
195
- }
196
- if (node.released) {
197
- continue;
198
- }
199
- let depth = 0;
200
- for (let p = o.parent; p; p = p.parent) {
201
- depth += p.space ? 1 : 0;
202
- }
203
- drawn.push({ depth, node, o });
204
- }
205
- drawn.sort((a, b) => b.depth - a.depth);
206
- for (const { depth, node, o } of drawn) {
207
- const plane = node.plane;
208
- // What it draws is measured again only when it may have changed, as its bitmap is drawn.
209
- if (plane.stale || plane.drawnRect === undefined) {
210
- const r = bounds(o, true, true);
211
- let rect = r && { x: r.xMin, y: r.yMin, width: r.xMax - r.xMin, height: r.yMax - r.yMin };
212
- for (const f of node.filterRecords) {
213
- rect = rect && filterRect(rect, f);
214
- }
215
- plane.drawnRect = rect;
216
- }
217
- const rect = plane.drawnRect;
218
- let shown = false;
219
- // A 3D mask on a 3D object leaves nothing of it drawn in Flash.
220
- if (rect && node.container.visible && !o.mask?.space) {
221
- shown = plane.place(o.placed, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, depth > 0 ? this.unitsAbove(o) : onStage);
222
- }
223
- plane.changed ||= plane.quad.visible !== shown;
224
- plane.quad.visible = shown;
225
- if (shown) {
226
- if (plane.outsideMask && o.mask) {
227
- plane.placeMask(outsideMaskMap(o, o.mask));
228
- }
229
- plane.draw(this.renderer);
230
- // Drawn at other units than its content was made for, as an object grown past what the
231
- // GPU or the budget takes at full samples: its lines and filters made again for them.
232
- if (plane.units !== plane.syncedUnits) {
233
- this.resync(o, node);
234
- plane.draw(this.renderer);
235
- }
236
- }
237
- // Its quad is drawn into the bitmap of the 3D object it is in, which then shows it as it is
238
- // now: its plane there moves as that object turns, which changes nothing in it.
239
- if (depth > 0 && plane.changed) {
240
- this.restaleAbove(o);
241
- }
242
- plane.changed = false;
243
- }
244
- }
245
- /** The units of the bitmap of the nearest 3D object above `o`, which its quad is drawn into. */
246
- unitsAbove(o) {
247
- for (let p = o.parent; p; p = p.parent) {
248
- if (p.space) {
249
- return this.objectNodes.get(p)?.plane?.units ?? SAMPLES;
250
- }
251
- }
252
- return SAMPLES;
253
- }
254
- /** The bitmap of the nearest 3D object above `o` marked to be drawn again. */
255
- restaleAbove(o) {
256
- for (let p = o.parent; p; p = p.parent) {
257
- if (p.space) {
258
- const plane = this.objectNodes.get(p)?.plane;
259
- if (plane) {
260
- plane.stale = true;
261
- }
262
- return;
263
- }
264
- }
265
- }
266
- }
267
- //# sourceMappingURL=planes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planes.js","sourceRoot":"","sources":["../../src/render/planes.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,CAAgB,EAAE,IAAmB;IAC3D,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACpB,KAAK,IAAI,CAAC,GA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ainer, type Renderer } from "pixi.js";
2
- import type { Player } from "../player.js";
3
- /** Let Pixi normalize browser coordinates; Flash's display list chooses the target. */
4
- export declare function bindPointer(renderer: Renderer, stage: PixiContainer, player: Player): () => void;
5
- //# sourceMappingURL=pointer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/render/pointer.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,SAAS,IAAI,aAAa,EAE/B,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA0E3C,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAuOhG"}
@@ -1,279 +0,0 @@
1
- // The pointer, touches and wheel on the canvas, taken to the player's stage:
2
- // Pixi's events normalize the browser's, and Flash's display list, not
3
- // Pixi's, chooses the target (PixiView.bindPointer).
4
- import { Rectangle, } from "pixi.js";
5
- /**
6
- * Where a pointer event is on the SWF's stage. CSS `object-fit` shows the
7
- * canvas's pixels in a box of their own within its content box, letterboxed
8
- * by `contain`, cropped by `cover`: Pixi maps a point over the whole element
9
- * as `fill` would, so the point is taken within that box instead, centred
10
- * as the default `object-position` puts it, and then from the canvas's
11
- * pixels to Pixi's screen and the stage. `style` is the canvas's live
12
- * computed style, null where there is no DOM. A `size`, a touch's
13
- * contact, comes back in stage units after the point.
14
- */
15
- function stagePoint(renderer, player, e, style, size = { width: 0, height: 0 }) {
16
- const screen = renderer.screen;
17
- const toStage = (x, y, w, h) => [
18
- (x * player.width) / screen.width,
19
- (y * player.height) / screen.height,
20
- (w * player.width) / screen.width,
21
- (h * player.height) / screen.height,
22
- ];
23
- const canvas = renderer.canvas;
24
- if (!canvas?.getBoundingClientRect || !style) {
25
- return toStage(e.global.x, e.global.y, size.width, size.height);
26
- }
27
- // The content box: the element's rectangle within its borders and padding.
28
- const px = (v) => Number.parseFloat(v ?? "") || 0;
29
- const rect = canvas.getBoundingClientRect();
30
- let left = rect.left + px(style.borderLeftWidth) + px(style.paddingLeft);
31
- let top = rect.top + px(style.borderTopWidth) + px(style.paddingTop);
32
- const width = rect.width -
33
- px(style.borderLeftWidth) -
34
- px(style.paddingLeft) -
35
- px(style.borderRightWidth) -
36
- px(style.paddingRight);
37
- const height = rect.height -
38
- px(style.borderTopWidth) -
39
- px(style.paddingTop) -
40
- px(style.borderBottomWidth) -
41
- px(style.paddingBottom);
42
- let sx = width / canvas.width;
43
- let sy = height / canvas.height;
44
- const fit = style.objectFit;
45
- if (fit === "contain" || fit === "scale-down" || fit === "cover" || fit === "none") {
46
- let scale = fit === "cover" ? Math.max(sx, sy) : fit === "none" ? 1 : Math.min(sx, sy);
47
- if (fit === "scale-down") {
48
- scale = Math.min(scale, 1);
49
- }
50
- left += (width - canvas.width * scale) / 2;
51
- top += (height - canvas.height * scale) / 2;
52
- sx = scale;
53
- sy = scale;
54
- }
55
- const resolution = renderer.resolution || 1;
56
- return toStage((e.clientX - left) / sx / resolution, (e.clientY - top) / sy / resolution, size.width / sx / resolution, size.height / sy / resolution);
57
- }
58
- /** Let Pixi normalize browser coordinates; Flash's display list chooses the target. */
59
- export function bindPointer(renderer, stage, player) {
60
- stage.eventMode = "static";
61
- stage.hitArea = new Rectangle(0, 0, renderer.screen.width, renderer.screen.height);
62
- // The stage is Pixi's only target: its hit test would otherwise search
63
- // every child on each move, which on a crowded display list made each
64
- // frame a third longer while the mouse moved.
65
- const interactiveChildren = stage.interactiveChildren;
66
- stage.interactiveChildren = false;
67
- // A move is posted, handled when the player next advances or before the
68
- // next press, release, leave or key; a frame callback of its own handles
69
- // it where the host does not advance (a paused player, say).
70
- let frame = 0;
71
- const canvas = renderer.canvas;
72
- // Live: read once, it follows the element's style as the page changes it.
73
- const style = canvas?.getBoundingClientRect && typeof getComputedStyle === "function"
74
- ? getComputedStyle(canvas)
75
- : null;
76
- const flushSoon = () => {
77
- frame ||= requestAnimationFrame(() => {
78
- frame = 0;
79
- player.pointer?.flush();
80
- player.touch?.flush();
81
- });
82
- };
83
- // Each touch's last point, which a cancel, whose own may be anywhere, ends at.
84
- const touches = new Map();
85
- // A touch goes to the player's touches, which move the mouse for the primary one.
86
- const touched = (type, e) => {
87
- const touch = player.touch;
88
- // A lifted finger leaves the canvas too: the mouse it moved stays, as Flash's does.
89
- if (!touch || type === "leave") {
90
- return;
91
- }
92
- const [x, y, width, height] = stagePoint(renderer, player, e, style, e);
93
- const t = {
94
- x,
95
- y,
96
- id: e.pointerId,
97
- primary: e.isPrimary,
98
- width,
99
- height,
100
- pressure: e.pressure,
101
- altKey: e.altKey,
102
- ctrlKey: e.ctrlKey,
103
- shiftKey: e.shiftKey,
104
- time: e.timeStamp,
105
- };
106
- if (type === "up") {
107
- touches.delete(t.id);
108
- }
109
- else {
110
- touches.set(t.id, t);
111
- }
112
- if (type === "move" && typeof requestAnimationFrame === "function") {
113
- touch.post(t);
114
- flushSoon();
115
- return;
116
- }
117
- touch.handle(type === "down" ? "begin" : type === "up" ? "end" : "move", t);
118
- };
119
- const send = (type) => (e) => {
120
- if (e.pointerType === "touch") {
121
- touched(type, e);
122
- return;
123
- }
124
- const [x, y] = stagePoint(renderer, player, e, style);
125
- const p = {
126
- x,
127
- y,
128
- button: e.button,
129
- buttons: e.buttons,
130
- altKey: e.altKey,
131
- ctrlKey: e.ctrlKey,
132
- shiftKey: e.shiftKey,
133
- time: e.timeStamp,
134
- };
135
- if (type === "move" && player.pointer && typeof requestAnimationFrame === "function") {
136
- player.pointer.post(p);
137
- flushSoon();
138
- return;
139
- }
140
- player.pointer?.handle(type, p);
141
- };
142
- const moved = send("move");
143
- const down = send("down");
144
- const up = send("up");
145
- const leave = send("leave");
146
- // Every move on the page: one over the canvas, and, while the mouse's
147
- // button is down after a press on it, one anywhere, as Flash keeps the
148
- // mouse until the release.
149
- const screen = renderer.screen;
150
- // A release outside after a press that held the mouse leaves it at the
151
- // next move outside, as Flash's mouseLeave comes.
152
- let leaveNext = false;
153
- const move = (e) => {
154
- const { x, y } = e.global;
155
- const inside = x >= 0 && y >= 0 && x < screen.width && y < screen.height;
156
- if (inside || (e.pointerType !== "touch" && player.pointer?.captured)) {
157
- leaveNext = false;
158
- moved(e);
159
- }
160
- else if (leaveNext && e.pointerType !== "touch") {
161
- leaveNext = false;
162
- leave(e);
163
- }
164
- };
165
- const upOutside = (e) => {
166
- const held = e.pointerType !== "touch" && !!player.pointer?.captured;
167
- up(e);
168
- leaveNext ||= held && !player.pointer?.captured;
169
- };
170
- stage.on("globalpointermove", move);
171
- stage.on("pointerdown", down);
172
- stage.on("pointerup", up);
173
- stage.on("pointerupoutside", upOutside);
174
- stage.on("pointerleave", leave);
175
- // Pixi listens for no cancel: the browser takes a touch back so, as for a
176
- // system gesture, and the touch ends where it last was, without its tap or click.
177
- const cancel = (e) => {
178
- const t = touches.get(e.pointerId);
179
- if (t && e.pointerType === "touch") {
180
- touches.delete(t.id);
181
- player.touch?.handle("cancel", { ...t, time: e.timeStamp });
182
- }
183
- };
184
- canvas?.addEventListener?.("pointercancel", cancel);
185
- // The wheel in Flash's lines, up positive: 3 a notch, Flash's delta on
186
- // Windows. A browser gives a notch as 3 lines, or as about 100 pixels,
187
- // fewer where the page is zoomed or the screen scaled, and several at
188
- // once as their multiple; a touchpad's few pixels at a time add up, 100
189
- // to 3 lines. The page scrolls unless the SWF takes the wheel where the
190
- // pointer is. With Ctrl, as a touchpad's pinch comes too, the page zooms
191
- // and the SWF hears nothing. Pixi listens passively.
192
- let lines = 0;
193
- const wheel = (e) => {
194
- const pointer = player.pointer;
195
- if (!pointer || e.deltaY === 0 || e.ctrlKey) {
196
- return;
197
- }
198
- const size = Math.abs(e.deltaY);
199
- if (e.deltaMode !== 0) {
200
- lines = -e.deltaY * (e.deltaMode === 2 ? 3 : 1);
201
- }
202
- else if (size >= 50) {
203
- lines = -Math.sign(e.deltaY) * 3 * Math.max(1, Math.round(size / 100));
204
- }
205
- else {
206
- lines -= (e.deltaY * 3) / 100;
207
- }
208
- const delta = Math.trunc(lines);
209
- lines -= delta;
210
- const at = { clientX: e.clientX, clientY: e.clientY, global: { x: e.offsetX, y: e.offsetY } };
211
- const [x, y] = stagePoint(renderer, player, at, style);
212
- const p = {
213
- x,
214
- y,
215
- buttons: e.buttons,
216
- altKey: e.altKey,
217
- shiftKey: e.shiftKey,
218
- time: e.timeStamp,
219
- };
220
- if (pointer.wheel(p, delta)) {
221
- e.preventDefault();
222
- }
223
- };
224
- canvas?.addEventListener?.("wheel", wheel, { passive: false });
225
- // Pixi sets the canvas's cursor on every move, from its target's, which
226
- // is this stage: the player's cursor goes there, and through Pixi's own
227
- // setter now, which keeps Pixi's record of it right.
228
- const events = renderer.events;
229
- // Pixi's "default" is "inherit", which shows the page's cursor where the
230
- // page sets one; Flash's arrow, auto's or a forced one, is the arrow.
231
- const pixiDefault = events?.cursorStyles.default;
232
- if (events) {
233
- events.cursorStyles.default = "default";
234
- }
235
- const show = (cursor) => {
236
- stage.cursor = cursor;
237
- if (events) {
238
- events.setCursor(cursor);
239
- }
240
- else if (canvas?.style) {
241
- canvas.style.cursor = cursor;
242
- }
243
- };
244
- const pointer = player.pointer;
245
- if (pointer) {
246
- pointer.onCursor = show;
247
- show(pointer.cursor());
248
- }
249
- return () => {
250
- // Pixi's own default back first, then the canvas left to it, as before the bind.
251
- if (events) {
252
- events.cursorStyles.default = pixiDefault;
253
- }
254
- if (pointer) {
255
- pointer.onCursor = null;
256
- stage.cursor = "default";
257
- if (canvas?.style) {
258
- canvas.style.cursor = "";
259
- }
260
- }
261
- if (frame) {
262
- cancelAnimationFrame(frame);
263
- frame = 0;
264
- }
265
- player.pointer?.flush();
266
- player.touch?.flush();
267
- canvas?.removeEventListener?.("pointercancel", cancel);
268
- canvas?.removeEventListener?.("wheel", wheel);
269
- stage.off("globalpointermove", move);
270
- stage.off("pointerdown", down);
271
- stage.off("pointerup", up);
272
- stage.off("pointerupoutside", upOutside);
273
- stage.off("pointerleave", leave);
274
- stage.eventMode = "passive";
275
- stage.hitArea = null;
276
- stage.interactiveChildren = interactiveChildren;
277
- };
278
- }
279
- //# sourceMappingURL=pointer.js.map