@eva/plugin-renderer-tiling-sprite 2.0.1-beta.9 → 2.0.2-beta.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.
@@ -1 +1 @@
1
- globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_tilingSprite=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))((function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function c(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,c)}l((r=r.apply(e,t||[])).next())}))}function s(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function c(e){return function(t,i){var r=s(t,i);r.key=i,r.type=e}}function l(e){return function(t,i){s(t,i).step=e}}class a extends t.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}}a.componentName="TilingSprite",n([c("string")],a.prototype,"resource",void 0),n([c("vector2"),l(.1)],a.prototype,"tileScale",void 0),n([c("vector2"),l(1)],a.prototype,"tilePosition",void 0);let p=class extends i.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size,r=this.imgs[e.id];r&&(r.tilingSprite.width=t,r.tilingSprite.height=i)}componentChanged(e){return o(this,void 0,void 0,(function*(){const i=e.gameObject.id;if("TilingSprite"===e.componentName){const n=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const o=new r.TilingSprite(null);this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.tilingSprite,0),this.setProp(e.gameObject.id,n);const s=this.increaseAsyncId(i),{data:c}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,s))return;if(!c)return void console.error(`GameObject:${e.gameObject.name}'s TilingSprite resource load error`);o.image=c.image}else if(e.type===t.OBSERVER_TYPE.CHANGE)if("resource"===e.prop.prop[0]){const r=this.increaseAsyncId(i),{data:o}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,r))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,n);else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(i);const t=this.imgs[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(t.tilingSprite),t.tilingSprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}}}))}setProp(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale}};p=n([t.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],p);var g=p;return e.TilingSprite=a,e.TilingSpriteSystem=g,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.tilingSprite=globalThis.EVA.plugin.renderer.tilingSprite||_EVA_IIFE_tilingSprite;
1
+ globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_tilingSprite=function(e,t,i,r){"use strict";function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))(function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function c(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,c)}l((r=r.apply(e,t||[])).next())})}function s(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function c(e){return function(t,i){var r=s(t,i);r.key=i,r.type=e}}function l(e){return function(t,i){s(t,i).step=e}}class a extends t.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}}a.componentName="TilingSprite",n([c("string")],a.prototype,"resource",void 0),n([c("vector2"),l(.1)],a.prototype,"tileScale",void 0),n([c("vector2"),l(1)],a.prototype,"tilePosition",void 0);let p=class extends i.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size,r=this.imgs[e.id];r&&(r.tilingSprite.width=t,r.tilingSprite.height=i)}componentChanged(e){return o(this,void 0,void 0,function*(){const i=e.gameObject.id;if("TilingSprite"===e.componentName){const n=e.component;if(e.type===t.OBSERVER_TYPE.ADD){const o=new r.TilingSprite(null);this.imgs[e.gameObject.id]=o,this.containerManager.getContainer(e.gameObject.id).addChildAt(o.tilingSprite,0),this.setProp(e.gameObject.id,n);const s=this.increaseAsyncId(i),{data:c}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,s))return;if(!c)return void console.error(`GameObject:${e.gameObject.name}'s TilingSprite resource load error`);o.image=c.image}else if(e.type===t.OBSERVER_TYPE.CHANGE)if("resource"===e.prop.prop[0]){const r=this.increaseAsyncId(i),{data:o}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,r))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,n);else if(e.type===t.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(i);const t=this.imgs[e.gameObject.id];this.containerManager.getContainer(e.gameObject.id).removeChild(t.tilingSprite),t.tilingSprite.destroy({children:!0}),delete this.imgs[e.gameObject.id]}}})}setProp(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale}};p=n([t.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],p);var g=p;return e.TilingSprite=a,e.TilingSpriteSystem=g,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.tilingSprite=globalThis.EVA.plugin.renderer.tilingSprite||_EVA_IIFE_tilingSprite;
@@ -7,19 +7,19 @@ var inspectorDecorator = require('@eva/inspector-decorator');
7
7
  var pluginRenderer = require('@eva/plugin-renderer');
8
8
  var rendererAdapter = require('@eva/renderer-adapter');
9
9
 
