@industry-theme/repository-composition-panels 0.2.57 → 0.2.59
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/{BufferResource-DEjDe1s8.js → BufferResource-BCBfCsT6.js} +5 -80
- package/dist/BufferResource-BCBfCsT6.js.map +1 -0
- package/dist/{CanvasRenderer-D2eDumWy.js → CanvasRenderer-2yEMbusr.js} +3 -339
- package/dist/CanvasRenderer-2yEMbusr.js.map +1 -0
- package/dist/{Filter-BSpiVWUN.js → Filter-CdzQNTtc.js} +2 -2
- package/dist/{Filter-BSpiVWUN.js.map → Filter-CdzQNTtc.js.map} +1 -1
- package/dist/{RenderTargetSystem-3-YKfxPi.js → RenderTargetSystem-CvocGhAO.js} +3 -3
- package/dist/{RenderTargetSystem-3-YKfxPi.js.map → RenderTargetSystem-CvocGhAO.js.map} +1 -1
- package/dist/{WebGLRenderer-BKhoAof0.js → WebGLRenderer-CsAZzI7W.js} +4 -4
- package/dist/{WebGLRenderer-BKhoAof0.js.map → WebGLRenderer-CsAZzI7W.js.map} +1 -1
- package/dist/{WebGPURenderer-BMMCBjut.js → WebGPURenderer-D2GRpSb3.js} +4 -4
- package/dist/{WebGPURenderer-BMMCBjut.js.map → WebGPURenderer-D2GRpSb3.js.map} +1 -1
- package/dist/{browserAll-BaiHieOj.js → browserAll-BG2Mm9Lt.js} +3 -3
- package/dist/{browserAll-BaiHieOj.js.map → browserAll-BG2Mm9Lt.js.map} +1 -1
- package/dist/{index-72-eqzyq.js → index-L48T6UlC.js} +2096 -467
- package/dist/index-L48T6UlC.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/{init-CZ5jJ8OJ.js → init-DWPvbIZ9.js} +3 -3
- package/dist/{init-CZ5jJ8OJ.js.map → init-DWPvbIZ9.js.map} +1 -1
- package/dist/panels/CollectionMapPanel.d.ts +3 -0
- package/dist/panels/CollectionMapPanel.d.ts.map +1 -1
- package/dist/panels/GitProjectsMapPanel.d.ts +3 -0
- package/dist/panels/GitProjectsMapPanel.d.ts.map +1 -1
- package/dist/panels/overworld-map/OverworldMapPanel.d.ts +3 -0
- package/dist/panels/overworld-map/OverworldMapPanel.d.ts.map +1 -1
- package/dist/panels/overworld-map/dataConverter.d.ts +2 -0
- package/dist/panels/overworld-map/dataConverter.d.ts.map +1 -1
- package/dist/panels/overworld-map/genericMapper.d.ts +12 -0
- package/dist/panels/overworld-map/genericMapper.d.ts.map +1 -1
- package/dist/panels/overworld-map/spriteGenerator.d.ts +8 -0
- package/dist/panels/overworld-map/spriteGenerator.d.ts.map +1 -1
- package/dist/panels/overworld-map/types.d.ts +4 -0
- package/dist/panels/overworld-map/types.d.ts.map +1 -1
- package/dist/panels.bundle.js +35 -39
- package/dist/webworkerAll-MEZKzuuk.js +3 -0
- package/dist/webworkerAll-MEZKzuuk.js.map +1 -0
- package/package.json +1 -1
- package/dist/BufferResource-DEjDe1s8.js.map +0 -1
- package/dist/CanvasRenderer-D2eDumWy.js.map +0 -1
- package/dist/index-72-eqzyq.js.map +0 -1
- package/dist/webworkerAll-Ccu7Tp4h.js +0 -3
- package/dist/webworkerAll-Ccu7Tp4h.js.map +0 -1
|
@@ -1,76 +1,4 @@
|
|
|
1
|
-
import { w as warn, g as getAttributeInfoFromFormat, h as STENCIL_MODES, u as unsafeEvalSupported, i as Buffer, j as BufferUsage, k as EventEmitter, l as uid } from "./index-
|
|
2
|
-
const localUniformBit = {
|
|
3
|
-
name: "local-uniform-bit",
|
|
4
|
-
vertex: {
|
|
5
|
-
header: (
|
|
6
|
-
/* wgsl */
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
struct LocalUniforms {
|
|
10
|
-
uTransformMatrix:mat3x3<f32>,
|
|
11
|
-
uColor:vec4<f32>,
|
|
12
|
-
uRound:f32,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
16
|
-
`
|
|
17
|
-
),
|
|
18
|
-
main: (
|
|
19
|
-
/* wgsl */
|
|
20
|
-
`
|
|
21
|
-
vColor *= localUniforms.uColor;
|
|
22
|
-
modelMatrix *= localUniforms.uTransformMatrix;
|
|
23
|
-
`
|
|
24
|
-
),
|
|
25
|
-
end: (
|
|
26
|
-
/* wgsl */
|
|
27
|
-
`
|
|
28
|
-
if(localUniforms.uRound == 1)
|
|
29
|
-
{
|
|
30
|
-
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
31
|
-
}
|
|
32
|
-
`
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const localUniformBitGroup2 = {
|
|
37
|
-
...localUniformBit,
|
|
38
|
-
vertex: {
|
|
39
|
-
...localUniformBit.vertex,
|
|
40
|
-
// replace the group!
|
|
41
|
-
header: localUniformBit.vertex.header.replace("group(1)", "group(2)")
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const localUniformBitGl = {
|
|
45
|
-
name: "local-uniform-bit",
|
|
46
|
-
vertex: {
|
|
47
|
-
header: (
|
|
48
|
-
/* glsl */
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
uniform mat3 uTransformMatrix;
|
|
52
|
-
uniform vec4 uColor;
|
|
53
|
-
uniform float uRound;
|
|
54
|
-
`
|
|
55
|
-
),
|
|
56
|
-
main: (
|
|
57
|
-
/* glsl */
|
|
58
|
-
`
|
|
59
|
-
vColor *= uColor;
|
|
60
|
-
modelMatrix = uTransformMatrix;
|
|
61
|
-
`
|
|
62
|
-
),
|
|
63
|
-
end: (
|
|
64
|
-
/* glsl */
|
|
65
|
-
`
|
|
66
|
-
if(uRound == 1.)
|
|
67
|
-
{
|
|
68
|
-
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
};
|
|
1
|
+
import { w as warn, g as getAttributeInfoFromFormat, h as STENCIL_MODES, u as unsafeEvalSupported, i as Buffer, j as BufferUsage, k as EventEmitter, l as uid } from "./index-L48T6UlC.js";
|
|
74
2
|
const textureBit = {
|
|
75
3
|
name: "texture-bit",
|
|
76
4
|
vertex: {
|
|
@@ -579,15 +507,12 @@ export {
|
|
|
579
507
|
BufferResource as B,
|
|
580
508
|
GpuStencilModesToPixi as G,
|
|
581
509
|
UboSystem as U,
|
|
582
|
-
|
|
583
|
-
|
|
510
|
+
uboSyncFunctionsSTD40 as a,
|
|
511
|
+
uniformParsers as b,
|
|
584
512
|
createUboSyncFunction as c,
|
|
585
|
-
|
|
513
|
+
textureBitGl as d,
|
|
586
514
|
ensureAttributes as e,
|
|
587
|
-
localUniformBitGl as f,
|
|
588
|
-
textureBitGl as g,
|
|
589
|
-
localUniformBitGroup2 as l,
|
|
590
515
|
textureBit as t,
|
|
591
516
|
uboSyncFunctionsWGSL as u
|
|
592
517
|
};
|
|
593
|
-
//# sourceMappingURL=BufferResource-
|
|
518
|
+
//# sourceMappingURL=BufferResource-BCBfCsT6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferResource-BCBfCsT6.js","sources":["../node_modules/pixi.js/lib/rendering/high-shader/shader-bits/textureBit.mjs","../node_modules/pixi.js/lib/rendering/renderers/gl/shader/program/ensureAttributes.mjs","../node_modules/pixi.js/lib/rendering/renderers/gpu/state/GpuStencilModesToPixi.mjs","../node_modules/pixi.js/lib/rendering/renderers/shared/shader/UboSystem.mjs","../node_modules/pixi.js/lib/rendering/renderers/shared/shader/utils/uniformParsers.mjs","../node_modules/pixi.js/lib/rendering/renderers/shared/shader/utils/createUboSyncFunction.mjs","../node_modules/pixi.js/lib/rendering/renderers/shared/shader/utils/uboSyncFunctions.mjs","../node_modules/pixi.js/lib/rendering/renderers/shared/buffer/BufferResource.mjs"],"sourcesContent":["\"use strict\";\nconst textureBit = {\n name: \"texture-bit\",\n vertex: {\n header: (\n /* wgsl */\n `\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n `\n ),\n main: (\n /* wgsl */\n `\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n `\n )\n },\n fragment: {\n header: (\n /* wgsl */\n `\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n `\n ),\n main: (\n /* wgsl */\n `\n outColor = textureSample(uTexture, uSampler, vUV);\n `\n )\n }\n};\nconst textureBitGl = {\n name: \"texture-bit\",\n vertex: {\n header: (\n /* glsl */\n `\n uniform mat3 uTextureMatrix;\n `\n ),\n main: (\n /* glsl */\n `\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n `\n )\n },\n fragment: {\n header: (\n /* glsl */\n `\n uniform sampler2D uTexture;\n\n\n `\n ),\n main: (\n /* glsl */\n `\n outColor = texture(uTexture, vUV);\n `\n )\n }\n};\n\nexport { textureBit, textureBitGl };\n//# sourceMappingURL=textureBit.mjs.map\n","import { warn } from '../../../../../utils/logging/warn.mjs';\nimport { getAttributeInfoFromFormat } from '../../../shared/geometry/utils/getAttributeInfoFromFormat.mjs';\n\n\"use strict\";\nfunction ensureAttributes(geometry, extractedData) {\n for (const i in geometry.attributes) {\n const attribute = geometry.attributes[i];\n const attributeData = extractedData[i];\n if (attributeData) {\n attribute.format ?? (attribute.format = attributeData.format);\n attribute.offset ?? (attribute.offset = attributeData.offset);\n attribute.instance ?? (attribute.instance = attributeData.instance);\n } else {\n warn(`Attribute ${i} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`);\n }\n }\n ensureStartAndStride(geometry);\n}\nfunction ensureStartAndStride(geometry) {\n const { buffers, attributes } = geometry;\n const tempStride = {};\n const tempStart = {};\n for (const j in buffers) {\n const buffer = buffers[j];\n tempStride[buffer.uid] = 0;\n tempStart[buffer.uid] = 0;\n }\n for (const j in attributes) {\n const attribute = attributes[j];\n tempStride[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n for (const j in attributes) {\n const attribute = attributes[j];\n attribute.stride ?? (attribute.stride = tempStride[attribute.buffer.uid]);\n attribute.start ?? (attribute.start = tempStart[attribute.buffer.uid]);\n tempStart[attribute.buffer.uid] += getAttributeInfoFromFormat(attribute.format).stride;\n }\n}\n\nexport { ensureAttributes };\n//# sourceMappingURL=ensureAttributes.mjs.map\n","import { STENCIL_MODES } from '../../shared/state/const.mjs';\n\n\"use strict\";\nconst GpuStencilModesToPixi = [];\nGpuStencilModesToPixi[STENCIL_MODES.NONE] = void 0;\nGpuStencilModesToPixi[STENCIL_MODES.DISABLED] = {\n stencilWriteMask: 0,\n stencilReadMask: 0\n};\nGpuStencilModesToPixi[STENCIL_MODES.RENDERING_MASK_ADD] = {\n stencilFront: {\n compare: \"equal\",\n passOp: \"increment-clamp\"\n },\n stencilBack: {\n compare: \"equal\",\n passOp: \"increment-clamp\"\n }\n};\nGpuStencilModesToPixi[STENCIL_MODES.RENDERING_MASK_REMOVE] = {\n stencilFront: {\n compare: \"equal\",\n passOp: \"decrement-clamp\"\n },\n stencilBack: {\n compare: \"equal\",\n passOp: \"decrement-clamp\"\n }\n};\nGpuStencilModesToPixi[STENCIL_MODES.MASK_ACTIVE] = {\n stencilWriteMask: 0,\n stencilFront: {\n compare: \"equal\",\n passOp: \"keep\"\n },\n stencilBack: {\n compare: \"equal\",\n passOp: \"keep\"\n }\n};\nGpuStencilModesToPixi[STENCIL_MODES.INVERSE_MASK_ACTIVE] = {\n stencilWriteMask: 0,\n stencilFront: {\n compare: \"not-equal\",\n passOp: \"keep\"\n },\n stencilBack: {\n compare: \"not-equal\",\n passOp: \"keep\"\n }\n};\n\nexport { GpuStencilModesToPixi };\n//# sourceMappingURL=GpuStencilModesToPixi.mjs.map\n","import { unsafeEvalSupported } from '../../../../utils/browser/unsafeEvalSupported.mjs';\nimport { Buffer } from '../buffer/Buffer.mjs';\nimport { BufferUsage } from '../buffer/const.mjs';\n\n\"use strict\";\nclass UboSystem {\n constructor(adaptor) {\n /** Cache of uniform buffer layouts and sync functions, so we don't have to re-create them */\n this._syncFunctionHash = /* @__PURE__ */ Object.create(null);\n this._adaptor = adaptor;\n this._systemCheck();\n }\n /**\n * Overridable function by `pixi.js/unsafe-eval` to silence\n * throwing an error if platform doesn't support unsafe-evals.\n * @private\n */\n _systemCheck() {\n if (!unsafeEvalSupported()) {\n throw new Error(\"Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.\");\n }\n }\n ensureUniformGroup(uniformGroup) {\n const uniformData = this.getUniformGroupData(uniformGroup);\n uniformGroup.buffer || (uniformGroup.buffer = new Buffer({\n data: new Float32Array(uniformData.layout.size / 4),\n usage: BufferUsage.UNIFORM | BufferUsage.COPY_DST\n }));\n }\n getUniformGroupData(uniformGroup) {\n return this._syncFunctionHash[uniformGroup._signature] || this._initUniformGroup(uniformGroup);\n }\n _initUniformGroup(uniformGroup) {\n const uniformGroupSignature = uniformGroup._signature;\n let uniformData = this._syncFunctionHash[uniformGroupSignature];\n if (!uniformData) {\n const elements = Object.keys(uniformGroup.uniformStructures).map((i) => uniformGroup.uniformStructures[i]);\n const layout = this._adaptor.createUboElements(elements);\n const syncFunction = this._generateUboSync(layout.uboElements);\n uniformData = this._syncFunctionHash[uniformGroupSignature] = {\n layout,\n syncFunction\n };\n }\n return this._syncFunctionHash[uniformGroupSignature];\n }\n _generateUboSync(uboElements) {\n return this._adaptor.generateUboSync(uboElements);\n }\n syncUniformGroup(uniformGroup, data, offset) {\n const uniformGroupData = this.getUniformGroupData(uniformGroup);\n uniformGroup.buffer || (uniformGroup.buffer = new Buffer({\n data: new Float32Array(uniformGroupData.layout.size / 4),\n usage: BufferUsage.UNIFORM | BufferUsage.COPY_DST\n }));\n let dataInt32 = null;\n if (!data) {\n data = uniformGroup.buffer.data;\n dataInt32 = uniformGroup.buffer.dataInt32;\n }\n offset || (offset = 0);\n uniformGroupData.syncFunction(uniformGroup.uniforms, data, dataInt32, offset);\n return true;\n }\n updateUniformGroup(uniformGroup) {\n if (uniformGroup.isStatic && !uniformGroup._dirtyId) return false;\n uniformGroup._dirtyId = 0;\n const synced = this.syncUniformGroup(uniformGroup);\n uniformGroup.buffer.update();\n return synced;\n }\n destroy() {\n this._syncFunctionHash = null;\n }\n}\n\nexport { UboSystem };\n//# sourceMappingURL=UboSystem.mjs.map\n","\"use strict\";\nconst uniformParsers = [\n // uploading pixi matrix object to mat3\n {\n type: \"mat3x3<f32>\",\n test: (data) => {\n const value = data.value;\n return value.a !== void 0;\n },\n ubo: `\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n `,\n uniform: `\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n `\n },\n // uploading a pixi rectangle as a vec4\n {\n type: \"vec4<f32>\",\n test: (data) => data.type === \"vec4<f32>\" && data.size === 1 && data.value.width !== void 0,\n ubo: `\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n `,\n uniform: `\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n `\n },\n // uploading a pixi point as a vec2\n {\n type: \"vec2<f32>\",\n test: (data) => data.type === \"vec2<f32>\" && data.size === 1 && data.value.x !== void 0,\n ubo: `\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n `,\n uniform: `\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n `\n },\n // uploading a pixi color as a vec4\n {\n type: \"vec4<f32>\",\n test: (data) => data.type === \"vec4<f32>\" && data.size === 1 && data.value.red !== void 0,\n ubo: `\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n `,\n uniform: `\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n `\n },\n // uploading a pixi color as a vec3\n {\n type: \"vec3<f32>\",\n test: (data) => data.type === \"vec3<f32>\" && data.size === 1 && data.value.red !== void 0,\n ubo: `\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n `,\n uniform: `\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n `\n }\n];\n\nexport { uniformParsers };\n//# sourceMappingURL=uniformParsers.mjs.map\n","import { uniformParsers } from './uniformParsers.mjs';\n\n\"use strict\";\nfunction createUboSyncFunction(uboElements, parserCode, arrayGenerationFunction, singleSettersMap) {\n const funcFragments = [`\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n `];\n let prev = 0;\n for (let i = 0; i < uboElements.length; i++) {\n const uboElement = uboElements[i];\n const name = uboElement.data.name;\n let parsed = false;\n let offset = 0;\n for (let j = 0; j < uniformParsers.length; j++) {\n const uniformParser = uniformParsers[j];\n if (uniformParser.test(uboElement.data)) {\n offset = uboElement.offset / 4;\n funcFragments.push(\n `name = \"${name}\";`,\n `offset += ${offset - prev};`,\n uniformParsers[j][parserCode] || uniformParsers[j].ubo\n );\n parsed = true;\n break;\n }\n }\n if (!parsed) {\n if (uboElement.data.size > 1) {\n offset = uboElement.offset / 4;\n funcFragments.push(arrayGenerationFunction(uboElement, offset - prev));\n } else {\n const template = singleSettersMap[uboElement.data.type];\n offset = uboElement.offset / 4;\n funcFragments.push(\n /* wgsl */\n `\n v = uv.${name};\n offset += ${offset - prev};\n ${template};\n `\n );\n }\n }\n prev = offset;\n }\n const fragmentSrc = funcFragments.join(\"\\n\");\n return new Function(\n \"uv\",\n \"data\",\n \"dataInt32\",\n \"offset\",\n fragmentSrc\n );\n}\n\nexport { createUboSyncFunction };\n//# sourceMappingURL=createUboSyncFunction.mjs.map\n","\"use strict\";\nfunction loopMatrix(col, row) {\n const total = col * row;\n return `\n for (let i = 0; i < ${total}; i++) {\n data[offset + (((i / ${col})|0) * 4) + (i % ${col})] = v[i];\n }\n `;\n}\nconst uboSyncFunctionsSTD40 = {\n f32: `\n data[offset] = v;`,\n i32: `\n dataInt32[offset] = v;`,\n \"vec2<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];`,\n \"vec3<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];`,\n \"vec4<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];`,\n \"vec2<i32>\": `\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];`,\n \"vec3<i32>\": `\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];`,\n \"vec4<i32>\": `\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];`,\n \"mat2x2<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];`,\n \"mat3x3<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];`,\n \"mat4x4<f32>\": `\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }`,\n \"mat3x2<f32>\": loopMatrix(3, 2),\n \"mat4x2<f32>\": loopMatrix(4, 2),\n \"mat2x3<f32>\": loopMatrix(2, 3),\n \"mat4x3<f32>\": loopMatrix(4, 3),\n \"mat2x4<f32>\": loopMatrix(2, 4),\n \"mat3x4<f32>\": loopMatrix(3, 4)\n};\nconst uboSyncFunctionsWGSL = {\n ...uboSyncFunctionsSTD40,\n \"mat2x2<f32>\": `\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n `\n};\n\nexport { uboSyncFunctionsSTD40, uboSyncFunctionsWGSL };\n//# sourceMappingURL=uboSyncFunctions.mjs.map\n","import EventEmitter from 'eventemitter3';\nimport { uid } from '../../../../utils/data/uid.mjs';\n\n\"use strict\";\nclass BufferResource extends EventEmitter {\n /**\n * Create a new Buffer Resource.\n * @param options - The options for the buffer resource\n * @param options.buffer - The underlying buffer that this resource is using\n * @param options.offset - The offset of the buffer this resource is using.\n * If not provided, then it will use the offset of the buffer.\n * @param options.size - The size of the buffer this resource is using.\n * If not provided, then it will use the size of the buffer.\n */\n constructor({ buffer, offset, size }) {\n super();\n /**\n * emits when the underlying buffer has changed shape (i.e. resized)\n * letting the renderer know that it needs to discard the old buffer on the GPU and create a new one\n * @event change\n */\n /** a unique id for this uniform group used through the renderer */\n this.uid = uid(\"buffer\");\n /**\n * a resource type, used to identify how to handle it when its in a bind group / shader resource\n * @internal\n */\n this._resourceType = \"bufferResource\";\n /**\n * used internally to know if a uniform group was used in the last render pass\n * @internal\n */\n this._touched = 0;\n /**\n * the resource id used internally by the renderer to build bind group keys\n * @internal\n */\n this._resourceId = uid(\"resource\");\n /**\n * A cheeky hint to the GL renderer to let it know this is a BufferResource\n * @internal\n */\n this._bufferResource = true;\n /**\n * Has the Buffer resource been destroyed?\n * @readonly\n */\n this.destroyed = false;\n this.buffer = buffer;\n this.offset = offset | 0;\n this.size = size;\n this.buffer.on(\"change\", this.onBufferChange, this);\n }\n onBufferChange() {\n this._resourceId = uid(\"resource\");\n this.emit(\"change\", this);\n }\n /**\n * Destroys this resource. Make sure the underlying buffer is not used anywhere else\n * if you want to destroy it as well, or code will explode\n * @param destroyBuffer - Should the underlying buffer be destroyed as well?\n */\n destroy(destroyBuffer = false) {\n this.destroyed = true;\n if (destroyBuffer) {\n this.buffer.destroy();\n }\n this.emit(\"change\", this);\n this.buffer = null;\n this.removeAllListeners();\n }\n}\n\nexport { BufferResource };\n//# sourceMappingURL=BufferResource.mjs.map\n"],"names":[],"mappings":";AACK,MAAC,aAAa;AAAA,EACjB,MAAM;AAAA,EACN,QAAQ;AAAA,IACN;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASF;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA,EAIN;AAAA,EACE,UAAU;AAAA,IACR;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOF;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA,EAIN;AACA;AACK,MAAC,eAAe;AAAA,EACnB,MAAM;AAAA,EACN,QAAQ;AAAA,IACN;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA,IAIF;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA,EAIN;AAAA,EACE,UAAU;AAAA,IACR;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMF;AAAA;AAAA,MAEE;AAAA;AAAA;AAAA;AAAA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c,IAAI,UAAU;AACjC,SAAK,KAAK,UAAU,IAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAQ,gBAAgB,OAAO;AAC7B,SAAK,YAAY;AACjB,QAAI,eAAe;AACjB,WAAK,OAAO,QAAO;AAAA,IACrB;AACA,SAAK,KAAK,UAAU,IAAI;AACxB,SAAK,SAAS;AACd,SAAK,mBAAkB;AAAA,EACzB;AACF;","x_google_ignoreList":[0,1,2,3,4,5,6,7]}
|
|
@@ -1,341 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { R as RenderTargetSystem, S as SharedSystems, B as BlendModePipe, a as BatcherPipe, b as SpritePipe, c as RenderGroupPipe, A as AlphaMaskPipe, C as CustomRenderPipe } from "./RenderTargetSystem-
|
|
3
|
-
let canUseNewCanvasBlendModesValue;
|
|
4
|
-
function createColoredCanvas(color) {
|
|
5
|
-
const canvas = DOMAdapter.get().createCanvas(6, 1);
|
|
6
|
-
const context = canvas.getContext("2d");
|
|
7
|
-
context.fillStyle = color;
|
|
8
|
-
context.fillRect(0, 0, 6, 1);
|
|
9
|
-
return canvas;
|
|
10
|
-
}
|
|
11
|
-
function canUseNewCanvasBlendModes() {
|
|
12
|
-
if (canUseNewCanvasBlendModesValue !== void 0) {
|
|
13
|
-
return canUseNewCanvasBlendModesValue;
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const magenta = createColoredCanvas("#ff00ff");
|
|
17
|
-
const yellow = createColoredCanvas("#ffff00");
|
|
18
|
-
const canvas = DOMAdapter.get().createCanvas(6, 1);
|
|
19
|
-
const context = canvas.getContext("2d");
|
|
20
|
-
context.globalCompositeOperation = "multiply";
|
|
21
|
-
context.drawImage(magenta, 0, 0);
|
|
22
|
-
context.drawImage(yellow, 2, 0);
|
|
23
|
-
const imageData = context.getImageData(2, 0, 1, 1);
|
|
24
|
-
if (!imageData) {
|
|
25
|
-
canUseNewCanvasBlendModesValue = false;
|
|
26
|
-
} else {
|
|
27
|
-
const data = imageData.data;
|
|
28
|
-
canUseNewCanvasBlendModesValue = data[0] === 255 && data[1] === 0 && data[2] === 0;
|
|
29
|
-
}
|
|
30
|
-
} catch (_error) {
|
|
31
|
-
canUseNewCanvasBlendModesValue = false;
|
|
32
|
-
}
|
|
33
|
-
return canUseNewCanvasBlendModesValue;
|
|
34
|
-
}
|
|
35
|
-
const canvasUtils = {
|
|
36
|
-
canvas: null,
|
|
37
|
-
convertTintToImage: false,
|
|
38
|
-
cacheStepsPerColorChannel: 8,
|
|
39
|
-
canUseMultiply: canUseNewCanvasBlendModes(),
|
|
40
|
-
tintMethod: null,
|
|
41
|
-
_canvasSourceCache: /* @__PURE__ */ new WeakMap(),
|
|
42
|
-
_unpremultipliedCache: /* @__PURE__ */ new WeakMap(),
|
|
43
|
-
getCanvasSource: (texture) => {
|
|
44
|
-
const source = texture.source;
|
|
45
|
-
const resource = source == null ? void 0 : source.resource;
|
|
46
|
-
if (!resource) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const isPMA = source.alphaMode === "premultiplied-alpha";
|
|
50
|
-
const resourceWidth = source.resourceWidth ?? source.pixelWidth;
|
|
51
|
-
const resourceHeight = source.resourceHeight ?? source.pixelHeight;
|
|
52
|
-
const needsResize = resourceWidth !== source.pixelWidth || resourceHeight !== source.pixelHeight;
|
|
53
|
-
if (isPMA) {
|
|
54
|
-
if (resource instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && resource instanceof OffscreenCanvas) {
|
|
55
|
-
if (!needsResize) {
|
|
56
|
-
return resource;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const cached = canvasUtils._unpremultipliedCache.get(source);
|
|
60
|
-
if ((cached == null ? void 0 : cached.resourceId) === source._resourceId) {
|
|
61
|
-
return cached.canvas;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (resource instanceof Uint8Array || resource instanceof Uint8ClampedArray || resource instanceof Int8Array || resource instanceof Uint16Array || resource instanceof Int16Array || resource instanceof Uint32Array || resource instanceof Int32Array || resource instanceof Float32Array || resource instanceof ArrayBuffer) {
|
|
65
|
-
const cached = canvasUtils._canvasSourceCache.get(source);
|
|
66
|
-
if ((cached == null ? void 0 : cached.resourceId) === source._resourceId) {
|
|
67
|
-
return cached.canvas;
|
|
68
|
-
}
|
|
69
|
-
const canvas = DOMAdapter.get().createCanvas(source.pixelWidth, source.pixelHeight);
|
|
70
|
-
const context = canvas.getContext("2d");
|
|
71
|
-
const imageData = context.createImageData(source.pixelWidth, source.pixelHeight);
|
|
72
|
-
const data = imageData.data;
|
|
73
|
-
const bytes = resource instanceof ArrayBuffer ? new Uint8Array(resource) : new Uint8Array(resource.buffer, resource.byteOffset, resource.byteLength);
|
|
74
|
-
if (source.format === "bgra8unorm") {
|
|
75
|
-
for (let i = 0; i < data.length && i + 3 < bytes.length; i += 4) {
|
|
76
|
-
data[i] = bytes[i + 2];
|
|
77
|
-
data[i + 1] = bytes[i + 1];
|
|
78
|
-
data[i + 2] = bytes[i];
|
|
79
|
-
data[i + 3] = bytes[i + 3];
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
data.set(bytes.subarray(0, data.length));
|
|
83
|
-
}
|
|
84
|
-
context.putImageData(imageData, 0, 0);
|
|
85
|
-
canvasUtils._canvasSourceCache.set(source, { canvas, resourceId: source._resourceId });
|
|
86
|
-
return canvas;
|
|
87
|
-
}
|
|
88
|
-
if (isPMA) {
|
|
89
|
-
const canvas = DOMAdapter.get().createCanvas(source.pixelWidth, source.pixelHeight);
|
|
90
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
91
|
-
canvas.width = source.pixelWidth;
|
|
92
|
-
canvas.height = source.pixelHeight;
|
|
93
|
-
context.drawImage(resource, 0, 0);
|
|
94
|
-
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
95
|
-
const data = imageData.data;
|
|
96
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
97
|
-
const a = data[i + 3];
|
|
98
|
-
if (a > 0) {
|
|
99
|
-
const alphaInv = 255 / a;
|
|
100
|
-
data[i] = Math.min(255, data[i] * alphaInv + 0.5);
|
|
101
|
-
data[i + 1] = Math.min(255, data[i + 1] * alphaInv + 0.5);
|
|
102
|
-
data[i + 2] = Math.min(255, data[i + 2] * alphaInv + 0.5);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
context.putImageData(imageData, 0, 0);
|
|
106
|
-
canvasUtils._unpremultipliedCache.set(source, { canvas, resourceId: source._resourceId });
|
|
107
|
-
return canvas;
|
|
108
|
-
}
|
|
109
|
-
if (needsResize) {
|
|
110
|
-
const cached = canvasUtils._canvasSourceCache.get(source);
|
|
111
|
-
if ((cached == null ? void 0 : cached.resourceId) === source._resourceId) {
|
|
112
|
-
return cached.canvas;
|
|
113
|
-
}
|
|
114
|
-
const canvas = DOMAdapter.get().createCanvas(source.pixelWidth, source.pixelHeight);
|
|
115
|
-
const context = canvas.getContext("2d");
|
|
116
|
-
canvas.width = source.pixelWidth;
|
|
117
|
-
canvas.height = source.pixelHeight;
|
|
118
|
-
context.drawImage(resource, 0, 0);
|
|
119
|
-
canvasUtils._canvasSourceCache.set(source, { canvas, resourceId: source._resourceId });
|
|
120
|
-
return canvas;
|
|
121
|
-
}
|
|
122
|
-
return resource;
|
|
123
|
-
},
|
|
124
|
-
getTintedCanvas: (sprite, color) => {
|
|
125
|
-
const texture = sprite.texture;
|
|
126
|
-
const stringColor = Color.shared.setValue(color).toHex();
|
|
127
|
-
const cache = texture.tintCache || (texture.tintCache = {});
|
|
128
|
-
const cachedCanvas = cache[stringColor];
|
|
129
|
-
const resourceId = texture.source._resourceId;
|
|
130
|
-
if ((cachedCanvas == null ? void 0 : cachedCanvas.tintId) === resourceId) {
|
|
131
|
-
return cachedCanvas;
|
|
132
|
-
}
|
|
133
|
-
const canvas = cachedCanvas && "getContext" in cachedCanvas ? cachedCanvas : DOMAdapter.get().createCanvas();
|
|
134
|
-
canvasUtils.tintMethod(texture, color, canvas);
|
|
135
|
-
canvas.tintId = resourceId;
|
|
136
|
-
{
|
|
137
|
-
cache[stringColor] = canvas;
|
|
138
|
-
}
|
|
139
|
-
return cache[stringColor];
|
|
140
|
-
},
|
|
141
|
-
getTintedPattern: (texture, color) => {
|
|
142
|
-
const stringColor = Color.shared.setValue(color).toHex();
|
|
143
|
-
const cache = texture.patternCache || (texture.patternCache = {});
|
|
144
|
-
const resourceId = texture.source._resourceId;
|
|
145
|
-
let pattern = cache[stringColor];
|
|
146
|
-
if ((pattern == null ? void 0 : pattern.tintId) === resourceId) {
|
|
147
|
-
return pattern;
|
|
148
|
-
}
|
|
149
|
-
if (!canvasUtils.canvas) {
|
|
150
|
-
canvasUtils.canvas = DOMAdapter.get().createCanvas();
|
|
151
|
-
}
|
|
152
|
-
canvasUtils.tintMethod(texture, color, canvasUtils.canvas);
|
|
153
|
-
const context = canvasUtils.canvas.getContext("2d");
|
|
154
|
-
pattern = context.createPattern(canvasUtils.canvas, "repeat");
|
|
155
|
-
pattern.tintId = resourceId;
|
|
156
|
-
cache[stringColor] = pattern;
|
|
157
|
-
return pattern;
|
|
158
|
-
},
|
|
159
|
-
/**
|
|
160
|
-
* Applies a transform to a CanvasPattern.
|
|
161
|
-
* @param pattern - The pattern to apply the transform to.
|
|
162
|
-
* @param matrix - The matrix to apply.
|
|
163
|
-
* @param matrix.a
|
|
164
|
-
* @param matrix.b
|
|
165
|
-
* @param matrix.c
|
|
166
|
-
* @param matrix.d
|
|
167
|
-
* @param matrix.tx
|
|
168
|
-
* @param matrix.ty
|
|
169
|
-
* @param invert
|
|
170
|
-
*/
|
|
171
|
-
applyPatternTransform: (pattern, matrix, invert = true) => {
|
|
172
|
-
if (!matrix) return;
|
|
173
|
-
const patternAny = pattern;
|
|
174
|
-
if (!patternAny.setTransform) return;
|
|
175
|
-
const DOMMatrixCtor = globalThis.DOMMatrix;
|
|
176
|
-
if (!DOMMatrixCtor) return;
|
|
177
|
-
const domMatrix = new DOMMatrixCtor([matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty]);
|
|
178
|
-
patternAny.setTransform(invert ? domMatrix.inverse() : domMatrix);
|
|
179
|
-
},
|
|
180
|
-
tintWithMultiply: (texture, color, canvas) => {
|
|
181
|
-
const context = canvas.getContext("2d");
|
|
182
|
-
const crop = texture.frame.clone();
|
|
183
|
-
const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
|
|
184
|
-
const rotate = texture.rotate;
|
|
185
|
-
crop.x *= resolution;
|
|
186
|
-
crop.y *= resolution;
|
|
187
|
-
crop.width *= resolution;
|
|
188
|
-
crop.height *= resolution;
|
|
189
|
-
const isVertical = groupD8.isVertical(rotate);
|
|
190
|
-
const outWidth = isVertical ? crop.height : crop.width;
|
|
191
|
-
const outHeight = isVertical ? crop.width : crop.height;
|
|
192
|
-
canvas.width = Math.ceil(outWidth);
|
|
193
|
-
canvas.height = Math.ceil(outHeight);
|
|
194
|
-
context.save();
|
|
195
|
-
context.fillStyle = Color.shared.setValue(color).toHex();
|
|
196
|
-
context.fillRect(0, 0, outWidth, outHeight);
|
|
197
|
-
context.globalCompositeOperation = "multiply";
|
|
198
|
-
const source = canvasUtils.getCanvasSource(texture);
|
|
199
|
-
if (!source) {
|
|
200
|
-
context.restore();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (rotate) {
|
|
204
|
-
canvasUtils._applyInverseRotation(context, rotate, crop.width, crop.height);
|
|
205
|
-
}
|
|
206
|
-
context.drawImage(
|
|
207
|
-
source,
|
|
208
|
-
crop.x,
|
|
209
|
-
crop.y,
|
|
210
|
-
crop.width,
|
|
211
|
-
crop.height,
|
|
212
|
-
0,
|
|
213
|
-
0,
|
|
214
|
-
crop.width,
|
|
215
|
-
crop.height
|
|
216
|
-
);
|
|
217
|
-
context.globalCompositeOperation = "destination-atop";
|
|
218
|
-
context.drawImage(
|
|
219
|
-
source,
|
|
220
|
-
crop.x,
|
|
221
|
-
crop.y,
|
|
222
|
-
crop.width,
|
|
223
|
-
crop.height,
|
|
224
|
-
0,
|
|
225
|
-
0,
|
|
226
|
-
crop.width,
|
|
227
|
-
crop.height
|
|
228
|
-
);
|
|
229
|
-
context.restore();
|
|
230
|
-
},
|
|
231
|
-
tintWithOverlay: (texture, color, canvas) => {
|
|
232
|
-
const context = canvas.getContext("2d");
|
|
233
|
-
const crop = texture.frame.clone();
|
|
234
|
-
const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
|
|
235
|
-
const rotate = texture.rotate;
|
|
236
|
-
crop.x *= resolution;
|
|
237
|
-
crop.y *= resolution;
|
|
238
|
-
crop.width *= resolution;
|
|
239
|
-
crop.height *= resolution;
|
|
240
|
-
const isVertical = groupD8.isVertical(rotate);
|
|
241
|
-
const outWidth = isVertical ? crop.height : crop.width;
|
|
242
|
-
const outHeight = isVertical ? crop.width : crop.height;
|
|
243
|
-
canvas.width = Math.ceil(outWidth);
|
|
244
|
-
canvas.height = Math.ceil(outHeight);
|
|
245
|
-
context.save();
|
|
246
|
-
context.globalCompositeOperation = "copy";
|
|
247
|
-
context.fillStyle = Color.shared.setValue(color).toHex();
|
|
248
|
-
context.fillRect(0, 0, outWidth, outHeight);
|
|
249
|
-
context.globalCompositeOperation = "destination-atop";
|
|
250
|
-
const source = canvasUtils.getCanvasSource(texture);
|
|
251
|
-
if (!source) {
|
|
252
|
-
context.restore();
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (rotate) {
|
|
256
|
-
canvasUtils._applyInverseRotation(context, rotate, crop.width, crop.height);
|
|
257
|
-
}
|
|
258
|
-
context.drawImage(
|
|
259
|
-
source,
|
|
260
|
-
crop.x,
|
|
261
|
-
crop.y,
|
|
262
|
-
crop.width,
|
|
263
|
-
crop.height,
|
|
264
|
-
0,
|
|
265
|
-
0,
|
|
266
|
-
crop.width,
|
|
267
|
-
crop.height
|
|
268
|
-
);
|
|
269
|
-
context.restore();
|
|
270
|
-
},
|
|
271
|
-
tintWithPerPixel: (texture, color, canvas) => {
|
|
272
|
-
const context = canvas.getContext("2d");
|
|
273
|
-
const crop = texture.frame.clone();
|
|
274
|
-
const resolution = texture.source._resolution ?? texture.source.resolution ?? 1;
|
|
275
|
-
const rotate = texture.rotate;
|
|
276
|
-
crop.x *= resolution;
|
|
277
|
-
crop.y *= resolution;
|
|
278
|
-
crop.width *= resolution;
|
|
279
|
-
crop.height *= resolution;
|
|
280
|
-
const isVertical = groupD8.isVertical(rotate);
|
|
281
|
-
const outWidth = isVertical ? crop.height : crop.width;
|
|
282
|
-
const outHeight = isVertical ? crop.width : crop.height;
|
|
283
|
-
canvas.width = Math.ceil(outWidth);
|
|
284
|
-
canvas.height = Math.ceil(outHeight);
|
|
285
|
-
context.save();
|
|
286
|
-
context.globalCompositeOperation = "copy";
|
|
287
|
-
const source = canvasUtils.getCanvasSource(texture);
|
|
288
|
-
if (!source) {
|
|
289
|
-
context.restore();
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
if (rotate) {
|
|
293
|
-
canvasUtils._applyInverseRotation(context, rotate, crop.width, crop.height);
|
|
294
|
-
}
|
|
295
|
-
context.drawImage(
|
|
296
|
-
source,
|
|
297
|
-
crop.x,
|
|
298
|
-
crop.y,
|
|
299
|
-
crop.width,
|
|
300
|
-
crop.height,
|
|
301
|
-
0,
|
|
302
|
-
0,
|
|
303
|
-
crop.width,
|
|
304
|
-
crop.height
|
|
305
|
-
);
|
|
306
|
-
context.restore();
|
|
307
|
-
const r = color >> 16 & 255;
|
|
308
|
-
const g = color >> 8 & 255;
|
|
309
|
-
const b = color & 255;
|
|
310
|
-
const imageData = context.getImageData(0, 0, outWidth, outHeight);
|
|
311
|
-
const data = imageData.data;
|
|
312
|
-
for (let i = 0; i < data.length; i += 4) {
|
|
313
|
-
data[i] = data[i] * r / 255;
|
|
314
|
-
data[i + 1] = data[i + 1] * g / 255;
|
|
315
|
-
data[i + 2] = data[i + 2] * b / 255;
|
|
316
|
-
}
|
|
317
|
-
context.putImageData(imageData, 0, 0);
|
|
318
|
-
},
|
|
319
|
-
/**
|
|
320
|
-
* Applies inverse rotation transform to context for texture packer rotation compensation.
|
|
321
|
-
* Supports all 16 groupD8 symmetries (rotations and reflections).
|
|
322
|
-
* @param context - Canvas 2D context
|
|
323
|
-
* @param rotate - The groupD8 rotation value
|
|
324
|
-
* @param srcWidth - Source crop width (before rotation)
|
|
325
|
-
* @param srcHeight - Source crop height (before rotation)
|
|
326
|
-
*/
|
|
327
|
-
_applyInverseRotation: (context, rotate, srcWidth, srcHeight) => {
|
|
328
|
-
const inv = groupD8.inv(rotate);
|
|
329
|
-
const a = groupD8.uX(inv);
|
|
330
|
-
const b = groupD8.uY(inv);
|
|
331
|
-
const c = groupD8.vX(inv);
|
|
332
|
-
const d = groupD8.vY(inv);
|
|
333
|
-
const tx = -Math.min(0, a * srcWidth, c * srcHeight, a * srcWidth + c * srcHeight);
|
|
334
|
-
const ty = -Math.min(0, b * srcWidth, d * srcHeight, b * srcWidth + d * srcHeight);
|
|
335
|
-
context.transform(a, b, c, d, tx, ty);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
canvasUtils.tintMethod = canvasUtils.canUseMultiply ? canvasUtils.tintWithMultiply : canvasUtils.tintWithPerPixel;
|
|
1
|
+
import { m as canvasUtils, n as groupD8, o as bgr2rgb, p as multiplyHexColors, M as Matrix, E as ExtensionType, q as Graphics, w as warn, r as canUseNewCanvasBlendModes, C as Color, c as Texture, s as generateTextureMatrix, t as shapeBuilders, v as buildLine, F as FillGradient, x as FillPattern, y as CanvasSource, D as DOMAdapter, A as AbstractRenderer, R as RendererType, f as extensions } from "./index-L48T6UlC.js";
|
|
2
|
+
import { R as RenderTargetSystem, S as SharedSystems, B as BlendModePipe, a as BatcherPipe, b as SpritePipe, c as RenderGroupPipe, A as AlphaMaskPipe, C as CustomRenderPipe } from "./RenderTargetSystem-CvocGhAO.js";
|
|
339
3
|
const _CanvasBatchAdaptor = class _CanvasBatchAdaptor2 {
|
|
340
4
|
static _getPatternRepeat(addressModeU, addressModeV) {
|
|
341
5
|
const repeatU = addressModeU && addressModeU !== "clamp-to-edge";
|
|
@@ -1522,4 +1186,4 @@ class CanvasRenderer extends AbstractRenderer {
|
|
|
1522
1186
|
export {
|
|
1523
1187
|
CanvasRenderer
|
|
1524
1188
|
};
|
|
1525
|
-
//# sourceMappingURL=CanvasRenderer-
|
|
1189
|
+
//# sourceMappingURL=CanvasRenderer-2yEMbusr.js.map
|