sdfsdfs
This commit is contained in:
39
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.d.ts
generated
vendored
Normal file
39
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.d.ts
generated
vendored
Normal 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;
|
||||
}
|
68
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.js
generated
vendored
Normal file
68
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.js
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
66
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.mjs
generated
vendored
Normal file
66
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.mjs
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/BatchableMesh.mjs.map
generated
vendored
Normal file
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
126
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.d.ts
generated
vendored
Normal 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
207
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.js
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.js.map
generated
vendored
Normal file
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
205
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.mjs
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/Mesh.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
42
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.d.ts
generated
vendored
Normal file
42
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.d.ts
generated
vendored
Normal 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);
|
||||
}
|
92
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.js
generated
vendored
Normal file
92
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.js
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
90
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.mjs
generated
vendored
Normal file
90
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.mjs
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshGeometry.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.d.ts
generated
vendored
Normal file
51
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.d.ts
generated
vendored
Normal 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
149
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.js
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.js.map
generated
vendored
Normal file
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
147
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.mjs
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/MeshPipe.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.d.ts
generated
vendored
Normal file
3
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.d.ts
generated
vendored
Normal 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;
|
11
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.js
generated
vendored
Normal file
11
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.js
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.js.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.js.map
generated
vendored
Normal 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;;;;"}
|
9
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.mjs
generated
vendored
Normal file
9
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.mjs
generated
vendored
Normal 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
|
1
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.mjs.map
generated
vendored
Normal file
1
node_modules/pixi.js/lib/scene/mesh/shared/getTextureDefaultMatrix.mjs.map
generated
vendored
Normal 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;;;;"}
|
Reference in New Issue
Block a user