10
- /*! *****************************************************************************
11
- Copyright (c) Microsoft Corporation. All rights reserved.
12
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
13
- this file except in compliance with the License. You may obtain a copy of the
14
- License at http://www.apache.org/licenses/LICENSE-2.0
10
+ /******************************************************************************
11
+ Copyright (c) Microsoft Corporation.
15
12
 
16
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
18
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
19
- MERCHANTABLITY OR NON-INFRINGEMENT.
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
20
15
 
21
- See the Apache Version 2.0 License for specific language governing permissions
22
- and limitations under the License.
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
23
  ***************************************************************************** */
24
24
 
25
25
  function __decorate(decorators, target, key, desc) {
@@ -30,27 +30,83 @@ function __decorate(decorators, target, key, desc) {
30
30
  }
31
31
 
32
32
  function __awaiter(thisArg, _arguments, P, generator) {
33
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
33
34
  return new (P || (P = Promise))(function (resolve, reject) {
34
35
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
35
36
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
37
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
37
38
  step((generator = generator.apply(thisArg, _arguments || [])).next());
38
39
  });
39
- }
40
+ }
41
+
42
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
43
+ var e = new Error(message);
44
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45
+ };
40
46
 
47
+ /**
48
+ * 平铺精灵组件
49
+ *
50
+ * TilingSprite 组件用于创建可平铺重复的纹理,支持无限滚动效果。
51
+ * 纹理会在指定区域内重复平铺,并可以设置平铺的缩放和偏移,
52
+ * 适用于背景滚动、地面贴图、水面波纹等需要重复纹理的场景。
53
+ *
54
+ * 主要功能:
55
+ * - 纹理平铺重复
56
+ * - 支持平铺缩放
57
+ * - 支持平铺偏移(实现滚动效果)
58
+ * - 性能优化(只渲染可见区域)
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // 创建滚动背景
63
+ * const background = new GameObject('background');
64
+ * background.addComponent(new TilingSprite({
65
+ * resource: 'bgTile', // 平铺纹理资源
66
+ * tileScale: { x: 1, y: 1 }, // 平铺缩放
67
+ * tilePosition: { x: 0, y: 0 } // 平铺偏移
68
+ * }));
69
+ * background.transform.size = { width: 800, height: 600 };
70
+ *
71
+ * // 实现无限滚动
72
+ * const tilingSprite = background.getComponent('TilingSprite');
73
+ * let offset = 0;
74
+ * setInterval(() => {
75
+ * offset += 1;
76
+ * tilingSprite.tilePosition = { x: offset, y: 0 };
77
+ * }, 16);
78
+ *
79
+ * // 创建水面效果
80
+ * const water = new GameObject('water');
81
+ * water.addComponent(new TilingSprite({
82
+ * resource: 'waterTile',
83
+ * tileScale: { x: 2, y: 2 } // 放大 2 倍平铺
84
+ * }));
85
+ * ```
86
+ */
41
87
  class TilingSprite$2 extends eva_js.Component {
42
88
  constructor() {
43
89
  super(...arguments);
90
+ /** 平铺纹理资源名称 */
44
91
  this.resource = '';
92
+ /** 平铺缩放比例 */
45
93
  this.tileScale = {
46
94
  x: 1,
47
95
  y: 1,
48
96
  };
97
+ /** 平铺位置偏移(用于实现滚动效果) */
49
98
  this.tilePosition = {
50
99
  x: 0,
51
100
  y: 0,
52
101
  };
53
102
  }
103
+ /**
104
+ * 初始化组件
105
+ * @param obj - 初始化参数
106
+ * @param obj.resource - 纹理资源名称
107
+ * @param obj.tileScale - 平铺缩放
108
+ * @param obj.tilePosition - 平铺偏移
109
+ */
54
110
  init(obj) {
55
111
  if (obj) {
56
112
  this.resource = obj.resource;
@@ -59,6 +115,7 @@ class TilingSprite$2 extends eva_js.Component {
59
115
  }
60
116
  }
61
117
  }
118
+ /** 组件名称 */
62
119
  TilingSprite$2.componentName = 'TilingSprite';
63
120
  __decorate([
64
121
  inspectorDecorator.type('string')
@@ -1,16 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),i=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter");
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
5
- this file except in compliance with the License. You may obtain a copy of the
6
- License at http://www.apache.org/licenses/LICENSE-2.0
7
-
8
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
- MERCHANTABLITY OR NON-INFRINGEMENT.
12
-
13
- See the Apache Version 2.0 License for specific language governing permissions
14
- and limitations under the License.
15
- ***************************************************************************** */
16
- function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}class o extends e.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}}o.componentName="TilingSprite",n([t.type("string")],o.prototype,"resource",void 0),n([t.type("vector2"),t.step(.1)],o.prototype,"tileScale",void 0),n([t.type("vector2"),t.step(1)],o.prototype,"tilePosition",void 0);let s=class extends i.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size,r=this.imgs[e.id];r&&(r.tilingSprite.width=t,r.tilingSprite.height=i)}componentChanged(t){return i=this,n=void 0,s=function*(){const i=t.gameObject.id;if("TilingSprite"===t.componentName){const n=t.component;if(t.type===e.OBSERVER_TYPE.ADD){const o=new r.TilingSprite(null);this.imgs[t.gameObject.id]=o,this.containerManager.getContainer(t.gameObject.id).addChildAt(o.tilingSprite,0),this.setProp(t.gameObject.id,n);const s=this.increaseAsyncId(i),{data:c}=yield e.resource.getResource(n.resource);if(!this.validateAsyncId(i,s))return;if(!c)return void console.error(`GameObject:${t.gameObject.name}'s TilingSprite resource load error`);o.image=c.image}else if(t.type===e.OBSERVER_TYPE.CHANGE)if("resource"===t.prop.prop[0]){const r=this.increaseAsyncId(i),{data:o}=yield e.resource.getResource(n.resource);if(!this.validateAsyncId(i,r))return;if(!o)return void console.error(`GameObject:${t.gameObject.name}'s TilingSprite resource load error`);this.imgs[t.gameObject.id].image=o.image}else this.setProp(t.gameObject.id,n);else if(t.type===e.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(i);const e=this.imgs[t.gameObject.id];this.containerManager.getContainer(t.gameObject.id).removeChild(e.tilingSprite),e.tilingSprite.destroy({children:!0}),delete this.imgs[t.gameObject.id]}}},new((o=void 0)||(o=Promise))((function(e,t){function r(e){try{a(s.next(e))}catch(e){t(e)}}function c(e){try{a(s.throw(e))}catch(e){t(e)}}function a(t){t.done?e(t.value):new o((function(e){e(t.value)})).then(r,c)}a((s=s.apply(i,n||[])).next())}));var i,n,o,s}setProp(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale}};s=n([e.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],s);var c=s;exports.TilingSprite=o,exports.TilingSpriteSystem=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),i=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter");function n(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function o(e,t,i,r){return new(i||(i=Promise))(function(n,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,c)}a((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class s extends e.Component{constructor(){super(...arguments),this.resource="",this.tileScale={x:1,y:1},this.tilePosition={x:0,y:0}}init(e){e&&(this.resource=e.resource,this.tileScale=e.tileScale,this.tilePosition=e.tilePosition)}}s.componentName="TilingSprite",n([t.type("string")],s.prototype,"resource",void 0),n([t.type("vector2"),t.step(.1)],s.prototype,"tileScale",void 0),n([t.type("vector2"),t.step(1)],s.prototype,"tilePosition",void 0);let c=class extends i.Renderer{constructor(){super(...arguments),this.name="TilingSprite",this.imgs={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.transform.size,r=this.imgs[e.id];r&&(r.tilingSprite.width=t,r.tilingSprite.height=i)}componentChanged(t){return o(this,void 0,void 0,function*(){const i=t.gameObject.id;if("TilingSprite"===t.componentName){const n=t.component;if(t.type===e.OBSERVER_TYPE.ADD){const o=new r.TilingSprite(null);this.imgs[t.gameObject.id]=o,this.containerManager.getContainer(t.gameObject.id).addChildAt(o.tilingSprite,0),this.setProp(t.gameObject.id,n);const s=this.increaseAsyncId(i),{data:c}=yield e.resource.getResource(n.resource);if(!this.validateAsyncId(i,s))return;if(!c)return void console.error(`GameObject:${t.gameObject.name}'s TilingSprite resource load error`);o.image=c.image}else if(t.type===e.OBSERVER_TYPE.CHANGE)if("resource"===t.prop.prop[0]){const r=this.increaseAsyncId(i),{data:o}=yield e.resource.getResource(n.resource);if(!this.validateAsyncId(i,r))return;if(!o)return void console.error(`GameObject:${t.gameObject.name}'s TilingSprite resource load error`);this.imgs[t.gameObject.id].image=o.image}else this.setProp(t.gameObject.id,n);else if(t.type===e.OBSERVER_TYPE.REMOVE){this.increaseAsyncId(i);const e=this.imgs[t.gameObject.id];this.containerManager.getContainer(t.gameObject.id).removeChild(e.tilingSprite),e.tilingSprite.destroy({children:!0}),delete this.imgs[t.gameObject.id]}}})}setProp(e,t){this.imgs[e].tilingSprite.tilePosition=t.tilePosition,this.imgs[e].tilingSprite.tileScale=t.tileScale}};c=n([e.decorators.componentObserver({TilingSprite:[{prop:["resource"],deep:!1},{prop:["tileScale"],deep:!0},{prop:["tilePosition"],deep:!0}]})],c);var a=c;exports.TilingSprite=s,exports.TilingSpriteSystem=a;
@@ -7,11 +7,62 @@ import { RendererManager } from '@eva/plugin-renderer';
7
7
  import { RendererSystem } from '@eva/plugin-renderer';
