This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

11
node_modules/pixi.js/lib/scene/mesh/MeshMixins.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
declare global
{
namespace PixiMixins
{
interface RendererPipes
{
mesh: import('./shared/MeshPipe').MeshPipe;
}
}
}
export {};

View File

@@ -0,0 +1,18 @@
import { ExtensionType } from '../../../extensions/Extensions';
import type { Mesh } from '../shared/Mesh';
import type { MeshAdaptor, MeshPipe } from '../shared/MeshPipe';
/**
* A MeshAdaptor that uses the WebGL to render meshes.
* @memberof rendering
* @ignore
*/
export declare class GlMeshAdaptor implements MeshAdaptor {
static extension: {
readonly type: readonly [ExtensionType.WebGLPipesAdaptor];
readonly name: "mesh";
};
private _shader;
init(): void;
execute(meshPipe: MeshPipe, mesh: Mesh): void;
destroy(): void;
}

View File

@@ -0,0 +1,69 @@
'use strict';
var Extensions = require('../../../extensions/Extensions.js');
var Matrix = require('../../../maths/matrix/Matrix.js');
var compileHighShaderToProgram = require('../../../rendering/high-shader/compileHighShaderToProgram.js');
var localUniformBit = require('../../../rendering/high-shader/shader-bits/localUniformBit.js');
var roundPixelsBit = require('../../../rendering/high-shader/shader-bits/roundPixelsBit.js');
var textureBit = require('../../../rendering/high-shader/shader-bits/textureBit.js');
var Shader = require('../../../rendering/renderers/shared/shader/Shader.js');
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
var warn = require('../../../utils/logging/warn.js');
"use strict";
class GlMeshAdaptor {
init() {
const glProgram = compileHighShaderToProgram.compileHighShaderGlProgram({
name: "mesh",
bits: [
localUniformBit.localUniformBitGl,
textureBit.textureBitGl,
roundPixelsBit.roundPixelsBitGl
]
});
this._shader = new Shader.Shader({
glProgram,
resources: {
uTexture: Texture.Texture.EMPTY.source,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix.Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
const texture = mesh.texture;
const source = texture.source;
shader.resources.uTexture = source;
shader.resources.uSampler = source.style;
shader.resources.textureUniforms.uniforms.uTextureMatrix = texture.textureMatrix.mapCoord;
} else if (!shader.glProgram) {
warn.warn("Mesh shader has no glProgram", mesh.shader);
return;
}
shader.groups[100] = renderer.globalUniforms.bindGroup;
shader.groups[101] = meshPipe.localUniformsBindGroup;
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
GlMeshAdaptor.extension = {
type: [
Extensions.ExtensionType.WebGLPipesAdaptor
],
name: "mesh"
};
exports.GlMeshAdaptor = GlMeshAdaptor;
//# sourceMappingURL=GlMeshAdaptor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlMeshAdaptor.js","sources":["../../../../src/scene/mesh/gl/GlMeshAdaptor.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\nimport { Matrix } from '../../../maths/matrix/Matrix';\nimport { compileHighShaderGlProgram } from '../../../rendering/high-shader/compileHighShaderToProgram';\nimport { localUniformBitGl } from '../../../rendering/high-shader/shader-bits/localUniformBit';\nimport { roundPixelsBitGl } from '../../../rendering/high-shader/shader-bits/roundPixelsBit';\nimport { textureBitGl } from '../../../rendering/high-shader/shader-bits/textureBit';\nimport { Shader } from '../../../rendering/renderers/shared/shader/Shader';\nimport { Texture } from '../../../rendering/renderers/shared/texture/Texture';\nimport { warn } from '../../../utils/logging/warn';\n\nimport type { Mesh } from '../shared/Mesh';\nimport type { MeshAdaptor, MeshPipe } from '../shared/MeshPipe';\n\n/**\n * A MeshAdaptor that uses the WebGL to render meshes.\n * @memberof rendering\n * @ignore\n */\nexport class GlMeshAdaptor implements MeshAdaptor\n{\n public static extension = {\n type: [\n ExtensionType.WebGLPipesAdaptor,\n ],\n name: 'mesh',\n } as const;\n\n private _shader: Shader;\n\n public init(): void\n {\n const glProgram = compileHighShaderGlProgram({\n name: 'mesh',\n bits: [\n localUniformBitGl,\n textureBitGl,\n roundPixelsBitGl,\n ]\n });\n\n this._shader = new Shader({\n glProgram,\n resources: {\n uTexture: Texture.EMPTY.source,\n textureUniforms: {\n uTextureMatrix: { type: 'mat3x3<f32>', value: new Matrix() },\n }\n }\n });\n }\n\n public execute(meshPipe: MeshPipe, mesh: Mesh): void\n {\n const renderer = meshPipe.renderer;\n\n let shader: Shader = mesh._shader;\n\n if (!shader)\n {\n shader = this._shader;\n\n const texture = mesh.texture;\n const source = texture.source;\n\n shader.resources.uTexture = source;\n shader.resources.uSampler = source.style;\n shader.resources.textureUniforms.uniforms.uTextureMatrix = texture.textureMatrix.mapCoord;\n }\n else if (!shader.glProgram)\n {\n // #if _DEBUG\n warn('Mesh shader has no glProgram', mesh.shader);\n // #endif\n\n return;\n }\n\n // setting the groups to be high to be compatible and not\n // overlap any other groups\n shader.groups[100] = renderer.globalUniforms.bindGroup;\n shader.groups[101] = meshPipe.localUniformsBindGroup;\n\n renderer.encoder.draw({\n geometry: mesh._geometry,\n shader,\n state: mesh.state,\n });\n }\n\n public destroy(): void\n {\n this._shader.destroy(true);\n this._shader = null;\n }\n}\n"],"names":["compileHighShaderGlProgram","localUniformBitGl","textureBitGl","roundPixelsBitGl","Shader","Texture","Matrix","warn","ExtensionType"],"mappings":";;;;;;;;;;;;;AAkBO,MAAM,aACb,CAAA;AAAA,EAUW,IACP,GAAA;AACI,IAAA,MAAM,YAAYA,qDAA2B,CAAA;AAAA,MACzC,IAAM,EAAA,MAAA;AAAA,MACN,IAAM,EAAA;AAAA,QACFC,iCAAA;AAAA,QACAC,uBAAA;AAAA,QACAC,+BAAA;AAAA,OACJ;AAAA,KACH,CAAA,CAAA;AAED,IAAK,IAAA,CAAA,OAAA,GAAU,IAAIC,aAAO,CAAA;AAAA,MACtB,SAAA;AAAA,MACA,SAAW,EAAA;AAAA,QACP,QAAA,EAAUC,gBAAQ,KAAM,CAAA,MAAA;AAAA,QACxB,eAAiB,EAAA;AAAA,UACb,gBAAgB,EAAE,IAAA,EAAM,eAAe,KAAO,EAAA,IAAIC,eAAS,EAAA;AAAA,SAC/D;AAAA,OACJ;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAAA,EAEO,OAAA,CAAQ,UAAoB,IACnC,EAAA;AACI,IAAA,MAAM,WAAW,QAAS,CAAA,QAAA,CAAA;AAE1B,IAAA,IAAI,SAAiB,IAAK,CAAA,OAAA,CAAA;AAE1B,IAAA,IAAI,CAAC,MACL,EAAA;AACI,MAAA,MAAA,GAAS,IAAK,CAAA,OAAA,CAAA;AAEd,MAAA,MAAM,UAAU,IAAK,CAAA,OAAA,CAAA;AACrB,MAAA,MAAM,SAAS,OAAQ,CAAA,MAAA,CAAA;AAEvB,MAAA,MAAA,CAAO,UAAU,QAAW,GAAA,MAAA,CAAA;AAC5B,MAAO,MAAA,CAAA,SAAA,CAAU,WAAW,MAAO,CAAA,KAAA,CAAA;AACnC,MAAA,MAAA,CAAO,SAAU,CAAA,eAAA,CAAgB,QAAS,CAAA,cAAA,GAAiB,QAAQ,aAAc,CAAA,QAAA,CAAA;AAAA,KACrF,MAAA,IACS,CAAC,MAAA,CAAO,SACjB,EAAA;AAEI,MAAKC,SAAA,CAAA,8BAAA,EAAgC,KAAK,MAAM,CAAA,CAAA;AAGhD,MAAA,OAAA;AAAA,KACJ;AAIA,IAAA,MAAA,CAAO,MAAO,CAAA,GAAG,CAAI,GAAA,QAAA,CAAS,cAAe,CAAA,SAAA,CAAA;AAC7C,IAAO,MAAA,CAAA,MAAA,CAAO,GAAG,CAAA,GAAI,QAAS,CAAA,sBAAA,CAAA;AAE9B,IAAA,QAAA,CAAS,QAAQ,IAAK,CAAA;AAAA,MAClB,UAAU,IAAK,CAAA,SAAA;AAAA,MACf,MAAA;AAAA,MACA,OAAO,IAAK,CAAA,KAAA;AAAA,KACf,CAAA,CAAA;AAAA,GACL;AAAA,EAEO,OACP,GAAA;AACI,IAAK,IAAA,CAAA,OAAA,CAAQ,QAAQ,IAAI,CAAA,CAAA;AACzB,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AAAA,GACnB;AACJ,CAAA;AA5Ea,aAAA,CAEK,SAAY,GAAA;AAAA,EACtB,IAAM,EAAA;AAAA,IACFC,wBAAc,CAAA,iBAAA;AAAA,GAClB;AAAA,EACA,IAAM,EAAA,MAAA;AACV,CAAA;;;;"}

View File

@@ -0,0 +1,67 @@
import { ExtensionType } from '../../../extensions/Extensions.mjs';
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { compileHighShaderGlProgram } from '../../../rendering/high-shader/compileHighShaderToProgram.mjs';
import { localUniformBitGl } from '../../../rendering/high-shader/shader-bits/localUniformBit.mjs';
import { roundPixelsBitGl } from '../../../rendering/high-shader/shader-bits/roundPixelsBit.mjs';
import { textureBitGl } from '../../../rendering/high-shader/shader-bits/textureBit.mjs';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader.mjs';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
import { warn } from '../../../utils/logging/warn.mjs';
"use strict";
class GlMeshAdaptor {
init() {
const glProgram = compileHighShaderGlProgram({
name: "mesh",
bits: [
localUniformBitGl,
textureBitGl,
roundPixelsBitGl
]
});
this._shader = new Shader({
glProgram,
resources: {
uTexture: Texture.EMPTY.source,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
const texture = mesh.texture;
const source = texture.source;
shader.resources.uTexture = source;
shader.resources.uSampler = source.style;
shader.resources.textureUniforms.uniforms.uTextureMatrix = texture.textureMatrix.mapCoord;
} else if (!shader.glProgram) {
warn("Mesh shader has no glProgram", mesh.shader);
return;
}
shader.groups[100] = renderer.globalUniforms.bindGroup;
shader.groups[101] = meshPipe.localUniformsBindGroup;
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
GlMeshAdaptor.extension = {
type: [
ExtensionType.WebGLPipesAdaptor
],
name: "mesh"
};
export { GlMeshAdaptor };
//# sourceMappingURL=GlMeshAdaptor.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"GlMeshAdaptor.mjs","sources":["../../../../src/scene/mesh/gl/GlMeshAdaptor.ts"],"sourcesContent":["import { ExtensionType } from '../../../extensions/Extensions';\nimport { Matrix } from '../../../maths/matrix/Matrix';\nimport { compileHighShaderGlProgram } from '../../../rendering/high-shader/compileHighShaderToProgram';\nimport { localUniformBitGl } from '../../../rendering/high-shader/shader-bits/localUniformBit';\nimport { roundPixelsBitGl } from '../../../rendering/high-shader/shader-bits/roundPixelsBit';\nimport { textureBitGl } from '../../../rendering/high-shader/shader-bits/textureBit';\nimport { Shader } from '../../../rendering/renderers/shared/shader/Shader';\nimport { Texture } from '../../../rendering/renderers/shared/texture/Texture';\nimport { warn } from '../../../utils/logging/warn';\n\nimport type { Mesh } from '../shared/Mesh';\nimport type { MeshAdaptor, MeshPipe } from '../shared/MeshPipe';\n\n/**\n * A MeshAdaptor that uses the WebGL to render meshes.\n * @memberof rendering\n * @ignore\n */\nexport class GlMeshAdaptor implements MeshAdaptor\n{\n public static extension = {\n type: [\n ExtensionType.WebGLPipesAdaptor,\n ],\n name: 'mesh',\n } as const;\n\n private _shader: Shader;\n\n public init(): void\n {\n const glProgram = compileHighShaderGlProgram({\n name: 'mesh',\n bits: [\n localUniformBitGl,\n textureBitGl,\n roundPixelsBitGl,\n ]\n });\n\n this._shader = new Shader({\n glProgram,\n resources: {\n uTexture: Texture.EMPTY.source,\n textureUniforms: {\n uTextureMatrix: { type: 'mat3x3<f32>', value: new Matrix() },\n }\n }\n });\n }\n\n public execute(meshPipe: MeshPipe, mesh: Mesh): void\n {\n const renderer = meshPipe.renderer;\n\n let shader: Shader = mesh._shader;\n\n if (!shader)\n {\n shader = this._shader;\n\n const texture = mesh.texture;\n const source = texture.source;\n\n shader.resources.uTexture = source;\n shader.resources.uSampler = source.style;\n shader.resources.textureUniforms.uniforms.uTextureMatrix = texture.textureMatrix.mapCoord;\n }\n else if (!shader.glProgram)\n {\n // #if _DEBUG\n warn('Mesh shader has no glProgram', mesh.shader);\n // #endif\n\n return;\n }\n\n // setting the groups to be high to be compatible and not\n // overlap any other groups\n shader.groups[100] = renderer.globalUniforms.bindGroup;\n shader.groups[101] = meshPipe.localUniformsBindGroup;\n\n renderer.encoder.draw({\n geometry: mesh._geometry,\n shader,\n state: mesh.state,\n });\n }\n\n public destroy(): void\n {\n this._shader.destroy(true);\n this._shader = null;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAkBO,MAAM,aACb,CAAA;AAAA,EAUW,IACP,GAAA;AACI,IAAA,MAAM,YAAY,0BAA2B,CAAA;AAAA,MACzC,IAAM,EAAA,MAAA;AAAA,MACN,IAAM,EAAA;AAAA,QACF,iBAAA;AAAA,QACA,YAAA;AAAA,QACA,gBAAA;AAAA,OACJ;AAAA,KACH,CAAA,CAAA;AAED,IAAK,IAAA,CAAA,OAAA,GAAU,IAAI,MAAO,CAAA;AAAA,MACtB,SAAA;AAAA,MACA,SAAW,EAAA;AAAA,QACP,QAAA,EAAU,QAAQ,KAAM,CAAA,MAAA;AAAA,QACxB,eAAiB,EAAA;AAAA,UACb,gBAAgB,EAAE,IAAA,EAAM,eAAe,KAAO,EAAA,IAAI,QAAS,EAAA;AAAA,SAC/D;AAAA,OACJ;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAAA,EAEO,OAAA,CAAQ,UAAoB,IACnC,EAAA;AACI,IAAA,MAAM,WAAW,QAAS,CAAA,QAAA,CAAA;AAE1B,IAAA,IAAI,SAAiB,IAAK,CAAA,OAAA,CAAA;AAE1B,IAAA,IAAI,CAAC,MACL,EAAA;AACI,MAAA,MAAA,GAAS,IAAK,CAAA,OAAA,CAAA;AAEd,MAAA,MAAM,UAAU,IAAK,CAAA,OAAA,CAAA;AACrB,MAAA,MAAM,SAAS,OAAQ,CAAA,MAAA,CAAA;AAEvB,MAAA,MAAA,CAAO,UAAU,QAAW,GAAA,MAAA,CAAA;AAC5B,MAAO,MAAA,CAAA,SAAA,CAAU,WAAW,MAAO,CAAA,KAAA,CAAA;AACnC,MAAA,MAAA,CAAO,SAAU,CAAA,eAAA,CAAgB,QAAS,CAAA,cAAA,GAAiB,QAAQ,aAAc,CAAA,QAAA,CAAA;AAAA,KACrF,MAAA,IACS,CAAC,MAAA,CAAO,SACjB,EAAA;AAEI,MAAK,IAAA,CAAA,8BAAA,EAAgC,KAAK,MAAM,CAAA,CAAA;AAGhD,MAAA,OAAA;AAAA,KACJ;AAIA,IAAA,MAAA,CAAO,MAAO,CAAA,GAAG,CAAI,GAAA,QAAA,CAAS,cAAe,CAAA,SAAA,CAAA;AAC7C,IAAO,MAAA,CAAA,MAAA,CAAO,GAAG,CAAA,GAAI,QAAS,CAAA,sBAAA,CAAA;AAE9B,IAAA,QAAA,CAAS,QAAQ,IAAK,CAAA;AAAA,MAClB,UAAU,IAAK,CAAA,SAAA;AAAA,MACf,MAAA;AAAA,MACA,OAAO,IAAK,CAAA,KAAA;AAAA,KACf,CAAA,CAAA;AAAA,GACL;AAAA,EAEO,OACP,GAAA;AACI,IAAK,IAAA,CAAA,OAAA,CAAQ,QAAQ,IAAI,CAAA,CAAA;AACzB,IAAA,IAAA,CAAK,OAAU,GAAA,IAAA,CAAA;AAAA,GACnB;AACJ,CAAA;AA5Ea,aAAA,CAEK,SAAY,GAAA;AAAA,EACtB,IAAM,EAAA;AAAA,IACF,aAAc,CAAA,iBAAA;AAAA,GAClB;AAAA,EACA,IAAM,EAAA,MAAA;AACV,CAAA;;;;"}

View File

@@ -0,0 +1,19 @@
import { ExtensionType } from '../../../extensions/Extensions';
import type { Mesh } from '../shared/Mesh';
import type { MeshAdaptor, MeshPipe } from '../shared/MeshPipe';
/**
* The WebGL adaptor for the mesh system. Allows the Mesh System to be used with the WebGl renderer
* @memberof rendering
* @ignore
*/
export declare class GpuMeshAdapter implements MeshAdaptor {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGPUPipesAdaptor];
readonly name: "mesh";
};
private _shader;
init(): void;
execute(meshPipe: MeshPipe, mesh: Mesh): void;
destroy(): void;
}

View File

@@ -0,0 +1,73 @@
'use strict';
var Extensions = require('../../../extensions/Extensions.js');
var Matrix = require('../../../maths/matrix/Matrix.js');
var compileHighShaderToProgram = require('../../../rendering/high-shader/compileHighShaderToProgram.js');
var localUniformBit = require('../../../rendering/high-shader/shader-bits/localUniformBit.js');
var roundPixelsBit = require('../../../rendering/high-shader/shader-bits/roundPixelsBit.js');
var textureBit = require('../../../rendering/high-shader/shader-bits/textureBit.js');
var Shader = require('../../../rendering/renderers/shared/shader/Shader.js');
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
var warn = require('../../../utils/logging/warn.js');
"use strict";
class GpuMeshAdapter {
init() {
const gpuProgram = compileHighShaderToProgram.compileHighShaderGpuProgram({
name: "mesh",
bits: [
localUniformBit.localUniformBit,
textureBit.textureBit,
roundPixelsBit.roundPixelsBit
]
});
this._shader = new Shader.Shader({
gpuProgram,
resources: {
uTexture: Texture.Texture.EMPTY._source,
uSampler: Texture.Texture.EMPTY._source.style,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix.Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
} else if (!shader.gpuProgram) {
warn.warn("Mesh shader has no gpuProgram", mesh.shader);
return;
}
const gpuProgram = shader.gpuProgram;
if (gpuProgram.autoAssignGlobalUniforms) {
shader.groups[0] = renderer.globalUniforms.bindGroup;
}
if (gpuProgram.autoAssignLocalUniforms) {
const localUniforms = meshPipe.localUniforms;
shader.groups[1] = renderer.renderPipes.uniformBatch.getUniformBindGroup(localUniforms, true);
}
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
/** @ignore */
GpuMeshAdapter.extension = {
type: [
Extensions.ExtensionType.WebGPUPipesAdaptor
],
name: "mesh"
};
exports.GpuMeshAdapter = GpuMeshAdapter;
//# sourceMappingURL=GpuMeshAdapter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,71 @@
import { ExtensionType } from '../../../extensions/Extensions.mjs';
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { compileHighShaderGpuProgram } from '../../../rendering/high-shader/compileHighShaderToProgram.mjs';
import { localUniformBit } from '../../../rendering/high-shader/shader-bits/localUniformBit.mjs';
import { roundPixelsBit } from '../../../rendering/high-shader/shader-bits/roundPixelsBit.mjs';
import { textureBit } from '../../../rendering/high-shader/shader-bits/textureBit.mjs';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader.mjs';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
import { warn } from '../../../utils/logging/warn.mjs';
"use strict";
class GpuMeshAdapter {
init() {
const gpuProgram = compileHighShaderGpuProgram({
name: "mesh",
bits: [
localUniformBit,
textureBit,
roundPixelsBit
]
});
this._shader = new Shader({
gpuProgram,
resources: {
uTexture: Texture.EMPTY._source,
uSampler: Texture.EMPTY._source.style,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
} else if (!shader.gpuProgram) {
warn("Mesh shader has no gpuProgram", mesh.shader);
return;
}
const gpuProgram = shader.gpuProgram;
if (gpuProgram.autoAssignGlobalUniforms) {
shader.groups[0] = renderer.globalUniforms.bindGroup;
}
if (gpuProgram.autoAssignLocalUniforms) {
const localUniforms = meshPipe.localUniforms;
shader.groups[1] = renderer.renderPipes.uniformBatch.getUniformBindGroup(localUniforms, true);
}
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
/** @ignore */
GpuMeshAdapter.extension = {
type: [
ExtensionType.WebGPUPipesAdaptor
],
name: "mesh"
};
export { GpuMeshAdapter };
//# sourceMappingURL=GpuMeshAdapter.mjs.map

File diff suppressed because one or more lines are too long

1
node_modules/pixi.js/lib/scene/mesh/init.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

8
node_modules/pixi.js/lib/scene/mesh/init.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
'use strict';
var Extensions = require('../../extensions/Extensions.js');
var MeshPipe = require('./shared/MeshPipe.js');
"use strict";
Extensions.extensions.add(MeshPipe.MeshPipe);
//# sourceMappingURL=init.js.map

1
node_modules/pixi.js/lib/scene/mesh/init.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"init.js","sources":["../../../src/scene/mesh/init.ts"],"sourcesContent":["import { extensions } from '../../extensions/Extensions';\nimport { MeshPipe } from './shared/MeshPipe';\n\nextensions.add(MeshPipe);\n"],"names":["extensions","MeshPipe"],"mappings":";;;;;;AAGAA,qBAAA,CAAW,IAAIC,iBAAQ,CAAA;;"}

6
node_modules/pixi.js/lib/scene/mesh/init.mjs generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { extensions } from '../../extensions/Extensions.mjs';
import { MeshPipe } from './shared/MeshPipe.mjs';
"use strict";
extensions.add(MeshPipe);
//# sourceMappingURL=init.mjs.map

1
node_modules/pixi.js/lib/scene/mesh/init.mjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"init.mjs","sources":["../../../src/scene/mesh/init.ts"],"sourcesContent":["import { extensions } from '../../extensions/Extensions';\nimport { MeshPipe } from './shared/MeshPipe';\n\nextensions.add(MeshPipe);\n"],"names":[],"mappings":";;;;AAGA,UAAA,CAAW,IAAI,QAAQ,CAAA"}

View File

@@ -0,0 +1,39 @@
import type { Matrix } from '../../../maths/matrix/Matrix';
import type { Batch, Batcher } from '../../../rendering/batcher/shared/Batcher';
import type { DefaultBatchableMeshElement } from '../../../rendering/batcher/shared/DefaultBatcher';
import type { Texture } from '../../../rendering/renderers/shared/texture/Texture';
import type { ViewContainer } from '../../view/View';
import type { MeshGeometry } from './MeshGeometry';
/**
* A batchable mesh object.
* @ignore
*/
export declare class BatchableMesh implements DefaultBatchableMeshElement {
batcherName: string;
readonly packAsQuad = false;
location: number;
renderable: ViewContainer;
indexOffset: number;
attributeOffset: number;
texture: Texture;
geometry: MeshGeometry;
transform: Matrix;
roundPixels: 0 | 1;
_attributeStart: number;
_batcher: Batcher;
_batch: Batch;
_indexStart: number;
_textureId: number;
private _transformedUvs;
private _uvUpdateId;
private _textureMatrixUpdateId;
get blendMode(): import("../../..").BLEND_MODES;
reset(): void;
get uvs(): Float32Array;
get positions(): Float32Array;
get indices(): Uint32Array;
get color(): number;
get groupTransform(): Matrix;
get attributeSize(): number;
get indexSize(): number;
}

View File

@@ -0,0 +1,68 @@
'use strict';
"use strict";
class BatchableMesh {
constructor() {
this.batcherName = "default";
this.packAsQuad = false;
this.indexOffset = 0;
this.attributeOffset = 0;
this.roundPixels = 0;
this._batcher = null;
this._batch = null;
this._uvUpdateId = -1;
this._textureMatrixUpdateId = -1;
}
get blendMode() {
return this.renderable.groupBlendMode;
}
reset() {
this.renderable = null;
this.texture = null;
this._batcher = null;
this._batch = null;
this.geometry = null;
this._uvUpdateId = -1;
this._textureMatrixUpdateId = -1;
}
get uvs() {
const geometry = this.geometry;
const uvBuffer = geometry.getBuffer("aUV");
const uvs = uvBuffer.data;
let transformedUvs = uvs;
const textureMatrix = this.texture.textureMatrix;
if (!textureMatrix.isSimple) {
transformedUvs = this._transformedUvs;
if (this._textureMatrixUpdateId !== textureMatrix._updateID || this._uvUpdateId !== uvBuffer._updateID) {
if (!transformedUvs || transformedUvs.length < uvs.length) {
transformedUvs = this._transformedUvs = new Float32Array(uvs.length);
}
this._textureMatrixUpdateId = textureMatrix._updateID;
this._uvUpdateId = uvBuffer._updateID;
textureMatrix.multiplyUvs(uvs, transformedUvs);
}
}
return transformedUvs;
}
get positions() {
return this.geometry.positions;
}
get indices() {
return this.geometry.indices;
}
get color() {
return this.renderable.groupColorAlpha;
}
get groupTransform() {
return this.renderable.groupTransform;
}
get attributeSize() {
return this.geometry.positions.length / 2;
}
get indexSize() {
return this.geometry.indices.length;
}
}
exports.BatchableMesh = BatchableMesh;
//# sourceMappingURL=BatchableMesh.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,66 @@
"use strict";
class BatchableMesh {
constructor() {
this.batcherName = "default";
this.packAsQuad = false;
this.indexOffset = 0;
this.attributeOffset = 0;
this.roundPixels = 0;
this._batcher = null;
this._batch = null;
this._uvUpdateId = -1;
this._textureMatrixUpdateId = -1;
}
get blendMode() {
return this.renderable.groupBlendMode;
}
reset() {
this.renderable = null;
this.texture = null;
this._batcher = null;
this._batch = null;
this.geometry = null;
this._uvUpdateId = -1;
this._textureMatrixUpdateId = -1;
}
get uvs() {
const geometry = this.geometry;
const uvBuffer = geometry.getBuffer("aUV");
const uvs = uvBuffer.data;
let transformedUvs = uvs;
const textureMatrix = this.texture.textureMatrix;
if (!textureMatrix.isSimple) {
transformedUvs = this._transformedUvs;
if (this._textureMatrixUpdateId !== textureMatrix._updateID || this._uvUpdateId !== uvBuffer._updateID) {
if (!transformedUvs || transformedUvs.length < uvs.length) {
transformedUvs = this._transformedUvs = new Float32Array(uvs.length);
}
this._textureMatrixUpdateId = textureMatrix._updateID;
this._uvUpdateId = uvBuffer._updateID;
textureMatrix.multiplyUvs(uvs, transformedUvs);
}
}
return transformedUvs;
}
get positions() {
return this.geometry.positions;
}
get indices() {
return this.geometry.indices;
}
get color() {
return this.renderable.groupColorAlpha;
}
get groupTransform() {
return this.renderable.groupTransform;
}
get attributeSize() {
return this.geometry.positions.length / 2;
}
get indexSize() {
return this.geometry.indices.length;
}
}
export { BatchableMesh };
//# sourceMappingURL=BatchableMesh.mjs.map

File diff suppressed because one or more lines are too long

126
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.d.ts generated vendored Normal file
View File

@@ -0,0 +1,126 @@
import { Geometry } from '../../../rendering/renderers/shared/geometry/Geometry';
import { State } from '../../../rendering/renderers/shared/state/State';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture';
import { ViewContainer } from '../../view/View';
import { MeshGeometry } from './MeshGeometry';
import type { PointData } from '../../../maths/point/PointData';
import type { Topology } from '../../../rendering/renderers/shared/geometry/const';
import type { Instruction } from '../../../rendering/renderers/shared/instructions/Instruction';
import type { Shader } from '../../../rendering/renderers/shared/shader/Shader';
import type { View } from '../../../rendering/renderers/shared/view/View';
import type { Bounds } from '../../container/bounds/Bounds';
import type { ContainerOptions } from '../../container/Container';
import type { DestroyOptions } from '../../container/destroyTypes';
export interface TextureShader extends Shader {
texture: Texture;
}
/**
* Constructor options used for `Mesh` instances. Extends {@link scene.MeshViewOptions}
* ```js
* const mesh = new Mesh({
* texture: Texture.from('assets/image.png'),
* geometry: new PlaneGeometry(),
* shader: Shader.from(VERTEX, FRAGMENT),
* });
* ```
* @see {@link scene.Mesh}
* @see {@link scene.MeshViewOptions}
* @memberof scene
*/
/**
* @memberof scene
*/
export interface MeshOptions<GEOMETRY extends Geometry = MeshGeometry, SHADER extends Shader = TextureShader> extends ContainerOptions {
/**
* Includes vertex positions, face indices, colors, UVs, and
* custom attributes within buffers, reducing the cost of passing all
* this data to the GPU. Can be shared between multiple Mesh objects.
*/
geometry: GEOMETRY;
/**
* Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.
* Can be shared between multiple Mesh objects.
*/
shader?: SHADER | null;
/** The state of WebGL required to render the mesh. */
state?: State;
/** The texture that the Mesh uses. Null for non-MeshMaterial shaders */
texture?: Texture;
/** Whether or not to round the x/y position. */
roundPixels?: boolean;
}
/**
* Base mesh class.
*
* This class empowers you to have maximum flexibility to render any kind of WebGL/WebGPU visuals you can think of.
* This class assumes a certain level of WebGL/WebGPU knowledge.
* If you know a bit this should abstract enough away to make your life easier!
*
* Pretty much ALL WebGL/WebGPU can be broken down into the following:
* - Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc..
* - Shader - This is the shader that PixiJS will render the geometry with (attributes in the shader must match the geometry)
* - State - This is the state of WebGL required to render the mesh.
*
* Through a combination of the above elements you can render anything you want, 2D or 3D!
* @memberof scene
*/
export declare class Mesh<GEOMETRY extends Geometry = MeshGeometry, SHADER extends Shader = TextureShader> extends ViewContainer implements View, Instruction {
readonly renderPipeId: string;
state: State;
/** @ignore */
_texture: Texture;
/** @ignore */
_geometry: GEOMETRY;
/** @ignore */
_shader: SHADER | null;
/**
* @param {scene.MeshOptions} options - options for the mesh instance
*/
constructor(options: MeshOptions<GEOMETRY, SHADER>);
/** @deprecated since 8.0.0 */
constructor(geometry: GEOMETRY, shader: SHADER, state?: State, drawMode?: Topology);
/** Alias for {@link scene.Mesh#shader}. */
get material(): SHADER;
/**
* Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.
* Can be shared between multiple Mesh objects.
*/
set shader(value: SHADER | null);
get shader(): SHADER | null;
/**
* Includes vertex positions, face indices, colors, UVs, and
* custom attributes within buffers, reducing the cost of passing all
* this data to the GPU. Can be shared between multiple Mesh objects.
*/
set geometry(value: GEOMETRY);
get geometry(): GEOMETRY;
/** The texture that the Mesh uses. Null for non-MeshMaterial shaders */
set texture(value: Texture);
get texture(): Texture;
get batched(): boolean;
/**
* The local bounds of the mesh.
* @type {rendering.Bounds}
*/
get bounds(): Bounds;
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds: Bounds): void;
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point: PointData): boolean;
/** @ignore */
onViewUpdate(): void;
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options?: DestroyOptions): void;
}

207
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.js generated vendored Normal file
View File

@@ -0,0 +1,207 @@
'use strict';
var pointInTriangle = require('../../../maths/point/pointInTriangle.js');
var Geometry = require('../../../rendering/renderers/shared/geometry/Geometry.js');
var State = require('../../../rendering/renderers/shared/state/State.js');
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
var deprecation = require('../../../utils/logging/deprecation.js');
var View = require('../../view/View.js');
var MeshGeometry = require('./MeshGeometry.js');
"use strict";
class Mesh extends View.ViewContainer {
constructor(...args) {
let options = args[0];
if (options instanceof Geometry.Geometry) {
deprecation.deprecation(deprecation.v8_0_0, "Mesh: use new Mesh({ geometry, shader }) instead");
options = {
geometry: options,
shader: args[1]
};
if (args[3]) {
deprecation.deprecation(deprecation.v8_0_0, "Mesh: drawMode argument has been removed, use geometry.topology instead");
options.geometry.topology = args[3];
}
}
const { geometry, shader, texture, roundPixels, state, ...rest } = options;
super({
label: "Mesh",
...rest
});
this.renderPipeId = "mesh";
/** @ignore */
this._shader = null;
this.allowChildren = false;
this.shader = shader ?? null;
this.texture = texture ?? shader?.texture ?? Texture.Texture.WHITE;
this.state = state ?? State.State.for2d();
this._geometry = geometry;
this._geometry.on("update", this.onViewUpdate, this);
this.roundPixels = roundPixels ?? false;
}
/** Alias for {@link scene.Mesh#shader}. */
get material() {
deprecation.deprecation(deprecation.v8_0_0, "mesh.material property has been removed, use mesh.shader instead");
return this._shader;
}
/**
* Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.
* Can be shared between multiple Mesh objects.
*/
set shader(value) {
if (this._shader === value)
return;
this._shader = value;
this.onViewUpdate();
}
get shader() {
return this._shader;
}
/**
* Includes vertex positions, face indices, colors, UVs, and
* custom attributes within buffers, reducing the cost of passing all
* this data to the GPU. Can be shared between multiple Mesh objects.
*/
set geometry(value) {
if (this._geometry === value)
return;
this._geometry?.off("update", this.onViewUpdate, this);
value.on("update", this.onViewUpdate, this);
this._geometry = value;
this.onViewUpdate();
}
get geometry() {
return this._geometry;
}
/** The texture that the Mesh uses. Null for non-MeshMaterial shaders */
set texture(value) {
value || (value = Texture.Texture.EMPTY);
const currentTexture = this._texture;
if (currentTexture === value)
return;
if (currentTexture && currentTexture.dynamic)
currentTexture.off("update", this.onViewUpdate, this);
if (value.dynamic)
value.on("update", this.onViewUpdate, this);
if (this.shader) {
this.shader.texture = value;
}
this._texture = value;
this.onViewUpdate();
}
get texture() {
return this._texture;
}
get batched() {
if (this._shader)
return false;
if ((this.state.data & 12) !== 0)
return false;
if (this._geometry instanceof MeshGeometry.MeshGeometry) {
if (this._geometry.batchMode === "auto") {
return this._geometry.positions.length / 2 <= 100;
}
return this._geometry.batchMode === "batch";
}
return false;
}
/**
* The local bounds of the mesh.
* @type {rendering.Bounds}
*/
get bounds() {
return this._geometry.bounds;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
bounds.addBounds(this.geometry.bounds);
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const { x, y } = point;
if (!this.bounds.containsPoint(x, y))
return false;
const vertices = this.geometry.getBuffer("aPosition").data;
const step = this.geometry.topology === "triangle-strip" ? 3 : 1;
if (this.geometry.getIndex()) {
const indices = this.geometry.getIndex().data;
const len = indices.length;
for (let i = 0; i + 2 < len; i += step) {
const ind0 = indices[i] * 2;
const ind1 = indices[i + 1] * 2;
const ind2 = indices[i + 2] * 2;
if (pointInTriangle.pointInTriangle(
x,
y,
vertices[ind0],
vertices[ind0 + 1],
vertices[ind1],
vertices[ind1 + 1],
vertices[ind2],
vertices[ind2 + 1]
)) {
return true;
}
}
} else {
const len = vertices.length / 2;
for (let i = 0; i + 2 < len; i += step) {
const ind0 = i * 2;
const ind1 = (i + 1) * 2;
const ind2 = (i + 2) * 2;
if (pointInTriangle.pointInTriangle(
x,
y,
vertices[ind0],
vertices[ind0 + 1],
vertices[ind1],
vertices[ind1 + 1],
vertices[ind2],
vertices[ind2 + 1]
)) {
return true;
}
}
}
return false;
}
/** @ignore */
onViewUpdate() {
this._didViewChangeTick++;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options) {
super.destroy(options);
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
if (destroyTexture) {
const destroyTextureSource = typeof options === "boolean" ? options : options?.textureSource;
this._texture.destroy(destroyTextureSource);
}
this._geometry?.off("update", this.onViewUpdate, this);
this._texture = null;
this._geometry = null;
this._shader = null;
}
}
exports.Mesh = Mesh;
//# sourceMappingURL=Mesh.js.map

File diff suppressed because one or more lines are too long

205
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.mjs generated vendored Normal file
View File

@@ -0,0 +1,205 @@
import { pointInTriangle } from '../../../maths/point/pointInTriangle.mjs';
import { Geometry } from '../../../rendering/renderers/shared/geometry/Geometry.mjs';
import { State } from '../../../rendering/renderers/shared/state/State.mjs';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
import { deprecation, v8_0_0 } from '../../../utils/logging/deprecation.mjs';
import { ViewContainer } from '../../view/View.mjs';
import { MeshGeometry } from './MeshGeometry.mjs';
"use strict";
class Mesh extends ViewContainer {
constructor(...args) {
let options = args[0];
if (options instanceof Geometry) {
deprecation(v8_0_0, "Mesh: use new Mesh({ geometry, shader }) instead");
options = {
geometry: options,
shader: args[1]
};
if (args[3]) {
deprecation(v8_0_0, "Mesh: drawMode argument has been removed, use geometry.topology instead");
options.geometry.topology = args[3];
}
}
const { geometry, shader, texture, roundPixels, state, ...rest } = options;
super({
label: "Mesh",
...rest
});
this.renderPipeId = "mesh";
/** @ignore */
this._shader = null;
this.allowChildren = false;
this.shader = shader ?? null;
this.texture = texture ?? shader?.texture ?? Texture.WHITE;
this.state = state ?? State.for2d();
this._geometry = geometry;
this._geometry.on("update", this.onViewUpdate, this);
this.roundPixels = roundPixels ?? false;
}
/** Alias for {@link scene.Mesh#shader}. */
get material() {
deprecation(v8_0_0, "mesh.material property has been removed, use mesh.shader instead");
return this._shader;
}
/**
* Represents the vertex and fragment shaders that processes the geometry and runs on the GPU.
* Can be shared between multiple Mesh objects.
*/
set shader(value) {
if (this._shader === value)
return;
this._shader = value;
this.onViewUpdate();
}
get shader() {
return this._shader;
}
/**
* Includes vertex positions, face indices, colors, UVs, and
* custom attributes within buffers, reducing the cost of passing all
* this data to the GPU. Can be shared between multiple Mesh objects.
*/
set geometry(value) {
if (this._geometry === value)
return;
this._geometry?.off("update", this.onViewUpdate, this);
value.on("update", this.onViewUpdate, this);
this._geometry = value;
this.onViewUpdate();
}
get geometry() {
return this._geometry;
}
/** The texture that the Mesh uses. Null for non-MeshMaterial shaders */
set texture(value) {
value || (value = Texture.EMPTY);
const currentTexture = this._texture;
if (currentTexture === value)
return;
if (currentTexture && currentTexture.dynamic)
currentTexture.off("update", this.onViewUpdate, this);
if (value.dynamic)
value.on("update", this.onViewUpdate, this);
if (this.shader) {
this.shader.texture = value;
}
this._texture = value;
this.onViewUpdate();
}
get texture() {
return this._texture;
}
get batched() {
if (this._shader)
return false;
if ((this.state.data & 12) !== 0)
return false;
if (this._geometry instanceof MeshGeometry) {
if (this._geometry.batchMode === "auto") {
return this._geometry.positions.length / 2 <= 100;
}
return this._geometry.batchMode === "batch";
}
return false;
}
/**
* The local bounds of the mesh.
* @type {rendering.Bounds}
*/
get bounds() {
return this._geometry.bounds;
}
/**
* Adds the bounds of this object to the bounds object.
* @param bounds - The output bounds object.
*/
addBounds(bounds) {
bounds.addBounds(this.geometry.bounds);
}
/**
* Checks if the object contains the given point.
* @param point - The point to check
*/
containsPoint(point) {
const { x, y } = point;
if (!this.bounds.containsPoint(x, y))
return false;
const vertices = this.geometry.getBuffer("aPosition").data;
const step = this.geometry.topology === "triangle-strip" ? 3 : 1;
if (this.geometry.getIndex()) {
const indices = this.geometry.getIndex().data;
const len = indices.length;
for (let i = 0; i + 2 < len; i += step) {
const ind0 = indices[i] * 2;
const ind1 = indices[i + 1] * 2;
const ind2 = indices[i + 2] * 2;
if (pointInTriangle(
x,
y,
vertices[ind0],
vertices[ind0 + 1],
vertices[ind1],
vertices[ind1 + 1],
vertices[ind2],
vertices[ind2 + 1]
)) {
return true;
}
}
} else {
const len = vertices.length / 2;
for (let i = 0; i + 2 < len; i += step) {
const ind0 = i * 2;
const ind1 = (i + 1) * 2;
const ind2 = (i + 2) * 2;
if (pointInTriangle(
x,
y,
vertices[ind0],
vertices[ind0 + 1],
vertices[ind1],
vertices[ind1 + 1],
vertices[ind2],
vertices[ind2 + 1]
)) {
return true;
}
}
}
return false;
}
/** @ignore */
onViewUpdate() {
this._didViewChangeTick++;
if (this.didViewUpdate)
return;
this.didViewUpdate = true;
const renderGroup = this.renderGroup || this.parentRenderGroup;
if (renderGroup) {
renderGroup.onChildViewUpdate(this);
}
}
/**
* Destroys this sprite renderable and optionally its texture.
* @param options - Options parameter. A boolean will act as if all options
* have been set to that value
* @param {boolean} [options.texture=false] - Should it destroy the current texture of the renderable as well
* @param {boolean} [options.textureSource=false] - Should it destroy the textureSource of the renderable as well
*/
destroy(options) {
super.destroy(options);
const destroyTexture = typeof options === "boolean" ? options : options?.texture;
if (destroyTexture) {
const destroyTextureSource = typeof options === "boolean" ? options : options?.textureSource;
this._texture.destroy(destroyTextureSource);
}
this._geometry?.off("update", this.onViewUpdate, this);
this._texture = null;
this._geometry = null;
this._shader = null;
}
}
export { Mesh };
//# sourceMappingURL=Mesh.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,42 @@
import { Geometry } from '../../../rendering/renderers/shared/geometry/Geometry';
import type { Topology } from '../../../rendering/renderers/shared/geometry/const';
import type { BatchMode } from '../../graphics/shared/GraphicsContext';
/**
* Options for the mesh geometry.
* @memberof scene
*/
export interface MeshGeometryOptions {
/** The positions of the mesh. */
positions?: Float32Array;
/** The UVs of the mesh. */
uvs?: Float32Array;
/** The indices of the mesh. */
indices?: Uint32Array;
/** The topology of the mesh. */
topology?: Topology;
/** Whether to shrink the buffers to fit the data. */
shrinkBuffersToFit?: boolean;
}
/**
* A geometry used to batch multiple meshes with the same texture.
* @memberof scene
*/
export declare class MeshGeometry extends Geometry {
static defaultOptions: MeshGeometryOptions;
batchMode: BatchMode;
/**
* @param {scene.MeshGeometryOptions} options - The options of the mesh geometry.
*/
constructor(options: MeshGeometryOptions);
/** @deprecated since 8.0.0 */
constructor(positions: Float32Array, uvs: Float32Array, indices: Uint32Array);
/** The positions of the mesh. */
get positions(): Float32Array;
set positions(value: Float32Array);
/** The UVs of the mesh. */
get uvs(): Float32Array;
set uvs(value: Float32Array);
/** The indices of the mesh. */
get indices(): Uint32Array;
set indices(value: Uint32Array);
}

View File

@@ -0,0 +1,92 @@
'use strict';
var Buffer = require('../../../rendering/renderers/shared/buffer/Buffer.js');
var _const = require('../../../rendering/renderers/shared/buffer/const.js');
var Geometry = require('../../../rendering/renderers/shared/geometry/Geometry.js');
var deprecation = require('../../../utils/logging/deprecation.js');
"use strict";
const _MeshGeometry = class _MeshGeometry extends Geometry.Geometry {
constructor(...args) {
let options = args[0] ?? {};
if (options instanceof Float32Array) {
deprecation.deprecation(deprecation.v8_0_0, "use new MeshGeometry({ positions, uvs, indices }) instead");
options = {
positions: options,
uvs: args[1],
indices: args[2]
};
}
options = { ..._MeshGeometry.defaultOptions, ...options };
const positions = options.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
const uvs = options.uvs || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
const indices = options.indices || new Uint32Array([0, 1, 2, 0, 2, 3]);
const shrinkToFit = options.shrinkBuffersToFit;
const positionBuffer = new Buffer.Buffer({
data: positions,
label: "attribute-mesh-positions",
shrinkToFit,
usage: _const.BufferUsage.VERTEX | _const.BufferUsage.COPY_DST
});
const uvBuffer = new Buffer.Buffer({
data: uvs,
label: "attribute-mesh-uvs",
shrinkToFit,
usage: _const.BufferUsage.VERTEX | _const.BufferUsage.COPY_DST
});
const indexBuffer = new Buffer.Buffer({
data: indices,
label: "index-mesh-buffer",
shrinkToFit,
usage: _const.BufferUsage.INDEX | _const.BufferUsage.COPY_DST
});
super({
attributes: {
aPosition: {
buffer: positionBuffer,
format: "float32x2",
stride: 2 * 4,
offset: 0
},
aUV: {
buffer: uvBuffer,
format: "float32x2",
stride: 2 * 4,
offset: 0
}
},
indexBuffer,
topology: options.topology
});
this.batchMode = "auto";
}
/** The positions of the mesh. */
get positions() {
return this.attributes.aPosition.buffer.data;
}
set positions(value) {
this.attributes.aPosition.buffer.data = value;
}
/** The UVs of the mesh. */
get uvs() {
return this.attributes.aUV.buffer.data;
}
set uvs(value) {
this.attributes.aUV.buffer.data = value;
}
/** The indices of the mesh. */
get indices() {
return this.indexBuffer.data;
}
set indices(value) {
this.indexBuffer.data = value;
}
};
_MeshGeometry.defaultOptions = {
topology: "triangle-list",
shrinkBuffersToFit: false
};
let MeshGeometry = _MeshGeometry;
exports.MeshGeometry = MeshGeometry;
//# sourceMappingURL=MeshGeometry.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
import { Buffer } from '../../../rendering/renderers/shared/buffer/Buffer.mjs';
import { BufferUsage } from '../../../rendering/renderers/shared/buffer/const.mjs';
import { Geometry } from '../../../rendering/renderers/shared/geometry/Geometry.mjs';
import { deprecation, v8_0_0 } from '../../../utils/logging/deprecation.mjs';
"use strict";
const _MeshGeometry = class _MeshGeometry extends Geometry {
constructor(...args) {
let options = args[0] ?? {};
if (options instanceof Float32Array) {
deprecation(v8_0_0, "use new MeshGeometry({ positions, uvs, indices }) instead");
options = {
positions: options,
uvs: args[1],
indices: args[2]
};
}
options = { ..._MeshGeometry.defaultOptions, ...options };
const positions = options.positions || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
const uvs = options.uvs || new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
const indices = options.indices || new Uint32Array([0, 1, 2, 0, 2, 3]);
const shrinkToFit = options.shrinkBuffersToFit;
const positionBuffer = new Buffer({
data: positions,
label: "attribute-mesh-positions",
shrinkToFit,
usage: BufferUsage.VERTEX | BufferUsage.COPY_DST
});
const uvBuffer = new Buffer({
data: uvs,
label: "attribute-mesh-uvs",
shrinkToFit,
usage: BufferUsage.VERTEX | BufferUsage.COPY_DST
});
const indexBuffer = new Buffer({
data: indices,
label: "index-mesh-buffer",
shrinkToFit,
usage: BufferUsage.INDEX | BufferUsage.COPY_DST
});
super({
attributes: {
aPosition: {
buffer: positionBuffer,
format: "float32x2",
stride: 2 * 4,
offset: 0
},
aUV: {
buffer: uvBuffer,
format: "float32x2",
stride: 2 * 4,
offset: 0
}
},
indexBuffer,
topology: options.topology
});
this.batchMode = "auto";
}
/** The positions of the mesh. */
get positions() {
return this.attributes.aPosition.buffer.data;
}
set positions(value) {
this.attributes.aPosition.buffer.data = value;
}
/** The UVs of the mesh. */
get uvs() {
return this.attributes.aUV.buffer.data;
}
set uvs(value) {
this.attributes.aUV.buffer.data = value;
}
/** The indices of the mesh. */
get indices() {
return this.indexBuffer.data;
}
set indices(value) {
this.indexBuffer.data = value;
}
};
_MeshGeometry.defaultOptions = {
topology: "triangle-list",
shrinkBuffersToFit: false
};
let MeshGeometry = _MeshGeometry;
export { MeshGeometry };
//# sourceMappingURL=MeshGeometry.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,51 @@
import { ExtensionType } from '../../../extensions/Extensions';
import { Matrix } from '../../../maths/matrix/Matrix';
import { BindGroup } from '../../../rendering/renderers/gpu/shader/BindGroup';
import { UniformGroup } from '../../../rendering/renderers/shared/shader/UniformGroup';
import type { InstructionSet } from '../../../rendering/renderers/shared/instructions/InstructionSet';
import type { InstructionPipe, RenderPipe } from '../../../rendering/renderers/shared/instructions/RenderPipe';
import type { Renderer } from '../../../rendering/renderers/types';
import type { Mesh } from './Mesh';
export interface MeshAdaptor {
init(): void;
execute(meshPipe: MeshPipe, mesh: Mesh): void;
destroy(): void;
}
export declare class MeshPipe implements RenderPipe<Mesh>, InstructionPipe<Mesh> {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGLPipes, ExtensionType.WebGPUPipes, ExtensionType.CanvasPipes];
readonly name: "mesh";
};
localUniforms: UniformGroup<{
uTransformMatrix: {
value: Matrix;
type: "mat3x3<f32>";
};
uColor: {
value: Float32Array;
type: "vec4<f32>";
};
uRound: {
value: number;
type: "f32";
};
}>;
localUniformsBindGroup: BindGroup;
renderer: Renderer;
private _meshDataHash;
private _gpuBatchableMeshHash;
private _adaptor;
private readonly _destroyRenderableBound;
constructor(renderer: Renderer, adaptor: MeshAdaptor);
validateRenderable(mesh: Mesh): boolean;
addRenderable(mesh: Mesh, instructionSet: InstructionSet): void;
updateRenderable(mesh: Mesh): void;
destroyRenderable(mesh: Mesh): void;
execute(mesh: Mesh): void;
private _getMeshData;
private _initMeshData;
private _getBatchableMesh;
private _initBatchableMesh;
destroy(): void;
}

149
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.js generated vendored Normal file
View File

@@ -0,0 +1,149 @@
'use strict';
var Extensions = require('../../../extensions/Extensions.js');
var Matrix = require('../../../maths/matrix/Matrix.js');
var BindGroup = require('../../../rendering/renderers/gpu/shader/BindGroup.js');
var UniformGroup = require('../../../rendering/renderers/shared/shader/UniformGroup.js');
var getAdjustedBlendModeBlend = require('../../../rendering/renderers/shared/state/getAdjustedBlendModeBlend.js');
var PoolGroup = require('../../../utils/pool/PoolGroup.js');
var colorToUniform = require('../../graphics/gpu/colorToUniform.js');
var BatchableMesh = require('./BatchableMesh.js');
"use strict";
class MeshPipe {
constructor(renderer, adaptor) {
this.localUniforms = new UniformGroup.UniformGroup({
uTransformMatrix: { value: new Matrix.Matrix(), type: "mat3x3<f32>" },
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uRound: { value: 0, type: "f32" }
});
this.localUniformsBindGroup = new BindGroup.BindGroup({
0: this.localUniforms
});
this._meshDataHash = /* @__PURE__ */ Object.create(null);
this._gpuBatchableMeshHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this.renderer = renderer;
this._adaptor = adaptor;
this._adaptor.init();
}
validateRenderable(mesh) {
const meshData = this._getMeshData(mesh);
const wasBatched = meshData.batched;
const isBatched = mesh.batched;
meshData.batched = isBatched;
if (wasBatched !== isBatched) {
return true;
} else if (isBatched) {
const geometry = mesh._geometry;
if (geometry.indices.length !== meshData.indexSize || geometry.positions.length !== meshData.vertexSize) {
meshData.indexSize = geometry.indices.length;
meshData.vertexSize = geometry.positions.length;
return true;
}
const batchableMesh = this._getBatchableMesh(mesh);
const texture = mesh.texture;
if (batchableMesh.texture._source !== texture._source) {
if (batchableMesh.texture._source !== texture._source) {
return !batchableMesh._batcher.checkAndUpdateTexture(batchableMesh, texture);
}
}
}
return false;
}
addRenderable(mesh, instructionSet) {
const batcher = this.renderer.renderPipes.batch;
const { batched } = this._getMeshData(mesh);
if (batched) {
const gpuBatchableMesh = this._getBatchableMesh(mesh);
gpuBatchableMesh.texture = mesh._texture;
gpuBatchableMesh.geometry = mesh._geometry;
batcher.addToBatch(gpuBatchableMesh, instructionSet);
} else {
batcher.break(instructionSet);
instructionSet.add(mesh);
}
}
updateRenderable(mesh) {
if (mesh.batched) {
const gpuBatchableMesh = this._gpuBatchableMeshHash[mesh.uid];
gpuBatchableMesh.texture = mesh._texture;
gpuBatchableMesh.geometry = mesh._geometry;
gpuBatchableMesh._batcher.updateElement(gpuBatchableMesh);
}
}
destroyRenderable(mesh) {
this._meshDataHash[mesh.uid] = null;
const gpuMesh = this._gpuBatchableMeshHash[mesh.uid];
if (gpuMesh) {
PoolGroup.BigPool.return(gpuMesh);
this._gpuBatchableMeshHash[mesh.uid] = null;
}
mesh.off("destroyed", this._destroyRenderableBound);
}
execute(mesh) {
if (!mesh.isRenderable)
return;
mesh.state.blendMode = getAdjustedBlendModeBlend.getAdjustedBlendModeBlend(mesh.groupBlendMode, mesh.texture._source);
const localUniforms = this.localUniforms;
localUniforms.uniforms.uTransformMatrix = mesh.groupTransform;
localUniforms.uniforms.uRound = this.renderer._roundPixels | mesh._roundPixels;
localUniforms.update();
colorToUniform.color32BitToUniform(
mesh.groupColorAlpha,
localUniforms.uniforms.uColor,
0
);
this._adaptor.execute(this, mesh);
}
_getMeshData(mesh) {
return this._meshDataHash[mesh.uid] || this._initMeshData(mesh);
}
_initMeshData(mesh) {
this._meshDataHash[mesh.uid] = {
batched: mesh.batched,
indexSize: mesh._geometry.indices?.length,
vertexSize: mesh._geometry.positions?.length
};
mesh.on("destroyed", this._destroyRenderableBound);
return this._meshDataHash[mesh.uid];
}
_getBatchableMesh(mesh) {
return this._gpuBatchableMeshHash[mesh.uid] || this._initBatchableMesh(mesh);
}
_initBatchableMesh(mesh) {
const gpuMesh = PoolGroup.BigPool.get(BatchableMesh.BatchableMesh);
gpuMesh.renderable = mesh;
gpuMesh.texture = mesh._texture;
gpuMesh.transform = mesh.groupTransform;
gpuMesh.roundPixels = this.renderer._roundPixels | mesh._roundPixels;
this._gpuBatchableMeshHash[mesh.uid] = gpuMesh;
return gpuMesh;
}
destroy() {
for (const i in this._gpuBatchableMeshHash) {
if (this._gpuBatchableMeshHash[i]) {
PoolGroup.BigPool.return(this._gpuBatchableMeshHash[i]);
}
}
this._gpuBatchableMeshHash = null;
this._meshDataHash = null;
this.localUniforms = null;
this.localUniformsBindGroup = null;
this._adaptor.destroy();
this._adaptor = null;
this.renderer = null;
}
}
/** @ignore */
MeshPipe.extension = {
type: [
Extensions.ExtensionType.WebGLPipes,
Extensions.ExtensionType.WebGPUPipes,
Extensions.ExtensionType.CanvasPipes
],
name: "mesh"
};
exports.MeshPipe = MeshPipe;
//# sourceMappingURL=MeshPipe.js.map

File diff suppressed because one or more lines are too long

147
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.mjs generated vendored Normal file
View File

@@ -0,0 +1,147 @@
import { ExtensionType } from '../../../extensions/Extensions.mjs';
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { BindGroup } from '../../../rendering/renderers/gpu/shader/BindGroup.mjs';
import { UniformGroup } from '../../../rendering/renderers/shared/shader/UniformGroup.mjs';
import { getAdjustedBlendModeBlend } from '../../../rendering/renderers/shared/state/getAdjustedBlendModeBlend.mjs';
import { BigPool } from '../../../utils/pool/PoolGroup.mjs';
import { color32BitToUniform } from '../../graphics/gpu/colorToUniform.mjs';
import { BatchableMesh } from './BatchableMesh.mjs';
"use strict";
class MeshPipe {
constructor(renderer, adaptor) {
this.localUniforms = new UniformGroup({
uTransformMatrix: { value: new Matrix(), type: "mat3x3<f32>" },
uColor: { value: new Float32Array([1, 1, 1, 1]), type: "vec4<f32>" },
uRound: { value: 0, type: "f32" }
});
this.localUniformsBindGroup = new BindGroup({
0: this.localUniforms
});
this._meshDataHash = /* @__PURE__ */ Object.create(null);
this._gpuBatchableMeshHash = /* @__PURE__ */ Object.create(null);
this._destroyRenderableBound = this.destroyRenderable.bind(this);
this.renderer = renderer;
this._adaptor = adaptor;
this._adaptor.init();
}
validateRenderable(mesh) {
const meshData = this._getMeshData(mesh);
const wasBatched = meshData.batched;
const isBatched = mesh.batched;
meshData.batched = isBatched;
if (wasBatched !== isBatched) {
return true;
} else if (isBatched) {
const geometry = mesh._geometry;
if (geometry.indices.length !== meshData.indexSize || geometry.positions.length !== meshData.vertexSize) {
meshData.indexSize = geometry.indices.length;
meshData.vertexSize = geometry.positions.length;
return true;
}
const batchableMesh = this._getBatchableMesh(mesh);
const texture = mesh.texture;
if (batchableMesh.texture._source !== texture._source) {
if (batchableMesh.texture._source !== texture._source) {
return !batchableMesh._batcher.checkAndUpdateTexture(batchableMesh, texture);
}
}
}
return false;
}
addRenderable(mesh, instructionSet) {
const batcher = this.renderer.renderPipes.batch;
const { batched } = this._getMeshData(mesh);
if (batched) {
const gpuBatchableMesh = this._getBatchableMesh(mesh);
gpuBatchableMesh.texture = mesh._texture;
gpuBatchableMesh.geometry = mesh._geometry;
batcher.addToBatch(gpuBatchableMesh, instructionSet);
} else {
batcher.break(instructionSet);
instructionSet.add(mesh);
}
}
updateRenderable(mesh) {
if (mesh.batched) {
const gpuBatchableMesh = this._gpuBatchableMeshHash[mesh.uid];
gpuBatchableMesh.texture = mesh._texture;
gpuBatchableMesh.geometry = mesh._geometry;
gpuBatchableMesh._batcher.updateElement(gpuBatchableMesh);
}
}
destroyRenderable(mesh) {
this._meshDataHash[mesh.uid] = null;
const gpuMesh = this._gpuBatchableMeshHash[mesh.uid];
if (gpuMesh) {
BigPool.return(gpuMesh);
this._gpuBatchableMeshHash[mesh.uid] = null;
}
mesh.off("destroyed", this._destroyRenderableBound);
}
execute(mesh) {
if (!mesh.isRenderable)
return;
mesh.state.blendMode = getAdjustedBlendModeBlend(mesh.groupBlendMode, mesh.texture._source);
const localUniforms = this.localUniforms;
localUniforms.uniforms.uTransformMatrix = mesh.groupTransform;
localUniforms.uniforms.uRound = this.renderer._roundPixels | mesh._roundPixels;
localUniforms.update();
color32BitToUniform(
mesh.groupColorAlpha,
localUniforms.uniforms.uColor,
0
);
this._adaptor.execute(this, mesh);
}
_getMeshData(mesh) {
return this._meshDataHash[mesh.uid] || this._initMeshData(mesh);
}
_initMeshData(mesh) {
this._meshDataHash[mesh.uid] = {
batched: mesh.batched,
indexSize: mesh._geometry.indices?.length,
vertexSize: mesh._geometry.positions?.length
};
mesh.on("destroyed", this._destroyRenderableBound);
return this._meshDataHash[mesh.uid];
}
_getBatchableMesh(mesh) {
return this._gpuBatchableMeshHash[mesh.uid] || this._initBatchableMesh(mesh);
}
_initBatchableMesh(mesh) {
const gpuMesh = BigPool.get(BatchableMesh);
gpuMesh.renderable = mesh;
gpuMesh.texture = mesh._texture;
gpuMesh.transform = mesh.groupTransform;
gpuMesh.roundPixels = this.renderer._roundPixels | mesh._roundPixels;
this._gpuBatchableMeshHash[mesh.uid] = gpuMesh;
return gpuMesh;
}
destroy() {
for (const i in this._gpuBatchableMeshHash) {
if (this._gpuBatchableMeshHash[i]) {
BigPool.return(this._gpuBatchableMeshHash[i]);
}
}
this._gpuBatchableMeshHash = null;
this._meshDataHash = null;
this.localUniforms = null;
this.localUniformsBindGroup = null;
this._adaptor.destroy();
this._adaptor = null;
this.renderer = null;
}
}
/** @ignore */
MeshPipe.extension = {
type: [
ExtensionType.WebGLPipes,
ExtensionType.WebGPUPipes,
ExtensionType.CanvasPipes
],
name: "mesh"
};
export { MeshPipe };
//# sourceMappingURL=MeshPipe.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
import type { Matrix } from '../../../maths/matrix/Matrix';
import type { Texture } from '../../../rendering/renderers/shared/texture/Texture';
export declare function getTextureDefaultMatrix(texture: Texture, out: Matrix): Matrix;

View File

@@ -0,0 +1,11 @@
'use strict';
"use strict";
function getTextureDefaultMatrix(texture, out) {
const { width, height } = texture.frame;
out.scale(1 / width, 1 / height);
return out;
}
exports.getTextureDefaultMatrix = getTextureDefaultMatrix;
//# sourceMappingURL=getTextureDefaultMatrix.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTextureDefaultMatrix.js","sources":["../../../../src/scene/mesh/shared/getTextureDefaultMatrix.ts"],"sourcesContent":["import type { Matrix } from '../../../maths/matrix/Matrix';\nimport type { Texture } from '../../../rendering/renderers/shared/texture/Texture';\n\nexport function getTextureDefaultMatrix(texture: Texture, out: Matrix): Matrix\n{\n const { width, height } = texture.frame;\n\n out.scale(1 / width, 1 / height);\n\n return out;\n}\n"],"names":[],"mappings":";;;AAGgB,SAAA,uBAAA,CAAwB,SAAkB,GAC1D,EAAA;AACI,EAAA,MAAM,EAAE,KAAA,EAAO,MAAO,EAAA,GAAI,OAAQ,CAAA,KAAA,CAAA;AAElC,EAAA,GAAA,CAAI,KAAM,CAAA,CAAA,GAAI,KAAO,EAAA,CAAA,GAAI,MAAM,CAAA,CAAA;AAE/B,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,9 @@
"use strict";
function getTextureDefaultMatrix(texture, out) {
const { width, height } = texture.frame;
out.scale(1 / width, 1 / height);
return out;
}
export { getTextureDefaultMatrix };
//# sourceMappingURL=getTextureDefaultMatrix.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getTextureDefaultMatrix.mjs","sources":["../../../../src/scene/mesh/shared/getTextureDefaultMatrix.ts"],"sourcesContent":["import type { Matrix } from '../../../maths/matrix/Matrix';\nimport type { Texture } from '../../../rendering/renderers/shared/texture/Texture';\n\nexport function getTextureDefaultMatrix(texture: Texture, out: Matrix): Matrix\n{\n const { width, height } = texture.frame;\n\n out.scale(1 / width, 1 / height);\n\n return out;\n}\n"],"names":[],"mappings":";AAGgB,SAAA,uBAAA,CAAwB,SAAkB,GAC1D,EAAA;AACI,EAAA,MAAM,EAAE,KAAA,EAAO,MAAO,EAAA,GAAI,OAAQ,CAAA,KAAA,CAAA;AAElC,EAAA,GAAA,CAAI,KAAM,CAAA,CAAA,GAAI,KAAO,EAAA,CAAA,GAAI,MAAM,CAAA,CAAA;AAE/B,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}