@combos-fun/plugin-renderer-tiling-sprite 0.0.54 → 0.2.0
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/agent-skill.md +1 -1
- package/dist/plugin-renderer-tiling-sprite.cjs.js +1 -1
- package/dist/plugin-renderer-tiling-sprite.cjs.js.map +1 -1
- package/dist/plugin-renderer-tiling-sprite.cjs.prod.js +1 -1
- package/dist/plugin-renderer-tiling-sprite.esm.js +2 -2
- package/dist/plugin-renderer-tiling-sprite.esm.js.map +1 -1
- package/package.json +5 -5
package/agent-skill.md
CHANGED
|
@@ -26,4 +26,4 @@ bg.addComponent(new TilingSprite({
|
|
|
26
26
|
}));
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
The repeated area follows `
|
|
29
|
+
The repeated area follows `Transform2D.size`. The system reads IMAGE `data.image` directly, so importing `plugin-renderer-img` is unnecessary. Mutating either vector is observed deeply; advance `tilePosition` using frame delta for smooth scrolling.
|
|
@@ -68,7 +68,7 @@ let TilingSprite = class TilingSprite extends pluginRenderer.Renderer {
|
|
|
68
68
|
this.renderSystem.rendererManager.register(this);
|
|
69
69
|
}
|
|
70
70
|
rendererUpdate(gameObject) {
|
|
71
|
-
const { width, height } = gameObject.
|
|
71
|
+
const { width, height } = gameObject.getComponent(pluginRenderer.Transform2D)?.size ?? { width: 0, height: 0 };
|
|
72
72
|
const img = this.imgs[gameObject.id];
|
|
73
73
|
if (img) {
|
|
74
74
|
img.tilingSprite.width = width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-tiling-sprite.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface TilingSpriteParams {\n resource: string;\n tileScale: { x: number; y: number };\n tilePosition: { x: number; y: number };\n}\n\nexport default class TilingSprite extends Component<TilingSpriteParams> {\n static componentName: string = 'TilingSprite';\n\n @Field({\n type: 'string',\n group: 'TilingSprite',\n label: 'resource',\n description: 'Tiling texture resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'vector2',\n step: 0.1,\n group: 'TilingSprite',\n label: 'tileScale',\n description: 'Scale of each repeated tile on X and Y.',\n })\n tileScale: TilingSpriteParams['tileScale'] = {\n x: 1,\n y: 1,\n };\n\n @Field({\n type: 'vector2',\n step: 1,\n group: 'TilingSprite',\n label: 'tilePosition',\n description: 'Offset of the tiled texture on X and Y.',\n })\n tilePosition: TilingSpriteParams['tilePosition'] = {\n x: 0,\n y: 0,\n };\n\n init(obj?: TilingSpriteParams) {\n if (obj) {\n this.resource = obj.resource;\n this.tileScale = obj.tileScale;\n this.tilePosition = obj.tilePosition;\n }\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@combos-fun/plugin-renderer';\nimport TilingSpriteComponent from './component';\nimport { TilingSprite as TilingSpriteEngine } from '@combos-fun/renderer-adapter';\nimport type { Point } from 'pixi.js';\n\n@decorators.componentObserver({\n TilingSprite: [\n { prop: ['resource'], deep: false },\n { prop: ['tileScale'], deep: true },\n { prop: ['tilePosition'], deep: true },\n ],\n})\nexport default class TilingSprite extends Renderer {\n static systemName: string = 'TilingSprite';\n name: string = 'TilingSprite';\n imgs: { [propName: number]: TilingSpriteEngine } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.
|
|
1
|
+
{"version":3,"file":"plugin-renderer-tiling-sprite.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface TilingSpriteParams {\n resource: string;\n tileScale: { x: number; y: number };\n tilePosition: { x: number; y: number };\n}\n\nexport default class TilingSprite extends Component<TilingSpriteParams> {\n static componentName: string = 'TilingSprite';\n\n @Field({\n type: 'string',\n group: 'TilingSprite',\n label: 'resource',\n description: 'Tiling texture resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'vector2',\n step: 0.1,\n group: 'TilingSprite',\n label: 'tileScale',\n description: 'Scale of each repeated tile on X and Y.',\n })\n tileScale: TilingSpriteParams['tileScale'] = {\n x: 1,\n y: 1,\n };\n\n @Field({\n type: 'vector2',\n step: 1,\n group: 'TilingSprite',\n label: 'tilePosition',\n description: 'Offset of the tiled texture on X and Y.',\n })\n tilePosition: TilingSpriteParams['tilePosition'] = {\n x: 0,\n y: 0,\n };\n\n init(obj?: TilingSpriteParams) {\n if (obj) {\n this.resource = obj.resource;\n this.tileScale = obj.tileScale;\n this.tilePosition = obj.tilePosition;\n }\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, Transform2D } from '@combos-fun/plugin-renderer';\nimport TilingSpriteComponent from './component';\nimport { TilingSprite as TilingSpriteEngine } from '@combos-fun/renderer-adapter';\nimport type { Point } from 'pixi.js';\n\n@decorators.componentObserver({\n TilingSprite: [\n { prop: ['resource'], deep: false },\n { prop: ['tileScale'], deep: true },\n { prop: ['tilePosition'], deep: true },\n ],\n})\nexport default class TilingSprite extends Renderer {\n static systemName: string = 'TilingSprite';\n name: string = 'TilingSprite';\n imgs: { [propName: number]: TilingSpriteEngine } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n const img = this.imgs[gameObject.id];\n if (img) {\n img.tilingSprite.width = width;\n img.tilingSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'TilingSprite') {\n const component: TilingSpriteComponent = changed.component as TilingSpriteComponent;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const sprite = new TilingSpriteEngine(null);\n this.imgs[changed.gameObject.id] = sprite;\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0);\n this.setProp(changed.gameObject.id, component);\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { data } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!data) {\n console.error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`);\n return\n }\n sprite.image = data.image;\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n if (changed.prop.prop[0] === 'resource') {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { data } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!data) {\n console.error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`);\n return\n }\n this.imgs[changed.gameObject.id].image = data.image;\n } else {\n this.setProp(changed.gameObject.id, component);\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n const sprite = this.imgs[changed.gameObject.id];\n this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.tilingSprite);\n sprite.tilingSprite.destroy({\n children: true\n });\n delete this.imgs[changed.gameObject.id];\n }\n }\n }\n setProp(id: number, component: TilingSpriteComponent) {\n // bug possible\n this.imgs[id].tilingSprite.tilePosition = component.tilePosition as Point;\n this.imgs[id].tilingSprite.tileScale = component.tileScale as Point;\n }\n}\n"],"names":["Component","__decorate","Field","TilingSprite","Renderer","RendererSystem","Transform2D","OBSERVER_TYPE","TilingSpriteEngine","resource","decorators"],"mappings":";;;;;;;;qBASc,MAAO,YAAa,SAAQA,gBAA6B,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AE;YACnC,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;YACnC,EAAE,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;AACvC,SAAA;KACF;AACoB,CAAA,EAAA,YAAY,CAiEhC;2BAjEoB,YAAY;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),i=require("@combos-fun/engine"),t=require("@combos-fun/inspector-decorator"),r=require("@combos-fun/plugin-renderer"),s=require("@combos-fun/renderer-adapter");let o=class extends i.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}static{this.componentName="TilingSprite"}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}};e.__decorate([t.Field({type:"string",group:"TilingSprite",label:"resource",description:"Tiling texture resource id.",editor:"text"})],o.prototype,"resource",void 0),e.__decorate([t.Field({type:"vector2",step:.1,group:"TilingSprite",label:"tileScale",description:"Scale of each repeated tile on X and Y."})],o.prototype,"tileScale",void 0),e.__decorate([t.Field({type:"vector2",step:1,group:"TilingSprite",label:"tilePosition",description:"Offset of the tiled texture on X and Y."})],o.prototype,"tilePosition",void 0);let n=class extends r.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}static{this.systemName="TilingSprite"}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:i,height:t}=e.
|
|
1
|
+
"use strict";var e=require("tslib"),i=require("@combos-fun/engine"),t=require("@combos-fun/inspector-decorator"),r=require("@combos-fun/plugin-renderer"),s=require("@combos-fun/renderer-adapter");let o=class extends i.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}static{this.componentName="TilingSprite"}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}};e.__decorate([t.Field({type:"string",group:"TilingSprite",label:"resource",description:"Tiling texture resource id.",editor:"text"})],o.prototype,"resource",void 0),e.__decorate([t.Field({type:"vector2",step:.1,group:"TilingSprite",label:"tileScale",description:"Scale of each repeated tile on X and Y."})],o.prototype,"tileScale",void 0),e.__decorate([t.Field({type:"vector2",step:1,group:"TilingSprite",label:"tilePosition",description:"Offset of the tiled texture on X and Y."})],o.prototype,"tilePosition",void 0);let n=class extends r.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}static{this.systemName="TilingSprite"}init(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:i,height:t}=e.getComponent(r.Transform2D)?.size??{width:0,height:0},s=this.imgs[e.id];s&&(s.tilingSprite.width=i,s.tilingSprite.height=t)}async componentChanged(e){const t=e.gameObject.id;if("TilingSprite"===e.componentName){const r=e.component;if(e.type===i.OBSERVER_TYPE.ADD){const o=new s.TilingSprite(null);this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.tilingSprite,0),this.setProp(e.gameObject.id,r);const n=this.increaseAsyncId(t),{data:c}=await i.resource.getResource(r.resource);if(!this.validateAsyncId(t,n))return;if(!c)return void console.error(`GameObject:${e.gameObject.name}'s TilingSprite resource load error`);o.image=c.image}else if(e.type===i.OBSERVER_TYPE.CHANGE)if("resource"===e.prop.prop[0]){const s=this.increaseAsyncId(t),{data:o}=await i.resource.getResource(r.resource);if(!this.validateAsyncId(t,s))return;if(!o)return void console.error(`GameObject:${e.gameObject.name}'s TilingSprite resource load error`);this.imgs[e.gameObject.id].image=o.image}else this.setProp(e.gameObject.id,r);else if(e.type===i.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(t);const i=this.imgs[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(i.tilingSprite),i.tilingSprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}}}setProp(e,i){this.imgs[e].tilingSprite.tilePosition=i.tilePosition,this.imgs[e].tilingSprite.tileScale=i.tileScale}};n=e.__decorate([i.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],n);var c=n;exports.TilingSprite=o,exports.TilingSpriteSystem=c;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { Component, OBSERVER_TYPE, resource, decorators } from '@combos-fun/engine';
|
|
3
3
|
import { Field } from '@combos-fun/inspector-decorator';
|
|
4
|
-
import { Renderer, RendererSystem } from '@combos-fun/plugin-renderer';
|
|
4
|
+
import { Renderer, RendererSystem, Transform2D } from '@combos-fun/plugin-renderer';
|
|
5
5
|
import { TilingSprite as TilingSprite$2 } from '@combos-fun/renderer-adapter';
|
|
6
6
|
|
|
7
7
|
let TilingSprite$1 = class TilingSprite extends Component {
|
|
@@ -66,7 +66,7 @@ let TilingSprite = class TilingSprite extends Renderer {
|
|
|
66
66
|
this.renderSystem.rendererManager.register(this);
|
|
67
67
|
}
|
|
68
68
|
rendererUpdate(gameObject) {
|
|
69
|
-
const { width, height } = gameObject.
|
|
69
|
+
const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };
|
|
70
70
|
const img = this.imgs[gameObject.id];
|
|
71
71
|
if (img) {
|
|
72
72
|
img.tilingSprite.width = width;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-tiling-sprite.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface TilingSpriteParams {\n resource: string;\n tileScale: { x: number; y: number };\n tilePosition: { x: number; y: number };\n}\n\nexport default class TilingSprite extends Component<TilingSpriteParams> {\n static componentName: string = 'TilingSprite';\n\n @Field({\n type: 'string',\n group: 'TilingSprite',\n label: 'resource',\n description: 'Tiling texture resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'vector2',\n step: 0.1,\n group: 'TilingSprite',\n label: 'tileScale',\n description: 'Scale of each repeated tile on X and Y.',\n })\n tileScale: TilingSpriteParams['tileScale'] = {\n x: 1,\n y: 1,\n };\n\n @Field({\n type: 'vector2',\n step: 1,\n group: 'TilingSprite',\n label: 'tilePosition',\n description: 'Offset of the tiled texture on X and Y.',\n })\n tilePosition: TilingSpriteParams['tilePosition'] = {\n x: 0,\n y: 0,\n };\n\n init(obj?: TilingSpriteParams) {\n if (obj) {\n this.resource = obj.resource;\n this.tileScale = obj.tileScale;\n this.tilePosition = obj.tilePosition;\n }\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@combos-fun/plugin-renderer';\nimport TilingSpriteComponent from './component';\nimport { TilingSprite as TilingSpriteEngine } from '@combos-fun/renderer-adapter';\nimport type { Point } from 'pixi.js';\n\n@decorators.componentObserver({\n TilingSprite: [\n { prop: ['resource'], deep: false },\n { prop: ['tileScale'], deep: true },\n { prop: ['tilePosition'], deep: true },\n ],\n})\nexport default class TilingSprite extends Renderer {\n static systemName: string = 'TilingSprite';\n name: string = 'TilingSprite';\n imgs: { [propName: number]: TilingSpriteEngine } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.
|
|
1
|
+
{"version":3,"file":"plugin-renderer-tiling-sprite.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\n\nexport interface TilingSpriteParams {\n resource: string;\n tileScale: { x: number; y: number };\n tilePosition: { x: number; y: number };\n}\n\nexport default class TilingSprite extends Component<TilingSpriteParams> {\n static componentName: string = 'TilingSprite';\n\n @Field({\n type: 'string',\n group: 'TilingSprite',\n label: 'resource',\n description: 'Tiling texture resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'vector2',\n step: 0.1,\n group: 'TilingSprite',\n label: 'tileScale',\n description: 'Scale of each repeated tile on X and Y.',\n })\n tileScale: TilingSpriteParams['tileScale'] = {\n x: 1,\n y: 1,\n };\n\n @Field({\n type: 'vector2',\n step: 1,\n group: 'TilingSprite',\n label: 'tilePosition',\n description: 'Offset of the tiled texture on X and Y.',\n })\n tilePosition: TilingSpriteParams['tilePosition'] = {\n x: 0,\n y: 0,\n };\n\n init(obj?: TilingSpriteParams) {\n if (obj) {\n this.resource = obj.resource;\n this.tileScale = obj.tileScale;\n this.tilePosition = obj.tilePosition;\n }\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, OBSERVER_TYPE } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, Transform2D } from '@combos-fun/plugin-renderer';\nimport TilingSpriteComponent from './component';\nimport { TilingSprite as TilingSpriteEngine } from '@combos-fun/renderer-adapter';\nimport type { Point } from 'pixi.js';\n\n@decorators.componentObserver({\n TilingSprite: [\n { prop: ['resource'], deep: false },\n { prop: ['tileScale'], deep: true },\n { prop: ['tilePosition'], deep: true },\n ],\n})\nexport default class TilingSprite extends Renderer {\n static systemName: string = 'TilingSprite';\n name: string = 'TilingSprite';\n imgs: { [propName: number]: TilingSpriteEngine } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n const img = this.imgs[gameObject.id];\n if (img) {\n img.tilingSprite.width = width;\n img.tilingSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'TilingSprite') {\n const component: TilingSpriteComponent = changed.component as TilingSpriteComponent;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const sprite = new TilingSpriteEngine(null);\n this.imgs[changed.gameObject.id] = sprite;\n this.containerManager.getContainer(changed.gameObject.id).addChildAt(sprite.tilingSprite, 0);\n this.setProp(changed.gameObject.id, component);\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { data } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!data) {\n console.error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`);\n return\n }\n sprite.image = data.image;\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n if (changed.prop.prop[0] === 'resource') {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { data } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!data) {\n console.error(`GameObject:${changed.gameObject.name}'s TilingSprite resource load error`);\n return\n }\n this.imgs[changed.gameObject.id].image = data.image;\n } else {\n this.setProp(changed.gameObject.id, component);\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n const sprite = this.imgs[changed.gameObject.id];\n this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite.tilingSprite);\n sprite.tilingSprite.destroy({\n children: true\n });\n delete this.imgs[changed.gameObject.id];\n }\n }\n }\n setProp(id: number, component: TilingSpriteComponent) {\n // bug possible\n this.imgs[id].tilingSprite.tilePosition = component.tilePosition as Point;\n this.imgs[id].tilingSprite.tileScale = component.tileScale as Point;\n }\n}\n"],"names":["TilingSprite","TilingSpriteEngine"],"mappings":";;;;;;qBASc,MAAO,YAAa,SAAQ,SAA6B,CAAA;AAAvE,IAAA,WAAA,GAAA;;QAUE,IAAA,CAAA,QAAQ,GAAW,EAAE;AASrB,QAAA,IAAA,CAAA,SAAS,GAAoC;AAC3C,YAAA,CAAC,EAAE,CAAC;AACJ,YAAA,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YAAY,CAiEhC;2BAjEoB,YAAY;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-tiling-sprite",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Repeating tiled texture",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-tiling-sprite.esm.js",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "sun668 <q947692259@gmail.com>",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"pixi.js": "^8.18.1",
|
|
40
|
-
"@combos-fun/plugin-renderer": "0.0
|
|
41
|
-
"@combos-fun/engine": "0.0
|
|
42
|
-
"@combos-fun/
|
|
43
|
-
"@combos-fun/
|
|
40
|
+
"@combos-fun/plugin-renderer": "0.2.0",
|
|
41
|
+
"@combos-fun/engine": "0.2.0",
|
|
42
|
+
"@combos-fun/inspector-decorator": "0.2.0",
|
|
43
|
+
"@combos-fun/renderer-adapter": "0.2.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node ../../scripts/build-package.mjs"
|