@combos-fun/plugin-renderer-3d-sprite-animation 0.0.6
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/dist/plugin-renderer-3d-sprite-animation.cjs.js +242 -0
- package/dist/plugin-renderer-3d-sprite-animation.cjs.js.map +1 -0
- package/dist/plugin-renderer-3d-sprite-animation.cjs.prod.js +1 -0
- package/dist/plugin-renderer-3d-sprite-animation.d.ts +52 -0
- package/dist/plugin-renderer-3d-sprite-animation.esm.js +239 -0
- package/dist/plugin-renderer-3d-sprite-animation.esm.js.map +1 -0
- package/index.js +7 -0
- package/package.json +23 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var engine = require('@combos-fun/engine');
|
|
5
|
+
var inspectorDecorator = require('@combos-fun/inspector-decorator');
|
|
6
|
+
var pluginRenderer3d = require('@combos-fun/plugin-renderer-3d');
|
|
7
|
+
var three = require('three');
|
|
8
|
+
|
|
9
|
+
class SpriteAnimation3D extends engine.Component {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.resource = '';
|
|
13
|
+
this.autoPlay = true;
|
|
14
|
+
this.speed = 100;
|
|
15
|
+
this.positionX = 0;
|
|
16
|
+
this.positionY = 0;
|
|
17
|
+
this.positionZ = 0;
|
|
18
|
+
this.rotationX = 0;
|
|
19
|
+
this.rotationY = 0;
|
|
20
|
+
this.rotationZ = 0;
|
|
21
|
+
this.scaleX = 1;
|
|
22
|
+
this.scaleY = 1;
|
|
23
|
+
}
|
|
24
|
+
static { this.componentName = 'SpriteAnimation3D'; }
|
|
25
|
+
init(obj) {
|
|
26
|
+
if (obj)
|
|
27
|
+
Object.assign(this, obj);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
tslib.__decorate([
|
|
31
|
+
inspectorDecorator.type('string')
|
|
32
|
+
], SpriteAnimation3D.prototype, "resource", void 0);
|
|
33
|
+
tslib.__decorate([
|
|
34
|
+
inspectorDecorator.type('boolean')
|
|
35
|
+
], SpriteAnimation3D.prototype, "autoPlay", void 0);
|
|
36
|
+
tslib.__decorate([
|
|
37
|
+
inspectorDecorator.type('number'),
|
|
38
|
+
inspectorDecorator.step(10)
|
|
39
|
+
], SpriteAnimation3D.prototype, "speed", void 0);
|
|
40
|
+
tslib.__decorate([
|
|
41
|
+
inspectorDecorator.type('number'),
|
|
42
|
+
inspectorDecorator.step(0.1)
|
|
43
|
+
], SpriteAnimation3D.prototype, "positionX", void 0);
|
|
44
|
+
tslib.__decorate([
|
|
45
|
+
inspectorDecorator.type('number'),
|
|
46
|
+
inspectorDecorator.step(0.1)
|
|
47
|
+
], SpriteAnimation3D.prototype, "positionY", void 0);
|
|
48
|
+
tslib.__decorate([
|
|
49
|
+
inspectorDecorator.type('number'),
|
|
50
|
+
inspectorDecorator.step(0.1)
|
|
51
|
+
], SpriteAnimation3D.prototype, "positionZ", void 0);
|
|
52
|
+
tslib.__decorate([
|
|
53
|
+
inspectorDecorator.type('number'),
|
|
54
|
+
inspectorDecorator.step(0.01)
|
|
55
|
+
], SpriteAnimation3D.prototype, "rotationX", void 0);
|
|
56
|
+
tslib.__decorate([
|
|
57
|
+
inspectorDecorator.type('number'),
|
|
58
|
+
inspectorDecorator.step(0.01)
|
|
59
|
+
], SpriteAnimation3D.prototype, "rotationY", void 0);
|
|
60
|
+
tslib.__decorate([
|
|
61
|
+
inspectorDecorator.type('number'),
|
|
62
|
+
inspectorDecorator.step(0.01)
|
|
63
|
+
], SpriteAnimation3D.prototype, "rotationZ", void 0);
|
|
64
|
+
tslib.__decorate([
|
|
65
|
+
inspectorDecorator.type('number'),
|
|
66
|
+
inspectorDecorator.step(0.1)
|
|
67
|
+
], SpriteAnimation3D.prototype, "scaleX", void 0);
|
|
68
|
+
tslib.__decorate([
|
|
69
|
+
inspectorDecorator.type('number'),
|
|
70
|
+
inspectorDecorator.step(0.1)
|
|
71
|
+
], SpriteAnimation3D.prototype, "scaleY", void 0);
|
|
72
|
+
|
|
73
|
+
let SpriteAnimation3DSystem = class SpriteAnimation3DSystem extends pluginRenderer3d.Renderer3D {
|
|
74
|
+
constructor() {
|
|
75
|
+
super(...arguments);
|
|
76
|
+
this.name = 'SpriteAnimation3DSystem';
|
|
77
|
+
this.entries = new Map();
|
|
78
|
+
this.textureLoader = new three.TextureLoader();
|
|
79
|
+
}
|
|
80
|
+
static { this.systemName = 'SpriteAnimation3DSystem'; }
|
|
81
|
+
init() {
|
|
82
|
+
const renderer3DSystem = this.game.getSystem(pluginRenderer3d.Renderer3DSystem);
|
|
83
|
+
renderer3DSystem.rendererManager.register(this);
|
|
84
|
+
}
|
|
85
|
+
componentChanged(changed) {
|
|
86
|
+
if (changed.componentName !== 'SpriteAnimation3D')
|
|
87
|
+
return;
|
|
88
|
+
if (changed.type === engine.OBSERVER_TYPE.ADD) {
|
|
89
|
+
this.handleAdd(changed.gameObject, changed.component);
|
|
90
|
+
}
|
|
91
|
+
else if (changed.type === engine.OBSERVER_TYPE.REMOVE) {
|
|
92
|
+
this.handleRemove(changed.gameObject.id);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.handleChange(changed);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
rendererUpdate(gameObject) {
|
|
99
|
+
const component = gameObject.getComponent(SpriteAnimation3D);
|
|
100
|
+
if (!component)
|
|
101
|
+
return;
|
|
102
|
+
const entry = this.entries.get(gameObject.id);
|
|
103
|
+
if (!entry)
|
|
104
|
+
return;
|
|
105
|
+
entry.mesh.position.set(component.positionX, component.positionY, component.positionZ);
|
|
106
|
+
entry.mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
107
|
+
entry.mesh.scale.set(component.scaleX, component.scaleY, 1);
|
|
108
|
+
if (!entry.playing || entry.frames.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
const delta = this.threeContext.clock.getDelta() * 1000;
|
|
111
|
+
entry.elapsed += delta;
|
|
112
|
+
if (entry.elapsed >= component.speed) {
|
|
113
|
+
entry.elapsed -= component.speed;
|
|
114
|
+
entry.currentFrame = (entry.currentFrame + 1) % entry.frames.length;
|
|
115
|
+
this.applyFrame(entry);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async handleAdd(gameObject, component) {
|
|
119
|
+
if (!component.resource)
|
|
120
|
+
return;
|
|
121
|
+
const asyncId = this.increaseAsyncId(gameObject.id);
|
|
122
|
+
try {
|
|
123
|
+
const response = await fetch(component.resource);
|
|
124
|
+
const json = await response.json();
|
|
125
|
+
if (!this.validateAsyncId(gameObject.id, asyncId))
|
|
126
|
+
return;
|
|
127
|
+
const meta = json.meta;
|
|
128
|
+
const framesData = json.frames;
|
|
129
|
+
const imageUrl = this.resolveImageUrl(component.resource, meta.image);
|
|
130
|
+
const texture = await this.loadTexture(imageUrl);
|
|
131
|
+
if (!this.validateAsyncId(gameObject.id, asyncId)) {
|
|
132
|
+
texture.dispose();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const frames = this.parseFrames(framesData);
|
|
136
|
+
const sheetWidth = meta.size.w;
|
|
137
|
+
const sheetHeight = meta.size.h;
|
|
138
|
+
const firstFrame = frames[0];
|
|
139
|
+
const aspectRatio = firstFrame.w / firstFrame.h;
|
|
140
|
+
const geometry = new three.PlaneGeometry(aspectRatio, 1);
|
|
141
|
+
const material = new three.MeshBasicMaterial({
|
|
142
|
+
map: texture,
|
|
143
|
+
transparent: true,
|
|
144
|
+
side: three.DoubleSide,
|
|
145
|
+
});
|
|
146
|
+
const mesh = new three.Mesh(geometry, material);
|
|
147
|
+
const entry = {
|
|
148
|
+
mesh,
|
|
149
|
+
texture,
|
|
150
|
+
frames,
|
|
151
|
+
sheetWidth,
|
|
152
|
+
sheetHeight,
|
|
153
|
+
currentFrame: 0,
|
|
154
|
+
elapsed: 0,
|
|
155
|
+
playing: component.autoPlay,
|
|
156
|
+
};
|
|
157
|
+
this.applyFrame(entry);
|
|
158
|
+
mesh.position.set(component.positionX, component.positionY, component.positionZ);
|
|
159
|
+
mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
160
|
+
mesh.scale.set(component.scaleX, component.scaleY, 1);
|
|
161
|
+
this.threeContext.scene.add(mesh);
|
|
162
|
+
this.entries.set(gameObject.id, entry);
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
console.error('SpriteAnimation3DSystem: failed to load spritesheet', e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
handleChange(changed) {
|
|
169
|
+
const component = changed.component;
|
|
170
|
+
const changedProp = changed.prop?.prop?.[0];
|
|
171
|
+
if (changedProp === 'resource') {
|
|
172
|
+
this.handleRemove(changed.gameObject.id);
|
|
173
|
+
this.handleAdd(changed.gameObject, component);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
handleRemove(id) {
|
|
177
|
+
this.increaseAsyncId(id);
|
|
178
|
+
const entry = this.entries.get(id);
|
|
179
|
+
if (!entry)
|
|
180
|
+
return;
|
|
181
|
+
this.threeContext.scene.remove(entry.mesh);
|
|
182
|
+
entry.mesh.geometry.dispose();
|
|
183
|
+
entry.mesh.material.dispose();
|
|
184
|
+
entry.texture.dispose();
|
|
185
|
+
this.entries.delete(id);
|
|
186
|
+
}
|
|
187
|
+
applyFrame(entry) {
|
|
188
|
+
const frame = entry.frames[entry.currentFrame];
|
|
189
|
+
const tex = entry.texture;
|
|
190
|
+
tex.offset.set(frame.x / entry.sheetWidth, 1 - (frame.y + frame.h) / entry.sheetHeight);
|
|
191
|
+
tex.repeat.set(frame.w / entry.sheetWidth, frame.h / entry.sheetHeight);
|
|
192
|
+
}
|
|
193
|
+
parseFrames(framesData) {
|
|
194
|
+
if (Array.isArray(framesData)) {
|
|
195
|
+
return framesData.map((f) => ({
|
|
196
|
+
x: f.frame.x,
|
|
197
|
+
y: f.frame.y,
|
|
198
|
+
w: f.frame.w,
|
|
199
|
+
h: f.frame.h,
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
// Object-based format: { "frameName": { frame: { x, y, w, h } } }
|
|
203
|
+
return Object.keys(framesData)
|
|
204
|
+
.sort()
|
|
205
|
+
.map((key) => ({
|
|
206
|
+
x: framesData[key].frame.x,
|
|
207
|
+
y: framesData[key].frame.y,
|
|
208
|
+
w: framesData[key].frame.w,
|
|
209
|
+
h: framesData[key].frame.h,
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
resolveImageUrl(jsonUrl, imageName) {
|
|
213
|
+
const base = jsonUrl.substring(0, jsonUrl.lastIndexOf('/') + 1);
|
|
214
|
+
return base + imageName;
|
|
215
|
+
}
|
|
216
|
+
loadTexture(url) {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
this.textureLoader.load(url, resolve, undefined, reject);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
onDestroy() {
|
|
222
|
+
for (const [id] of this.entries) {
|
|
223
|
+
this.handleRemove(id);
|
|
224
|
+
}
|
|
225
|
+
this.entries.clear();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
SpriteAnimation3DSystem = tslib.__decorate([
|
|
229
|
+
engine.decorators.componentObserver({
|
|
230
|
+
SpriteAnimation3D: [
|
|
231
|
+
'resource', 'speed',
|
|
232
|
+
'positionX', 'positionY', 'positionZ',
|
|
233
|
+
'rotationX', 'rotationY', 'rotationZ',
|
|
234
|
+
'scaleX', 'scaleY',
|
|
235
|
+
],
|
|
236
|
+
})
|
|
237
|
+
], SpriteAnimation3DSystem);
|
|
238
|
+
var SpriteAnimation3DSystem_default = SpriteAnimation3DSystem;
|
|
239
|
+
|
|
240
|
+
exports.SpriteAnimation3D = SpriteAnimation3D;
|
|
241
|
+
exports.SpriteAnimation3DSystem = SpriteAnimation3DSystem_default;
|
|
242
|
+
//# sourceMappingURL=plugin-renderer-3d-sprite-animation.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-3d-sprite-animation.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { type, step } from '@combos-fun/inspector-decorator';\n\nexport interface SpriteAnimation3DParams {\n resource?: string;\n autoPlay?: boolean;\n speed?: number;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n scaleX?: number;\n scaleY?: number;\n}\n\nexport default class SpriteAnimation3D extends Component<SpriteAnimation3DParams> {\n static componentName: string = 'SpriteAnimation3D';\n\n @type('string') resource: string = '';\n @type('boolean') autoPlay: boolean = true;\n @type('number') @step(10) speed: number = 100;\n @type('number') @step(0.1) positionX: number = 0;\n @type('number') @step(0.1) positionY: number = 0;\n @type('number') @step(0.1) positionZ: number = 0;\n @type('number') @step(0.01) rotationX: number = 0;\n @type('number') @step(0.01) rotationY: number = 0;\n @type('number') @step(0.01) rotationZ: number = 0;\n @type('number') @step(0.1) scaleX: number = 1;\n @type('number') @step(0.1) scaleY: number = 1;\n\n init(obj?: SpriteAnimation3DParams) {\n if (obj) Object.assign(this, obj);\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem } from '@combos-fun/plugin-renderer-3d';\nimport {\n TextureLoader,\n PlaneGeometry,\n MeshBasicMaterial,\n Mesh,\n DoubleSide,\n} from 'three';\nimport type { Texture } from 'three';\nimport SpriteAnimation3D from './component';\n\ninterface FrameData {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface SpriteAnimation3DEntry {\n mesh: Mesh;\n texture: Texture;\n frames: FrameData[];\n sheetWidth: number;\n sheetHeight: number;\n currentFrame: number;\n elapsed: number;\n playing: boolean;\n}\n\n@decorators.componentObserver({\n SpriteAnimation3D: [\n 'resource', 'speed',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n 'scaleX', 'scaleY',\n ],\n})\nexport default class SpriteAnimation3DSystem extends Renderer3D {\n static systemName = 'SpriteAnimation3DSystem';\n name: string = 'SpriteAnimation3DSystem';\n\n private entries: Map<number, SpriteAnimation3DEntry> = new Map();\n private textureLoader = new TextureLoader();\n\n init() {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'SpriteAnimation3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as SpriteAnimation3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(SpriteAnimation3D) as SpriteAnimation3D;\n if (!component) return;\n\n const entry = this.entries.get(gameObject.id);\n if (!entry) return;\n\n entry.mesh.position.set(component.positionX, component.positionY, component.positionZ);\n entry.mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n entry.mesh.scale.set(component.scaleX, component.scaleY, 1);\n\n if (!entry.playing || entry.frames.length === 0) return;\n\n const delta = this.threeContext.clock.getDelta() * 1000;\n entry.elapsed += delta;\n\n if (entry.elapsed >= component.speed) {\n entry.elapsed -= component.speed;\n entry.currentFrame = (entry.currentFrame + 1) % entry.frames.length;\n this.applyFrame(entry);\n }\n }\n\n private async handleAdd(gameObject: GameObject, component: SpriteAnimation3D) {\n if (!component.resource) return;\n\n const asyncId = this.increaseAsyncId(gameObject.id);\n\n try {\n const response = await fetch(component.resource);\n const json = await response.json();\n if (!this.validateAsyncId(gameObject.id, asyncId)) return;\n\n const meta = json.meta;\n const framesData = json.frames;\n const imageUrl = this.resolveImageUrl(component.resource, meta.image);\n\n const texture = await this.loadTexture(imageUrl);\n if (!this.validateAsyncId(gameObject.id, asyncId)) {\n texture.dispose();\n return;\n }\n\n const frames = this.parseFrames(framesData);\n const sheetWidth = meta.size.w;\n const sheetHeight = meta.size.h;\n\n const firstFrame = frames[0];\n const aspectRatio = firstFrame.w / firstFrame.h;\n const geometry = new PlaneGeometry(aspectRatio, 1);\n const material = new MeshBasicMaterial({\n map: texture,\n transparent: true,\n side: DoubleSide,\n });\n const mesh = new Mesh(geometry, material);\n\n const entry: SpriteAnimation3DEntry = {\n mesh,\n texture,\n frames,\n sheetWidth,\n sheetHeight,\n currentFrame: 0,\n elapsed: 0,\n playing: component.autoPlay,\n };\n\n this.applyFrame(entry);\n\n mesh.position.set(component.positionX, component.positionY, component.positionZ);\n mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n mesh.scale.set(component.scaleX, component.scaleY, 1);\n\n this.threeContext.scene.add(mesh);\n this.entries.set(gameObject.id, entry);\n } catch (e) {\n console.error('SpriteAnimation3DSystem: failed to load spritesheet', e);\n }\n }\n\n private handleChange(changed: ComponentChanged) {\n const component = changed.component as SpriteAnimation3D;\n const changedProp = changed.prop?.prop?.[0];\n\n if (changedProp === 'resource') {\n this.handleRemove(changed.gameObject.id);\n this.handleAdd(changed.gameObject, component);\n }\n }\n\n private handleRemove(id: number) {\n this.increaseAsyncId(id);\n const entry = this.entries.get(id);\n if (!entry) return;\n\n this.threeContext.scene.remove(entry.mesh);\n entry.mesh.geometry.dispose();\n (entry.mesh.material as MeshBasicMaterial).dispose();\n entry.texture.dispose();\n this.entries.delete(id);\n }\n\n private applyFrame(entry: SpriteAnimation3DEntry) {\n const frame = entry.frames[entry.currentFrame];\n const tex = entry.texture;\n\n tex.offset.set(frame.x / entry.sheetWidth, 1 - (frame.y + frame.h) / entry.sheetHeight);\n tex.repeat.set(frame.w / entry.sheetWidth, frame.h / entry.sheetHeight);\n }\n\n private parseFrames(framesData: any): FrameData[] {\n if (Array.isArray(framesData)) {\n return framesData.map((f: any) => ({\n x: f.frame.x,\n y: f.frame.y,\n w: f.frame.w,\n h: f.frame.h,\n }));\n }\n // Object-based format: { \"frameName\": { frame: { x, y, w, h } } }\n return Object.keys(framesData)\n .sort()\n .map((key) => ({\n x: framesData[key].frame.x,\n y: framesData[key].frame.y,\n w: framesData[key].frame.w,\n h: framesData[key].frame.h,\n }));\n }\n\n private resolveImageUrl(jsonUrl: string, imageName: string): string {\n const base = jsonUrl.substring(0, jsonUrl.lastIndexOf('/') + 1);\n return base + imageName;\n }\n\n private loadTexture(url: string): Promise<Texture> {\n return new Promise((resolve, reject) => {\n this.textureLoader.load(url, resolve, undefined, reject);\n });\n }\n\n onDestroy() {\n for (const [id] of this.entries) {\n this.handleRemove(id);\n }\n this.entries.clear();\n }\n}\n"],"names":["Component","__decorate","type","step","Renderer3D","TextureLoader","Renderer3DSystem","OBSERVER_TYPE","PlaneGeometry","MeshBasicMaterial","DoubleSide","Mesh","decorators"],"mappings":";;;;;;;;AAiBc,MAAO,iBAAkB,SAAQA,gBAAkC,CAAA;AAAjF,IAAA,WAAA,GAAA;;QAGkB,IAAA,CAAA,QAAQ,GAAW,EAAE;QACpB,IAAA,CAAA,QAAQ,GAAY,IAAI;QACf,IAAA,CAAA,KAAK,GAAW,GAAG;QAClB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACpB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACtB,IAAA,CAAA,MAAM,GAAW,CAAC;QAClB,IAAA,CAAA,MAAM,GAAW,CAAC;IAK/C;aAjBS,IAAA,CAAA,aAAa,GAAW,mBAAX,CAA+B;AAcnD,IAAA,IAAI,CAAC,GAA6B,EAAA;AAChC,QAAA,IAAI,GAAG;AAAE,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;IACnC;;AAdgBC,gBAAA,CAAA;IAAfC,uBAAI,CAAC,QAAQ;AAAwB,CAAA,EA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,OAAO,CAAC,KAAK,EAAE;IACtB;;AA3KmB,uBAAuB,GAAAV,gBAAA,CAAA;IAR3CW,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,iBAAiB,EAAE;AACjB,YAAA,UAAU,EAAE,OAAO;YACnB,WAAW,EAAE,WAAW,EAAE,WAAW;YACrC,WAAW,EAAE,WAAW,EAAE,WAAW;AACrC,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA;KACF;AACoB,CAAA,EAAA,uBAAuB,CA4K3C;sCA5KoB,uBAAuB;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),s=require("@combos-fun/inspector-decorator"),r=require("@combos-fun/plugin-renderer-3d"),o=require("three");class i extends t.Component{constructor(){super(...arguments),this.resource="",this.autoPlay=!0,this.speed=100,this.positionX=0,this.positionY=0,this.positionZ=0,this.rotationX=0,this.rotationY=0,this.rotationZ=0,this.scaleX=1,this.scaleY=1}static{this.componentName="SpriteAnimation3D"}init(e){e&&Object.assign(this,e)}}e.__decorate([s.type("string")],i.prototype,"resource",void 0),e.__decorate([s.type("boolean")],i.prototype,"autoPlay",void 0),e.__decorate([s.type("number"),s.step(10)],i.prototype,"speed",void 0),e.__decorate([s.type("number"),s.step(.1)],i.prototype,"positionX",void 0),e.__decorate([s.type("number"),s.step(.1)],i.prototype,"positionY",void 0),e.__decorate([s.type("number"),s.step(.1)],i.prototype,"positionZ",void 0),e.__decorate([s.type("number"),s.step(.01)],i.prototype,"rotationX",void 0),e.__decorate([s.type("number"),s.step(.01)],i.prototype,"rotationY",void 0),e.__decorate([s.type("number"),s.step(.01)],i.prototype,"rotationZ",void 0),e.__decorate([s.type("number"),s.step(.1)],i.prototype,"scaleX",void 0),e.__decorate([s.type("number"),s.step(.1)],i.prototype,"scaleY",void 0);let n=class extends r.Renderer3D{constructor(){super(...arguments),this.name="SpriteAnimation3DSystem",this.entries=new Map,this.textureLoader=new o.TextureLoader}static{this.systemName="SpriteAnimation3DSystem"}init(){this.game.getSystem(r.Renderer3DSystem).rendererManager.register(this)}componentChanged(e){"SpriteAnimation3D"===e.componentName&&(e.type===t.OBSERVER_TYPE.ADD?this.handleAdd(e.gameObject,e.component):e.type===t.OBSERVER_TYPE.REMOVE?this.handleRemove(e.gameObject.id):this.handleChange(e))}rendererUpdate(e){const t=e.getComponent(i);if(!t)return;const s=this.entries.get(e.id);if(!s)return;if(s.mesh.position.set(t.positionX,t.positionY,t.positionZ),s.mesh.rotation.set(t.rotationX,t.rotationY,t.rotationZ),s.mesh.scale.set(t.scaleX,t.scaleY,1),!s.playing||0===s.frames.length)return;const r=1e3*this.threeContext.clock.getDelta();s.elapsed+=r,s.elapsed>=t.speed&&(s.elapsed-=t.speed,s.currentFrame=(s.currentFrame+1)%s.frames.length,this.applyFrame(s))}async handleAdd(e,t){if(!t.resource)return;const s=this.increaseAsyncId(e.id);try{const r=await fetch(t.resource),i=await r.json();if(!this.validateAsyncId(e.id,s))return;const n=i.meta,a=i.frames,p=this.resolveImageUrl(t.resource,n.image),d=await this.loadTexture(p);if(!this.validateAsyncId(e.id,s))return void d.dispose();const h=this.parseFrames(a),c=n.size.w,m=n.size.h,l=h[0],u=l.w/l.h,y=new o.PlaneGeometry(u,1),g=new o.MeshBasicMaterial({map:d,transparent:!0,side:o.DoubleSide}),f=new o.Mesh(y,g),_={mesh:f,texture:d,frames:h,sheetWidth:c,sheetHeight:m,currentFrame:0,elapsed:0,playing:t.autoPlay};this.applyFrame(_),f.position.set(t.positionX,t.positionY,t.positionZ),f.rotation.set(t.rotationX,t.rotationY,t.rotationZ),f.scale.set(t.scaleX,t.scaleY,1),this.threeContext.scene.add(f),this.entries.set(e.id,_)}catch(e){console.error("SpriteAnimation3DSystem: failed to load spritesheet",e)}}handleChange(e){const t=e.component,s=e.prop?.prop?.[0];"resource"===s&&(this.handleRemove(e.gameObject.id),this.handleAdd(e.gameObject,t))}handleRemove(e){this.increaseAsyncId(e);const t=this.entries.get(e);t&&(this.threeContext.scene.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose(),t.texture.dispose(),this.entries.delete(e))}applyFrame(e){const t=e.frames[e.currentFrame],s=e.texture;s.offset.set(t.x/e.sheetWidth,1-(t.y+t.h)/e.sheetHeight),s.repeat.set(t.w/e.sheetWidth,t.h/e.sheetHeight)}parseFrames(e){return Array.isArray(e)?e.map(e=>({x:e.frame.x,y:e.frame.y,w:e.frame.w,h:e.frame.h})):Object.keys(e).sort().map(t=>({x:e[t].frame.x,y:e[t].frame.y,w:e[t].frame.w,h:e[t].frame.h}))}resolveImageUrl(e,t){return e.substring(0,e.lastIndexOf("/")+1)+t}loadTexture(e){return new Promise((t,s)=>{this.textureLoader.load(e,t,void 0,s)})}onDestroy(){for(const[e]of this.entries)this.handleRemove(e);this.entries.clear()}};n=e.__decorate([t.decorators.componentObserver({SpriteAnimation3D:["resource","speed","positionX","positionY","positionZ","rotationX","rotationY","rotationZ","scaleX","scaleY"]})],n);var a=n;exports.SpriteAnimation3D=i,exports.SpriteAnimation3DSystem=a;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Component, ComponentChanged, GameObject } from '@combos-fun/engine';
|
|
2
|
+
import { Renderer3D } from '@combos-fun/plugin-renderer-3d';
|
|
3
|
+
|
|
4
|
+
interface SpriteAnimation3DParams {
|
|
5
|
+
resource?: string;
|
|
6
|
+
autoPlay?: boolean;
|
|
7
|
+
speed?: number;
|
|
8
|
+
positionX?: number;
|
|
9
|
+
positionY?: number;
|
|
10
|
+
positionZ?: number;
|
|
11
|
+
rotationX?: number;
|
|
12
|
+
rotationY?: number;
|
|
13
|
+
rotationZ?: number;
|
|
14
|
+
scaleX?: number;
|
|
15
|
+
scaleY?: number;
|
|
16
|
+
}
|
|
17
|
+
declare class SpriteAnimation3D extends Component<SpriteAnimation3DParams> {
|
|
18
|
+
static componentName: string;
|
|
19
|
+
resource: string;
|
|
20
|
+
autoPlay: boolean;
|
|
21
|
+
speed: number;
|
|
22
|
+
positionX: number;
|
|
23
|
+
positionY: number;
|
|
24
|
+
positionZ: number;
|
|
25
|
+
rotationX: number;
|
|
26
|
+
rotationY: number;
|
|
27
|
+
rotationZ: number;
|
|
28
|
+
scaleX: number;
|
|
29
|
+
scaleY: number;
|
|
30
|
+
init(obj?: SpriteAnimation3DParams): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class SpriteAnimation3DSystem extends Renderer3D {
|
|
34
|
+
static systemName: string;
|
|
35
|
+
name: string;
|
|
36
|
+
private entries;
|
|
37
|
+
private textureLoader;
|
|
38
|
+
init(): void;
|
|
39
|
+
componentChanged(changed: ComponentChanged): void;
|
|
40
|
+
rendererUpdate(gameObject: GameObject): void;
|
|
41
|
+
private handleAdd;
|
|
42
|
+
private handleChange;
|
|
43
|
+
private handleRemove;
|
|
44
|
+
private applyFrame;
|
|
45
|
+
private parseFrames;
|
|
46
|
+
private resolveImageUrl;
|
|
47
|
+
private loadTexture;
|
|
48
|
+
onDestroy(): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { SpriteAnimation3D, SpriteAnimation3DSystem };
|
|
52
|
+
export type { SpriteAnimation3DParams };
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { Component, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
|
|
3
|
+
import { type, step } from '@combos-fun/inspector-decorator';
|
|
4
|
+
import { Renderer3D, Renderer3DSystem } from '@combos-fun/plugin-renderer-3d';
|
|
5
|
+
import { TextureLoader, PlaneGeometry, MeshBasicMaterial, DoubleSide, Mesh } from 'three';
|
|
6
|
+
|
|
7
|
+
class SpriteAnimation3D extends Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.resource = '';
|
|
11
|
+
this.autoPlay = true;
|
|
12
|
+
this.speed = 100;
|
|
13
|
+
this.positionX = 0;
|
|
14
|
+
this.positionY = 0;
|
|
15
|
+
this.positionZ = 0;
|
|
16
|
+
this.rotationX = 0;
|
|
17
|
+
this.rotationY = 0;
|
|
18
|
+
this.rotationZ = 0;
|
|
19
|
+
this.scaleX = 1;
|
|
20
|
+
this.scaleY = 1;
|
|
21
|
+
}
|
|
22
|
+
static { this.componentName = 'SpriteAnimation3D'; }
|
|
23
|
+
init(obj) {
|
|
24
|
+
if (obj)
|
|
25
|
+
Object.assign(this, obj);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
__decorate([
|
|
29
|
+
type('string')
|
|
30
|
+
], SpriteAnimation3D.prototype, "resource", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
type('boolean')
|
|
33
|
+
], SpriteAnimation3D.prototype, "autoPlay", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
type('number'),
|
|
36
|
+
step(10)
|
|
37
|
+
], SpriteAnimation3D.prototype, "speed", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
type('number'),
|
|
40
|
+
step(0.1)
|
|
41
|
+
], SpriteAnimation3D.prototype, "positionX", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
type('number'),
|
|
44
|
+
step(0.1)
|
|
45
|
+
], SpriteAnimation3D.prototype, "positionY", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
type('number'),
|
|
48
|
+
step(0.1)
|
|
49
|
+
], SpriteAnimation3D.prototype, "positionZ", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
type('number'),
|
|
52
|
+
step(0.01)
|
|
53
|
+
], SpriteAnimation3D.prototype, "rotationX", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
type('number'),
|
|
56
|
+
step(0.01)
|
|
57
|
+
], SpriteAnimation3D.prototype, "rotationY", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
type('number'),
|
|
60
|
+
step(0.01)
|
|
61
|
+
], SpriteAnimation3D.prototype, "rotationZ", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
type('number'),
|
|
64
|
+
step(0.1)
|
|
65
|
+
], SpriteAnimation3D.prototype, "scaleX", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
type('number'),
|
|
68
|
+
step(0.1)
|
|
69
|
+
], SpriteAnimation3D.prototype, "scaleY", void 0);
|
|
70
|
+
|
|
71
|
+
let SpriteAnimation3DSystem = class SpriteAnimation3DSystem extends Renderer3D {
|
|
72
|
+
constructor() {
|
|
73
|
+
super(...arguments);
|
|
74
|
+
this.name = 'SpriteAnimation3DSystem';
|
|
75
|
+
this.entries = new Map();
|
|
76
|
+
this.textureLoader = new TextureLoader();
|
|
77
|
+
}
|
|
78
|
+
static { this.systemName = 'SpriteAnimation3DSystem'; }
|
|
79
|
+
init() {
|
|
80
|
+
const renderer3DSystem = this.game.getSystem(Renderer3DSystem);
|
|
81
|
+
renderer3DSystem.rendererManager.register(this);
|
|
82
|
+
}
|
|
83
|
+
componentChanged(changed) {
|
|
84
|
+
if (changed.componentName !== 'SpriteAnimation3D')
|
|
85
|
+
return;
|
|
86
|
+
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
87
|
+
this.handleAdd(changed.gameObject, changed.component);
|
|
88
|
+
}
|
|
89
|
+
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
90
|
+
this.handleRemove(changed.gameObject.id);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.handleChange(changed);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
rendererUpdate(gameObject) {
|
|
97
|
+
const component = gameObject.getComponent(SpriteAnimation3D);
|
|
98
|
+
if (!component)
|
|
99
|
+
return;
|
|
100
|
+
const entry = this.entries.get(gameObject.id);
|
|
101
|
+
if (!entry)
|
|
102
|
+
return;
|
|
103
|
+
entry.mesh.position.set(component.positionX, component.positionY, component.positionZ);
|
|
104
|
+
entry.mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
105
|
+
entry.mesh.scale.set(component.scaleX, component.scaleY, 1);
|
|
106
|
+
if (!entry.playing || entry.frames.length === 0)
|
|
107
|
+
return;
|
|
108
|
+
const delta = this.threeContext.clock.getDelta() * 1000;
|
|
109
|
+
entry.elapsed += delta;
|
|
110
|
+
if (entry.elapsed >= component.speed) {
|
|
111
|
+
entry.elapsed -= component.speed;
|
|
112
|
+
entry.currentFrame = (entry.currentFrame + 1) % entry.frames.length;
|
|
113
|
+
this.applyFrame(entry);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async handleAdd(gameObject, component) {
|
|
117
|
+
if (!component.resource)
|
|
118
|
+
return;
|
|
119
|
+
const asyncId = this.increaseAsyncId(gameObject.id);
|
|
120
|
+
try {
|
|
121
|
+
const response = await fetch(component.resource);
|
|
122
|
+
const json = await response.json();
|
|
123
|
+
if (!this.validateAsyncId(gameObject.id, asyncId))
|
|
124
|
+
return;
|
|
125
|
+
const meta = json.meta;
|
|
126
|
+
const framesData = json.frames;
|
|
127
|
+
const imageUrl = this.resolveImageUrl(component.resource, meta.image);
|
|
128
|
+
const texture = await this.loadTexture(imageUrl);
|
|
129
|
+
if (!this.validateAsyncId(gameObject.id, asyncId)) {
|
|
130
|
+
texture.dispose();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const frames = this.parseFrames(framesData);
|
|
134
|
+
const sheetWidth = meta.size.w;
|
|
135
|
+
const sheetHeight = meta.size.h;
|
|
136
|
+
const firstFrame = frames[0];
|
|
137
|
+
const aspectRatio = firstFrame.w / firstFrame.h;
|
|
138
|
+
const geometry = new PlaneGeometry(aspectRatio, 1);
|
|
139
|
+
const material = new MeshBasicMaterial({
|
|
140
|
+
map: texture,
|
|
141
|
+
transparent: true,
|
|
142
|
+
side: DoubleSide,
|
|
143
|
+
});
|
|
144
|
+
const mesh = new Mesh(geometry, material);
|
|
145
|
+
const entry = {
|
|
146
|
+
mesh,
|
|
147
|
+
texture,
|
|
148
|
+
frames,
|
|
149
|
+
sheetWidth,
|
|
150
|
+
sheetHeight,
|
|
151
|
+
currentFrame: 0,
|
|
152
|
+
elapsed: 0,
|
|
153
|
+
playing: component.autoPlay,
|
|
154
|
+
};
|
|
155
|
+
this.applyFrame(entry);
|
|
156
|
+
mesh.position.set(component.positionX, component.positionY, component.positionZ);
|
|
157
|
+
mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);
|
|
158
|
+
mesh.scale.set(component.scaleX, component.scaleY, 1);
|
|
159
|
+
this.threeContext.scene.add(mesh);
|
|
160
|
+
this.entries.set(gameObject.id, entry);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
console.error('SpriteAnimation3DSystem: failed to load spritesheet', e);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
handleChange(changed) {
|
|
167
|
+
const component = changed.component;
|
|
168
|
+
const changedProp = changed.prop?.prop?.[0];
|
|
169
|
+
if (changedProp === 'resource') {
|
|
170
|
+
this.handleRemove(changed.gameObject.id);
|
|
171
|
+
this.handleAdd(changed.gameObject, component);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
handleRemove(id) {
|
|
175
|
+
this.increaseAsyncId(id);
|
|
176
|
+
const entry = this.entries.get(id);
|
|
177
|
+
if (!entry)
|
|
178
|
+
return;
|
|
179
|
+
this.threeContext.scene.remove(entry.mesh);
|
|
180
|
+
entry.mesh.geometry.dispose();
|
|
181
|
+
entry.mesh.material.dispose();
|
|
182
|
+
entry.texture.dispose();
|
|
183
|
+
this.entries.delete(id);
|
|
184
|
+
}
|
|
185
|
+
applyFrame(entry) {
|
|
186
|
+
const frame = entry.frames[entry.currentFrame];
|
|
187
|
+
const tex = entry.texture;
|
|
188
|
+
tex.offset.set(frame.x / entry.sheetWidth, 1 - (frame.y + frame.h) / entry.sheetHeight);
|
|
189
|
+
tex.repeat.set(frame.w / entry.sheetWidth, frame.h / entry.sheetHeight);
|
|
190
|
+
}
|
|
191
|
+
parseFrames(framesData) {
|
|
192
|
+
if (Array.isArray(framesData)) {
|
|
193
|
+
return framesData.map((f) => ({
|
|
194
|
+
x: f.frame.x,
|
|
195
|
+
y: f.frame.y,
|
|
196
|
+
w: f.frame.w,
|
|
197
|
+
h: f.frame.h,
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
// Object-based format: { "frameName": { frame: { x, y, w, h } } }
|
|
201
|
+
return Object.keys(framesData)
|
|
202
|
+
.sort()
|
|
203
|
+
.map((key) => ({
|
|
204
|
+
x: framesData[key].frame.x,
|
|
205
|
+
y: framesData[key].frame.y,
|
|
206
|
+
w: framesData[key].frame.w,
|
|
207
|
+
h: framesData[key].frame.h,
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
resolveImageUrl(jsonUrl, imageName) {
|
|
211
|
+
const base = jsonUrl.substring(0, jsonUrl.lastIndexOf('/') + 1);
|
|
212
|
+
return base + imageName;
|
|
213
|
+
}
|
|
214
|
+
loadTexture(url) {
|
|
215
|
+
return new Promise((resolve, reject) => {
|
|
216
|
+
this.textureLoader.load(url, resolve, undefined, reject);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
onDestroy() {
|
|
220
|
+
for (const [id] of this.entries) {
|
|
221
|
+
this.handleRemove(id);
|
|
222
|
+
}
|
|
223
|
+
this.entries.clear();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
SpriteAnimation3DSystem = __decorate([
|
|
227
|
+
decorators.componentObserver({
|
|
228
|
+
SpriteAnimation3D: [
|
|
229
|
+
'resource', 'speed',
|
|
230
|
+
'positionX', 'positionY', 'positionZ',
|
|
231
|
+
'rotationX', 'rotationY', 'rotationZ',
|
|
232
|
+
'scaleX', 'scaleY',
|
|
233
|
+
],
|
|
234
|
+
})
|
|
235
|
+
], SpriteAnimation3DSystem);
|
|
236
|
+
var SpriteAnimation3DSystem_default = SpriteAnimation3DSystem;
|
|
237
|
+
|
|
238
|
+
export { SpriteAnimation3D, SpriteAnimation3DSystem_default as SpriteAnimation3DSystem };
|
|
239
|
+
//# sourceMappingURL=plugin-renderer-3d-sprite-animation.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-3d-sprite-animation.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { type, step } from '@combos-fun/inspector-decorator';\n\nexport interface SpriteAnimation3DParams {\n resource?: string;\n autoPlay?: boolean;\n speed?: number;\n positionX?: number;\n positionY?: number;\n positionZ?: number;\n rotationX?: number;\n rotationY?: number;\n rotationZ?: number;\n scaleX?: number;\n scaleY?: number;\n}\n\nexport default class SpriteAnimation3D extends Component<SpriteAnimation3DParams> {\n static componentName: string = 'SpriteAnimation3D';\n\n @type('string') resource: string = '';\n @type('boolean') autoPlay: boolean = true;\n @type('number') @step(10) speed: number = 100;\n @type('number') @step(0.1) positionX: number = 0;\n @type('number') @step(0.1) positionY: number = 0;\n @type('number') @step(0.1) positionZ: number = 0;\n @type('number') @step(0.01) rotationX: number = 0;\n @type('number') @step(0.01) rotationY: number = 0;\n @type('number') @step(0.01) rotationZ: number = 0;\n @type('number') @step(0.1) scaleX: number = 1;\n @type('number') @step(0.1) scaleY: number = 1;\n\n init(obj?: SpriteAnimation3DParams) {\n if (obj) Object.assign(this, obj);\n }\n}\n","import { decorators, ComponentChanged, OBSERVER_TYPE, GameObject } from '@combos-fun/engine';\nimport { Renderer3D, Renderer3DSystem } from '@combos-fun/plugin-renderer-3d';\nimport {\n TextureLoader,\n PlaneGeometry,\n MeshBasicMaterial,\n Mesh,\n DoubleSide,\n} from 'three';\nimport type { Texture } from 'three';\nimport SpriteAnimation3D from './component';\n\ninterface FrameData {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface SpriteAnimation3DEntry {\n mesh: Mesh;\n texture: Texture;\n frames: FrameData[];\n sheetWidth: number;\n sheetHeight: number;\n currentFrame: number;\n elapsed: number;\n playing: boolean;\n}\n\n@decorators.componentObserver({\n SpriteAnimation3D: [\n 'resource', 'speed',\n 'positionX', 'positionY', 'positionZ',\n 'rotationX', 'rotationY', 'rotationZ',\n 'scaleX', 'scaleY',\n ],\n})\nexport default class SpriteAnimation3DSystem extends Renderer3D {\n static systemName = 'SpriteAnimation3DSystem';\n name: string = 'SpriteAnimation3DSystem';\n\n private entries: Map<number, SpriteAnimation3DEntry> = new Map();\n private textureLoader = new TextureLoader();\n\n init() {\n const renderer3DSystem = this.game.getSystem(Renderer3DSystem) as Renderer3DSystem;\n renderer3DSystem.rendererManager.register(this);\n }\n\n componentChanged(changed: ComponentChanged) {\n if (changed.componentName !== 'SpriteAnimation3D') return;\n\n if (changed.type === OBSERVER_TYPE.ADD) {\n this.handleAdd(changed.gameObject, changed.component as SpriteAnimation3D);\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.handleRemove(changed.gameObject.id);\n } else {\n this.handleChange(changed);\n }\n }\n\n rendererUpdate(gameObject: GameObject) {\n const component = gameObject.getComponent(SpriteAnimation3D) as SpriteAnimation3D;\n if (!component) return;\n\n const entry = this.entries.get(gameObject.id);\n if (!entry) return;\n\n entry.mesh.position.set(component.positionX, component.positionY, component.positionZ);\n entry.mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n entry.mesh.scale.set(component.scaleX, component.scaleY, 1);\n\n if (!entry.playing || entry.frames.length === 0) return;\n\n const delta = this.threeContext.clock.getDelta() * 1000;\n entry.elapsed += delta;\n\n if (entry.elapsed >= component.speed) {\n entry.elapsed -= component.speed;\n entry.currentFrame = (entry.currentFrame + 1) % entry.frames.length;\n this.applyFrame(entry);\n }\n }\n\n private async handleAdd(gameObject: GameObject, component: SpriteAnimation3D) {\n if (!component.resource) return;\n\n const asyncId = this.increaseAsyncId(gameObject.id);\n\n try {\n const response = await fetch(component.resource);\n const json = await response.json();\n if (!this.validateAsyncId(gameObject.id, asyncId)) return;\n\n const meta = json.meta;\n const framesData = json.frames;\n const imageUrl = this.resolveImageUrl(component.resource, meta.image);\n\n const texture = await this.loadTexture(imageUrl);\n if (!this.validateAsyncId(gameObject.id, asyncId)) {\n texture.dispose();\n return;\n }\n\n const frames = this.parseFrames(framesData);\n const sheetWidth = meta.size.w;\n const sheetHeight = meta.size.h;\n\n const firstFrame = frames[0];\n const aspectRatio = firstFrame.w / firstFrame.h;\n const geometry = new PlaneGeometry(aspectRatio, 1);\n const material = new MeshBasicMaterial({\n map: texture,\n transparent: true,\n side: DoubleSide,\n });\n const mesh = new Mesh(geometry, material);\n\n const entry: SpriteAnimation3DEntry = {\n mesh,\n texture,\n frames,\n sheetWidth,\n sheetHeight,\n currentFrame: 0,\n elapsed: 0,\n playing: component.autoPlay,\n };\n\n this.applyFrame(entry);\n\n mesh.position.set(component.positionX, component.positionY, component.positionZ);\n mesh.rotation.set(component.rotationX, component.rotationY, component.rotationZ);\n mesh.scale.set(component.scaleX, component.scaleY, 1);\n\n this.threeContext.scene.add(mesh);\n this.entries.set(gameObject.id, entry);\n } catch (e) {\n console.error('SpriteAnimation3DSystem: failed to load spritesheet', e);\n }\n }\n\n private handleChange(changed: ComponentChanged) {\n const component = changed.component as SpriteAnimation3D;\n const changedProp = changed.prop?.prop?.[0];\n\n if (changedProp === 'resource') {\n this.handleRemove(changed.gameObject.id);\n this.handleAdd(changed.gameObject, component);\n }\n }\n\n private handleRemove(id: number) {\n this.increaseAsyncId(id);\n const entry = this.entries.get(id);\n if (!entry) return;\n\n this.threeContext.scene.remove(entry.mesh);\n entry.mesh.geometry.dispose();\n (entry.mesh.material as MeshBasicMaterial).dispose();\n entry.texture.dispose();\n this.entries.delete(id);\n }\n\n private applyFrame(entry: SpriteAnimation3DEntry) {\n const frame = entry.frames[entry.currentFrame];\n const tex = entry.texture;\n\n tex.offset.set(frame.x / entry.sheetWidth, 1 - (frame.y + frame.h) / entry.sheetHeight);\n tex.repeat.set(frame.w / entry.sheetWidth, frame.h / entry.sheetHeight);\n }\n\n private parseFrames(framesData: any): FrameData[] {\n if (Array.isArray(framesData)) {\n return framesData.map((f: any) => ({\n x: f.frame.x,\n y: f.frame.y,\n w: f.frame.w,\n h: f.frame.h,\n }));\n }\n // Object-based format: { \"frameName\": { frame: { x, y, w, h } } }\n return Object.keys(framesData)\n .sort()\n .map((key) => ({\n x: framesData[key].frame.x,\n y: framesData[key].frame.y,\n w: framesData[key].frame.w,\n h: framesData[key].frame.h,\n }));\n }\n\n private resolveImageUrl(jsonUrl: string, imageName: string): string {\n const base = jsonUrl.substring(0, jsonUrl.lastIndexOf('/') + 1);\n return base + imageName;\n }\n\n private loadTexture(url: string): Promise<Texture> {\n return new Promise((resolve, reject) => {\n this.textureLoader.load(url, resolve, undefined, reject);\n });\n }\n\n onDestroy() {\n for (const [id] of this.entries) {\n this.handleRemove(id);\n }\n this.entries.clear();\n }\n}\n"],"names":[],"mappings":";;;;;;AAiBc,MAAO,iBAAkB,SAAQ,SAAkC,CAAA;AAAjF,IAAA,WAAA,GAAA;;QAGkB,IAAA,CAAA,QAAQ,GAAW,EAAE;QACpB,IAAA,CAAA,QAAQ,GAAY,IAAI;QACf,IAAA,CAAA,KAAK,GAAW,GAAG;QAClB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACpB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACrB,IAAA,CAAA,SAAS,GAAW,CAAC;QACtB,IAAA,CAAA,MAAM,GAAW,CAAC;QAClB,IAAA,CAAA,MAAM,GAAW,CAAC;IAK/C;aAjBS,IAAA,CAAA,aAAa,GAAW,mBAAX,CAA+B;AAcnD,IAAA,IAAI,CAAC,GAA6B,EAAA;AAChC,QAAA,IAAI,GAAG;AAAE,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;IACnC;;AAdgB,UAAA,CAAA;IAAf,IAAI,CAAC,QAAQ;AAAwB,CAAA,EAAA,iBAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AACrB,UAAA,CAAA;IAAhB,IAAI,C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EAAE,WAAW,EAAE,WAAW;YACrC,WAAW,EAAE,WAAW,EAAE,WAAW;AACrC,YAAA,QAAQ,EAAE,QAAQ;AACnB,SAAA;KACF;AACoB,CAAA,EAAA,uBAAuB,CA4K3C;sCA5KoB,uBAAuB;;;;"}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@combos-fun/plugin-renderer-3d-sprite-animation",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "@combos-fun/plugin-renderer-3d-sprite-animation",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/plugin-renderer-3d-sprite-animation.esm.js",
|
|
7
|
+
"bundle": "CombosFun.plugin.renderer.3d.sprite.animation",
|
|
8
|
+
"unpkg": "dist/CombosFun.plugin.renderer.3d.sprite.animation.min.js",
|
|
9
|
+
"types": "dist/plugin-renderer-3d-sprite-animation.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"three": "^0.172.0",
|
|
16
|
+
"@combos-fun/inspector-decorator": "0.0.6",
|
|
17
|
+
"@combos-fun/plugin-renderer-3d": "0.0.6",
|
|
18
|
+
"@combos-fun/engine": "0.0.6"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node ../../scripts/build-package.mjs"
|
|
22
|
+
}
|
|
23
|
+
}
|