8
8
  import { TilingSprite as TilingSprite_2 } from '@eva/renderer-adapter';
9
9
 
10
+ /**
11
+ * 平铺精灵组件
12
+ *
13
+ * TilingSprite 组件用于创建可平铺重复的纹理,支持无限滚动效果。
14
+ * 纹理会在指定区域内重复平铺,并可以设置平铺的缩放和偏移,
15
+ * 适用于背景滚动、地面贴图、水面波纹等需要重复纹理的场景。
16
+ *
17
+ * 主要功能:
18
+ * - 纹理平铺重复
19
+ * - 支持平铺缩放
20
+ * - 支持平铺偏移(实现滚动效果)
21
+ * - 性能优化(只渲染可见区域)
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // 创建滚动背景
26
+ * const background = new GameObject('background');
27
+ * background.addComponent(new TilingSprite({
28
+ * resource: 'bgTile', // 平铺纹理资源
29
+ * tileScale: { x: 1, y: 1 }, // 平铺缩放
30
+ * tilePosition: { x: 0, y: 0 } // 平铺偏移
31
+ * }));
32
+ * background.transform.size = { width: 800, height: 600 };
33
+ *
34
+ * // 实现无限滚动
35
+ * const tilingSprite = background.getComponent('TilingSprite');
36
+ * let offset = 0;
37
+ * setInterval(() => {
38
+ * offset += 1;
39
+ * tilingSprite.tilePosition = { x: offset, y: 0 };
40
+ * }, 16);
41
+ *
42
+ * // 创建水面效果
43
+ * const water = new GameObject('water');
44
+ * water.addComponent(new TilingSprite({
45
+ * resource: 'waterTile',
46
+ * tileScale: { x: 2, y: 2 } // 放大 2 倍平铺
47
+ * }));
48
+ * ```
49
+ */
10
50
  export declare class TilingSprite extends Component<TilingSpriteParams> {
51
+ /** 组件名称 */
11
52
  static componentName: string;
53
+ /** 平铺纹理资源名称 */
12
54
  resource: string;
55
+ /** 平铺缩放比例 */
13
56
  tileScale: TilingSpriteParams['tileScale'];
57
+ /** 平铺位置偏移(用于实现滚动效果) */
14
58
  tilePosition: TilingSpriteParams['tilePosition'];
59
+ /**
60
+ * 初始化组件
61
+ * @param obj - 初始化参数
62
+ * @param obj.resource - 纹理资源名称
63
+ * @param obj.tileScale - 平铺缩放
64
+ * @param obj.tilePosition - 平铺偏移
65
+ */
15
66
  init(obj?: TilingSpriteParams): void;
16
67
  }
