evomeme 0.1.7 → 0.1.9-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/canvas-public/app.js +8517 -1692
  2. package/dist/canvas-public/assets/presets/catalog.json +47 -0
  3. package/dist/canvas-public/assets/presets/tiles/A_01_CaoDi.png +0 -0
  4. package/dist/canvas-public/assets/presets/tiles/A_02_ShaMo.png +0 -0
  5. package/dist/canvas-public/assets/presets/tiles/A_03_TianKong.png +0 -0
  6. package/dist/canvas-public/assets/presets/tiles/A_04_ShuiBo.png +0 -0
  7. package/dist/canvas-public/assets/presets/tiles/A_05_HaiMian.png +0 -0
  8. package/dist/canvas-public/assets/presets/tiles/A_06_MuDiBan.png +0 -0
  9. package/dist/canvas-public/assets/presets/tiles/A_07_ShiZhuan.png +0 -0
  10. package/dist/canvas-public/assets/presets/tiles/A_08_AnRongYan.png +0 -0
  11. package/dist/canvas-public/assets/presets/tiles/A_09_QingTaiShi.png +0 -0
  12. package/dist/canvas-public/assets/presets/tiles/A_10_ShenHai.png +0 -0
  13. package/dist/canvas-public/assets/presets/tiles/A_11_HuiYanShi.png +0 -0
  14. package/dist/canvas-public/assets/presets/tiles/A_12_HongTu.png +0 -0
  15. package/dist/canvas-public/assets/presets/tiles/A_13_GengDi.png +0 -0
  16. package/dist/canvas-public/assets/presets/tiles/A_14_HuoShanYan.png +0 -0
  17. package/dist/canvas-public/assets/presets/tiles/A_15_NiTu.png +0 -0
  18. package/dist/canvas-public/assets/presets/tiles/A_16_HuangSha.png +0 -0
  19. package/dist/canvas-public/assets/presets/tiles/A_17_CongLin.png +0 -0
  20. package/dist/canvas-public/assets/presets/tiles/A_18_ZiYanShi.png +0 -0
  21. package/dist/canvas-public/assets/presets/tiles/A_19_MoGuTu.png +0 -0
  22. package/dist/canvas-public/assets/presets/tiles/A_20_HuaDian.png +0 -0
  23. package/dist/canvas-public/assets/presets/tiles/A_21_HaiLang.png +0 -0
  24. package/dist/canvas-public/assets/presets/tiles/A_22_GanTu.png +0 -0
  25. package/dist/canvas-public/assets/presets/tiles/A_23_QingTaiShiBan.png +0 -0
  26. package/dist/canvas-public/assets/presets/tiles/A_24_XingKong.png +0 -0
  27. package/dist/canvas-public/assets/presets/tiles/A_25_MoFaFuWen.png +0 -0
  28. package/dist/canvas-public/assets/presets/tiles/A_26_ShiTuYeDi.png +0 -0
  29. package/dist/canvas-public/assets/presets/tiles/A_27_LanZhuan.png +0 -0
  30. package/dist/canvas-public/assets/presets/tiles/A_28_HongZhuan.png +0 -0
  31. package/dist/canvas-public/assets/presets/tiles/A_29_YueQiu.png +0 -0
  32. package/dist/canvas-public/assets/presets/tiles/A_30_JinShuGe.png +0 -0
  33. package/dist/canvas-public/assets/presets/tiles/A_31_JinShuJingGai.png +0 -0
  34. package/dist/canvas-public/assets/presets/tiles/A_32_ShuZiChuang.png +0 -0
  35. package/dist/canvas-public/color-key-worker.js +280 -0
  36. package/dist/canvas-public/image-canvas-size-editor.js +254 -0
  37. package/dist/canvas-public/index.html +226 -119
  38. package/dist/canvas-public/perfect-pixel-worker.js +499 -0
  39. package/dist/canvas-public/smart-split.js +1 -1
  40. package/dist/canvas-public/styles.css +3902 -1225
  41. package/dist/canvas-public/tile-map-editor.js +2120 -0
  42. package/dist/canvas-public/ui-controls.js +95 -0
  43. package/dist/canvas-public/vendor/pixi-tilemap.js +126 -0
  44. package/dist/canvas-public/vendor/pixi.min.js +2340 -0
  45. package/dist/index.js +32263 -4187
  46. package/dist/stage-blender/bake_materials.py +102 -0
  47. package/dist/stage-blender/export_scene.py +275 -0
  48. package/dist/stage-blender/preview_camera.py +90 -0
  49. package/dist/stage-blender/repair_mesh.py +112 -0
  50. package/dist/stage-public/app.js +759 -0
  51. package/dist/stage-public/baked/bakePilot.js +44 -0
  52. package/dist/stage-public/baked/bakedScene.js +129 -0
  53. package/dist/stage-public/baked/sceneAppearance.js +225 -0
  54. package/dist/stage-public/baked/sceneCamera.js +45 -0
  55. package/dist/stage-public/comparison-contract.js +28 -0
  56. package/dist/stage-public/delivery.html +4 -0
  57. package/dist/stage-public/delivery.js +17 -0
  58. package/dist/stage-public/godot/appearance.gd +170 -0
  59. package/dist/stage-public/godot/preview.gd +79 -0
  60. package/dist/stage-public/index.html +141 -0
  61. package/dist/stage-public/review-app.js +289 -0
  62. package/dist/stage-public/review-runtime.js +63 -0
  63. package/dist/stage-public/review.css +24 -0
  64. package/dist/stage-public/review.html +47 -0
  65. package/dist/stage-public/scene-runtime.js +212 -0
  66. package/dist/stage-public/sceneContractRuntime.js +235 -0
  67. package/dist/stage-public/styles.css +328 -0
  68. package/dist/stage-public/three-appearance.js +104 -0
  69. package/dist/stage-public/vendor/three170/LICENSE +21 -0
  70. package/dist/stage-public/vendor/three170/build/three.module.js +54571 -0
  71. package/dist/stage-public/vendor/three170/examples/jsm/controls/OrbitControls.js +1523 -0
  72. package/dist/stage-public/vendor/three170/examples/jsm/environments/RoomEnvironment.js +144 -0
  73. package/dist/stage-public/vendor/three170/examples/jsm/libs/fflate.module.js +2672 -0
  74. package/dist/stage-public/vendor/three170/examples/jsm/loaders/EXRLoader.js +2563 -0
  75. package/dist/stage-public/vendor/three170/examples/jsm/loaders/GLTFLoader.js +4727 -0
  76. package/dist/stage-public/vendor/three170/examples/jsm/utils/BufferGeometryUtils.js +1373 -0
  77. package/dist/tile-transition-mask.svg +40 -0
  78. package/package.json +77 -69
  79. package/skills/evomeme-canvas/SKILL.md +52 -0
  80. package/skills/evomeme-canvas/agents/openai.yaml +7 -0
  81. package/skills/evomeme-cover/SKILL.md +1 -1
  82. package/skills/evomeme-game-maker/SKILL.md +79 -8
  83. package/skills/game-asset-align/SKILL.md +45 -0
  84. package/skills/game-asset-align/agents/openai.yaml +8 -0
  85. package/skills/game-asset-align/references/alignment-contract.md +61 -0
  86. package/skills/game-asset-align/references/blender-scene-pipeline.md +45 -0
  87. package/skills/game-asset-align/references/canonical-package.md +26 -0
  88. package/skills/game-asset-align/references/engine-capabilities.md +14 -0
  89. package/skills/game-asset-align/references/lightweight-review.md +32 -0
  90. package/skills/game-asset-align/references/repair-policy.md +30 -0
  91. package/skills/game-asset-align/references/tool-contract.md +39 -0
  92. package/skills/game-asset-align/references/visual-review.md +26 -0
  93. package/skills/game-asset-image-generator/SKILL.md +1 -1
  94. package/skills/godot-3d-game/SKILL.md +39 -0
  95. package/skills/godot-3d-game/agents/openai.yaml +8 -0
  96. package/skills/godot-3d-game/references/alignment-gates.md +26 -0
  97. package/skills/godot-3d-game/references/appearance-alignment.md +52 -0
  98. package/skills/godot-3d-game/references/build-and-qa.md +22 -0
  99. package/skills/godot-3d-game/references/canonical-asset-runtime.md +27 -0
  100. package/skills/godot-3d-game/references/import-and-wrapper-scenes.md +20 -0
  101. package/skills/godot-3d-game/references/physics-colliders.md +13 -0
  102. package/skills/godot-3d-game/references/project-structure.md +22 -0
  103. package/skills/godot-3d-game/references/skeleton-animation.md +16 -0
  104. package/skills/threejs-3d-game/SKILL.md +6 -2
  105. package/skills/threejs-3d-game/references/engine-asset-pipeline.md +52 -15
  106. package/dist/canvas-public/sequence-sheet.js +0 -59
