@eva/plugin-renderer-render-texture 2.1.0-beta.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/README.md +11 -0
- package/dist/EVA.plugin.renderer.render.texture.js +545 -0
- package/dist/EVA.plugin.renderer.render.texture.min.js +1 -0
- package/dist/plugin-renderer-render-texture.cjs.js +493 -0
- package/dist/plugin-renderer-render-texture.cjs.prod.js +1 -0
- package/dist/plugin-renderer-render-texture.d.ts +167 -0
- package/dist/plugin-renderer-render-texture.esm.js +488 -0
- package/index.js +7 -0
- package/package.json +27 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var eva_js = require('@eva/eva.js');
|
|
6
|
+
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
7
|
+
var pluginRenderer = require('@eva/plugin-renderer');
|
|
8
|
+
var pixi_js = require('pixi.js');
|
|
9
|
+
|
|
10
|
+
/******************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
|
|
25
|
+
function __decorate(decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function __metadata(metadataKey, metadataValue) {
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
47
|
+
var e = new Error(message);
|
|
48
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* RenderTexture component.
|
|
53
|
+
*
|
|
54
|
+
* Equivalent of Phaser RenderTexture / DynamicTexture. Holds a Pixi RenderTexture
|
|
55
|
+
* underneath and lets the DSL declaratively enqueue draw ops via `ops`.
|
|
56
|
+
*
|
|
57
|
+
* Mutating `ops` (or any of the simple props) replays the queue.
|
|
58
|
+
*/
|
|
59
|
+
class RenderTexture extends eva_js.Component {
|
|
60
|
+
constructor() {
|
|
61
|
+
super(...arguments);
|
|
62
|
+
this.width = 256;
|
|
63
|
+
this.height = 256;
|
|
64
|
+
this.ops = [];
|
|
65
|
+
this.backgroundColor = -1;
|
|
66
|
+
this.backgroundAlpha = 1;
|
|
67
|
+
this.append = true;
|
|
68
|
+
/** Bumped by clear()/fill()/etc. so the system can detect imperative changes. */
|
|
69
|
+
this.dirty = 0;
|
|
70
|
+
}
|
|
71
|
+
init(obj) {
|
|
72
|
+
if (obj)
|
|
73
|
+
Object.assign(this, obj);
|
|
74
|
+
if (!Array.isArray(this.ops))
|
|
75
|
+
this.ops = [];
|
|
76
|
+
}
|
|
77
|
+
/** Append an op + mark dirty (works at runtime, not just init). */
|
|
78
|
+
addOp(op) {
|
|
79
|
+
this.ops = [...this.ops, op];
|
|
80
|
+
this.dirty++;
|
|
81
|
+
}
|
|
82
|
+
/** Clear the queue (and the texture next commit). */
|
|
83
|
+
clearOps() {
|
|
84
|
+
this.ops = [{ type: 'clear' }];
|
|
85
|
+
this.dirty++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
RenderTexture.componentName = 'RenderTexture';
|
|
89
|
+
__decorate([
|
|
90
|
+
inspectorDecorator.type('number'),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], RenderTexture.prototype, "width", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
inspectorDecorator.type('number'),
|
|
95
|
+
__metadata("design:type", Number)
|
|
96
|
+
], RenderTexture.prototype, "height", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
inspectorDecorator.type('array'),
|
|
99
|
+
__metadata("design:type", Array)
|
|
100
|
+
], RenderTexture.prototype, "ops", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
inspectorDecorator.type('number'),
|
|
103
|
+
__metadata("design:type", Number)
|
|
104
|
+
], RenderTexture.prototype, "backgroundColor", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
inspectorDecorator.type('number'),
|
|
107
|
+
__metadata("design:type", Number)
|
|
108
|
+
], RenderTexture.prototype, "backgroundAlpha", void 0);
|
|
109
|
+
|
|
110
|
+
const FRAME_SEP = '#'; // resource name separator: `myAtlas#frame.png`
|
|
111
|
+
let RenderTextureSystem = class RenderTextureSystem extends pluginRenderer.Renderer {
|
|
112
|
+
constructor() {
|
|
113
|
+
super(...arguments);
|
|
114
|
+
this.name = 'RenderTexture';
|
|
115
|
+
this.records = {};
|
|
116
|
+
}
|
|
117
|
+
init() {
|
|
118
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
119
|
+
this.renderSystem.rendererManager.register(this);
|
|
120
|
+
}
|
|
121
|
+
rendererUpdate(gameObject) {
|
|
122
|
+
const record = this.records[gameObject.id];
|
|
123
|
+
if (!record)
|
|
124
|
+
return;
|
|
125
|
+
if (record.needsReplay) {
|
|
126
|
+
record.needsReplay = false;
|
|
127
|
+
// fire-and-forget: replay is async (loads textures). next frame will see updated RT.
|
|
128
|
+
this.replay(gameObject.id);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
componentChanged(changed) {
|
|
132
|
+
var _a, _b, _c, _d;
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
if (changed.componentName !== 'RenderTexture')
|
|
135
|
+
return;
|
|
136
|
+
const component = changed.component;
|
|
137
|
+
const gameObjectId = changed.gameObject.id;
|
|
138
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
139
|
+
const rt = pixi_js.RenderTexture.create({
|
|
140
|
+
width: Math.max(1, component.width || 1),
|
|
141
|
+
height: Math.max(1, component.height || 1),
|
|
142
|
+
resolution: 1,
|
|
143
|
+
});
|
|
144
|
+
const sprite = new pixi_js.Sprite(rt);
|
|
145
|
+
// Force sprite display rect to match component.width/height (in design units)
|
|
146
|
+
// so the RT shows at intended logical size regardless of devicePixelRatio.
|
|
147
|
+
sprite.width = component.width;
|
|
148
|
+
sprite.height = component.height;
|
|
149
|
+
this.containerManager.getContainer(gameObjectId).addChildAt(sprite, 0);
|
|
150
|
+
this.records[gameObjectId] = { rt, sprite, component, lastSig: '', needsReplay: true };
|
|
151
|
+
// schedule replay for next frame so PIXI Application & renderer are ready.
|
|
152
|
+
this.maybeSave(gameObjectId);
|
|
153
|
+
}
|
|
154
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
155
|
+
const record = this.records[gameObjectId];
|
|
156
|
+
if (!record)
|
|
157
|
+
return;
|
|
158
|
+
record.component = component;
|
|
159
|
+
// Resize when width/height changed
|
|
160
|
+
if (record.rt.width !== component.width || record.rt.height !== component.height) {
|
|
161
|
+
try {
|
|
162
|
+
(_b = (_a = record.rt).resize) === null || _b === void 0 ? void 0 : _b.call(_a, Math.max(1, component.width), Math.max(1, component.height));
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
// ignore
|
|
166
|
+
}
|
|
167
|
+
record.sprite.width = component.width;
|
|
168
|
+
record.sprite.height = component.height;
|
|
169
|
+
}
|
|
170
|
+
record.needsReplay = true;
|
|
171
|
+
this.maybeSave(gameObjectId);
|
|
172
|
+
}
|
|
173
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
174
|
+
const record = this.records[gameObjectId];
|
|
175
|
+
if (!record)
|
|
176
|
+
return;
|
|
177
|
+
(_d = (_c = this.containerManager) === null || _c === void 0 ? void 0 : _c.getContainer(gameObjectId)) === null || _d === void 0 ? void 0 : _d.removeChild(record.sprite);
|
|
178
|
+
record.sprite.destroy({ children: true });
|
|
179
|
+
record.rt.destroy(true);
|
|
180
|
+
delete this.records[gameObjectId];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/** Resolve a resource name (optionally with `#frame` suffix) → Texture. */
|
|
185
|
+
resolveTexture(name, explicitFrame) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
if (!name)
|
|
188
|
+
return null;
|
|
189
|
+
let resName = name;
|
|
190
|
+
let frame = explicitFrame;
|
|
191
|
+
if (!frame && name.includes(FRAME_SEP)) {
|
|
192
|
+
const idx = name.indexOf(FRAME_SEP);
|
|
193
|
+
resName = name.slice(0, idx);
|
|
194
|
+
frame = name.slice(idx + 1);
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const { instance } = yield eva_js.resource.getResource(resName);
|
|
198
|
+
if (!instance)
|
|
199
|
+
return null;
|
|
200
|
+
// sprite atlas: instance is a frames map
|
|
201
|
+
if (frame) {
|
|
202
|
+
if (instance && instance[frame] instanceof pixi_js.Texture) {
|
|
203
|
+
return instance[frame];
|
|
204
|
+
}
|
|
205
|
+
// Sometimes instance has `.textures[frame]`
|
|
206
|
+
const textures = instance.textures;
|
|
207
|
+
if (textures && textures[frame] instanceof pixi_js.Texture) {
|
|
208
|
+
return textures[frame];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (instance instanceof pixi_js.Texture)
|
|
212
|
+
return instance;
|
|
213
|
+
// sprite atlas single texture access
|
|
214
|
+
if (instance.baseTexture)
|
|
215
|
+
return instance;
|
|
216
|
+
// grab first frame as fallback
|
|
217
|
+
if (typeof instance === 'object') {
|
|
218
|
+
const keys = Object.keys(instance);
|
|
219
|
+
for (const k of keys) {
|
|
220
|
+
const v = instance[k];
|
|
221
|
+
if (v instanceof pixi_js.Texture)
|
|
222
|
+
return v;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
catch (_a) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/** Build an offscreen Pixi DisplayObject describing the op, then render it into the RT. */
|
|
233
|
+
replay(gameObjectId) {
|
|
234
|
+
var _a, _b, _c, _d, _e, _f;
|
|
235
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
const record = this.records[gameObjectId];
|
|
237
|
+
if (!record)
|
|
238
|
+
return;
|
|
239
|
+
const { rt, component } = record;
|
|
240
|
+
const sig = `${component.dirty}|${(_b = (_a = component.ops) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0}|${component.width}|${component.height}`;
|
|
241
|
+
if (record.lastSig === sig && component.append) ;
|
|
242
|
+
record.lastSig = sig;
|
|
243
|
+
const renderer = (_c = this.renderSystem.application) === null || _c === void 0 ? void 0 : _c.renderer;
|
|
244
|
+
if (!renderer)
|
|
245
|
+
return;
|
|
246
|
+
// Build a single staging Container that aggregates this commit's ops.
|
|
247
|
+
const stage = new pixi_js.Container();
|
|
248
|
+
// Optional background (fill RT with color, replacing previous content)
|
|
249
|
+
const bg = component.backgroundColor;
|
|
250
|
+
const bgA = (_d = component.backgroundAlpha) !== null && _d !== void 0 ? _d : 1;
|
|
251
|
+
if (!component.append) {
|
|
252
|
+
const g = new pixi_js.Graphics();
|
|
253
|
+
if (bg != null && bg >= 0) {
|
|
254
|
+
g.rect(0, 0, component.width, component.height).fill({ color: bg, alpha: bgA });
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// transparent clear
|
|
258
|
+
g.rect(0, 0, component.width, component.height).fill({ color: 0x000000, alpha: 0 });
|
|
259
|
+
}
|
|
260
|
+
stage.addChild(g);
|
|
261
|
+
}
|
|
262
|
+
for (const op of component.ops || []) {
|
|
263
|
+
const node = yield this.buildOpNode(op);
|
|
264
|
+
if (node)
|
|
265
|
+
stage.addChild(node);
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
// Pixi v8 render-to-target API
|
|
269
|
+
renderer.render({
|
|
270
|
+
container: stage,
|
|
271
|
+
target: rt,
|
|
272
|
+
clear: !component.append,
|
|
273
|
+
});
|
|
274
|
+
// eslint-disable-next-line no-console
|
|
275
|
+
if (globalThis.__RT_DEBUG) {
|
|
276
|
+
console.log('[RT] replayed', {
|
|
277
|
+
ops: (_e = component.ops) === null || _e === void 0 ? void 0 : _e.length,
|
|
278
|
+
w: rt.width,
|
|
279
|
+
h: rt.height,
|
|
280
|
+
stageChildren: (_f = stage.children) === null || _f === void 0 ? void 0 : _f.length,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
// fallback for older API: renderer.render(displayObject, { renderTexture: rt })
|
|
286
|
+
try {
|
|
287
|
+
renderer.render(stage, { renderTexture: rt, clear: !component.append });
|
|
288
|
+
}
|
|
289
|
+
catch (_g) {
|
|
290
|
+
console.warn('[RenderTexture] renderer.render failed', e);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
// Defer destroy to next microtask so the GPU has time to consume.
|
|
295
|
+
// Some Pixi v8 builds upload the geometry lazily.
|
|
296
|
+
Promise.resolve().then(() => {
|
|
297
|
+
try {
|
|
298
|
+
stage.destroy({ children: true });
|
|
299
|
+
}
|
|
300
|
+
catch (_a) {
|
|
301
|
+
/* noop */
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
buildOpNode(op) {
|
|
308
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
if (op.type === 'clear') {
|
|
311
|
+
const g = new pixi_js.Graphics();
|
|
312
|
+
g.rect(0, 0, 1e6, 1e6).fill({ color: 0x000000, alpha: 0 });
|
|
313
|
+
// Use destination-in trick alternative: simpler — caller knows append=false to actually clear.
|
|
314
|
+
return g;
|
|
315
|
+
}
|
|
316
|
+
if (op.type === 'fill') {
|
|
317
|
+
const g = new pixi_js.Graphics();
|
|
318
|
+
const x = (_a = op.x) !== null && _a !== void 0 ? _a : 0;
|
|
319
|
+
const y = (_b = op.y) !== null && _b !== void 0 ? _b : 0;
|
|
320
|
+
const w = (_c = op.width) !== null && _c !== void 0 ? _c : 1e6;
|
|
321
|
+
const h = (_d = op.height) !== null && _d !== void 0 ? _d : 1e6;
|
|
322
|
+
g.rect(x, y, w, h).fill({ color: op.color, alpha: (_e = op.alpha) !== null && _e !== void 0 ? _e : 1 });
|
|
323
|
+
return g;
|
|
324
|
+
}
|
|
325
|
+
if (op.type === 'draw' || op.type === 'drawFrame') {
|
|
326
|
+
const tex = yield this.resolveTexture(op.resource, op.frame);
|
|
327
|
+
if (!tex)
|
|
328
|
+
return null;
|
|
329
|
+
const sp = new pixi_js.Sprite(tex);
|
|
330
|
+
sp.x = (_f = op.x) !== null && _f !== void 0 ? _f : 0;
|
|
331
|
+
sp.y = (_g = op.y) !== null && _g !== void 0 ? _g : 0;
|
|
332
|
+
const o = op;
|
|
333
|
+
sp.alpha = (_h = o.alpha) !== null && _h !== void 0 ? _h : 1;
|
|
334
|
+
if (o.tint != null)
|
|
335
|
+
sp.tint = o.tint;
|
|
336
|
+
if (o.width != null)
|
|
337
|
+
sp.width = o.width;
|
|
338
|
+
if (o.height != null)
|
|
339
|
+
sp.height = o.height;
|
|
340
|
+
if (o.rotation != null)
|
|
341
|
+
sp.rotation = o.rotation;
|
|
342
|
+
if (o.anchorX != null || o.anchorY != null) {
|
|
343
|
+
sp.anchor.set((_j = o.anchorX) !== null && _j !== void 0 ? _j : 0, (_k = o.anchorY) !== null && _k !== void 0 ? _k : 0);
|
|
344
|
+
}
|
|
345
|
+
if (o.scaleX != null || o.scaleY != null) {
|
|
346
|
+
sp.scale.set((_l = o.scaleX) !== null && _l !== void 0 ? _l : 1, (_m = o.scaleY) !== null && _m !== void 0 ? _m : 1);
|
|
347
|
+
}
|
|
348
|
+
if (o.blendMode) {
|
|
349
|
+
try {
|
|
350
|
+
sp.blendMode = o.blendMode;
|
|
351
|
+
}
|
|
352
|
+
catch (_15) {
|
|
353
|
+
// ignore
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return sp;
|
|
357
|
+
}
|
|
358
|
+
if (op.type === 'erase') {
|
|
359
|
+
const g = new pixi_js.Graphics();
|
|
360
|
+
const w = (_o = op.width) !== null && _o !== void 0 ? _o : 16;
|
|
361
|
+
const h = (_p = op.height) !== null && _p !== void 0 ? _p : 16;
|
|
362
|
+
const ax = (_q = op.anchorX) !== null && _q !== void 0 ? _q : 0;
|
|
363
|
+
const ay = (_r = op.anchorY) !== null && _r !== void 0 ? _r : 0;
|
|
364
|
+
const x = ((_s = op.x) !== null && _s !== void 0 ? _s : 0) - w * ax;
|
|
365
|
+
const y = ((_t = op.y) !== null && _t !== void 0 ? _t : 0) - h * ay;
|
|
366
|
+
g.rect(x, y, w, h).fill({ color: 0xffffff, alpha: 1 });
|
|
367
|
+
try {
|
|
368
|
+
g.blendMode = 'erase';
|
|
369
|
+
}
|
|
370
|
+
catch (_16) {
|
|
371
|
+
// ignore
|
|
372
|
+
}
|
|
373
|
+
return g;
|
|
374
|
+
}
|
|
375
|
+
if (op.type === 'drawText') {
|
|
376
|
+
const t = new pixi_js.Text({
|
|
377
|
+
text: op.text,
|
|
378
|
+
style: {
|
|
379
|
+
fontFamily: (_v = (_u = op.style) === null || _u === void 0 ? void 0 : _u.fontFamily) !== null && _v !== void 0 ? _v : 'Arial',
|
|
380
|
+
fontSize: (_x = (_w = op.style) === null || _w === void 0 ? void 0 : _w.fontSize) !== null && _x !== void 0 ? _x : 32,
|
|
381
|
+
fontWeight: (_z = (_y = op.style) === null || _y === void 0 ? void 0 : _y.fontWeight) !== null && _z !== void 0 ? _z : 'normal',
|
|
382
|
+
fill: (_1 = (_0 = op.style) === null || _0 === void 0 ? void 0 : _0.fill) !== null && _1 !== void 0 ? _1 : 0xffffff,
|
|
383
|
+
stroke: (_2 = op.style) === null || _2 === void 0 ? void 0 : _2.stroke,
|
|
384
|
+
align: (_4 = (_3 = op.style) === null || _3 === void 0 ? void 0 : _3.align) !== null && _4 !== void 0 ? _4 : 'left',
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
t.x = (_5 = op.x) !== null && _5 !== void 0 ? _5 : 0;
|
|
388
|
+
t.y = (_6 = op.y) !== null && _6 !== void 0 ? _6 : 0;
|
|
389
|
+
if (op.alpha != null)
|
|
390
|
+
t.alpha = op.alpha;
|
|
391
|
+
if (op.tint != null)
|
|
392
|
+
t.tint = op.tint;
|
|
393
|
+
return t;
|
|
394
|
+
}
|
|
395
|
+
if (op.type === 'paint') {
|
|
396
|
+
const tex = yield this.resolveTexture(op.resource, op.frame);
|
|
397
|
+
if (!tex)
|
|
398
|
+
return null;
|
|
399
|
+
const c = new pixi_js.Container();
|
|
400
|
+
const times = Math.max(1, (_7 = op.times) !== null && _7 !== void 0 ? _7 : 1);
|
|
401
|
+
const dx = (_9 = (_8 = op.step) === null || _8 === void 0 ? void 0 : _8.x) !== null && _9 !== void 0 ? _9 : 0;
|
|
402
|
+
const dy = (_11 = (_10 = op.step) === null || _10 === void 0 ? void 0 : _10.y) !== null && _11 !== void 0 ? _11 : 0;
|
|
403
|
+
for (let i = 0; i < times; i++) {
|
|
404
|
+
const sp = new pixi_js.Sprite(tex);
|
|
405
|
+
sp.x = ((_12 = op.x) !== null && _12 !== void 0 ? _12 : 0) + dx * i;
|
|
406
|
+
sp.y = ((_13 = op.y) !== null && _13 !== void 0 ? _13 : 0) + dy * i;
|
|
407
|
+
sp.anchor.set(0.5, 0.5);
|
|
408
|
+
sp.alpha = (_14 = op.alpha) !== null && _14 !== void 0 ? _14 : 1;
|
|
409
|
+
if (op.tintCycle && op.tintCycle.length > 0) {
|
|
410
|
+
sp.tint = op.tintCycle[i % op.tintCycle.length];
|
|
411
|
+
}
|
|
412
|
+
else if (op.tint != null) {
|
|
413
|
+
sp.tint = op.tint;
|
|
414
|
+
}
|
|
415
|
+
c.addChild(sp);
|
|
416
|
+
}
|
|
417
|
+
return c;
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* After a successful replay, save the RT as a resource so other Img/Sprite can reference it.
|
|
424
|
+
* Idempotent: registers once per gameObject.saveAs key.
|
|
425
|
+
*/
|
|
426
|
+
maybeSave(gameObjectId) {
|
|
427
|
+
var _a;
|
|
428
|
+
const record = this.records[gameObjectId];
|
|
429
|
+
if (!record)
|
|
430
|
+
return;
|
|
431
|
+
const key = record.component.saveAs;
|
|
432
|
+
if (!key)
|
|
433
|
+
return;
|
|
434
|
+
try {
|
|
435
|
+
// Check if already in resourcesMap
|
|
436
|
+
const existing = (_a = eva_js.resource.resourcesMap) === null || _a === void 0 ? void 0 : _a[key];
|
|
437
|
+
if (existing) {
|
|
438
|
+
existing.complete = true;
|
|
439
|
+
existing.instance = record.rt;
|
|
440
|
+
// Make sure callers awaiting getResource get our instance
|
|
441
|
+
const promiseMap = eva_js.resource.promiseMap;
|
|
442
|
+
if (promiseMap) {
|
|
443
|
+
promiseMap[key] = Promise.resolve({ instance: record.rt, name: key });
|
|
444
|
+
}
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
// Register a fresh entry
|
|
448
|
+
eva_js.resource.resourcesMap = eva_js.resource.resourcesMap || {};
|
|
449
|
+
eva_js.resource.resourcesMap[key] = {
|
|
450
|
+
name: key,
|
|
451
|
+
type: 'IMAGE',
|
|
452
|
+
complete: true,
|
|
453
|
+
instance: record.rt,
|
|
454
|
+
data: {},
|
|
455
|
+
};
|
|
456
|
+
const promiseMap = eva_js.resource.promiseMap;
|
|
457
|
+
if (promiseMap) {
|
|
458
|
+
promiseMap[key] = Promise.resolve({ instance: record.rt, name: key });
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
catch (e) {
|
|
462
|
+
console.warn('[RenderTexture] saveAs failed', e);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
destroy() {
|
|
466
|
+
var _a, _b;
|
|
467
|
+
for (const key in this.records) {
|
|
468
|
+
const id = parseInt(key);
|
|
469
|
+
const record = this.records[id];
|
|
470
|
+
(_b = (_a = this.containerManager) === null || _a === void 0 ? void 0 : _a.getContainer(id)) === null || _b === void 0 ? void 0 : _b.removeChild(record.sprite);
|
|
471
|
+
record.sprite.destroy({ children: true });
|
|
472
|
+
record.rt.destroy(true);
|
|
473
|
+
delete this.records[id];
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
RenderTextureSystem.systemName = 'RenderTexture';
|
|
478
|
+
RenderTextureSystem = __decorate([
|
|
479
|
+
eva_js.decorators.componentObserver({
|
|
480
|
+
RenderTexture: [
|
|
481
|
+
{ prop: ['width'], deep: false },
|
|
482
|
+
{ prop: ['height'], deep: false },
|
|
483
|
+
{ prop: ['ops'], deep: true },
|
|
484
|
+
{ prop: ['dirty'], deep: false },
|
|
485
|
+
{ prop: ['backgroundColor'], deep: false },
|
|
486
|
+
{ prop: ['backgroundAlpha'], deep: false },
|
|
487
|
+
],
|
|
488
|
+
})
|
|
489
|
+
], RenderTextureSystem);
|
|
490
|
+
var RenderTextureSystem$1 = RenderTextureSystem;
|
|
491
|
+
|
|
492
|
+
exports.RenderTexture = RenderTexture;
|
|
493
|
+
exports.RenderTextureSystem = RenderTextureSystem$1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("pixi.js");function i(e,t,r,n){var i,o=arguments.length,l=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(l=(o<3?i(l):o>3?i(t,r,l):i(t,r))||l);return o>3&&l&&Object.defineProperty(t,r,l),l}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function l(e,t,r,n){return new(r||(r=Promise))(function(i,o){function l(e){try{d(n.next(e))}catch(e){o(e)}}function s(e){try{d(n.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(l,s)}d((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class s extends e.Component{constructor(){super(...arguments),this.width=256,this.height=256,this.ops=[],this.backgroundColor=-1,this.backgroundAlpha=1,this.append=!0,this.dirty=0}init(e){e&&Object.assign(this,e),Array.isArray(this.ops)||(this.ops=[])}addOp(e){this.ops=[...this.ops,e],this.dirty++}clearOps(){this.ops=[{type:"clear"}],this.dirty++}}s.componentName="RenderTexture",i([t.type("number"),o("design:type",Number)],s.prototype,"width",void 0),i([t.type("number"),o("design:type",Number)],s.prototype,"height",void 0),i([t.type("array"),o("design:type",Array)],s.prototype,"ops",void 0),i([t.type("number"),o("design:type",Number)],s.prototype,"backgroundColor",void 0),i([t.type("number"),o("design:type",Number)],s.prototype,"backgroundAlpha",void 0);let d=class extends r.Renderer{constructor(){super(...arguments),this.name="RenderTexture",this.records={}}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const t=this.records[e.id];t&&t.needsReplay&&(t.needsReplay=!1,this.replay(e.id))}componentChanged(t){var r,i,o,s;return l(this,void 0,void 0,function*(){if("RenderTexture"!==t.componentName)return;const l=t.component,d=t.gameObject.id;if(t.type===e.OBSERVER_TYPE.ADD){const e=n.RenderTexture.create({width:Math.max(1,l.width||1),height:Math.max(1,l.height||1),resolution:1}),t=new n.Sprite(e);t.width=l.width,t.height=l.height,this.containerManager.getContainer(d).addChildAt(t,0),this.records[d]={rt:e,sprite:t,component:l,lastSig:"",needsReplay:!0},this.maybeSave(d)}else if(t.type===e.OBSERVER_TYPE.CHANGE){const e=this.records[d];if(!e)return;if(e.component=l,e.rt.width!==l.width||e.rt.height!==l.height){try{null===(i=(r=e.rt).resize)||void 0===i||i.call(r,Math.max(1,l.width),Math.max(1,l.height))}catch(e){}e.sprite.width=l.width,e.sprite.height=l.height}e.needsReplay=!0,this.maybeSave(d)}else if(t.type===e.OBSERVER_TYPE.REMOVE){const e=this.records[d];if(!e)return;null===(s=null===(o=this.containerManager)||void 0===o?void 0:o.getContainer(d))||void 0===s||s.removeChild(e.sprite),e.sprite.destroy({children:!0}),e.rt.destroy(!0),delete this.records[d]}})}resolveTexture(t,r){return l(this,void 0,void 0,function*(){if(!t)return null;let i=t,o=r;if(!o&&t.includes("#")){const e=t.indexOf("#");i=t.slice(0,e),o=t.slice(e+1)}try{const{instance:t}=yield e.resource.getResource(i);if(!t)return null;if(o){if(t&&t[o]instanceof n.Texture)return t[o];const e=t.textures;if(e&&e[o]instanceof n.Texture)return e[o]}if(t instanceof n.Texture)return t;if(t.baseTexture)return t;if("object"==typeof t){const e=Object.keys(t);for(const r of e){const e=t[r];if(e instanceof n.Texture)return e}}return null}catch(e){return null}})}replay(e){var t,r,i,o,s,d;return l(this,void 0,void 0,function*(){const l=this.records[e];if(!l)return;const{rt:a,component:c}=l,u=`${c.dirty}|${null!==(r=null===(t=c.ops)||void 0===t?void 0:t.length)&&void 0!==r?r:0}|${c.width}|${c.height}`;l.lastSig===u&&c.append,l.lastSig=u;const h=null===(i=this.renderSystem.application)||void 0===i?void 0:i.renderer;if(!h)return;const p=new n.Container,v=c.backgroundColor,y=null!==(o=c.backgroundAlpha)&&void 0!==o?o:1;if(!c.append){const e=new n.Graphics;null!=v&&v>=0?e.rect(0,0,c.width,c.height).fill({color:v,alpha:y}):e.rect(0,0,c.width,c.height).fill({color:0,alpha:0}),p.addChild(e)}for(const e of c.ops||[]){const t=yield this.buildOpNode(e);t&&p.addChild(t)}try{h.render({container:p,target:a,clear:!c.append}),globalThis.__RT_DEBUG&&console.log("[RT] replayed",{ops:null===(s=c.ops)||void 0===s?void 0:s.length,w:a.width,h:a.height,stageChildren:null===(d=p.children)||void 0===d?void 0:d.length})}catch(e){try{h.render(p,{renderTexture:a,clear:!c.append})}catch(t){console.warn("[RenderTexture] renderer.render failed",e)}}finally{Promise.resolve().then(()=>{try{p.destroy({children:!0})}catch(e){}})}})}buildOpNode(e){var t,r,i,o,s,d,a,c,u,h,p,v,y,f,g,m,x,w,b,R,T,C,M,S,O,E,A,j,k,N,P,Y,_,G,X,q,B,D,V;return l(this,void 0,void 0,function*(){if("clear"===e.type){const e=new n.Graphics;return e.rect(0,0,1e6,1e6).fill({color:0,alpha:0}),e}if("fill"===e.type){const l=new n.Graphics,d=null!==(t=e.x)&&void 0!==t?t:0,a=null!==(r=e.y)&&void 0!==r?r:0,c=null!==(i=e.width)&&void 0!==i?i:1e6,u=null!==(o=e.height)&&void 0!==o?o:1e6;return l.rect(d,a,c,u).fill({color:e.color,alpha:null!==(s=e.alpha)&&void 0!==s?s:1}),l}if("draw"===e.type||"drawFrame"===e.type){const t=yield this.resolveTexture(e.resource,e.frame);if(!t)return null;const r=new n.Sprite(t);r.x=null!==(d=e.x)&&void 0!==d?d:0,r.y=null!==(a=e.y)&&void 0!==a?a:0;const i=e;if(r.alpha=null!==(c=i.alpha)&&void 0!==c?c:1,null!=i.tint&&(r.tint=i.tint),null!=i.width&&(r.width=i.width),null!=i.height&&(r.height=i.height),null!=i.rotation&&(r.rotation=i.rotation),null==i.anchorX&&null==i.anchorY||r.anchor.set(null!==(u=i.anchorX)&&void 0!==u?u:0,null!==(h=i.anchorY)&&void 0!==h?h:0),null==i.scaleX&&null==i.scaleY||r.scale.set(null!==(p=i.scaleX)&&void 0!==p?p:1,null!==(v=i.scaleY)&&void 0!==v?v:1),i.blendMode)try{r.blendMode=i.blendMode}catch(e){}return r}if("erase"===e.type){const t=new n.Graphics,r=null!==(y=e.width)&&void 0!==y?y:16,i=null!==(f=e.height)&&void 0!==f?f:16,o=null!==(g=e.anchorX)&&void 0!==g?g:0,l=null!==(m=e.anchorY)&&void 0!==m?m:0,s=(null!==(x=e.x)&&void 0!==x?x:0)-r*o,d=(null!==(w=e.y)&&void 0!==w?w:0)-i*l;t.rect(s,d,r,i).fill({color:16777215,alpha:1});try{t.blendMode="erase"}catch(e){}return t}if("drawText"===e.type){const t=new n.Text({text:e.text,style:{fontFamily:null!==(R=null===(b=e.style)||void 0===b?void 0:b.fontFamily)&&void 0!==R?R:"Arial",fontSize:null!==(C=null===(T=e.style)||void 0===T?void 0:T.fontSize)&&void 0!==C?C:32,fontWeight:null!==(S=null===(M=e.style)||void 0===M?void 0:M.fontWeight)&&void 0!==S?S:"normal",fill:null!==(E=null===(O=e.style)||void 0===O?void 0:O.fill)&&void 0!==E?E:16777215,stroke:null===(A=e.style)||void 0===A?void 0:A.stroke,align:null!==(k=null===(j=e.style)||void 0===j?void 0:j.align)&&void 0!==k?k:"left"}});return t.x=null!==(N=e.x)&&void 0!==N?N:0,t.y=null!==(P=e.y)&&void 0!==P?P:0,null!=e.alpha&&(t.alpha=e.alpha),null!=e.tint&&(t.tint=e.tint),t}if("paint"===e.type){const t=yield this.resolveTexture(e.resource,e.frame);if(!t)return null;const r=new n.Container,i=Math.max(1,null!==(Y=e.times)&&void 0!==Y?Y:1),o=null!==(G=null===(_=e.step)||void 0===_?void 0:_.x)&&void 0!==G?G:0,l=null!==(q=null===(X=e.step)||void 0===X?void 0:X.y)&&void 0!==q?q:0;for(let s=0;s<i;s++){const i=new n.Sprite(t);i.x=(null!==(B=e.x)&&void 0!==B?B:0)+o*s,i.y=(null!==(D=e.y)&&void 0!==D?D:0)+l*s,i.anchor.set(.5,.5),i.alpha=null!==(V=e.alpha)&&void 0!==V?V:1,e.tintCycle&&e.tintCycle.length>0?i.tint=e.tintCycle[s%e.tintCycle.length]:null!=e.tint&&(i.tint=e.tint),r.addChild(i)}return r}return null})}maybeSave(t){var r;const n=this.records[t];if(!n)return;const i=n.component.saveAs;if(i)try{const t=null===(r=e.resource.resourcesMap)||void 0===r?void 0:r[i];if(t){t.complete=!0,t.instance=n.rt;const r=e.resource.promiseMap;return void(r&&(r[i]=Promise.resolve({instance:n.rt,name:i})))}e.resource.resourcesMap=e.resource.resourcesMap||{},e.resource.resourcesMap[i]={name:i,type:"IMAGE",complete:!0,instance:n.rt,data:{}};const o=e.resource.promiseMap;o&&(o[i]=Promise.resolve({instance:n.rt,name:i}))}catch(e){console.warn("[RenderTexture] saveAs failed",e)}}destroy(){var e,t;for(const r in this.records){const n=parseInt(r),i=this.records[n];null===(t=null===(e=this.containerManager)||void 0===e?void 0:e.getContainer(n))||void 0===t||t.removeChild(i.sprite),i.sprite.destroy({children:!0}),i.rt.destroy(!0),delete this.records[n]}}};d.systemName="RenderTexture",d=i([e.decorators.componentObserver({RenderTexture:[{prop:["width"],deep:!1},{prop:["height"],deep:!1},{prop:["ops"],deep:!0},{prop:["dirty"],deep:!1},{prop:["backgroundColor"],deep:!1},{prop:["backgroundAlpha"],deep:!1}]})],d);var a=d;exports.RenderTexture=s,exports.RenderTextureSystem=a;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Component } from '@eva/eva.js';
|
|
2
|
+
import { ComponentChanged } from '@eva/eva.js';
|
|
3
|
+
import { ContainerManager } from '@eva/plugin-renderer';
|
|
4
|
+
import { GameObject } from '@eva/eva.js';
|
|
5
|
+
import { Renderer } from '@eva/plugin-renderer';
|
|
6
|
+
import { RendererManager } from '@eva/plugin-renderer';
|
|
7
|
+
import { RendererSystem } from '@eva/plugin-renderer';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* RenderTexture component.
|
|
11
|
+
*
|
|
12
|
+
* Equivalent of Phaser RenderTexture / DynamicTexture. Holds a Pixi RenderTexture
|
|
13
|
+
* underneath and lets the DSL declaratively enqueue draw ops via `ops`.
|
|
14
|
+
*
|
|
15
|
+
* Mutating `ops` (or any of the simple props) replays the queue.
|
|
16
|
+
*/
|
|
17
|
+
export declare class RenderTexture extends Component<RenderTextureParams> {
|
|
18
|
+
static componentName: string;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
ops: RenderTextureOp[];
|
|
22
|
+
backgroundColor: number;
|
|
23
|
+
backgroundAlpha: number;
|
|
24
|
+
saveAs?: string;
|
|
25
|
+
append: boolean;
|
|
26
|
+
/** Bumped by clear()/fill()/etc. so the system can detect imperative changes. */
|
|
27
|
+
dirty: number;
|
|
28
|
+
init(obj?: RenderTextureParams): void;
|
|
29
|
+
/** Append an op + mark dirty (works at runtime, not just init). */
|
|
30
|
+
addOp(op: RenderTextureOp): void;
|
|
31
|
+
/** Clear the queue (and the texture next commit). */
|
|
32
|
+
clearOps(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Single declarative drawing op applied to a RenderTexture. */
|
|
36
|
+
export declare type RenderTextureOp =
|
|
37
|
+
/** Fill the whole RT (or a sub-rect) with a solid color. */
|
|
38
|
+
{
|
|
39
|
+
type: 'fill';
|
|
40
|
+
color: number;
|
|
41
|
+
alpha?: number;
|
|
42
|
+
x?: number;
|
|
43
|
+
y?: number;
|
|
44
|
+
width?: number;
|
|
45
|
+
height?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Clear the RT (transparent). */
|
|
48
|
+
| {
|
|
49
|
+
type: 'clear';
|
|
50
|
+
}
|
|
51
|
+
/** Draw an image / atlas frame / text-as-texture into the RT. */
|
|
52
|
+
| {
|
|
53
|
+
type: 'draw';
|
|
54
|
+
/** Resource name registered in DSL assets (image / sprite / saved RT). */
|
|
55
|
+
resource: string;
|
|
56
|
+
/** Optional sprite atlas frame name. */
|
|
57
|
+
frame?: string;
|
|
58
|
+
x?: number;
|
|
59
|
+
y?: number;
|
|
60
|
+
width?: number;
|
|
61
|
+
height?: number;
|
|
62
|
+
alpha?: number;
|
|
63
|
+
tint?: number;
|
|
64
|
+
rotation?: number;
|
|
65
|
+
anchorX?: number;
|
|
66
|
+
anchorY?: number;
|
|
67
|
+
scaleX?: number;
|
|
68
|
+
scaleY?: number;
|
|
69
|
+
blendMode?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Convenience alias for drawing an atlas frame at (x,y). */
|
|
72
|
+
| {
|
|
73
|
+
type: 'drawFrame';
|
|
74
|
+
resource: string;
|
|
75
|
+
frame: string;
|
|
76
|
+
x?: number;
|
|
77
|
+
y?: number;
|
|
78
|
+
alpha?: number;
|
|
79
|
+
tint?: number;
|
|
80
|
+
}
|
|
81
|
+
/** Erase a region (alpha→0) by drawing with destination-out blend. */
|
|
82
|
+
| {
|
|
83
|
+
type: 'erase';
|
|
84
|
+
resource?: string;
|
|
85
|
+
frame?: string;
|
|
86
|
+
x?: number;
|
|
87
|
+
y?: number;
|
|
88
|
+
width?: number;
|
|
89
|
+
height?: number;
|
|
90
|
+
anchorX?: number;
|
|
91
|
+
anchorY?: number;
|
|
92
|
+
}
|
|
93
|
+
/** Draw a text string (PIXI.Text) into the RT. */
|
|
94
|
+
| {
|
|
95
|
+
type: 'drawText';
|
|
96
|
+
text: string;
|
|
97
|
+
x?: number;
|
|
98
|
+
y?: number;
|
|
99
|
+
style?: {
|
|
100
|
+
fontFamily?: string;
|
|
101
|
+
fontSize?: number;
|
|
102
|
+
fontWeight?: string | number;
|
|
103
|
+
fill?: number | string;
|
|
104
|
+
stroke?: number | string;
|
|
105
|
+
strokeThickness?: number;
|
|
106
|
+
align?: 'left' | 'center' | 'right';
|
|
107
|
+
};
|
|
108
|
+
alpha?: number;
|
|
109
|
+
tint?: number;
|
|
110
|
+
}
|
|
111
|
+
/** Repeat the previous draw N times with offset (paint trail). */
|
|
112
|
+
| {
|
|
113
|
+
type: 'paint';
|
|
114
|
+
resource: string;
|
|
115
|
+
frame?: string;
|
|
116
|
+
x?: number;
|
|
117
|
+
y?: number;
|
|
118
|
+
step?: {
|
|
119
|
+
x?: number;
|
|
120
|
+
y?: number;
|
|
121
|
+
};
|
|
122
|
+
times?: number;
|
|
123
|
+
alpha?: number;
|
|
124
|
+
tint?: number;
|
|
125
|
+
tintCycle?: number[];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export declare interface RenderTextureParams {
|
|
129
|
+
/** Logical width in design units. */
|
|
130
|
+
width: number;
|
|
131
|
+
/** Logical height in design units. */
|
|
132
|
+
height: number;
|
|
133
|
+
/** Declarative draw queue replayed every commit. */
|
|
134
|
+
ops?: RenderTextureOp[];
|
|
135
|
+
/** Optional clear color before replaying ops. */
|
|
136
|
+
backgroundColor?: number;
|
|
137
|
+
backgroundAlpha?: number;
|
|
138
|
+
/** Save final RT as a resource key (so other Img/Sprite can reference it). */
|
|
139
|
+
saveAs?: string;
|
|
140
|
+
/** Append ops instead of clearing on each commit. Defaults true (Phaser-like). */
|
|
141
|
+
append?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export declare class RenderTextureSystem extends Renderer {
|
|
145
|
+
static systemName: string;
|
|
146
|
+
name: string;
|
|
147
|
+
private records;
|
|
148
|
+
renderSystem: RendererSystem;
|
|
149
|
+
rendererManager: RendererManager;
|
|
150
|
+
containerManager: ContainerManager;
|
|
151
|
+
init(): void;
|
|
152
|
+
rendererUpdate(gameObject: GameObject): void;
|
|
153
|
+
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
154
|
+
/** Resolve a resource name (optionally with `#frame` suffix) → Texture. */
|
|
155
|
+
private resolveTexture;
|
|
156
|
+
/** Build an offscreen Pixi DisplayObject describing the op, then render it into the RT. */
|
|
157
|
+
private replay;
|
|
158
|
+
private buildOpNode;
|
|
159
|
+
/**
|
|
160
|
+
* After a successful replay, save the RT as a resource so other Img/Sprite can reference it.
|
|
161
|
+
* Idempotent: registers once per gameObject.saveAs key.
|
|
162
|
+
*/
|
|
163
|
+
private maybeSave;
|
|
164
|
+
destroy(): void;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { }
|