17
68
 
@@ -3,19 +3,19 @@ import { type, step } from '@eva/inspector-decorator';
3
3
  import { Renderer, RendererSystem } from '@eva/plugin-renderer';
4
4
  import { TilingSprite as TilingSprite$3 } from '@eva/renderer-adapter';
5
5
 
6
- /*! *****************************************************************************
7
- Copyright (c) Microsoft Corporation. All rights reserved.
8
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
9
- this file except in compliance with the License. You may obtain a copy of the
10
- License at http://www.apache.org/licenses/LICENSE-2.0
6
+ /******************************************************************************
7
+ Copyright (c) Microsoft Corporation.
11
8
 
12
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
14
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
15
- MERCHANTABLITY OR NON-INFRINGEMENT.
9
+ Permission to use, copy, modify, and/or distribute this software for any
10
+ purpose with or without fee is hereby granted.
16
11
 
17
- See the Apache Version 2.0 License for specific language governing permissions
18
- and limitations under the License.
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.
19
19
  ***************************************************************************** */
20
20
 
21
21
  function __decorate(decorators, target, key, desc) {
@@ -26,27 +26,83 @@ function __decorate(decorators, target, key, desc) {
26
26
  }
27
27
 
28
28
  function __awaiter(thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
30
  return new (P || (P = Promise))(function (resolve, reject) {
30
31
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
32
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
34
  step((generator = generator.apply(thisArg, _arguments || [])).next());
34
35
  });
35
- }
36
+ }
37
+
38
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
39
+ var e = new Error(message);
40
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
41
+ };
36
42
 
