Initial
This commit is contained in:
39
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.js
generated
vendored
Normal file
39
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
var mesh = require("@pixi/mesh");
|
||||
class PlaneGeometry extends mesh.MeshGeometry {
|
||||
/**
|
||||
* @param width - The width of the plane.
|
||||
* @param height - The height of the plane.
|
||||
* @param segWidth - Number of horizontal segments.
|
||||
* @param segHeight - Number of vertical segments.
|
||||
*/
|
||||
constructor(width = 100, height = 100, segWidth = 10, segHeight = 10) {
|
||||
super(), this.segWidth = segWidth, this.segHeight = segHeight, this.width = width, this.height = height, this.build();
|
||||
}
|
||||
/**
|
||||
* Refreshes plane coordinates
|
||||
* @private
|
||||
*/
|
||||
build() {
|
||||
const total = this.segWidth * this.segHeight, verts = [], uvs = [], indices = [], segmentsX = this.segWidth - 1, segmentsY = this.segHeight - 1, sizeX = this.width / segmentsX, sizeY = this.height / segmentsY;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const x = i % this.segWidth, y = i / this.segWidth | 0;
|
||||
verts.push(x * sizeX, y * sizeY), uvs.push(x / segmentsX, y / segmentsY);
|
||||
}
|
||||
const totalSub = segmentsX * segmentsY;
|
||||
for (let i = 0; i < totalSub; i++) {
|
||||
const xpos = i % segmentsX, ypos = i / segmentsX | 0, value = ypos * this.segWidth + xpos, value2 = ypos * this.segWidth + xpos + 1, value3 = (ypos + 1) * this.segWidth + xpos, value4 = (ypos + 1) * this.segWidth + xpos + 1;
|
||||
indices.push(
|
||||
value,
|
||||
value2,
|
||||
value3,
|
||||
value2,
|
||||
value4,
|
||||
value3
|
||||
);
|
||||
}
|
||||
this.buffers[0].data = new Float32Array(verts), this.buffers[1].data = new Float32Array(uvs), this.indexBuffer.data = new Uint16Array(indices), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
|
||||
}
|
||||
}
|
||||
exports.PlaneGeometry = PlaneGeometry;
|
||||
//# sourceMappingURL=PlaneGeometry.js.map
|
||||
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.js.map
generated
vendored
Normal file
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlaneGeometry.js","sources":["../../src/geometry/PlaneGeometry.ts"],"sourcesContent":["import { MeshGeometry } from '@pixi/mesh';\n\n/**\n * @memberof PIXI\n */\nexport class PlaneGeometry extends MeshGeometry\n{\n public segWidth: number;\n public segHeight: number;\n public width: number;\n public height: number;\n\n /**\n * @param width - The width of the plane.\n * @param height - The height of the plane.\n * @param segWidth - Number of horizontal segments.\n * @param segHeight - Number of vertical segments.\n */\n constructor(width = 100, height = 100, segWidth = 10, segHeight = 10)\n {\n super();\n\n this.segWidth = segWidth;\n this.segHeight = segHeight;\n\n this.width = width;\n this.height = height;\n\n this.build();\n }\n\n /**\n * Refreshes plane coordinates\n * @private\n */\n build(): void\n {\n const total = this.segWidth * this.segHeight;\n const verts = [];\n const uvs = [];\n const indices = [];\n\n const segmentsX = this.segWidth - 1;\n const segmentsY = this.segHeight - 1;\n\n const sizeX = (this.width) / segmentsX;\n const sizeY = (this.height) / segmentsY;\n\n for (let i = 0; i < total; i++)\n {\n const x = (i % this.segWidth);\n const y = ((i / this.segWidth) | 0);\n\n verts.push(x * sizeX, y * sizeY);\n uvs.push(x / segmentsX, y / segmentsY);\n }\n\n const totalSub = segmentsX * segmentsY;\n\n for (let i = 0; i < totalSub; i++)\n {\n const xpos = i % segmentsX;\n const ypos = (i / segmentsX) | 0;\n\n const value = (ypos * this.segWidth) + xpos;\n const value2 = (ypos * this.segWidth) + xpos + 1;\n const value3 = ((ypos + 1) * this.segWidth) + xpos;\n const value4 = ((ypos + 1) * this.segWidth) + xpos + 1;\n\n indices.push(value, value2, value3,\n value2, value4, value3);\n }\n\n this.buffers[0].data = new Float32Array(verts);\n this.buffers[1].data = new Float32Array(uvs);\n this.indexBuffer.data = new Uint16Array(indices);\n\n // ensure that the changes are uploaded\n this.buffers[0].update();\n this.buffers[1].update();\n this.indexBuffer.update();\n }\n}\n"],"names":["MeshGeometry"],"mappings":";;AAKO,MAAM,sBAAsBA,KAAAA,aACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,YAAY,QAAQ,KAAK,SAAS,KAAK,WAAW,IAAI,YAAY,IAClE;AACU,aAEN,KAAK,WAAW,UAChB,KAAK,YAAY,WAEjB,KAAK,QAAQ,OACb,KAAK,SAAS,QAEd,KAAK,MAAM;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACI,UAAM,QAAQ,KAAK,WAAW,KAAK,WAC7B,QAAQ,CAAC,GACT,MAAM,CACN,GAAA,UAAU,CAAC,GAEX,YAAY,KAAK,WAAW,GAC5B,YAAY,KAAK,YAAY,GAE7B,QAAS,KAAK,QAAS,WACvB,QAAS,KAAK,SAAU;AAE9B,aAAS,IAAI,GAAG,IAAI,OAAO,KAC3B;AACI,YAAM,IAAK,IAAI,KAAK,UACd,IAAM,IAAI,KAAK,WAAY;AAE3B,YAAA,KAAK,IAAI,OAAO,IAAI,KAAK,GAC/B,IAAI,KAAK,IAAI,WAAW,IAAI,SAAS;AAAA,IACzC;AAEA,UAAM,WAAW,YAAY;AAE7B,aAAS,IAAI,GAAG,IAAI,UAAU,KAC9B;AACI,YAAM,OAAO,IAAI,WACX,OAAQ,IAAI,YAAa,GAEzB,QAAS,OAAO,KAAK,WAAY,MACjC,SAAU,OAAO,KAAK,WAAY,OAAO,GACzC,UAAW,OAAO,KAAK,KAAK,WAAY,MACxC,UAAW,OAAO,KAAK,KAAK,WAAY,OAAO;AAE7C,cAAA;AAAA,QAAK;AAAA,QAAO;AAAA,QAAQ;AAAA,QACxB;AAAA,QAAQ;AAAA,QAAQ;AAAA,MAAA;AAAA,IACxB;AAEA,SAAK,QAAQ,CAAC,EAAE,OAAO,IAAI,aAAa,KAAK,GAC7C,KAAK,QAAQ,CAAC,EAAE,OAAO,IAAI,aAAa,GAAG,GAC3C,KAAK,YAAY,OAAO,IAAI,YAAY,OAAO,GAG/C,KAAK,QAAQ,CAAC,EAAE,OAChB,GAAA,KAAK,QAAQ,CAAC,EAAE,UAChB,KAAK,YAAY;EACrB;AACJ;;"}
|
||||
40
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.mjs
generated
vendored
Normal file
40
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.mjs
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { MeshGeometry } from "@pixi/mesh";
|
||||
class PlaneGeometry extends MeshGeometry {
|
||||
/**
|
||||
* @param width - The width of the plane.
|
||||
* @param height - The height of the plane.
|
||||
* @param segWidth - Number of horizontal segments.
|
||||
* @param segHeight - Number of vertical segments.
|
||||
*/
|
||||
constructor(width = 100, height = 100, segWidth = 10, segHeight = 10) {
|
||||
super(), this.segWidth = segWidth, this.segHeight = segHeight, this.width = width, this.height = height, this.build();
|
||||
}
|
||||
/**
|
||||
* Refreshes plane coordinates
|
||||
* @private
|
||||
*/
|
||||
build() {
|
||||
const total = this.segWidth * this.segHeight, verts = [], uvs = [], indices = [], segmentsX = this.segWidth - 1, segmentsY = this.segHeight - 1, sizeX = this.width / segmentsX, sizeY = this.height / segmentsY;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const x = i % this.segWidth, y = i / this.segWidth | 0;
|
||||
verts.push(x * sizeX, y * sizeY), uvs.push(x / segmentsX, y / segmentsY);
|
||||
}
|
||||
const totalSub = segmentsX * segmentsY;
|
||||
for (let i = 0; i < totalSub; i++) {
|
||||
const xpos = i % segmentsX, ypos = i / segmentsX | 0, value = ypos * this.segWidth + xpos, value2 = ypos * this.segWidth + xpos + 1, value3 = (ypos + 1) * this.segWidth + xpos, value4 = (ypos + 1) * this.segWidth + xpos + 1;
|
||||
indices.push(
|
||||
value,
|
||||
value2,
|
||||
value3,
|
||||
value2,
|
||||
value4,
|
||||
value3
|
||||
);
|
||||
}
|
||||
this.buffers[0].data = new Float32Array(verts), this.buffers[1].data = new Float32Array(uvs), this.indexBuffer.data = new Uint16Array(indices), this.buffers[0].update(), this.buffers[1].update(), this.indexBuffer.update();
|
||||
}
|
||||
}
|
||||
export {
|
||||
PlaneGeometry
|
||||
};
|
||||
//# sourceMappingURL=PlaneGeometry.mjs.map
|
||||
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.mjs.map
generated
vendored
Normal file
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/PlaneGeometry.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlaneGeometry.mjs","sources":["../../src/geometry/PlaneGeometry.ts"],"sourcesContent":["import { MeshGeometry } from '@pixi/mesh';\n\n/**\n * @memberof PIXI\n */\nexport class PlaneGeometry extends MeshGeometry\n{\n public segWidth: number;\n public segHeight: number;\n public width: number;\n public height: number;\n\n /**\n * @param width - The width of the plane.\n * @param height - The height of the plane.\n * @param segWidth - Number of horizontal segments.\n * @param segHeight - Number of vertical segments.\n */\n constructor(width = 100, height = 100, segWidth = 10, segHeight = 10)\n {\n super();\n\n this.segWidth = segWidth;\n this.segHeight = segHeight;\n\n this.width = width;\n this.height = height;\n\n this.build();\n }\n\n /**\n * Refreshes plane coordinates\n * @private\n */\n build(): void\n {\n const total = this.segWidth * this.segHeight;\n const verts = [];\n const uvs = [];\n const indices = [];\n\n const segmentsX = this.segWidth - 1;\n const segmentsY = this.segHeight - 1;\n\n const sizeX = (this.width) / segmentsX;\n const sizeY = (this.height) / segmentsY;\n\n for (let i = 0; i < total; i++)\n {\n const x = (i % this.segWidth);\n const y = ((i / this.segWidth) | 0);\n\n verts.push(x * sizeX, y * sizeY);\n uvs.push(x / segmentsX, y / segmentsY);\n }\n\n const totalSub = segmentsX * segmentsY;\n\n for (let i = 0; i < totalSub; i++)\n {\n const xpos = i % segmentsX;\n const ypos = (i / segmentsX) | 0;\n\n const value = (ypos * this.segWidth) + xpos;\n const value2 = (ypos * this.segWidth) + xpos + 1;\n const value3 = ((ypos + 1) * this.segWidth) + xpos;\n const value4 = ((ypos + 1) * this.segWidth) + xpos + 1;\n\n indices.push(value, value2, value3,\n value2, value4, value3);\n }\n\n this.buffers[0].data = new Float32Array(verts);\n this.buffers[1].data = new Float32Array(uvs);\n this.indexBuffer.data = new Uint16Array(indices);\n\n // ensure that the changes are uploaded\n this.buffers[0].update();\n this.buffers[1].update();\n this.indexBuffer.update();\n }\n}\n"],"names":[],"mappings":";AAKO,MAAM,sBAAsB,aACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,YAAY,QAAQ,KAAK,SAAS,KAAK,WAAW,IAAI,YAAY,IAClE;AACU,aAEN,KAAK,WAAW,UAChB,KAAK,YAAY,WAEjB,KAAK,QAAQ,OACb,KAAK,SAAS,QAEd,KAAK,MAAM;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QACA;AACI,UAAM,QAAQ,KAAK,WAAW,KAAK,WAC7B,QAAQ,CAAC,GACT,MAAM,CACN,GAAA,UAAU,CAAC,GAEX,YAAY,KAAK,WAAW,GAC5B,YAAY,KAAK,YAAY,GAE7B,QAAS,KAAK,QAAS,WACvB,QAAS,KAAK,SAAU;AAE9B,aAAS,IAAI,GAAG,IAAI,OAAO,KAC3B;AACI,YAAM,IAAK,IAAI,KAAK,UACd,IAAM,IAAI,KAAK,WAAY;AAE3B,YAAA,KAAK,IAAI,OAAO,IAAI,KAAK,GAC/B,IAAI,KAAK,IAAI,WAAW,IAAI,SAAS;AAAA,IACzC;AAEA,UAAM,WAAW,YAAY;AAE7B,aAAS,IAAI,GAAG,IAAI,UAAU,KAC9B;AACI,YAAM,OAAO,IAAI,WACX,OAAQ,IAAI,YAAa,GAEzB,QAAS,OAAO,KAAK,WAAY,MACjC,SAAU,OAAO,KAAK,WAAY,OAAO,GACzC,UAAW,OAAO,KAAK,KAAK,WAAY,MACxC,UAAW,OAAO,KAAK,KAAK,WAAY,OAAO;AAE7C,cAAA;AAAA,QAAK;AAAA,QAAO;AAAA,QAAQ;AAAA,QACxB;AAAA,QAAQ;AAAA,QAAQ;AAAA,MAAA;AAAA,IACxB;AAEA,SAAK,QAAQ,CAAC,EAAE,OAAO,IAAI,aAAa,KAAK,GAC7C,KAAK,QAAQ,CAAC,EAAE,OAAO,IAAI,aAAa,GAAG,GAC3C,KAAK,YAAY,OAAO,IAAI,YAAY,OAAO,GAG/C,KAAK,QAAQ,CAAC,EAAE,OAChB,GAAA,KAAK,QAAQ,CAAC,EAAE,UAChB,KAAK,YAAY;EACrB;AACJ;"}
|
||||
80
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.js
generated
vendored
Normal file
80
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
var mesh = require("@pixi/mesh");
|
||||
class RopeGeometry extends mesh.MeshGeometry {
|
||||
/**
|
||||
* @param width - The width (i.e., thickness) of the rope.
|
||||
* @param points - An array of {@link PIXI.Point} objects to construct this rope.
|
||||
* @param textureScale - By default the rope texture will be stretched to match
|
||||
* rope length. If textureScale is positive this value will be treated as a scaling
|
||||
* factor and the texture will preserve its aspect ratio instead. To create a tiling rope
|
||||
* set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
|
||||
* then set textureScale=1 to keep the original texture pixel size.
|
||||
* In order to reduce alpha channel artifacts provide a larger texture and downsample -
|
||||
* i.e. set textureScale=0.5 to scale it down twice.
|
||||
*/
|
||||
constructor(width = 200, points, textureScale = 0) {
|
||||
super(
|
||||
new Float32Array(points.length * 4),
|
||||
new Float32Array(points.length * 4),
|
||||
new Uint16Array((points.length - 1) * 6)
|
||||
), this.points = points, this._width = width, this.textureScale = textureScale, this.build();
|
||||
}
|
||||
/**
|
||||
* The width (i.e., thickness) of the rope.
|
||||
* @readonly
|
||||
*/
|
||||
get width() {
|
||||
return this._width;
|
||||
}
|
||||
/** Refreshes Rope indices and uvs */
|
||||
build() {
|
||||
const points = this.points;
|
||||
if (!points)
|
||||
return;
|
||||
const vertexBuffer = this.getBuffer("aVertexPosition"), uvBuffer = this.getBuffer("aTextureCoord"), indexBuffer = this.getIndex();
|
||||
if (points.length < 1)
|
||||
return;
|
||||
vertexBuffer.data.length / 4 !== points.length && (vertexBuffer.data = new Float32Array(points.length * 4), uvBuffer.data = new Float32Array(points.length * 4), indexBuffer.data = new Uint16Array((points.length - 1) * 6));
|
||||
const uvs = uvBuffer.data, indices = indexBuffer.data;
|
||||
uvs[0] = 0, uvs[1] = 0, uvs[2] = 0, uvs[3] = 1;
|
||||
let amount = 0, prev = points[0];
|
||||
const textureWidth = this._width * this.textureScale, total = points.length;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const index = i * 4;
|
||||
if (this.textureScale > 0) {
|
||||
const dx = prev.x - points[i].x, dy = prev.y - points[i].y, distance = Math.sqrt(dx * dx + dy * dy);
|
||||
prev = points[i], amount += distance / textureWidth;
|
||||
} else
|
||||
amount = i / (total - 1);
|
||||
uvs[index] = amount, uvs[index + 1] = 0, uvs[index + 2] = amount, uvs[index + 3] = 1;
|
||||
}
|
||||
let indexCount = 0;
|
||||
for (let i = 0; i < total - 1; i++) {
|
||||
const index = i * 2;
|
||||
indices[indexCount++] = index, indices[indexCount++] = index + 1, indices[indexCount++] = index + 2, indices[indexCount++] = index + 2, indices[indexCount++] = index + 1, indices[indexCount++] = index + 3;
|
||||
}
|
||||
uvBuffer.update(), indexBuffer.update(), this.updateVertices();
|
||||
}
|
||||
/** refreshes vertices of Rope mesh */
|
||||
updateVertices() {
|
||||
const points = this.points;
|
||||
if (points.length < 1)
|
||||
return;
|
||||
let lastPoint = points[0], nextPoint, perpX = 0, perpY = 0;
|
||||
const vertices = this.buffers[0].data, total = points.length, halfWidth = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const point = points[i], index = i * 4;
|
||||
i < points.length - 1 ? nextPoint = points[i + 1] : nextPoint = point, perpY = -(nextPoint.x - lastPoint.x), perpX = nextPoint.y - lastPoint.y;
|
||||
let ratio = (1 - i / (total - 1)) * 10;
|
||||
ratio > 1 && (ratio = 1);
|
||||
const perpLength = Math.sqrt(perpX * perpX + perpY * perpY);
|
||||
perpLength < 1e-6 ? (perpX = 0, perpY = 0) : (perpX /= perpLength, perpY /= perpLength, perpX *= halfWidth, perpY *= halfWidth), vertices[index] = point.x + perpX, vertices[index + 1] = point.y + perpY, vertices[index + 2] = point.x - perpX, vertices[index + 3] = point.y - perpY, lastPoint = point;
|
||||
}
|
||||
this.buffers[0].update();
|
||||
}
|
||||
update() {
|
||||
this.textureScale > 0 ? this.build() : this.updateVertices();
|
||||
}
|
||||
}
|
||||
exports.RopeGeometry = RopeGeometry;
|
||||
//# sourceMappingURL=RopeGeometry.js.map
|
||||
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.js.map
generated
vendored
Normal file
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
81
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.mjs
generated
vendored
Normal file
81
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.mjs
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
import { MeshGeometry } from "@pixi/mesh";
|
||||
class RopeGeometry extends MeshGeometry {
|
||||
/**
|
||||
* @param width - The width (i.e., thickness) of the rope.
|
||||
* @param points - An array of {@link PIXI.Point} objects to construct this rope.
|
||||
* @param textureScale - By default the rope texture will be stretched to match
|
||||
* rope length. If textureScale is positive this value will be treated as a scaling
|
||||
* factor and the texture will preserve its aspect ratio instead. To create a tiling rope
|
||||
* set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
|
||||
* then set textureScale=1 to keep the original texture pixel size.
|
||||
* In order to reduce alpha channel artifacts provide a larger texture and downsample -
|
||||
* i.e. set textureScale=0.5 to scale it down twice.
|
||||
*/
|
||||
constructor(width = 200, points, textureScale = 0) {
|
||||
super(
|
||||
new Float32Array(points.length * 4),
|
||||
new Float32Array(points.length * 4),
|
||||
new Uint16Array((points.length - 1) * 6)
|
||||
), this.points = points, this._width = width, this.textureScale = textureScale, this.build();
|
||||
}
|
||||
/**
|
||||
* The width (i.e., thickness) of the rope.
|
||||
* @readonly
|
||||
*/
|
||||
get width() {
|
||||
return this._width;
|
||||
}
|
||||
/** Refreshes Rope indices and uvs */
|
||||
build() {
|
||||
const points = this.points;
|
||||
if (!points)
|
||||
return;
|
||||
const vertexBuffer = this.getBuffer("aVertexPosition"), uvBuffer = this.getBuffer("aTextureCoord"), indexBuffer = this.getIndex();
|
||||
if (points.length < 1)
|
||||
return;
|
||||
vertexBuffer.data.length / 4 !== points.length && (vertexBuffer.data = new Float32Array(points.length * 4), uvBuffer.data = new Float32Array(points.length * 4), indexBuffer.data = new Uint16Array((points.length - 1) * 6));
|
||||
const uvs = uvBuffer.data, indices = indexBuffer.data;
|
||||
uvs[0] = 0, uvs[1] = 0, uvs[2] = 0, uvs[3] = 1;
|
||||
let amount = 0, prev = points[0];
|
||||
const textureWidth = this._width * this.textureScale, total = points.length;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const index = i * 4;
|
||||
if (this.textureScale > 0) {
|
||||
const dx = prev.x - points[i].x, dy = prev.y - points[i].y, distance = Math.sqrt(dx * dx + dy * dy);
|
||||
prev = points[i], amount += distance / textureWidth;
|
||||
} else
|
||||
amount = i / (total - 1);
|
||||
uvs[index] = amount, uvs[index + 1] = 0, uvs[index + 2] = amount, uvs[index + 3] = 1;
|
||||
}
|
||||
let indexCount = 0;
|
||||
for (let i = 0; i < total - 1; i++) {
|
||||
const index = i * 2;
|
||||
indices[indexCount++] = index, indices[indexCount++] = index + 1, indices[indexCount++] = index + 2, indices[indexCount++] = index + 2, indices[indexCount++] = index + 1, indices[indexCount++] = index + 3;
|
||||
}
|
||||
uvBuffer.update(), indexBuffer.update(), this.updateVertices();
|
||||
}
|
||||
/** refreshes vertices of Rope mesh */
|
||||
updateVertices() {
|
||||
const points = this.points;
|
||||
if (points.length < 1)
|
||||
return;
|
||||
let lastPoint = points[0], nextPoint, perpX = 0, perpY = 0;
|
||||
const vertices = this.buffers[0].data, total = points.length, halfWidth = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;
|
||||
for (let i = 0; i < total; i++) {
|
||||
const point = points[i], index = i * 4;
|
||||
i < points.length - 1 ? nextPoint = points[i + 1] : nextPoint = point, perpY = -(nextPoint.x - lastPoint.x), perpX = nextPoint.y - lastPoint.y;
|
||||
let ratio = (1 - i / (total - 1)) * 10;
|
||||
ratio > 1 && (ratio = 1);
|
||||
const perpLength = Math.sqrt(perpX * perpX + perpY * perpY);
|
||||
perpLength < 1e-6 ? (perpX = 0, perpY = 0) : (perpX /= perpLength, perpY /= perpLength, perpX *= halfWidth, perpY *= halfWidth), vertices[index] = point.x + perpX, vertices[index + 1] = point.y + perpY, vertices[index + 2] = point.x - perpX, vertices[index + 3] = point.y - perpY, lastPoint = point;
|
||||
}
|
||||
this.buffers[0].update();
|
||||
}
|
||||
update() {
|
||||
this.textureScale > 0 ? this.build() : this.updateVertices();
|
||||
}
|
||||
}
|
||||
export {
|
||||
RopeGeometry
|
||||
};
|
||||
//# sourceMappingURL=RopeGeometry.mjs.map
|
||||
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.mjs.map
generated
vendored
Normal file
1
resources/app/node_modules/@pixi/mesh-extras/lib/geometry/RopeGeometry.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user