@@ -0,0 +1,95 @@
1
+ const NUMBER_INPUT_SELECTOR = 'input[type="number"]:not([data-unified-stepper])'
2
+
3
+ function decimalPlaces(value) {
4
+ const text = String(value || '')
5
+ if (/e-/i.test(text)) return Math.max(0, Number(text.split(/e-/i)[1]) || 0)
6
+ return (text.split('.')[1] || '').length
7
+ }
8
+
9
+ function fallbackStep(input, direction) {
10
+ const current = Number(input.value)
11
+ const minimum = input.min === '' ? -Infinity : Number(input.min)
12
+ const maximum = input.max === '' ? Infinity : Number(input.max)
13
+ const rawStep = Number(input.step)
14
+ const step = Number.isFinite(rawStep) && rawStep > 0 ? rawStep : 1
15
+ const base = Number.isFinite(current) ? current : Number.isFinite(minimum) ? minimum : 0
16
+ let next = base + direction * step
17
+ // Inputs such as FPS use a tiny positive minimum only to reject zero. Moving
18
+ // up from that boundary should produce a useful whole step, not 1.000001.
19
+ if (direction > 0 && base === minimum && minimum > 0 && minimum < step) next = step
20
+ next = Math.min(maximum, Math.max(minimum, next))
21
+ const precision = Math.min(12, Math.max(decimalPlaces(step), decimalPlaces(base)))
22
+ input.value = String(Number(next.toFixed(precision)))
23
+ }
24
+
25
+ function changeNumber(input, direction) {
26
+ if (input.disabled || input.readOnly) return
27
+ try {
28
+ if (direction > 0) input.stepUp()
29
+ else input.stepDown()
30
+ } catch {
31
+ fallbackStep(input, direction)
32
+ }
33
+ input.dispatchEvent(new Event('input', { bubbles: true }))
34
+ input.dispatchEvent(new Event('change', { bubbles: true }))
35
+ input.focus({ preventScroll: true })
36
+ }
37
+
38
+ function stepButton(input, direction) {
39
+ const label = input.getAttribute('aria-label') || '数值'
40
+ const button = document.createElement('button')
41
+ button.type = 'button'
42
+ button.className = `ui-number-stepper-button is-${direction > 0 ? 'up' : 'down'}`
43
+ button.tabIndex = -1
44
+ button.setAttribute('aria-label', `${direction > 0 ? '增加' : '减少'}${label}`)
45
+ button.innerHTML = direction > 0
46
+ ? '<svg viewBox="0 0 12 8" aria-hidden="true"><path d="m2 6 4-4 4 4"/></svg>'
47
+ : '<svg viewBox="0 0 12 8" aria-hidden="true"><path d="m2 2 4 4 4-4"/></svg>'
48
+ button.addEventListener('pointerdown', (event) => event.stopPropagation())
49
+ button.addEventListener('click', (event) => {
50
+ event.preventDefault()
51
+ event.stopPropagation()
52
+ changeNumber(input, direction)
53
+ })
54
+ return button
55
+ }
56
+
57
+ function enhanceNumberInput(input) {
58
+ if (!(input instanceof HTMLInputElement) || input.dataset.unifiedStepper) return
59
+ input.dataset.unifiedStepper = 'true'
60
+ const parent = input.parentNode
61
+ if (!parent) return
62
+
63
+ const rect = input.getBoundingClientRect()
64
+ const parentWidth = input.parentElement?.getBoundingClientRect().width || 0
65
+ const computedWidth = Number.parseFloat(getComputedStyle(input).width)
66
+ const fluid = parentWidth > 0 && rect.width / parentWidth >= 0.8
67
+ const wrapper = document.createElement('span')
68
+ wrapper.className = 'ui-number-stepper'
69
+ if (fluid || (!rect.width && !computedWidth)) wrapper.classList.add('is-fluid')
70
+ else wrapper.style.width = `${rect.width || computedWidth}px`
71
+
72
+ parent.insertBefore(wrapper, input)
73
+ wrapper.append(input)
74
+ const controls = document.createElement('span')
75
+ controls.className = 'ui-number-stepper-controls'
76
+ controls.append(stepButton(input, 1), stepButton(input, -1))
77
+ wrapper.appendChild(controls)
78
+ }
79
+
80
+ function enhanceTree(root) {
81
+ if (root instanceof HTMLInputElement && root.matches(NUMBER_INPUT_SELECTOR)) enhanceNumberInput(root)
82
+ if (!(root instanceof Element || root instanceof Document)) return
83
+ for (const input of root.querySelectorAll(NUMBER_INPUT_SELECTOR)) enhanceNumberInput(input)
84
+ }
85
+
86
+ export function initUnifiedNumberSteppers() {
87
+ enhanceTree(document)
88
+ const observer = new MutationObserver((records) => {
89
+ for (const record of records) {
90
+ for (const node of record.addedNodes) enhanceTree(node)
91
+ }
92
+ })
93
+ observer.observe(document.documentElement, { childList: true, subtree: true })
94
+ return () => observer.disconnect()
95
+ }
@@ -0,0 +1,126 @@
1
+ /*!
2
+ * @pixi/tilemap - v5.0.2
3
+ * Compiled Mon, 14 Jul 2025 00:24:17 UTC
4
+ *
5
+ * @pixi/tilemap is licensed under the MIT License.
6
+ * http://www.opensource.org/licenses/mit-license
7
+ *
8
+ * Copyright 2025, Ivan Popelyshev, All Rights Reserved
9
+ */this.PIXI=this.PIXI||{},this.PIXI.tilemap=function(M,u){"use strict";const B={TEXTURES_PER_TILEMAP:16,TEXTILE_SCALE_MODE:"linear",use32bitIndex:!1},oe=B;var ue=Object.defineProperty,le=(i,e,t)=>e in i?ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E=(i,e,t)=>(le(i,typeof e!="symbol"?e+"":e,t),t);const D=class S extends u.Geometry{constructor(e){const t=new u.Buffer({data:new Float32Array(2),label:"tilemap-buffer",usage:u.BufferUsage.VERTEX|u.BufferUsage.COPY_DST,shrinkToFit:!1}),r=S.stride;super({indexBuffer:e,attributes:{aVertexPosition:{buffer:t,format:"float32x2",stride:r,offset:0},aTextureCoord:{buffer:t,format:"float32x2",stride:r,offset:2*4},aFrame:{buffer:t,format:"float32x4",stride:r,offset:4*4},aAnim:{buffer:t,format:"float32x2",stride:r,offset:8*4},aTextureId:{buffer:t,format:"sint32",stride:r,offset:10*4},aAnimDivisor:{buffer:t,format:"float32",stride:r,offset:11*4},aAlpha:{buffer:t,format:"float32",stride:r,offset:12*4}}}),E(this,"lastTimeAccess",0),E(this,"vertSize",S.vertSize),E(this,"vertPerQuad",S.vertPerQuad),E(this,"stride",S.stride),E(this,"buf"),this.buf=t}};E(D,"vertSize",13),E(D,"vertPerQuad",4),E(D,"stride",D.vertSize*4);let ie=D;var he=Object.defineProperty,de=(i,e,t)=>e in i?he(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,C=(i,e,t)=>(de(i,typeof e!="symbol"?e+"":e,t),t);class N{constructor(){C(this,"pipe_uniforms",new u.UniformGroup({u_proj_trans:{value:new u.Matrix,type:"mat3x3<f32>"},u_anim_frame:{value:new Float32Array(2),type:"vec2<f32>"}}))}}class ${constructor(e,t){C(this,"renderer"),C(this,"tileAnim",[0,0]),C(this,"ibLen",0),C(this,"indexBuffer",null),C(this,"shader"),C(this,"adaptor"),this.renderer=e,this.adaptor=t,this.adaptor.init(),this.indexBuffer=new u.Buffer({data:new Uint16Array([0,1,2,0,2,3]),label:"index-tilemap-buffer",usage:u.BufferUsage.INDEX|u.BufferUsage.COPY_DST}),this.indexBuffer.destroy=u.NOOP,this.checkIndexBuffer(2e3)}start(){}createVb(){const e=new ie(this.indexBuffer);return e.lastTimeAccess=Date.now(),e}getShader(){return this.shader}destroy(){this.shader=null}checkIndexBuffer(e){const t=e*6;if(t<=this.ibLen)return;let r=t;for(;r<t;)r<<=1;this.ibLen=t,this.indexBuffer.data=fe(e,B.use32bitIndex?new Uint32Array(t):new Uint16Array(t))}destroyRenderable(e){e.vb.destroy(!0),e.vb=null}addRenderable(e,t){const r=this.renderer.renderPipes.batch;e.updateBuffer(this),e.checkValid(),e.getTileset().update(),e.is_valid&&(r.break(t),t.add(e._instruction))}updateRenderable(e,t){e.updateBuffer(this),e.getTileset().update()}validateRenderable(e){return e.checkValid()}execute({tilemap:e}){if(!e.isRenderable)return;e.state.blendMode=e.groupBlendMode;const{pipe_uniforms:t}=this.adaptor,r=t.uniforms.u_proj_trans,s=this.renderer.globalUniforms._activeUniforms.at(-1).uniforms;let n=this.tileAnim;const{u_anim_frame:l}=t.uniforms;s.uProjectionMatrix.copyTo(r).append(s.uWorldTransformMatrix).append(e.worldTransform),e.compositeParent&&(n=e.parent.tileAnim||n),l[0]=n[0],l[1]=n[1],t.update(),this.adaptor.execute(this,e)}}C($,"extension",{type:[u.ExtensionType.WebGLPipes,u.ExtensionType.WebGPUPipes],name:"tilemap"});function fe(i,e){const t=i*6;if(e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let r=0,s=0;r<t;r+=6,s+=4)e[r+0]=s+0,e[r+1]=s+1,e[r+2]=s+2,e[r+3]=s+0,e[r+4]=s+2,e[r+5]=s+3;return e}var me=Object.defineProperty,ce=(i,e,t)=>e in i?me(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,I=(i,e,t)=>(ce(i,typeof e!="symbol"?e+"":e,t),t);class U{constructor(e){I(this,"max_textures"),I(this,"arr",[]),I(this,"count",0),I(this,"dirty",!1),I(this,"dirty_gpu",!1),I(this,"bind_group",null),I(this,"bind_group_resources",{}),I(this,"tex_sizes",null),I(this,"null_color",new Float32Array([0,0,0,.5])),I(this,"tex_buf",null),this.max_textures=e,this.tex_sizes=new Float32Array(this.max_textures*4+4),this.tex_buf=new u.Buffer({usage:u.BufferUsage.UNIFORM|u.BufferUsage.COPY_DST})}get length(){return this.count}push(e){this.arr[this.count++]=e,this.dirty=!0}at(e){return this.arr[e]}update(){if(!this.dirty)return;this.dirty=!1,this.dirty_gpu=!0;const{tex_sizes:e,arr:t,count:r,max_textures:s,null_color:n}=this;for(let l=0;l<r;l++){const h=t[l];h&&(e[l*4]=h.pixelWidth,e[l*4+1]=h.pixelHeight,e[l*4+2]=1/h.pixelWidth,e[l*4+3]=1/h.pixelHeight)}e[s*4]=n[0],e[s*4+1]=n[1],e[s*4+2]=n[2],e[s*4+3]=n[3]}markDirty(){this.dirty=!0}getBindGroup(){if(this.update(),!this.dirty_gpu)return this.bind_group;const{bind_group_resources:e,max_textures:t,arr:r,count:s}=this;let n=0;e[n++]=new u.UniformGroup({u_texture_size:{value:this.tex_sizes,type:"vec4<f32>",size:t},u_null_color:{value:this.null_color,type:"vec4<f32>"}});for(let l=0;l<t;l++){const h=(l<s?r[l]:null)||u.Texture.EMPTY.source;e[n++]=h.source,e[n++]=h.style}return this.bind_group||(this.bind_group=new u.BindGroup(e)),this.bind_group}static generate_gpu_textures(e){const t=[];t.push("struct TextureArrayFields {"),t.push(` u_texture_size: array<vec4f, ${e}>,`),t.push(" u_null_color: vec4f"),t.push("}"),t.push("@group(1) @binding(0) var<uniform> taf: TextureArrayFields;");for(let r=0;r<e;r++)t.push(`@group(1) @binding(${r*2+1}) var u_texture_${r}: texture_2d<f32>;`),t.push(`@group(1) @binding(${r*2+2}) var u_sampler_${r}: sampler;`);t.push("fn sampleMultiTexture(texture_id: i32, uv: vec2f, dx: vec2f, dy: vec2f) -> vec4f {"),t.push("switch texture_id {");for(let r=0;r<e;r++)t.push(` case ${r}: { return textureSampleGrad(u_texture_${r}, u_sampler_${r}, uv, dx, dy); }`);return t.push(" default: { return taf.u_null_color; }"),t.push("} }"),t.join(`
10
+ `)}static generate_gl_textures(e){const t=[];t.push(`uniform vec4 u_texture_size[${e+1}];`),t.push(`uniform sampler2D u_textures[${e}];`),t.push("uniform vec4 u_null_color;"),t.push("vec4 sampleMultiTexture(float texture_id, vec2 uv) {"),t.push(`if(texture_id < -0.5) return u_texture_size[${e}];`);for(let r=0;r<e;r++)t.push(`if(texture_id < ${r}.5) return texture(u_textures[${r}], uv * u_texture_size[${r}].zw);`);return t.push(`return u_texture_size[${e}];`),t.push("}"),t.join(`
11
+ `)}static gl_gen_resources(e){const t=[];for(let s=0;s<e;s++)t[s]=s;const r=[];for(let s=0;s<e;s++)r.push(2048),r.push(2048),r.push(1/2048),r.push(1/2048);return{u_textures:{value:t,type:"i32",size:e},u_texture_size:{value:r,type:"vec4<f32>",size:e}}}}var pe=Object.defineProperty,ve=(i,e,t)=>e in i?pe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,L=(i,e,t)=>(ve(i,typeof e!="symbol"?e+"":e,t),t);const Te=`
12
+ in vec2 aVertexPosition;
13
+ in vec2 aTextureCoord;
14
+ in vec4 aFrame;
15
+ in vec2 aAnim;
16
+ in float aAnimDivisor;
17
+ in float aTextureId;
18
+ in float aAlpha;
19
+
20
+ uniform mat3 u_proj_trans;
21
+ uniform vec2 u_anim_frame;
22
+
23
+ out vec2 vTextureCoord;
24
+ out float vTextureId;
25
+ out vec4 vFrame;
26
+ out float vAlpha;
27
+
28
+ void main(void)
29
+ {
30
+ gl_Position = vec4((u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
31
+ vec2 animCount = floor((aAnim + 0.5) / 2048.0);
32
+ vec2 animFrameOffset = aAnim - animCount * 2048.0;
33
+ vec2 currentFrame = floor(u_anim_frame / aAnimDivisor);
34
+ vec2 loop_num = floor((currentFrame + 0.5) / animCount);
35
+ vec2 animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
36
+
37
+ vTextureCoord = aTextureCoord + animOffset;
38
+ vFrame = aFrame + vec4(animOffset, animOffset);
39
+ vTextureId = aTextureId;
40
+ vAlpha = aAlpha;
41
+ }
42
+ `,_e=`
43
+ #ifdef GL_FRAGMENT_PRECISION_HIGH
44
+ precision highp float;
45
+ #else
46
+ precision mediump float;
47
+ #endif
48
+ in vec2 vTextureCoord;
49
+ in vec4 vFrame;
50
+ in float vTextureId;
51
+ in float vAlpha;
52
+
53
+ //include_textures
54
+
55
+ void main(void)
56
+ {
57
+ float textureId = floor(vTextureId + 0.5);
58
+ vec2 textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
59
+ vec4 color = sampleMultiTexture(textureId, textureCoord);
60
+ finalColor = color * vAlpha;
61
+ }
62
+ `;class se extends N{constructor(){super(...arguments),L(this,"_shader",null),L(this,"max_textures",B.TEXTURES_PER_TILEMAP)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){const r=e.renderer,s=this._shader,n=t.getTileset(),l=s.resources.texture_uniforms;l.uniforms.u_texture_size!==n.tex_sizes&&(l.uniforms.u_texture_size=n.tex_sizes,l.update());for(let h=0;h<n.length;h++)r.texture.bind(n.arr[h],h);r.encoder.draw({geometry:t.vb,shader:s,state:t.state,size:t.rects_count*6})}init(){this._shader=new u.Shader({glProgram:u.GlProgram.from({vertex:Te,fragment:_e.replace("//include_textures",U.generate_gl_textures(this.max_textures))}),resources:{texture_uniforms:new u.UniformGroup(U.gl_gen_resources(this.max_textures),{isStatic:!0}),pipe_uniforms:this.pipe_uniforms.uniformStructures}})}}L(se,"extension",{type:[u.ExtensionType.WebGLPipesAdaptor],name:"tilemap"});var ge=Object.defineProperty,be=(i,e,t)=>e in i?ge(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Y=(i,e,t)=>(be(i,typeof e!="symbol"?e+"":e,t),t);const xe=`
63
+ struct GlobalUniforms {
64
+ uProjectionMatrix:mat3x3f,
65
+ uWorldTransformMatrix:mat3x3f,
66
+ uWorldColorAlpha: vec4f,
67
+ uResolution: vec2f,
68
+ }
69
+
70
+ struct TilemapUniforms {
71
+ u_proj_trans:mat3x3f,
72
+ u_anim_frame:vec2f
73
+ }
74
+
75
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
76
+ @group(2) @binding(0) var<uniform> loc: TilemapUniforms;
77
+
78
+ struct VSOutput {
79
+ @builtin(position) vPosition: vec4f,
80
+ @location(0) @interpolate(flat) vTextureId : i32,
81
+ @location(1) vTextureCoord : vec2f,
82
+ @location(2) @interpolate(flat) vFrame : vec4f,
83
+ @location(3) vAlpha : f32
84
+ };
85
+
86
+ @vertex
87
+ fn mainVert(
88
+ @location(6) aVertexPosition: vec2f,
89
+ @location(4) aTextureCoord: vec2f,
90
+ @location(3) aFrame: vec4f,
91
+ @location(1) aAnim: vec2f,
92
+ @location(2) aAnimDivisor: f32,
93
+ @location(5) aTextureId: i32,
94
+ @location(0) aAlpha: f32,
95
+ ) -> VSOutput {
96
+
97
+ var vPosition = vec4((loc.u_proj_trans * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
98
+ var animCount = floor((aAnim + 0.5) / 2048.0);
99
+ var animFrameOffset = aAnim - animCount * 2048.0;
100
+ var currentFrame = floor(loc.u_anim_frame / aAnimDivisor);
101
+ var loop_num = floor((currentFrame + 0.5) / animCount);
102
+ var animOffset = animFrameOffset * floor(currentFrame - loop_num * animCount);
103
+ var vTextureCoord = aTextureCoord + animOffset;
104
+ var vFrame = aFrame + vec4(animOffset, animOffset);
105
+
106
+ return VSOutput(vPosition, aTextureId, vTextureCoord, vFrame, aAlpha);
107
+ };
108
+ `,ye=`
109
+ //include_textures
110
+
111
+ @fragment
112
+ fn mainFrag(
113
+ @location(0) @interpolate(flat) vTextureId : i32,
114
+ @location(1) vTextureCoord : vec2f,
115
+ @location(2) @interpolate(flat) vFrame : vec4f,
116
+ @location(3) vAlpha : f32,
117
+ ) -> @location(0) vec4f {
118
+ var textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
119
+ var uv = textureCoord * taf.u_texture_size[vTextureId].zw;
120
+ var dx = dpdx(uv);
121
+ var dy = dpdy(uv);
122
+ var color = sampleMultiTexture(vTextureId, uv, dx, dy);
123
+ return color * vAlpha;
124
+ };
125
+ `;class ae extends N{constructor(){super(...arguments),Y(this,"_shader",null),Y(this,"max_textures",B.TEXTURES_PER_TILEMAP),Y(this,"bind_group",null)}destroy(){this._shader.destroy(!0),this._shader=null}execute(e,t){const r=e.renderer,s=this._shader;s.groups[0]=r.globalUniforms.bindGroup,s.groups[1]=t.getTileset().getBindGroup(),s.groups[2]=this.bind_group,r.encoder.draw({geometry:t.vb,shader:s,state:t.state,size:t.rects_count*6})}init(){this._shader=new u.Shader({gpuProgram:u.GpuProgram.from({vertex:{source:xe,entryPoint:"mainVert"},fragment:{source:ye.replace("//include_textures",U.generate_gpu_textures(this.max_textures))}})}),this.bind_group=new u.BindGroup({ut:this.pipe_uniforms})}}Y(ae,"extension",{type:[u.ExtensionType.WebGPUPipesAdaptor],name:"tilemap"});var Ae=Object.defineProperty,Pe=(i,e,t)=>e in i?Ae(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,m=(i,e,t)=>(Pe(i,typeof e!="symbol"?e+"":e,t),t),ne=(i=>(i[i.U=0]="U",i[i.V=1]="V",i[i.X=2]="X",i[i.Y=3]="Y",i[i.TILE_WIDTH=4]="TILE_WIDTH",i[i.TILE_HEIGHT=5]="TILE_HEIGHT",i[i.ROTATE=6]="ROTATE",i[i.ANIM_X=7]="ANIM_X",i[i.ANIM_Y=8]="ANIM_Y",i[i.TEXTURE_INDEX=9]="TEXTURE_INDEX",i[i.ANIM_COUNT_X=10]="ANIM_COUNT_X",i[i.ANIM_COUNT_Y=11]="ANIM_COUNT_Y",i[i.ANIM_DIVISOR=12]="ANIM_DIVISOR",i[i.ALPHA=13]="ALPHA",i))(ne||{});const x=Object.keys(ne).length/2;class k extends u.ViewContainer{constructor(e){super({}),m(this,"shadowColor",new Float32Array([0,0,0,.5])),m(this,"state",u.State.for2d()),m(this,"is_valid",!1),m(this,"renderPipeId","tilemap"),m(this,"canBundle",!0),m(this,"_instruction",{renderPipeId:"tilemap",tilemap:this}),m(this,"tileAnim",null),m(this,"rects_count",0),m(this,"compositeParent",!1),m(this,"tileset",new U(B.TEXTURES_PER_TILEMAP)),m(this,"tilemapBounds",new u.Bounds),m(this,"hasAnimatedTile",!1),m(this,"pointsBuf",[]),m(this,"batched"),m(this,"vbId",0),m(this,"vb",null),m(this,"vbBuffer",null),m(this,"vbArray",null),m(this,"vbInts",null),this.setTileset(e)}checkValid(){const e=this.tileset.count>0&&this.pointsBuf.length>0,t=this.is_valid!==e;return this.is_valid=e,t!==e}updateBounds(){const e=this.tilemapBounds;this._bounds.minX=e.minX,this._bounds.maxX=e.maxX,this._bounds.minY=e.minY,this._bounds.maxY=e.maxY}getTileset(){return this.tileset}setTileset(e=[]){var t,r;let s=this.tileset;if(e instanceof U)this.tileset=e,this.didViewUpdate=!0;else if(e instanceof u.TextureSource){if(s.count===1&&s.arr[0]===e)return this;s=this.tileset=new U(B.TEXTURES_PER_TILEMAP),s.push(e),this.didViewUpdate=!0}else{if(e.length===s.count){let n=!0;for(let l=0;l<e.length;l++)if(((t=e[l])==null?void 0:t.source)!==s.arr[l]){n=!1;break}if(n)return this}s=this.tileset=new U(B.TEXTURES_PER_TILEMAP);for(let n=0;n<e.length;n++)s.push((r=e[n])==null?void 0:r.source);this.didViewUpdate=!0}return this}clear(){return this.pointsBuf.length=0,this.rects_count=0,this.tilemapBounds.clear(),this.hasAnimatedTile=!1,this}tile(e,t,r,s={}){var n,l,h,a;this.didViewUpdate=!0;let c,o=-1,y=!1;if(typeof e=="number")o=e,y=!0,c=this.tileset.arr[o];else{let _;typeof e=="string"?_=u.Texture.from(e):_=e;const X=this.tileset;for(let w=0;w<X.count;w++)if(X.arr[w]===_.source){o=w;break}"frame"in _&&(s.u=(n=s.u)!=null?n:_.frame.x,s.v=(l=s.v)!=null?l:_.frame.y,s.tileWidth=(h=s.tileWidth)!=null?h:_.orig.width,s.tileHeight=(a=s.tileHeight)!=null?a:_.orig.height),c=_.source}if(!y&&!c)return console.error("The tile texture was not found in the tilemap tileset."),this;const{u:d=0,v:A=0,tileWidth:P=c.width,tileHeight:g=c.height,animX:b=0,animY:p=0,rotate:T=0,animCountX:f=1024,animCountY:H=1024,animDivisor:W=1,alpha:Q=1}=s,v=this.pointsBuf;return this.hasAnimatedTile=this.hasAnimatedTile||b>0||p>0,v.push(d),v.push(A),v.push(t),v.push(r),v.push(P),v.push(g),v.push(T),v.push(b|0),v.push(p|0),v.push(o),v.push(f),v.push(H),v.push(W),v.push(Q),this.tilemapBounds.addFrame(t,r,t+P,r+g),this}tileRotate(e){const t=this.pointsBuf;t[t.length-(x-9)]=e}tileAnimX(e,t){const r=this.pointsBuf;r[r.length-(x-7)]=e,r[r.length-(x-10)]=t}tileAnimY(e,t){const r=this.pointsBuf;r[r.length-(x-8)]=e,r[r.length-(x-11)]=t}tileAnimDivisor(e){const t=this.pointsBuf;t[t.length-(x-12)]=e}tileAlpha(e){const t=this.pointsBuf;t[t.length-(x-13)]=e}destroyVb(){this.vb&&(this.vb.destroy(),this.vb=null)}updateBuffer(e){const t=this.pointsBuf,r=t.length/x;let s=this.vb;if(this.tileset.count===0||r===0||this.rects_count===r&&s)return;this.rects_count=r,s||(s=e.createVb(),this.vb=s,this.vbId=s.id,this.vbBuffer=null);const n=r*s.vertPerQuad;e.checkIndexBuffer(r);const l=s.getBuffer("aVertexPosition"),h=s.stride*n;if(!this.vbBuffer||this.vbBuffer.byteLength<h){let d=s.stride;for(;d<h;)d*=2;this.vbBuffer=new ArrayBuffer(d),this.vbArray=new Float32Array(this.vbBuffer),this.vbInts=new Uint32Array(this.vbBuffer)}const a=this.vbArray,c=this.vbInts;let o=0,y=0;for(let d=0;d<t.length;d+=x){this.compositeParent&&(y=t[d+9]);const A=t[d+2],P=t[d+3],g=t[d+4],b=t[d+5],p=t[d+0],T=t[d+1];let f=t[d+6];const H=t[d+7],W=t[d+8],Q=t[d+10]||1024,v=t[d+11]||1024,_=H+Q*2048,X=W+v*2048,w=t[d+12],z=t[d+13];let Z,q,J,K,j,ee,te,re;if(f===0)Z=p,q=T,J=p+g,K=T,j=p+g,ee=T+b,te=p,re=T+b;else{let F=g/2,O=b/2;f%4!==0&&(F=b/2,O=g/2);const V=p+F,G=T+O;f=u.groupD8.add(f,u.groupD8.NW),Z=V+F*u.groupD8.uX(f),q=G+O*u.groupD8.uY(f),f=u.groupD8.add(f,2),J=V+F*u.groupD8.uX(f),K=G+O*u.groupD8.uY(f),f=u.groupD8.add(f,2),j=V+F*u.groupD8.uX(f),ee=G+O*u.groupD8.uY(f),f=u.groupD8.add(f,2),te=V+F*u.groupD8.uX(f),re=G+O*u.groupD8.uY(f)}a[o++]=A,a[o++]=P,a[o++]=Z,a[o++]=q,a[o++]=p+.5,a[o++]=T+.5,a[o++]=p+g-.5,a[o++]=T+b-.5,a[o++]=_,a[o++]=X,c[o++]=y,a[o++]=w,a[o++]=z,a[o++]=A+g,a[o++]=P,a[o++]=J,a[o++]=K,a[o++]=p+.5,a[o++]=T+.5,a[o++]=p+g-.5,a[o++]=T+b-.5,a[o++]=_,a[o++]=X,c[o++]=y,a[o++]=w,a[o++]=z,a[o++]=A+g,a[o++]=P+b,a[o++]=j,a[o++]=ee,a[o++]=p+.5,a[o++]=T+.5,a[o++]=p+g-.5,a[o++]=T+b-.5,a[o++]=_,a[o++]=X,c[o++]=y,a[o++]=w,a[o++]=z,a[o++]=A,a[o++]=P+b,a[o++]=te,a[o++]=re,a[o++]=p+.5,a[o++]=T+.5,a[o++]=p+g-.5,a[o++]=T+b-.5,a[o++]=_,a[o++]=X,c[o++]=y,a[o++]=w,a[o++]=z}l.data=a}isModified(e){return!!(this.rects_count*x!==this.pointsBuf.length||e&&this.hasAnimatedTile)}clearModify(){this.rects_count=this.pointsBuf.length/x}addBounds(e){const t=this.tilemapBounds;e.addFrame(t.minX,t.minY,t.maxX,t.maxY)}get bounds(){return this.tilemapBounds}destroy(e){super.destroy(e),this.destroyVb()}addFrame(e,t,r,s,n){return this.tile(e,t,r,{animX:s,animY:n}),!0}addRect(e,t,r,s,n,l,h,a=0,c=0,o=0,y=1024,d=1024,A=1,P=1){return this.tile(e,s,n,{u:t,v:r,tileWidth:l,tileHeight:h,animX:a,animY:c,rotate:o,animCountX:y,animCountY:d,animDivisor:A,alpha:P})}}var Ie=Object.defineProperty,Me=(i,e,t)=>e in i?Ie(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,R=(i,e,t)=>(Me(i,typeof e!="symbol"?e+"":e,t),t);class Be extends u.Container{constructor(e){super(),R(this,"texturesPerTilemap"),R(this,"tileAnim",null),R(this,"lastModifiedTilemap",null),R(this,"modificationMarker",0),R(this,"setBitmaps",this.tileset),this.texturesPerTilemap=B.TEXTURES_PER_TILEMAP,this.tileset(e)}tileset(e){e||(e=[]);const t=this.texturesPerTilemap,r=this.children.length,s=Math.ceil(e.length/t);for(let n=0;n<Math.min(r,s);n++)this.children[n].setTileset(e.slice(n*t,(n+1)*t));for(let n=r;n<s;n++){const l=new k(e.slice(n*t,(n+1)*t));l.compositeParent=!0,this.addChild(l)}return this}clear(){for(let e=0;e<this.children.length;e++)this.children[e].clear();return this.modificationMarker=0,this}tileRotate(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileRotate(e),this}tileAnimX(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimX(e,t),this}tileAnimY(e,t){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimY(e,t),this}tileAnimDivisor(e){return this.lastModifiedTilemap&&this.lastModifiedTilemap.tileAnimDivisor(e),this}tile(e,t,r,s={}){let n=null;const l=this.children;if(this.lastModifiedTilemap=null,typeof e=="number"){const h=e/this.texturesPerTilemap>>0;let a=0;if(n=l[h],n)a=e%this.texturesPerTilemap;else{if(n=l[0],!n)return this;a=0}n.tile(a,t,r,s)}else{typeof e=="string"&&(e=u.Texture.from(e));for(let h=0;h<l.length;h++){const a=l[h],c=a.getTileset().arr;for(let o=0;o<c.length;o++)if(c[o]===e.source){n=a;break}if(n)break}if(!n){for(let h=l.length-1;h>=0;h--){const a=l[h];if(a.getTileset().count<this.texturesPerTilemap){n=a,a.getTileset().push(e.source);break}}n||(n=new k(e.source),n.compositeParent=!0,this.addChild(n))}n.tile(e,t,r,s)}return this.lastModifiedTilemap=n,this}isModified(e){const t=this.children;if(this.modificationMarker!==t.length)return!0;for(let r=0;r<t.length;r++)if(t[r].isModified(e))return!0;return!1}clearModify(){const e=this.children;this.modificationMarker=e.length;for(let t=0;t<e.length;t++)e[t].clearModify()}addFrame(e,t,r,s,n,l,h,a,c){return this.tile(e,t,r,{animX:s,animY:n,animCountX:l,animCountY:h,animDivisor:a,alpha:c})}addRect(e,t,r,s,n,l,h,a,c,o,y,d){const A=e/this.texturesPerTilemap>>0,P=e%this.texturesPerTilemap;return this.children[A]&&this.children[A].getTileset().count>0?(this.lastModifiedTilemap=this.children[A],this.lastModifiedTilemap.addRect(P,t,r,s,n,l,h,a,c,o,y,d)):this.lastModifiedTilemap=null,this}get texPerChild(){return this.texturesPerTilemap}}return u.extensions.add($),u.extensions.add(se),u.extensions.add(ae),M.CompositeTilemap=Be,M.Constant=oe,M.POINT_STRUCT_SIZE=x,M.Tilemap=k,M.TilemapAdaptor=N,M.TilemapGeometry=ie,M.TilemapPipe=$,M.settings=B,M}({},PIXI);
126
+ //# sourceMappingURL=pixi-tilemap.js.map