43
+ /**
44
+ * 平铺精灵组件
45
+ *
46
+ * TilingSprite 组件用于创建可平铺重复的纹理,支持无限滚动效果。
47
+ * 纹理会在指定区域内重复平铺,并可以设置平铺的缩放和偏移,
48
+ * 适用于背景滚动、地面贴图、水面波纹等需要重复纹理的场景。
49
+ *
50
+ * 主要功能:
51
+ * - 纹理平铺重复
52
+ * - 支持平铺缩放
53
+ * - 支持平铺偏移(实现滚动效果)
54
+ * - 性能优化(只渲染可见区域)
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // 创建滚动背景
59
+ * const background = new GameObject('background');
60
+ * background.addComponent(new TilingSprite({
61
+ * resource: 'bgTile', // 平铺纹理资源
62
+ * tileScale: { x: 1, y: 1 }, // 平铺缩放
63
+ * tilePosition: { x: 0, y: 0 } // 平铺偏移
64
+ * }));
65
+ * background.transform.size = { width: 800, height: 600 };
66
+ *
67
+ * // 实现无限滚动
68
+ * const tilingSprite = background.getComponent('TilingSprite');
69
+ * let offset = 0;
70
+ * setInterval(() => {
71
+ * offset += 1;
72
+ * tilingSprite.tilePosition = { x: offset, y: 0 };
73
+ * }, 16);
74
+ *
75
+ * // 创建水面效果
76
+ * const water = new GameObject('water');
77
+ * water.addComponent(new TilingSprite({
78
+ * resource: 'waterTile',
79
+ * tileScale: { x: 2, y: 2 } // 放大 2 倍平铺
80
+ * }));
81
+ * ```
82
+ */
37
83
  class TilingSprite$2 extends Component {
38
84
  constructor() {
39
85
  super(...arguments);
86
+ /** 平铺纹理资源名称 */
40
87
  this.resource = '';
88
+ /** 平铺缩放比例 */
41
89
  this.tileScale = {
42
90
  x: 1,
43
91
  y: 1,
44
92
  };
93
+ /** 平铺位置偏移(用于实现滚动效果) */
45
94
  this.tilePosition = {
46
95
  x: 0,
47
96
  y: 0,
48
97
  };
49
98
  }
99
+ /**
100
+ * 初始化组件
101
+ * @param obj - 初始化参数
102
+ * @param obj.resource - 纹理资源名称
103
+ * @param obj.tileScale - 平铺缩放
104
+ * @param obj.tilePosition - 平铺偏移
105
+ */
50
106
  init(obj) {
51
107
  if (obj) {
52
108
  this.resource = obj.resource;
@@ -55,6 +111,7 @@ class TilingSprite$2 extends Component {
55
111
  }
56
112
  }
57
113
  }
114
+ /** 组件名称 */
58
115
  TilingSprite$2.componentName = 'TilingSprite';
59
116
  __decorate([
60
117
  type('string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-tiling-sprite",
3
- "version": "2.0.1-beta.9",
3
+ "version": "2.0.2-beta.0",
4
4
  "description": "@eva/plugin-renderer-tiling-sprite",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-tiling-sprite.esm.js",
@@ -19,8 +19,8 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "2.0.1-beta.9",
23
- "@eva/renderer-adapter": "2.0.1-beta.9",
24
- "@eva/eva.js": "2.0.1-beta.9"
22
+ "@eva/plugin-renderer": "2.0.2-beta.0",
23
+ "@eva/renderer-adapter": "2.0.2-beta.0",
24
+ "@eva/eva.js": "2.0.2-beta.0"
25
25
  }
26
26
  }