roavatar-renderer 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +32 -7
  2. package/dist/index.js +2163 -1741
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15089,6 +15089,94 @@ class PlaneGeometry extends BufferGeometry {
15089
15089
  return new PlaneGeometry(data.width, data.height, data.widthSegments, data.heightSegments);
15090
15090
  }
15091
15091
  }
15092
+ class SphereGeometry extends BufferGeometry {
15093
+ /**
15094
+ * Constructs a new sphere geometry.
15095
+ *
15096
+ * @param {number} [radius=1] - The sphere radius.
15097
+ * @param {number} [widthSegments=32] - The number of horizontal segments. Minimum value is `3`.
15098
+ * @param {number} [heightSegments=16] - The number of vertical segments. Minimum value is `2`.
15099
+ * @param {number} [phiStart=0] - The horizontal starting angle in radians.
15100
+ * @param {number} [phiLength=Math.PI*2] - The horizontal sweep angle size.
15101
+ * @param {number} [thetaStart=0] - The vertical starting angle in radians.
15102
+ * @param {number} [thetaLength=Math.PI] - The vertical sweep angle size.
15103
+ */
15104
+ constructor(radius = 1, widthSegments = 32, heightSegments = 16, phiStart = 0, phiLength = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI) {
15105
+ super();
15106
+ this.type = "SphereGeometry";
15107
+ this.parameters = {
15108
+ radius,
15109
+ widthSegments,
15110
+ heightSegments,
15111
+ phiStart,
15112
+ phiLength,
15113
+ thetaStart,
15114
+ thetaLength
15115
+ };
15116
+ widthSegments = Math.max(3, Math.floor(widthSegments));
15117
+ heightSegments = Math.max(2, Math.floor(heightSegments));
15118
+ const thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);
15119
+ let index = 0;
15120
+ const grid = [];
15121
+ const vertex2 = new Vector3$1();
15122
+ const normal = new Vector3$1();
15123
+ const indices = [];
15124
+ const vertices = [];
15125
+ const normals = [];
15126
+ const uvs = [];
15127
+ for (let iy = 0; iy <= heightSegments; iy++) {
15128
+ const verticesRow = [];
15129
+ const v = iy / heightSegments;
15130
+ let uOffset = 0;
15131
+ if (iy === 0 && thetaStart === 0) {
15132
+ uOffset = 0.5 / widthSegments;
15133
+ } else if (iy === heightSegments && thetaEnd === Math.PI) {
15134
+ uOffset = -0.5 / widthSegments;
15135
+ }
15136
+ for (let ix = 0; ix <= widthSegments; ix++) {
15137
+ const u = ix / widthSegments;
15138
+ vertex2.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
15139
+ vertex2.y = radius * Math.cos(thetaStart + v * thetaLength);
15140
+ vertex2.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
15141
+ vertices.push(vertex2.x, vertex2.y, vertex2.z);
15142
+ normal.copy(vertex2).normalize();
15143
+ normals.push(normal.x, normal.y, normal.z);
15144
+ uvs.push(u + uOffset, 1 - v);
15145
+ verticesRow.push(index++);
15146
+ }
15147
+ grid.push(verticesRow);
15148
+ }
15149
+ for (let iy = 0; iy < heightSegments; iy++) {
15150
+ for (let ix = 0; ix < widthSegments; ix++) {
15151
+ const a = grid[iy][ix + 1];
15152
+ const b = grid[iy][ix];
15153
+ const c = grid[iy + 1][ix];
15154
+ const d = grid[iy + 1][ix + 1];
15155
+ if (iy !== 0 || thetaStart > 0) indices.push(a, b, d);
15156
+ if (iy !== heightSegments - 1 || thetaEnd < Math.PI) indices.push(b, c, d);
15157
+ }
15158
+ }
15159
+ this.setIndex(indices);
15160
+ this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
15161
+ this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
15162
+ this.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
15163
+ }
15164
+ copy(source) {
15165
+ super.copy(source);
15166
+ this.parameters = Object.assign({}, source.parameters);
15167
+ return this;
15168
+ }
15169
+ /**
15170
+ * Factory method for creating an instance of this class from the given
15171
+ * JSON object.
15172
+ *
15173
+ * @param {Object} data - A JSON object representing the serialized geometry.
15174
+ * @return {SphereGeometry} A new instance.
15175
+ */
15176
+ static fromJSON(data) {
15177
+ return new SphereGeometry(data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength);
15178
+ }
15179
+ }
15092
15180
  class ShadowMaterial extends Material {
15093
15181
  /**
15094
15182
  * Constructs a new shadow material.
@@ -15301,6 +15389,87 @@ class MeshPhongMaterial extends Material {
15301
15389
  return this;
15302
15390
  }
15303
15391
  }
15392
+ class MeshLambertMaterial extends Material {
15393
+ /**
15394
+ * Constructs a new mesh lambert material.
15395
+ *
15396
+ * @param {Object} [parameters] - An object with one or more properties
15397
+ * defining the material's appearance. Any property of the material
15398
+ * (including any property from inherited materials) can be passed
15399
+ * in here. Color values can be passed any type of value accepted
15400
+ * by {@link Color#set}.
15401
+ */
15402
+ constructor(parameters) {
15403
+ super();
15404
+ this.isMeshLambertMaterial = true;
15405
+ this.type = "MeshLambertMaterial";
15406
+ this.color = new Color(16777215);
15407
+ this.map = null;
15408
+ this.lightMap = null;
15409
+ this.lightMapIntensity = 1;
15410
+ this.aoMap = null;
15411
+ this.aoMapIntensity = 1;
15412
+ this.emissive = new Color(0);
15413
+ this.emissiveIntensity = 1;
15414
+ this.emissiveMap = null;
15415
+ this.bumpMap = null;
15416
+ this.bumpScale = 1;
15417
+ this.normalMap = null;
15418
+ this.normalMapType = TangentSpaceNormalMap;
15419
+ this.normalScale = new Vector2$1(1, 1);
15420
+ this.displacementMap = null;
15421
+ this.displacementScale = 1;
15422
+ this.displacementBias = 0;
15423
+ this.specularMap = null;
15424
+ this.alphaMap = null;
15425
+ this.envMap = null;
15426
+ this.envMapRotation = new Euler();
15427
+ this.combine = MultiplyOperation;
15428
+ this.reflectivity = 1;
15429
+ this.refractionRatio = 0.98;
15430
+ this.wireframe = false;
15431
+ this.wireframeLinewidth = 1;
15432
+ this.wireframeLinecap = "round";
15433
+ this.wireframeLinejoin = "round";
15434
+ this.flatShading = false;
15435
+ this.fog = true;
15436
+ this.setValues(parameters);
15437
+ }
15438
+ copy(source) {
15439
+ super.copy(source);
15440
+ this.color.copy(source.color);
15441
+ this.map = source.map;
15442
+ this.lightMap = source.lightMap;
15443
+ this.lightMapIntensity = source.lightMapIntensity;
15444
+ this.aoMap = source.aoMap;
15445
+ this.aoMapIntensity = source.aoMapIntensity;
15446
+ this.emissive.copy(source.emissive);
15447
+ this.emissiveMap = source.emissiveMap;
15448
+ this.emissiveIntensity = source.emissiveIntensity;
15449
+ this.bumpMap = source.bumpMap;
15450
+ this.bumpScale = source.bumpScale;
15451
+ this.normalMap = source.normalMap;
15452
+ this.normalMapType = source.normalMapType;
15453
+ this.normalScale.copy(source.normalScale);
15454
+ this.displacementMap = source.displacementMap;
15455
+ this.displacementScale = source.displacementScale;
15456
+ this.displacementBias = source.displacementBias;
15457
+ this.specularMap = source.specularMap;
15458
+ this.alphaMap = source.alphaMap;
15459
+ this.envMap = source.envMap;
15460
+ this.envMapRotation.copy(source.envMapRotation);
15461
+ this.combine = source.combine;
15462
+ this.reflectivity = source.reflectivity;
15463
+ this.refractionRatio = source.refractionRatio;
15464
+ this.wireframe = source.wireframe;
15465
+ this.wireframeLinewidth = source.wireframeLinewidth;
15466
+ this.wireframeLinecap = source.wireframeLinecap;
15467
+ this.wireframeLinejoin = source.wireframeLinejoin;
15468
+ this.flatShading = source.flatShading;
15469
+ this.fog = source.fog;
15470
+ return this;
15471
+ }
15472
+ }
15304
15473
  class MeshDepthMaterial extends Material {
15305
15474
  /**
15306
15475
  * Constructs a new mesh depth material.
@@ -27309,9 +27478,13 @@ class RBXSimpleView {
27309
27478
  }
27310
27479
  const magic = "<roblox!";
27311
27480
  const xmlMagic = "<roblox ";
27312
- const ObjectDescClassTypes = ["Part", "MeshPart", "Decal"];
27313
- const EmitterGroupDescClassTypes = ["ParticleEmitter", "Sparkles", "Fire", "Smoke"];
27314
- const LightDescClassTypes = ["PointLight", "SpotLight", "SurfaceLight"];
27481
+ const PartType = {
27482
+ "Ball": 0,
27483
+ "Block": 1,
27484
+ "Cylinder": 2,
27485
+ "Wedge": 3,
27486
+ "CornerWedge": 4
27487
+ };
27315
27488
  const ParticleOrientation = {
27316
27489
  "FacingCamera": 0,
27317
27490
  "FacingCameraWorldUp": 1,
@@ -29719,6 +29892,7 @@ const FLAGS = {
29719
29892
  API_DOMAIN: "roblox.com",
29720
29893
  API_REQUEST_PREFIX: "",
29721
29894
  INCLUDE_REQUEST_CREDENTIALS_OVERRIDE: "include",
29895
+ API_REQUEST_RETRY: true,
29722
29896
  //assets
29723
29897
  ONLINE_ASSETS: false,
29724
29898
  ASSETS_PATH: "../assets/rbxasset/",
@@ -29751,6 +29925,7 @@ const FLAGS = {
29751
29925
  AUTO_RESTORE_CONTEXT: true,
29752
29926
  RENDERTARGET_TO_CANVASTEXTURE: false,
29753
29927
  THUMBNAIL_TIMEOUT: 500,
29928
+ ALWAYS_SHOW_ATTACHMENTS: false,
29754
29929
  //skeleton
29755
29930
  SHOW_SKELETON_HELPER: false,
29756
29931
  UPDATE_SKELETON: true,
@@ -29820,6 +29995,7 @@ class InstanceWrapper {
29820
29995
  const newPropertyNames = this.instance.getPropertyNames();
29821
29996
  const hasAllProperties2 = this.static().requiredProperties.every((value) => newPropertyNames.includes(value));
29822
29997
  if (!hasAllProperties2) {
29998
+ log(true, "actual vs required:", newPropertyNames, this.static().requiredProperties);
29823
29999
  throw new Error("setup() does not add all properties listed in requiredProperties");
29824
30000
  }
29825
30001
  }
@@ -29830,6 +30006,18 @@ class InstanceWrapper {
29830
30006
  static() {
29831
30007
  return this.constructor;
29832
30008
  }
30009
+ static IsA(className) {
30010
+ if (this === InstanceWrapper) return className === "Instance";
30011
+ if (this.className === className) {
30012
+ return true;
30013
+ } else {
30014
+ const prototype = Object.getPrototypeOf(this);
30015
+ return prototype.IsA(className);
30016
+ }
30017
+ }
30018
+ IsA(className) {
30019
+ return this.static().IsA(className);
30020
+ }
29833
30021
  static register() {
29834
30022
  ClassNameToWrapper.set(this.className, this);
29835
30023
  log(false, "Registered InstanceWrapper:", ClassNameToWrapper);
@@ -29851,6 +30039,11 @@ class InstanceWrapper {
29851
30039
  preRender() {
29852
30040
  }
29853
30041
  }
30042
+ const __vite_glob_0_11 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
30043
+ __proto__: null,
30044
+ GetWrapperForInstance,
30045
+ InstanceWrapper
30046
+ }, Symbol.toStringTag, { value: "Module" }));
29854
30047
  class UDim {
29855
30048
  Scale = 0;
29856
30049
  //Float32
@@ -30073,13 +30266,17 @@ class NumberSequence {
30073
30266
  return resultKey;
30074
30267
  }
30075
30268
  getValue(time2, seed) {
30076
- const higherKey = this.getHigherKey(time2);
30077
30269
  const lowerKey = this.getLowerKey(time2);
30078
- const rng = new RNG(seed);
30079
- const envelopeSignLow = rng.nextInt() % 2 == 0 ? 1 : -1;
30080
- const envelopeSignHigh = rng.nextInt() % 2 == 0 ? 1 : -1;
30081
- const lowValue = lowerKey ? lowerKey.value + lowerKey.envelope * rng.nextFloat() * envelopeSignLow : 0;
30082
- const highValue = higherKey ? higherKey.value + higherKey.envelope * rng.nextFloat() * envelopeSignHigh : 0;
30270
+ const higherKey = this.getHigherKey(time2);
30271
+ const lowerKeyIndex = lowerKey ? this.keypoints.indexOf(lowerKey) : 0;
30272
+ const higherKeyIndex = higherKey ? this.keypoints.indexOf(higherKey) : 0;
30273
+ const originalRng = new RNG(seed);
30274
+ const lowerRng = new RNG(seed + lowerKeyIndex * originalRng.nextInt());
30275
+ const higherRng = new RNG(seed + higherKeyIndex * originalRng.nextInt());
30276
+ const envelopeSignLow = lowerRng.nextInt() % 2 == 0 ? 1 : -1;
30277
+ const envelopeSignHigh = higherRng.nextInt() % 2 == 0 ? 1 : -1;
30278
+ const lowValue = lowerKey ? lowerKey.value + lowerKey.envelope * lowerRng.nextFloat() * envelopeSignLow : 0;
30279
+ const highValue = higherKey ? higherKey.value + higherKey.envelope * higherRng.nextFloat() * envelopeSignHigh : 0;
30083
30280
  if (higherKey && !lowerKey) {
30084
30281
  return highValue;
30085
30282
  }
@@ -30372,6 +30569,9 @@ class Instance {
30372
30569
  }
30373
30570
  return wrapper;
30374
30571
  }
30572
+ get w() {
30573
+ return this.createWrapper();
30574
+ }
30375
30575
  addConnectionReference(connection) {
30376
30576
  if (!this._connectionReferences.includes(connection)) {
30377
30577
  this._connectionReferences.push(connection);
@@ -30877,7 +31077,7 @@ class RBX {
30877
31077
  case DataType.String: {
30878
31078
  let totalRead = 0;
30879
31079
  while (totalRead < valuesLength) {
30880
- if (StringBufferProperties.includes(prop.propertyName)) {
31080
+ if (StringBufferProperties.includes(prop.propertyName) && !FLAGS.SEARCH_FOR_STRING) {
30881
31081
  const length = chunkView.readUint32();
30882
31082
  prop.values.push(chunkView.buffer.slice(chunkView.viewOffset, chunkView.viewOffset + length - 1));
30883
31083
  chunkView.viewOffset += length;
@@ -31401,7 +31601,7 @@ class RBX {
31401
31601
  break;
31402
31602
  }
31403
31603
  default: {
31404
- warn(false, `XML: Can't parse type "${propertyNode.nodeName}"`);
31604
+ warn(false, `XML: Can't parse type "${propertyNode.nodeName}" in "${propertyNode.getAttribute("name") || "null"}"`);
31405
31605
  }
31406
31606
  }
31407
31607
  }
@@ -31989,7 +32189,7 @@ class RNG {
31989
32189
  this.state = seed;
31990
32190
  }
31991
32191
  nextInt() {
31992
- this.state = this.a * this.state + this.c & this.m;
32192
+ this.state = (this.a * this.state + this.c) % this.m;
31993
32193
  return this.state;
31994
32194
  }
31995
32195
  nextFloat() {
@@ -35436,7 +35636,7 @@ async function RBLXPost(url, auth, body, attempt = 0, method = "POST") {
35436
35636
  xCsrfToken = "";
35437
35637
  }
35438
35638
  }
35439
- return new Promise((resolve) => {
35639
+ const response = await new Promise((resolve) => {
35440
35640
  const fetchHeaders = new Headers({
35441
35641
  "Content-Type": "application/json",
35442
35642
  "X-CSRF-TOKEN": xCsrfToken
@@ -35447,19 +35647,19 @@ async function RBLXPost(url, auth, body, attempt = 0, method = "POST") {
35447
35647
  credentials: FLAGS.INCLUDE_REQUEST_CREDENTIALS_OVERRIDE,
35448
35648
  headers: fetchHeaders,
35449
35649
  body
35450
- }).then((response) => {
35451
- if (response.status !== 200) {
35452
- if (response.status === 403 && attempt < 1) {
35453
- const responseToken = response.headers.get("x-csrf-token");
35650
+ }).then((response2) => {
35651
+ if (response2.status !== 200) {
35652
+ if (response2.status === 403 && attempt < 1) {
35653
+ const responseToken = response2.headers.get("x-csrf-token");
35454
35654
  if (responseToken && auth) {
35455
35655
  auth.TOKEN = responseToken;
35456
35656
  }
35457
35657
  resolve(RBLXPost(url, auth, body, attempt + 1, method));
35458
35658
  } else {
35459
- resolve(response);
35659
+ resolve(response2);
35460
35660
  }
35461
35661
  } else {
35462
- resolve(response);
35662
+ resolve(response2);
35463
35663
  }
35464
35664
  }).catch((error2) => {
35465
35665
  warn(true, error2);
@@ -35470,12 +35670,17 @@ async function RBLXPost(url, auth, body, attempt = 0, method = "POST") {
35470
35670
  resolve(new Response(JSON.stringify({ "error": error2 }), { status: 500 }));
35471
35671
  }
35472
35672
  });
35673
+ if (FLAGS.API_REQUEST_RETRY && response.status !== 200 && attempt === 0) {
35674
+ return RBLXPost(url, auth, body, attempt + 1, method);
35675
+ } else {
35676
+ return response;
35677
+ }
35473
35678
  }
35474
- async function RBLXGet(url, headers, includeCredentials = true) {
35679
+ async function RBLXGet(url, headers, includeCredentials = true, attempt = 0) {
35475
35680
  if (url.match(/https?:\/\/[a-z]+.roblox.com/)) {
35476
35681
  url = url.replace("roblox.com", FLAGS.API_DOMAIN);
35477
35682
  }
35478
- return new Promise((resolve) => {
35683
+ const response = await new Promise((resolve) => {
35479
35684
  let newHeaders = {
35480
35685
  "Content-Type": "application/json"
35481
35686
  };
@@ -35491,8 +35696,8 @@ async function RBLXGet(url, headers, includeCredentials = true) {
35491
35696
  credentials: includeCredentials ? FLAGS.INCLUDE_REQUEST_CREDENTIALS_OVERRIDE : void 0,
35492
35697
  headers: fetchHeaders,
35493
35698
  priority: FLAGS.ASSET_REQUEST_PRIORITY
35494
- }).then((response) => {
35495
- resolve(response);
35699
+ }).then((response2) => {
35700
+ resolve(response2);
35496
35701
  }).catch((error2) => {
35497
35702
  warn(true, error2);
35498
35703
  resolve(new Response(JSON.stringify({ "error": error2 }), { status: 500 }));
@@ -35502,6 +35707,11 @@ async function RBLXGet(url, headers, includeCredentials = true) {
35502
35707
  resolve(new Response(JSON.stringify({ "error": error2 }), { status: 500 }));
35503
35708
  }
35504
35709
  });
35710
+ if (FLAGS.API_REQUEST_RETRY && response.status !== 200 && attempt === 0) {
35711
+ return RBLXGet(url, headers, includeCredentials, attempt + 1);
35712
+ } else {
35713
+ return response;
35714
+ }
35505
35715
  }
35506
35716
  async function RBLXDelete(url, auth, body, attempt = 0) {
35507
35717
  return RBLXPost(url, auth, body, attempt, "DELETE");
@@ -40889,6 +41099,96 @@ const FXAAShader = {
40889
41099
  }`
40890
41100
  )
40891
41101
  };
41102
+ const RenderDescClassTypes = /* @__PURE__ */ new Map();
41103
+ function getRenderDescForClass(className) {
41104
+ return RenderDescClassTypes.get(className);
41105
+ }
41106
+ function getRenderDescForInstance(instance) {
41107
+ const potentialRenderDesc = getRenderDescForClass(instance.className);
41108
+ if (potentialRenderDesc && potentialRenderDesc.shouldRenderInstance(instance)) return potentialRenderDesc;
41109
+ return void 0;
41110
+ }
41111
+ function setTHREEObjectCF(threeObject, cframe) {
41112
+ threeObject.position.set(cframe.Position[0], cframe.Position[1], cframe.Position[2]);
41113
+ threeObject.rotation.order = "YXZ";
41114
+ threeObject.rotation.x = rad(cframe.Orientation[0]);
41115
+ threeObject.rotation.y = rad(cframe.Orientation[1]);
41116
+ threeObject.rotation.z = rad(cframe.Orientation[2]);
41117
+ }
41118
+ class DisposableDesc {
41119
+ disposeMesh(scene, mesh) {
41120
+ disposeMesh(scene, mesh);
41121
+ }
41122
+ disposeMeshes(scene, meshes) {
41123
+ for (const mesh of meshes) {
41124
+ this.disposeMesh(scene, mesh);
41125
+ }
41126
+ }
41127
+ disposeRenderLists(renderer) {
41128
+ renderer.renderLists.dispose();
41129
+ }
41130
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41131
+ dispose(_renderer, _scene) {
41132
+ throw new Error("Virtual method dispose called");
41133
+ }
41134
+ }
41135
+ class RenderDesc extends DisposableDesc {
41136
+ static classTypes = [];
41137
+ renderScene;
41138
+ results;
41139
+ instance;
41140
+ constructor(renderScene) {
41141
+ super();
41142
+ this.renderScene = renderScene;
41143
+ }
41144
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41145
+ isSame(_other) {
41146
+ throw new Error("Virtual method isSame called");
41147
+ }
41148
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41149
+ needsRegeneration(_other) {
41150
+ throw new Error("Virtual method needsRegeneration called");
41151
+ }
41152
+ fromRenderDesc(other) {
41153
+ if (this.needsRegeneration(other)) {
41154
+ throw new Error("These RenderableDesc objects have differences that require recompilation");
41155
+ }
41156
+ this.virtualFromRenderDesc(other);
41157
+ }
41158
+ transferFrom(other) {
41159
+ this.virtualTransferFrom(other);
41160
+ }
41161
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41162
+ virtualTransferFrom(_other) {
41163
+ }
41164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41165
+ virtualFromRenderDesc(_other) {
41166
+ throw new Error("Virtual method virtualFromRenderDesc called");
41167
+ }
41168
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41169
+ fromInstance(_child) {
41170
+ throw new Error("Virtual method fromInstance called");
41171
+ }
41172
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41173
+ async compileResults(_renderer, _scene) {
41174
+ throw new Error("Virtual method compileResults called");
41175
+ }
41176
+ updateResults() {
41177
+ throw new Error("Virtual method updateResults called");
41178
+ }
41179
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41180
+ static shouldRenderInstance(_instance) {
41181
+ return true;
41182
+ }
41183
+ static register() {
41184
+ for (const classType of this.classTypes) {
41185
+ RenderDescClassTypes.set(classType, this);
41186
+ }
41187
+ }
41188
+ static() {
41189
+ return this.constructor;
41190
+ }
41191
+ }
40892
41192
  class AccessoryWrapper extends InstanceWrapper {
40893
41193
  static className = "Accessory";
40894
41194
  static requiredProperties = [
@@ -40948,6 +41248,10 @@ class AccessoryWrapper extends InstanceWrapper {
40948
41248
  }
40949
41249
  }
40950
41250
  }
41251
+ const __vite_glob_0_0$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
41252
+ __proto__: null,
41253
+ AccessoryWrapper
41254
+ }, Symbol.toStringTag, { value: "Module" }));
40951
41255
  class AnimationConstraintWrapper extends InstanceWrapper {
40952
41256
  static className = "AnimationConstraint";
40953
41257
  static requiredProperties = [
@@ -40963,6 +41267,10 @@ class AnimationConstraintWrapper extends InstanceWrapper {
40963
41267
  if (!this.instance.HasProperty("Transform")) this.instance.addProperty(new Property("Transform", DataType.CFrame), new CFrame());
40964
41268
  }
40965
41269
  }
41270
+ const __vite_glob_0_2$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
41271
+ __proto__: null,
41272
+ AnimationConstraintWrapper
41273
+ }, Symbol.toStringTag, { value: "Module" }));
40966
41274
  const originalPositionName = "OriginalPosition";
40967
41275
  const originalOrientationName = "OriginalOrientation";
40968
41276
  const originalSizeName = "OriginalSize";
@@ -41098,7 +41406,7 @@ const SCALE_Wide_R15 = {
41098
41406
  function GetCharacterParts(rig) {
41099
41407
  const characterParts = [];
41100
41408
  for (const item of rig.GetChildren()) {
41101
- if (item.className === "MeshPart" || item.className === "Part") {
41409
+ if (item.createWrapper()?.IsA("BasePart")) {
41102
41410
  characterParts.push(item);
41103
41411
  }
41104
41412
  }
@@ -42551,6 +42859,23 @@ function buildCube(x, y, z) {
42551
42859
  addQuad(mesh, totalVerts, totalFaces, [x, y, z], [x, y, -z], [x, -y, -z], [x, -y, z], [1, 0, 0], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42552
42860
  return mesh;
42553
42861
  }
42862
+ function buildWedge(x, y, z) {
42863
+ const mesh = new FileMesh();
42864
+ mesh.coreMesh.increaseVerts(3 * 2 * 5);
42865
+ mesh.coreMesh.increaseFaces(2 * 5);
42866
+ let totalVerts = 0;
42867
+ let totalFaces = 0;
42868
+ totalVerts = addQuad(mesh, totalVerts, totalFaces, [-x, -y, -z], [x, -y, -z], [x, y, z], [-x, y, z], [0, 1, 0], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42869
+ totalFaces += 2;
42870
+ totalVerts = addQuad(mesh, totalVerts, totalFaces, [-x, -y, z], [x, -y, z], [x, -y, -z], [-x, -y, -z], [0, -1, 0], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42871
+ totalFaces += 2;
42872
+ totalVerts = addQuad(mesh, totalVerts, totalFaces, [-x, y, z], [x, y, z], [x, -y, z], [-x, -y, z], [0, 0, 1], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42873
+ totalFaces += 2;
42874
+ totalVerts = addQuad(mesh, totalVerts, totalFaces, [-x, -y, -z], [-x, y, z], [-x, -y, z], [-x, -y, -z], [-1, 0, 0], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42875
+ totalFaces += 2;
42876
+ addQuad(mesh, totalVerts, totalFaces, [x, y, z], [x, -y, -z], [x, -y, -z], [x, -y, z], [1, 0, 0], void 0, void 0, void 0, [0, 0], [1, 0], [1, 1], [0, 1]);
42877
+ return mesh;
42878
+ }
42554
42879
  const HSR_CACHE = /* @__PURE__ */ new Map();
42555
42880
  function doHSR(totalUvToHits, targetCage, mesh, moveVerts = true, cacheStr) {
42556
42881
  let closestVertIndexArr = void 0;
@@ -42684,6 +43009,7 @@ class MeshDesc {
42684
43009
  //size: Vector3 = new Vector3(1,1,1)
42685
43010
  scaleIsRelative = false;
42686
43011
  mesh;
43012
+ shape = "block";
42687
43013
  canHaveSkinning = true;
42688
43014
  forceVertexColor;
42689
43015
  //layering
@@ -42712,7 +43038,7 @@ class MeshDesc {
42712
43038
  isSame(other) {
42713
43039
  const singularTrue = (
42714
43040
  //this.size.isSame(other.size) &&
42715
- this.scaleIsRelative === other.scaleIsRelative && this.mesh === other.mesh && this.canHaveSkinning === other.canHaveSkinning && this.headMesh === other.headMesh && this.wrapTextureTarget === other.wrapTextureTarget
43041
+ this.scaleIsRelative === other.scaleIsRelative && this.mesh === other.mesh && this.canHaveSkinning === other.canHaveSkinning && this.headMesh === other.headMesh && this.wrapTextureTarget === other.wrapTextureTarget && this.shape === other.shape
42716
43042
  );
42717
43043
  if (!singularTrue) {
42718
43044
  return singularTrue;
@@ -43009,7 +43335,7 @@ class MeshDesc {
43009
43335
  }
43010
43336
  }
43011
43337
  }
43012
- async compileMesh() {
43338
+ async getMesh() {
43013
43339
  let mesh = void 0;
43014
43340
  const meshToLoad = this.mesh;
43015
43341
  if (meshToLoad) {
@@ -43019,8 +43345,22 @@ class MeshDesc {
43019
43345
  return mesh;
43020
43346
  }
43021
43347
  } else {
43022
- mesh = buildCube(0.5, 0.5, 0.5);
43348
+ switch (this.shape) {
43349
+ case "wedge":
43350
+ mesh = buildWedge(0.5, 0.5, 0.5);
43351
+ break;
43352
+ case "block":
43353
+ default:
43354
+ mesh = buildCube(0.5, 0.5, 0.5);
43355
+ break;
43356
+ }
43023
43357
  }
43358
+ return mesh;
43359
+ }
43360
+ async compileMesh() {
43361
+ let mesh = void 0;
43362
+ mesh = await this.getMesh();
43363
+ if (mesh instanceof Response) return mesh;
43024
43364
  if (!mesh.facs && this.headMesh && mesh.skinning.skinnings.length > 0) {
43025
43365
  const headMesh = await API.Asset.GetMesh(this.headMesh, void 0, true);
43026
43366
  if (headMesh instanceof Response) {
@@ -43056,9 +43396,6 @@ class MeshDesc {
43056
43396
  return threeMesh;
43057
43397
  }
43058
43398
  fromInstance(child) {
43059
- if (!ObjectDescClassTypes.includes(child.className)) {
43060
- return;
43061
- }
43062
43399
  this.instance = child;
43063
43400
  const wrapTextureTransfer = child.FindFirstChildOfClass("WrapTextureTransfer");
43064
43401
  let toUse = child;
@@ -43069,6 +43406,7 @@ class MeshDesc {
43069
43406
  this.fromWrapTextureTransfer(wrapTextureTransfer);
43070
43407
  }
43071
43408
  switch (toUse.className) {
43409
+ case "WedgePart":
43072
43410
  case "Part": {
43073
43411
  this.fromPart(toUse);
43074
43412
  break;
@@ -43084,6 +43422,7 @@ class MeshDesc {
43084
43422
  }
43085
43423
  fromPart(child) {
43086
43424
  this.canHaveSkinning = false;
43425
+ if (child.className === "WedgePart") this.shape = "wedge";
43087
43426
  const specialMesh = child.FindFirstChildOfClass("SpecialMesh");
43088
43427
  if (specialMesh) {
43089
43428
  switch (specialMesh.Property("MeshType")) {
@@ -43820,8 +44159,8 @@ class MaterialDesc {
43820
44159
  }
43821
44160
  break;
43822
44161
  case "Decal":
43823
- if (meshDesc.mesh && meshDesc.mesh.length > 0) {
43824
- const result = await API.Asset.GetMesh(meshDesc.mesh, void 0);
44162
+ {
44163
+ const result = await meshDesc.getMesh();
43825
44164
  if (result instanceof FileMesh) {
43826
44165
  const size = result.size;
43827
44166
  const geometry = fileMeshToTHREEGeometry(result);
@@ -43877,7 +44216,6 @@ class MaterialDesc {
43877
44216
  }
43878
44217
  }
43879
44218
  break;
43880
- //TODO: Decal
43881
44219
  default:
43882
44220
  composeInsts.push(await TextureComposer.simpleMesh(
43883
44221
  "CompositQuad",
@@ -44225,10 +44563,55 @@ class MaterialDesc {
44225
44563
  this.layers.push(tShirtLayer);
44226
44564
  }
44227
44565
  }
44228
- fromInstance(child) {
44229
- if (!ObjectDescClassTypes.includes(child.className)) {
44230
- return;
44566
+ addDecals(child, defaultUVType = "Decal", needsWrapTextureTranfer = false) {
44567
+ const decalsFound = [];
44568
+ const decals = child.GetChildren();
44569
+ for (const decal of decals) {
44570
+ if (decal.className === "Decal" && (!needsWrapTextureTranfer || decal.FindFirstChildOfClass("WrapTextureTransfer"))) {
44571
+ const decalTexture = decal.Property("Texture");
44572
+ const metallnessMap = decal.HasProperty("MetalnessMap") ? decal.Prop("MetalnessMap") : void 0;
44573
+ const normalMap = decal.HasProperty("NormalMap") ? decal.Prop("NormalMap") : void 0;
44574
+ const roughnessMap = decal.HasProperty("RoughnessMap") ? decal.Prop("RoughnessMap") : void 0;
44575
+ const decalLayer = new TextureLayer();
44576
+ decalLayer.color = decalTexture;
44577
+ if (metallnessMap instanceof Content) {
44578
+ decalLayer.metalness = metallnessMap?.uri;
44579
+ } else {
44580
+ decalLayer.metalness = metallnessMap;
44581
+ }
44582
+ if (normalMap instanceof Content) {
44583
+ decalLayer.normal = normalMap?.uri;
44584
+ } else {
44585
+ decalLayer.normal = normalMap;
44586
+ }
44587
+ if (roughnessMap instanceof Content) {
44588
+ decalLayer.roughness = roughnessMap?.uri;
44589
+ } else {
44590
+ decalLayer.roughness = roughnessMap;
44591
+ }
44592
+ if (child.Prop("Name") === "Head" && isAffectedByHumanoid(child)) {
44593
+ decalLayer.uvType = "Normal";
44594
+ this.canHaveMipmaps = false;
44595
+ } else {
44596
+ decalLayer.uvType = defaultUVType;
44597
+ decalLayer.face = decal.Prop("Face");
44598
+ }
44599
+ let ZIndex = 1;
44600
+ if (decal.HasProperty("ZIndex")) {
44601
+ ZIndex = decal.Prop("ZIndex");
44602
+ }
44603
+ decalsFound.push([ZIndex, decalLayer]);
44604
+ }
44605
+ }
44606
+ decalsFound.sort((a, b) => {
44607
+ return a[0] - b[0];
44608
+ });
44609
+ for (const decalFound of decalsFound) {
44610
+ this.layers.push(decalFound[1]);
44231
44611
  }
44612
+ return decalsFound;
44613
+ }
44614
+ fromInstance(child) {
44232
44615
  if (child.HasProperty("Transparency")) {
44233
44616
  const transparency = child.Prop("Transparency");
44234
44617
  if (transparency !== 0) {
@@ -44246,6 +44629,7 @@ class MaterialDesc {
44246
44629
  }
44247
44630
  }
44248
44631
  switch (child.className) {
44632
+ case "WedgePart":
44249
44633
  case "Part": {
44250
44634
  this.fromPart(child);
44251
44635
  break;
@@ -44281,6 +44665,10 @@ class MaterialDesc {
44281
44665
  } else if (specialMesh.Prop("TextureId").length > 0 && this.transparency === 0) {
44282
44666
  const colorLayer2 = new ColorLayer(new Color3(1, 1, 1));
44283
44667
  this.layers.push(colorLayer2);
44668
+ } else if (specialMesh.Prop("TextureId").length <= 0) {
44669
+ const partColor = child.Prop("Color").toColor3();
44670
+ const colorLayer2 = new ColorLayer(partColor);
44671
+ this.layers.push(colorLayer2);
44284
44672
  }
44285
44673
  const colorLayer = new TextureLayer();
44286
44674
  colorLayer.color = specialMesh.Property("TextureId");
@@ -44295,46 +44683,7 @@ class MaterialDesc {
44295
44683
  }
44296
44684
  }
44297
44685
  if (specialMesh.Prop("TextureId").length < 1 || !isAffectedByHumanoid(child)) {
44298
- const decalsFound = [];
44299
- const decals = child.GetChildren();
44300
- for (const decal of decals) {
44301
- if (decal.className === "Decal") {
44302
- const decalTexture = decal.Property("Texture");
44303
- const metallnessMap = decal.HasProperty("MetalnessMap") ? decal.Prop("MetalnessMap") : void 0;
44304
- const normalMap = decal.HasProperty("NormalMap") ? decal.Prop("NormalMap") : void 0;
44305
- const roughnessMap = decal.HasProperty("RoughnessMap") ? decal.Prop("RoughnessMap") : void 0;
44306
- const decalLayer = new TextureLayer();
44307
- decalLayer.color = decalTexture;
44308
- if (metallnessMap instanceof Content) {
44309
- decalLayer.metalness = metallnessMap?.uri;
44310
- } else {
44311
- decalLayer.metalness = metallnessMap;
44312
- }
44313
- if (normalMap instanceof Content) {
44314
- decalLayer.normal = normalMap?.uri;
44315
- } else {
44316
- decalLayer.normal = normalMap;
44317
- }
44318
- if (roughnessMap instanceof Content) {
44319
- decalLayer.roughness = roughnessMap?.uri;
44320
- } else {
44321
- decalLayer.roughness = roughnessMap;
44322
- }
44323
- decalLayer.uvType = "Normal";
44324
- this.canHaveMipmaps = false;
44325
- let ZIndex = 1;
44326
- if (decal.HasProperty("ZIndex")) {
44327
- ZIndex = decal.Prop("ZIndex");
44328
- }
44329
- decalsFound.push([ZIndex, decalLayer]);
44330
- }
44331
- }
44332
- decalsFound.sort((a, b) => {
44333
- return a[0] - b[0];
44334
- });
44335
- for (const decalFound of decalsFound) {
44336
- this.layers.push(decalFound[1]);
44337
- }
44686
+ if (this.addDecals(child, "Normal").length > 0) this.canHaveMipmaps = false;
44338
44687
  }
44339
44688
  } else {
44340
44689
  const affectedByHumanoid = isAffectedByHumanoid(child);
@@ -44384,6 +44733,7 @@ class MaterialDesc {
44384
44733
  const partColor = child.Prop("Color").toColor3();
44385
44734
  const colorLayer = new ColorLayer(partColor);
44386
44735
  this.layers.push(colorLayer);
44736
+ if (this.addDecals(child).length > 0) this.canHaveMipmaps = false;
44387
44737
  }
44388
44738
  }
44389
44739
  }
@@ -44446,96 +44796,14 @@ class MaterialDesc {
44446
44796
  this.layers.push(textureLayer);
44447
44797
  }
44448
44798
  if (meshPartTexture.length < 1 && !surfaceAppearance || !isAffectedByHumanoid(child)) {
44449
- const decalsFound = [];
44450
- const decals = child.GetChildren();
44451
- for (const decal of decals) {
44452
- if (decal.className === "Decal" && !decal.FindFirstChildOfClass("WrapTextureTransfer")) {
44453
- const decalTexture = decal.Property("Texture");
44454
- const metallnessMap = decal.HasProperty("MetalnessMap") ? decal.Prop("MetalnessMap") : void 0;
44455
- const normalMap = decal.HasProperty("NormalMap") ? decal.Prop("NormalMap") : void 0;
44456
- const roughnessMap = decal.HasProperty("RoughnessMap") ? decal.Prop("RoughnessMap") : void 0;
44457
- const decalLayer = new TextureLayer();
44458
- decalLayer.color = decalTexture;
44459
- if (metallnessMap instanceof Content) {
44460
- decalLayer.metalness = metallnessMap?.uri;
44461
- } else {
44462
- decalLayer.metalness = metallnessMap;
44463
- }
44464
- if (normalMap instanceof Content) {
44465
- decalLayer.normal = normalMap?.uri;
44466
- } else {
44467
- decalLayer.normal = normalMap;
44468
- }
44469
- if (roughnessMap instanceof Content) {
44470
- decalLayer.roughness = roughnessMap?.uri;
44471
- } else {
44472
- decalLayer.roughness = roughnessMap;
44473
- }
44474
- if (child.Prop("Name") === "Head" && isAffectedByHumanoid(child)) {
44475
- decalLayer.uvType = "Normal";
44476
- this.canHaveMipmaps = false;
44477
- } else {
44478
- decalLayer.uvType = "Decal";
44479
- decalLayer.face = decal.Prop("Face");
44480
- }
44481
- let ZIndex = 1;
44482
- if (decal.HasProperty("ZIndex")) {
44483
- ZIndex = decal.Prop("ZIndex");
44484
- }
44485
- decalsFound.push([ZIndex, decalLayer]);
44486
- }
44487
- }
44488
- decalsFound.sort((a, b) => {
44489
- return a[0] - b[0];
44490
- });
44491
- for (const decalFound of decalsFound) {
44492
- this.layers.push(decalFound[1]);
44493
- }
44799
+ this.addDecals(child);
44494
44800
  }
44495
44801
  }
44496
44802
  fromDecal(child) {
44497
44803
  this.isDecal = true;
44498
44804
  this.transparent = true;
44499
44805
  if (child.parent) {
44500
- const decalsFound = [];
44501
- const decals = child.parent.GetChildren();
44502
- for (const decal of decals) {
44503
- if (decal.className === "Decal" && decal.FindFirstChildOfClass("WrapTextureTransfer")) {
44504
- const decalTexture = decal.Property("Texture");
44505
- const metallnessMap = decal.HasProperty("MetalnessMap") ? decal.Prop("MetalnessMap") : void 0;
44506
- const normalMap = decal.HasProperty("NormalMap") ? decal.Prop("NormalMap") : void 0;
44507
- const roughnessMap = decal.HasProperty("RoughnessMap") ? decal.Prop("RoughnessMap") : void 0;
44508
- const decalLayer = new TextureLayer();
44509
- decalLayer.color = decalTexture;
44510
- if (metallnessMap instanceof Content) {
44511
- decalLayer.metalness = metallnessMap?.uri;
44512
- } else {
44513
- decalLayer.metalness = metallnessMap;
44514
- }
44515
- if (normalMap instanceof Content) {
44516
- decalLayer.normal = normalMap?.uri;
44517
- } else {
44518
- decalLayer.normal = normalMap;
44519
- }
44520
- if (roughnessMap instanceof Content) {
44521
- decalLayer.roughness = roughnessMap?.uri;
44522
- } else {
44523
- decalLayer.roughness = roughnessMap;
44524
- }
44525
- decalLayer.uvType = "Normal";
44526
- let ZIndex = 1;
44527
- if (decal.HasProperty("ZIndex")) {
44528
- ZIndex = decal.Prop("ZIndex");
44529
- }
44530
- decalsFound.push([ZIndex, decalLayer]);
44531
- }
44532
- }
44533
- decalsFound.sort((a, b) => {
44534
- return a[0] - b[0];
44535
- });
44536
- for (const decalFound of decalsFound) {
44537
- this.layers.push(decalFound[1]);
44538
- }
44806
+ this.addDecals(child.parent, "Normal", true);
44539
44807
  }
44540
44808
  }
44541
44809
  }
@@ -44551,74 +44819,10 @@ class FaceControlsWrapper extends InstanceWrapper {
44551
44819
  }
44552
44820
  }
44553
44821
  }
44554
- function setTHREEObjectCF(threeObject, cframe) {
44555
- threeObject.position.set(cframe.Position[0], cframe.Position[1], cframe.Position[2]);
44556
- threeObject.rotation.order = "YXZ";
44557
- threeObject.rotation.x = rad(cframe.Orientation[0]);
44558
- threeObject.rotation.y = rad(cframe.Orientation[1]);
44559
- threeObject.rotation.z = rad(cframe.Orientation[2]);
44560
- }
44561
- class DisposableDesc {
44562
- disposeMesh(scene, mesh) {
44563
- disposeMesh(scene, mesh);
44564
- }
44565
- disposeMeshes(scene, meshes) {
44566
- for (const mesh of meshes) {
44567
- this.disposeMesh(scene, mesh);
44568
- }
44569
- }
44570
- disposeRenderLists(renderer) {
44571
- renderer.renderLists.dispose();
44572
- }
44573
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44574
- dispose(_renderer, _scene) {
44575
- throw new Error("Virtual method dispose called");
44576
- }
44577
- }
44578
- class RenderDesc extends DisposableDesc {
44579
- renderScene;
44580
- results;
44581
- instance;
44582
- constructor(renderScene) {
44583
- super();
44584
- this.renderScene = renderScene;
44585
- }
44586
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44587
- isSame(_other) {
44588
- throw new Error("Virtual method isSame called");
44589
- }
44590
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44591
- needsRegeneration(_other) {
44592
- throw new Error("Virtual method needsRegeneration called");
44593
- }
44594
- fromRenderDesc(other) {
44595
- if (this.needsRegeneration(other)) {
44596
- throw new Error("These RenderableDesc objects have differences that require recompilation");
44597
- }
44598
- this.virtualFromRenderDesc(other);
44599
- }
44600
- transferFrom(other) {
44601
- this.virtualTransferFrom(other);
44602
- }
44603
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44604
- virtualTransferFrom(_other) {
44605
- }
44606
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44607
- virtualFromRenderDesc(_other) {
44608
- throw new Error("Virtual method virtualFromRenderDesc called");
44609
- }
44610
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44611
- fromInstance(_child) {
44612
- throw new Error("Virtual method fromInstance called");
44613
- }
44614
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
44615
- async compileResults(_renderer, _scene) {
44616
- throw new Error("Virtual method compileResults called");
44617
- }
44618
- updateResults() {
44619
- throw new Error("Virtual method updateResults called");
44620
- }
44621
- }
44822
+ const __vite_glob_0_9 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
44823
+ __proto__: null,
44824
+ FaceControlsWrapper
44825
+ }, Symbol.toStringTag, { value: "Module" }));
44622
44826
  const BaseR15Bones = ["Root", "HumanoidRootNode", "LowerTorso", "UpperTorso", "RightUpperArm", "RightLowerArm", "RightHand", "LeftUpperArm", "LeftLowerArm", "LeftHand", "Head", "DynamicHead"];
44623
44827
  function getJointForInstances$1(parent, child, includeTransform) {
44624
44828
  const childMotor = child.FindFirstChildOfClass("Motor6D");
@@ -45346,7 +45550,10 @@ class SkeletonDesc2 {
45346
45550
  return meshDesc.canHaveSkinning && meshDesc.fileMesh && meshDesc.fileMesh.skinning && meshDesc.fileMesh.skinning.subsets.length > 0 && meshDesc.fileMesh.skinning.skinnings.length > 0;
45347
45551
  }
45348
45552
  }
45553
+ const PartTypes = ["Part", "WedgePart"];
45554
+ const MeshPartTypes = ["MeshPart"];
45349
45555
  class ObjectDesc extends RenderDesc {
45556
+ static classTypes = ["Part", "WedgePart", "MeshPart", "Decal"];
45350
45557
  cframe = new CFrame();
45351
45558
  size = new Vector32(1, 1, 1);
45352
45559
  meshDesc = new MeshDesc();
@@ -45375,8 +45582,8 @@ class ObjectDesc extends RenderDesc {
45375
45582
  fromInstance(child) {
45376
45583
  this.instance = child;
45377
45584
  let part = child;
45378
- if (part.className !== "Part" && part.className !== "MeshPart") {
45379
- if (part.parent && (part.parent.className === "Part" || part.parent.className === "MeshPart")) {
45585
+ if (!PartTypes.includes(part.className) && !MeshPartTypes.includes(part.className)) {
45586
+ if (part.parent && (PartTypes.includes(part.parent.className) || MeshPartTypes.includes(part.parent.className))) {
45380
45587
  part = part.parent;
45381
45588
  } else {
45382
45589
  part = void 0;
@@ -45400,6 +45607,7 @@ class ObjectDesc extends RenderDesc {
45400
45607
  }
45401
45608
  if (part) {
45402
45609
  switch (part.className) {
45610
+ case "WedgePart":
45403
45611
  case "Part": {
45404
45612
  if (!isAffectedByHumanoid(part)) this.size = part.PropOrDefault("Size", this.size);
45405
45613
  const specialMesh = part.FindFirstChildOfClass("SpecialMesh");
@@ -45553,7 +45761,27 @@ class ObjectDesc extends RenderDesc {
45553
45761
  }
45554
45762
  }
45555
45763
  }
45764
+ static shouldRenderInstance(instance) {
45765
+ const isDecal = instance.className === "Decal";
45766
+ const isBakedDecal = isDecal && !instance.FindFirstChildOfClass("WrapTextureTransfer");
45767
+ let isFirstDecal = true;
45768
+ if (isDecal && instance.parent) {
45769
+ const children = instance.parent.GetChildren();
45770
+ for (const child of children) {
45771
+ if (child.className === "Decal" && child.FindFirstChildOfClass("WrapTextureTransfer") && child.id < instance.id) {
45772
+ isFirstDecal = false;
45773
+ }
45774
+ }
45775
+ }
45776
+ return !isBakedDecal && (!isDecal || isFirstDecal);
45777
+ }
45556
45778
  }
45779
+ const __vite_glob_0_3$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45780
+ __proto__: null,
45781
+ MeshPartTypes,
45782
+ ObjectDesc,
45783
+ PartTypes
45784
+ }, Symbol.toStringTag, { value: "Module" }));
45557
45785
  class FXAAPass extends ShaderPass {
45558
45786
  /**
45559
45787
  * Constructs a new FXAA pass.
@@ -45571,1191 +45799,505 @@ class FXAAPass extends ShaderPass {
45571
45799
  this.material.uniforms["resolution"].value.set(1 / width, 1 / height);
45572
45800
  }
45573
45801
  }
45574
- const particle_vertexShader = `
45575
- attribute vec3 instanceColor;
45576
- attribute vec2 instanceSeedTime;
45577
- attribute float instanceOpacity;
45578
-
45579
- varying vec2 vUv;
45580
- varying vec3 vInstanceColor;
45581
- varying float vInstanceOpacity;
45582
- varying vec2 vInstanceSeedTime;
45583
-
45584
- uniform float uZOffset;
45585
-
45586
- void main() {
45587
- vUv = uv;
45588
- vInstanceColor = instanceColor;
45589
- vInstanceOpacity = instanceOpacity;
45590
- vInstanceSeedTime = instanceSeedTime;
45591
-
45592
- vec4 modelViewPosition = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
45593
- modelViewPosition.z += uZOffset;
45594
-
45595
- gl_Position = projectionMatrix * modelViewPosition;
45802
+ class AccessoryDescriptionWrapper extends InstanceWrapper {
45803
+ static className = "AccessoryDescription";
45804
+ static requiredProperties = [
45805
+ "Name",
45806
+ "AssetId",
45807
+ "AccessoryType",
45808
+ "IsLayered",
45809
+ "Puffiness",
45810
+ "Order",
45811
+ "Position",
45812
+ "Rotation",
45813
+ "Scale",
45814
+ "Instance"
45815
+ ];
45816
+ setup() {
45817
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
45818
+ if (!this.instance.HasProperty("AssetId")) this.instance.addProperty(new Property("AssetId", DataType.Int64), 0n);
45819
+ if (!this.instance.HasProperty("AccessoryType")) this.instance.addProperty(new Property("AccessoryType", DataType.Enum), AccessoryType.Unknown);
45820
+ if (!this.instance.HasProperty("IsLayered")) this.instance.addProperty(new Property("IsLayered", DataType.Bool), false);
45821
+ if (!this.instance.HasProperty("Puffiness")) this.instance.addProperty(new Property("Puffiness", DataType.Float32), 1);
45822
+ if (!this.instance.HasProperty("Order")) this.instance.addProperty(new Property("Order", DataType.Int32), 1);
45823
+ if (!this.instance.HasProperty("Position")) this.instance.addProperty(new Property("Position", DataType.Vector3), new Vector32(0, 0, 0));
45824
+ if (!this.instance.HasProperty("Rotation")) this.instance.addProperty(new Property("Rotation", DataType.Vector3), new Vector32(0, 0, 0));
45825
+ if (!this.instance.HasProperty("Scale")) this.instance.addProperty(new Property("Scale", DataType.Vector3), new Vector32(1, 1, 1));
45826
+ if (!this.instance.HasProperty("Instance")) this.instance.addProperty(new Property("Instance", DataType.Referent), void 0);
45827
+ }
45596
45828
  }
45597
- `;
45598
- const particle_fragmentShader = `
45599
- varying vec2 vUv;
45600
- varying vec3 vInstanceColor;
45601
- varying float vInstanceOpacity;
45602
- varying vec2 vInstanceSeedTime;
45603
-
45604
- uniform sampler2D uColorMap;
45605
- uniform sampler2D uAlphaMap;
45606
- uniform sampler2D uMap;
45607
- uniform float uOpacity;
45608
-
45609
- void main() {
45610
- float seed = vInstanceSeedTime.x;
45611
- float time = vInstanceSeedTime.y;
45612
-
45613
- // Sample the texture using the UV coordinates
45614
- vec4 texColor = texture2D(uMap, vUv);
45615
- vec4 alphaTex = texture2D(uAlphaMap, vec2(time, seed));
45616
- vec4 colorTex = texture2D(uColorMap, vec2(time, seed));
45617
-
45618
- // Tint texture with our color
45619
- vec4 tintedColor = texColor * vec4(vInstanceColor, 1.0);
45620
-
45621
- // Apply opacity to the texture alpha
45622
- vec4 opacityColor = tintedColor * vec4(1.0, 1.0, 1.0, uOpacity * vInstanceOpacity) * alphaTex.r;
45623
-
45624
- // Apply that weird color things sparkles have
45625
- vec4 finalColor = opacityColor;
45626
- finalColor.rgb = mix(opacityColor.rgb, opacityColor.rgb * colorTex.rgb, colorTex.a);
45627
-
45628
- gl_FragColor = finalColor;
45829
+ const __vite_glob_0_1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
45830
+ __proto__: null,
45831
+ AccessoryDescriptionWrapper
45832
+ }, Symbol.toStringTag, { value: "Module" }));
45833
+ const AnimationPriority = {
45834
+ "Core": 1e3
45835
+ };
45836
+ const EasingDirection = {
45837
+ "In": 0,
45838
+ "Out": 1,
45839
+ "InOut": 2
45840
+ };
45841
+ const PoseEasingStyle = {
45842
+ "Linear": 0,
45843
+ "Constant": 1,
45844
+ "Elastic": 2,
45845
+ "Cubic": 3,
45846
+ "Bounce": 4,
45847
+ "CubicV2": 5
45848
+ };
45849
+ const KeyInterpolationMode = {
45850
+ "Constant": 0,
45851
+ "Linear": 1,
45852
+ "Cubic": 2
45853
+ };
45854
+ const RotationOrder = {
45855
+ "XYZ": 0
45856
+ };
45857
+ const RotationOrderToRotationOrderName = {
45858
+ 0: "XYZ",
45859
+ 1: "XZY",
45860
+ 2: "YZX",
45861
+ 3: "YXZ",
45862
+ 4: "ZXY",
45863
+ 5: "ZYX"
45864
+ };
45865
+ function easeLinear(x) {
45866
+ return x;
45629
45867
  }
45630
- `;
45631
- function randomBetween(min, max) {
45632
- return Math.random() * (max - min) + min;
45868
+ function easeConstant(x) {
45869
+ return x * 0;
45633
45870
  }
45634
- function velocityFromSpread(speed, spread) {
45635
- const theta = spread.X;
45636
- const phi = spread.Y;
45637
- const velocity = new Vector32(
45638
- -speed * Math.sin(phi),
45639
- -speed * Math.cos(phi) * Math.sin(theta),
45640
- -speed * Math.cos(phi) * Math.cos(theta)
45641
- );
45642
- return velocity;
45871
+ function easeInElastic(x) {
45872
+ const c4 = 2 * Math.PI / 3;
45873
+ return x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4);
45643
45874
  }
45644
- class Particle {
45645
- lifetime;
45646
- time = 0;
45647
- position;
45648
- rotation;
45649
- velocity;
45650
- rotationSpeed;
45651
- seed = Math.random();
45652
- constructor(lifetime, position, rotation, velocity, rotationSpeed) {
45653
- this.lifetime = lifetime;
45654
- this.position = position;
45655
- this.rotation = rotation;
45656
- this.velocity = velocity;
45657
- this.rotationSpeed = rotationSpeed;
45875
+ function easeOutElastic(x) {
45876
+ const c4 = 2 * Math.PI / 3;
45877
+ return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
45878
+ }
45879
+ function easeInOutElastic(x) {
45880
+ const c5 = 2 * Math.PI / 4.5;
45881
+ return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
45882
+ }
45883
+ function easeInCubic(x) {
45884
+ return x * x * x;
45885
+ }
45886
+ function easeOutCubic(x) {
45887
+ return 1 - Math.pow(1 - x, 3);
45888
+ }
45889
+ function easeInOutCubic(x) {
45890
+ return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
45891
+ }
45892
+ function easeOutBounce(x) {
45893
+ const n1 = 7.5625;
45894
+ const d1 = 2.75;
45895
+ if (x < 1 / d1) {
45896
+ return n1 * x * x;
45897
+ } else if (x < 2 / d1) {
45898
+ return n1 * (x -= 1.5 / d1) * x + 0.75;
45899
+ } else if (x < 2.5 / d1) {
45900
+ return n1 * (x -= 2.25 / d1) * x + 0.9375;
45901
+ } else {
45902
+ return n1 * (x -= 2.625 / d1) * x + 0.984375;
45658
45903
  }
45659
- camDistance(renderScene) {
45660
- const cameraPos = new Vector32(...renderScene.camera.position.toArray());
45661
- const particlePos = this.position;
45662
- const distance2 = cameraPos.minus(particlePos).magnitude();
45663
- return distance2;
45904
+ }
45905
+ function easeInBounce(x) {
45906
+ return 1 - easeOutBounce(1 - x);
45907
+ }
45908
+ function easeInOutBounce(x) {
45909
+ return x < 0.5 ? (1 - easeOutBounce(1 - 2 * x)) / 2 : (1 + easeOutBounce(2 * x - 1)) / 2;
45910
+ }
45911
+ const PartToMotorName = {
45912
+ "Head": "Neck",
45913
+ "UpperTorso": "Waist",
45914
+ "LowerTorso": "Root",
45915
+ "RightFoot": "RightAnkle",
45916
+ "RightLowerLeg": "RightKnee",
45917
+ "RightUpperLeg": "RightHip",
45918
+ "LeftFoot": "LeftAnkle",
45919
+ "LeftLowerLeg": "LeftKnee",
45920
+ "LeftUpperLeg": "LeftHip",
45921
+ "RightHand": "RightWrist",
45922
+ "RightLowerArm": "RightElbow",
45923
+ "RightUpperArm": "RightShoulder",
45924
+ "LeftHand": "LeftWrist",
45925
+ "LeftLowerArm": "LeftElbow",
45926
+ "LeftUpperArm": "LeftShoulder"
45927
+ };
45928
+ const EasingFunctionMap = {
45929
+ [EasingDirection.In]: {
45930
+ [PoseEasingStyle.Linear]: easeLinear,
45931
+ [PoseEasingStyle.Constant]: easeConstant,
45932
+ [PoseEasingStyle.Elastic]: easeInElastic,
45933
+ [PoseEasingStyle.Cubic]: easeInCubic,
45934
+ [PoseEasingStyle.Bounce]: easeInBounce,
45935
+ [PoseEasingStyle.CubicV2]: easeInCubic
45936
+ },
45937
+ [EasingDirection.Out]: {
45938
+ [PoseEasingStyle.Linear]: easeLinear,
45939
+ [PoseEasingStyle.Constant]: easeConstant,
45940
+ [PoseEasingStyle.Elastic]: easeOutElastic,
45941
+ [PoseEasingStyle.Cubic]: easeOutCubic,
45942
+ [PoseEasingStyle.Bounce]: easeOutBounce,
45943
+ [PoseEasingStyle.CubicV2]: easeOutCubic
45944
+ },
45945
+ [EasingDirection.InOut]: {
45946
+ [PoseEasingStyle.Linear]: easeLinear,
45947
+ [PoseEasingStyle.Constant]: easeConstant,
45948
+ [PoseEasingStyle.Elastic]: easeInOutElastic,
45949
+ [PoseEasingStyle.Cubic]: easeInOutCubic,
45950
+ [PoseEasingStyle.Bounce]: easeInOutBounce,
45951
+ [PoseEasingStyle.CubicV2]: easeInOutCubic
45664
45952
  }
45665
- getMatrix(renderScene, size, orientation) {
45666
- const camera = renderScene.camera;
45667
- const particlePos = new Vector3$1(...this.position.toVec3());
45668
- const translation = new Matrix4().makeTranslation(particlePos);
45669
- const scale = new Matrix4().makeScale(size, size, 1);
45670
- switch (orientation) {
45671
- case ParticleOrientation.FacingCameraWorldUp: {
45672
- const cameraLookVector = new Vector3$1();
45673
- camera.getWorldDirection(cameraLookVector);
45674
- const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), new Vector3$1(0, 1, 0), cameraLookVector);
45675
- const _pos = new Vector3$1();
45676
- const _scale = new Vector3$1();
45677
- const rotationQuat = new Quaternion();
45678
- rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
45679
- const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
45680
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
45681
- const offsetRotation = new Matrix4().makeRotationAxis(new Vector3$1(1, 0, 0), rad(-90));
45682
- const offset2Rotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 1, 0), rad(180));
45683
- const final = translation.multiply(rotation).multiply(offsetRotation).multiply(offset2Rotation).multiply(flatRotation).multiply(scale);
45684
- return final;
45685
- }
45686
- case ParticleOrientation.VelocityPerpendicular: {
45687
- const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
45688
- const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), normalizedVelocity, new Vector3$1(0, 1, 0));
45689
- const _pos = new Vector3$1();
45690
- const _scale = new Vector3$1();
45691
- const rotationQuat = new Quaternion();
45692
- rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
45693
- const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
45694
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
45695
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
45696
- return final;
45697
- }
45698
- case ParticleOrientation.VelocityParallel: {
45699
- const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
45700
- const rotationParticlePosMatrix = new Matrix4().lookAt(particlePos, camera.position, normalizedVelocity);
45701
- const _pos = new Vector3$1();
45702
- const _scale = new Vector3$1();
45703
- const rotationQuat = new Quaternion();
45704
- rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
45705
- const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
45706
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation + 90));
45707
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
45708
- return final;
45709
- }
45710
- case ParticleOrientation.FacingCamera:
45711
- default: {
45712
- const rotation = new Matrix4().makeRotationFromQuaternion(camera.quaternion);
45713
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
45714
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
45715
- return final;
45716
- }
45717
- }
45953
+ };
45954
+ function getEasingFunction(easingDirection, easingStyle) {
45955
+ const func = EasingFunctionMap[easingDirection][easingStyle];
45956
+ if (!func) {
45957
+ throw new Error(`No function equivalent for easingStyle: ${easingStyle}`);
45718
45958
  }
45719
- tick(dt, drag, acceleration) {
45720
- this.time += specialClamp(dt, 0, this.lifetime);
45721
- this.position = this.position.add(this.velocity.multiply(new Vector32(dt, dt, dt)));
45722
- const accMult = 0.5 * Math.pow(dt, 2);
45723
- this.position = this.position.add(acceleration.multiply(new Vector32(accMult, accMult, accMult)));
45724
- this.velocity = this.velocity.add(acceleration.multiply(new Vector32(dt, dt, dt)));
45725
- const dragVal = Math.pow(2, -drag * dt);
45726
- this.velocity = this.velocity.multiply(new Vector32(dragVal, dragVal, dragVal));
45727
- this.rotation += this.rotationSpeed * dt;
45959
+ return func;
45960
+ }
45961
+ function h00(t) {
45962
+ return 2 * Math.pow(t, 3) - 3 * Math.pow(t, 2) + 1;
45963
+ }
45964
+ function h10(t) {
45965
+ return Math.pow(t, 3) - 2 * Math.pow(t, 2) + t;
45966
+ }
45967
+ function h01(t) {
45968
+ return -2 * Math.pow(t, 3) + 3 * Math.pow(t, 2);
45969
+ }
45970
+ function h11(t) {
45971
+ return Math.pow(t, 3) - Math.pow(t, 2);
45972
+ }
45973
+ function p(t, p0, p1, m0, m1, xk, xk1) {
45974
+ return h00(t) * p0 + h10(t) * (xk1 - xk) * m0 + h01(t) * p1 + h11(t) * (xk1 - xk) * m1;
45975
+ }
45976
+ function lerpCFrame(oldCFrame, newCFrame, easedTime) {
45977
+ const oldPos = oldCFrame.Position;
45978
+ const oldRot = oldCFrame.Orientation;
45979
+ const newPos = newCFrame.Position;
45980
+ const newRot = newCFrame.Orientation;
45981
+ const oldEuler = new Euler(rad(oldRot[0]), rad(oldRot[1]), rad(oldRot[2]), "YXZ");
45982
+ const oldQuat = new Quaternion().setFromEuler(oldEuler);
45983
+ const newEuler = new Euler(rad(newRot[0]), rad(newRot[1]), rad(newRot[2]), "YXZ");
45984
+ const newQuat = new Quaternion().setFromEuler(newEuler);
45985
+ const resultQuat = oldQuat.slerp(newQuat, easedTime);
45986
+ const resultEuler = new Euler().setFromQuaternion(resultQuat, "YXZ");
45987
+ const resultOrientation = [deg(resultEuler.x), deg(resultEuler.y), deg(resultEuler.z)];
45988
+ const resultX = lerp(oldPos[0], newPos[0], easedTime);
45989
+ const resultY = lerp(oldPos[1], newPos[1], easedTime);
45990
+ const resultZ = lerp(oldPos[2], newPos[2], easedTime);
45991
+ const resultCFrame = new CFrame(resultX, resultY, resultZ);
45992
+ resultCFrame.Orientation = resultOrientation;
45993
+ return resultCFrame;
45994
+ }
45995
+ class BaseKeyframe {
45996
+ time;
45997
+ easingDirection = EasingDirection.In;
45998
+ easingStyle = PoseEasingStyle.Linear;
45999
+ constructor(time2) {
46000
+ this.time = time2;
45728
46001
  }
45729
46002
  }
45730
- class EmitterDesc extends DisposableDesc {
45731
- passedTime = 0;
45732
- lockedToPart = false;
45733
- lifetime = new NumberRange(1, 1);
45734
- spreadAngle = new Vector22(0, 0);
45735
- speed = new NumberRange(1, 1);
45736
- rotation = new NumberRange(0, 0);
45737
- rotationSpeed = new NumberRange(0, 0);
45738
- localAcceleration = new Vector32(0, 0, 0);
45739
- acceleration = new Vector32(0, 0, 0);
45740
- drag = 0;
45741
- timeScale = 1;
45742
- orientation = ParticleOrientation.FacingCamera;
45743
- zOffset = 0;
45744
- offset = new Vector32();
45745
- shapeInOut = 0;
45746
- opacity = 1;
45747
- lightEmission = 1;
45748
- blending = AdditiveBlending;
45749
- color = new ColorSequence();
45750
- size = new NumberSequence();
45751
- transparency = new NumberSequence([new NumberSequenceKeypoint(0, 0, 0)]);
45752
- normalizeSizeKeypointTime = true;
45753
- //requires recompilation
45754
- rate = 10;
45755
- colorTexture;
45756
- alphaTexture;
45757
- texture;
45758
- //results
45759
- instanceOpacityBuffer;
45760
- instanceColorBuffer;
45761
- instanceSeedTimeBuffer;
45762
- result;
45763
- particles = [];
45764
- initialParticleCount = 0;
45765
- get maxCount() {
45766
- const calculatedMax = Math.max(Math.ceil(this.lifetime.Max * this.rate) * 2, 1);
45767
- const particleMax = this.initialParticleCount + calculatedMax;
45768
- return particleMax;
46003
+ class PartKeyframe extends BaseKeyframe {
46004
+ cframe;
46005
+ constructor(time2, cframe) {
46006
+ super(time2);
46007
+ this.cframe = cframe;
45769
46008
  }
45770
- needsRegeneration(other) {
45771
- return this.texture === other.texture && this.alphaTexture === other.alphaTexture && this.colorTexture === other.colorTexture && this.rate === other.rate;
46009
+ }
46010
+ class FaceKeyframe extends BaseKeyframe {
46011
+ value;
46012
+ constructor(time2, value) {
46013
+ super(time2);
46014
+ this.value = value;
45772
46015
  }
45773
- isSame(other) {
45774
- return !this.needsRegeneration(other) && this.lockedToPart === other.lockedToPart && this.lifetime.isSame(other.lifetime) && this.spreadAngle.isSame(other.spreadAngle) && this.speed.isSame(other.speed) && this.rotation.isSame(other.rotation) && this.rotationSpeed.isSame(other.rotationSpeed) && this.localAcceleration.isSame(other.localAcceleration) && this.acceleration.isSame(other.acceleration) && this.drag === other.drag && this.timeScale === other.timeScale && this.orientation === other.orientation && this.zOffset === other.zOffset && this.offset.isSame(other.offset) && this.shapeInOut === other.shapeInOut && this.opacity === other.opacity && this.lightEmission === other.lightEmission && this.blending === other.blending && this.color.isSame(other.color) && this.size.isSame(other.size) && this.transparency.isSame(other.transparency) && this.normalizeSizeKeypointTime === other.normalizeSizeKeypointTime;
46016
+ }
46017
+ class BaseKeyframeGroup {
46018
+ keyframes = [];
46019
+ getLowerKeyframe(time2) {
46020
+ let resultKeyframe = null;
46021
+ for (const keyframe of this.keyframes) {
46022
+ if (keyframe.time <= time2) {
46023
+ resultKeyframe = keyframe;
46024
+ } else {
46025
+ break;
46026
+ }
46027
+ }
46028
+ return resultKeyframe;
45775
46029
  }
45776
- fromEmitterDesc(other) {
45777
- this.lockedToPart = other.lockedToPart;
45778
- this.lifetime = other.lifetime.clone();
45779
- this.rate = other.rate;
45780
- this.spreadAngle = other.spreadAngle.clone();
45781
- this.speed = other.speed.clone();
45782
- this.rotation = other.rotation.clone();
45783
- this.rotationSpeed = other.rotationSpeed.clone();
45784
- this.localAcceleration = other.localAcceleration.clone();
45785
- this.acceleration = other.acceleration.clone();
45786
- this.drag = other.drag;
45787
- this.timeScale = other.timeScale;
45788
- this.orientation = other.orientation;
45789
- this.zOffset = other.zOffset;
45790
- this.offset = other.offset.clone();
45791
- this.shapeInOut = other.shapeInOut;
45792
- this.opacity = other.opacity;
45793
- this.lightEmission = other.lightEmission;
45794
- this.blending = other.blending;
45795
- this.color = other.color.clone();
45796
- this.size = other.size.clone();
45797
- this.transparency = other.transparency.clone();
45798
- this.normalizeSizeKeypointTime = other.normalizeSizeKeypointTime;
45799
- }
45800
- dispose(renderer, scene) {
45801
- const mesh = this.result;
45802
- if (mesh) {
45803
- this.disposeMesh(scene, mesh);
45804
- this.disposeRenderLists(renderer);
45805
- }
45806
- }
45807
- async getTexture(texture, colorSpace = SRGBColorSpace) {
45808
- if (texture) {
45809
- const source = texture.replace(".dds", ".png");
45810
- const image = await API.Generic.LoadImage(source);
45811
- if (image) {
45812
- const texture2 = new Texture(image);
45813
- texture2.wrapS = ClampToEdgeWrapping;
45814
- texture2.wrapT = ClampToEdgeWrapping;
45815
- texture2.colorSpace = colorSpace;
45816
- texture2.needsUpdate = true;
45817
- return texture2;
46030
+ getHigherKeyframe(time2) {
46031
+ for (const keyframe of this.keyframes) {
46032
+ if (keyframe.time > time2) {
46033
+ return keyframe;
45818
46034
  }
45819
46035
  }
45820
- return void 0;
46036
+ return null;
45821
46037
  }
45822
- async compileResult(renderer, scene) {
45823
- const originalResult = this.result;
45824
- const texturePromises = [
45825
- this.getTexture(this.texture),
45826
- this.getTexture(this.alphaTexture, NoColorSpace),
45827
- this.getTexture(this.colorTexture)
45828
- ];
45829
- let [mapToUse, alphaMapToUse, colorMapToUse] = await Promise.all(texturePromises);
45830
- if (!mapToUse) {
45831
- mapToUse = new DataTexture(new Uint8Array([0, 0, 0, 0]), 1, 1, RGBAFormat);
45832
- mapToUse.needsUpdate = true;
45833
- }
45834
- if (!alphaMapToUse) {
45835
- alphaMapToUse = new DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, RGBAFormat);
45836
- alphaMapToUse.needsUpdate = true;
45837
- }
45838
- if (!colorMapToUse) {
45839
- colorMapToUse = new DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, RGBAFormat);
45840
- colorMapToUse.needsUpdate = true;
45841
- }
45842
- const geometry = new PlaneGeometry(2, 2);
45843
- this.instanceColorBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount * 3), 3);
45844
- geometry.setAttribute("instanceColor", this.instanceColorBuffer);
45845
- this.instanceOpacityBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount), 1);
45846
- geometry.setAttribute("instanceOpacity", this.instanceOpacityBuffer);
45847
- this.instanceSeedTimeBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount), 2);
45848
- geometry.setAttribute("instanceSeedTime", this.instanceSeedTimeBuffer);
45849
- const material = new ShaderMaterial({
45850
- transparent: true,
45851
- depthWrite: false,
45852
- side: DoubleSide,
45853
- blending: this.blending,
45854
- opacity: this.opacity,
45855
- vertexShader: particle_vertexShader,
45856
- fragmentShader: particle_fragmentShader,
45857
- uniforms: {
45858
- uMap: { value: mapToUse },
45859
- uAlphaMap: { value: alphaMapToUse },
45860
- uColorMap: { value: colorMapToUse },
45861
- uOpacity: { value: this.opacity },
45862
- uZOffset: { value: this.zOffset }
45863
- }
45864
- });
45865
- this.result = new InstancedMesh(geometry, material, this.maxCount);
45866
- this.result.frustumCulled = false;
45867
- if (originalResult) {
45868
- this.disposeMesh(scene, originalResult);
45869
- this.disposeRenderLists(renderer);
45870
- }
45871
- return this.result;
46038
+ }
46039
+ class PartKeyframeGroup extends BaseKeyframeGroup {
46040
+ motorParent = "LowerTorso";
46041
+ motorName = "Root";
46042
+ keyframes = [];
46043
+ getHigherKeyframe(time2) {
46044
+ const keyframe = super.getHigherKeyframe(time2);
46045
+ return keyframe ? keyframe : null;
45872
46046
  }
45873
- emit(groupDesc) {
45874
- if (this.particles.length >= this.maxCount || groupDesc.enabled === false) {
45875
- return;
45876
- }
45877
- const speed = randomBetween(this.speed.Min, this.speed.Max);
45878
- const spreadX = rad((Math.random() - 0.5) * 2 * Math.abs(this.spreadAngle.X));
45879
- const spreadY = rad((Math.random() - 0.5) * 2 * Math.abs(this.spreadAngle.Y));
45880
- const spread = new Vector22(spreadX, spreadY);
45881
- let velocityMultiplierScalar = 1;
45882
- if (this.shapeInOut === ParticleEmitterShapeInOut.Inward) {
45883
- velocityMultiplierScalar = -1;
45884
- } else if (this.shapeInOut === ParticleEmitterShapeInOut.InAndOut) {
45885
- velocityMultiplierScalar = Math.random() > 0.5 ? 1 : -1;
45886
- }
45887
- const velocityMultiplier = new Vector3$1(velocityMultiplierScalar, velocityMultiplierScalar, velocityMultiplierScalar);
45888
- const velocityFront = velocityFromSpread(speed, spread);
45889
- const velocityOriginal = new Vector3$1(...velocityFront.toVec3()).multiply(velocityMultiplier);
45890
- const velocityLocal = velocityOriginal.applyQuaternion(groupDesc.getNormalQuaternionForVelocity());
45891
- const worldVelocity = velocityLocal.applyQuaternion(new Quaternion().setFromRotationMatrix(groupDesc.cframe.getTHREEMatrix()));
45892
- const worldVelocityRoblox = new Vector32(...worldVelocity.toArray());
45893
- const particle = new Particle(
45894
- randomBetween(this.lifetime.Min, this.lifetime.Max),
45895
- groupDesc.getRandomWorldPos().add(this.offset),
45896
- randomBetween(this.rotation.Min, this.rotation.Max),
45897
- worldVelocityRoblox,
45898
- randomBetween(this.rotationSpeed.Min, this.rotationSpeed.Max)
45899
- );
45900
- this.particles.push(particle);
46047
+ getLowerKeyframe(time2) {
46048
+ const keyframe = super.getLowerKeyframe(time2);
46049
+ return keyframe ? keyframe : null;
45901
46050
  }
45902
- vectorLocalToWorld(pivot, vector) {
45903
- const localVectorCF = new CFrame(...vector.toVec3());
45904
- const rotatedWorldCF = pivot.clone();
45905
- rotatedWorldCF.Position = [0, 0, 0];
45906
- const localVectorToWorldCF = rotatedWorldCF.multiply(localVectorCF);
45907
- const localVectorToWorld = new Vector32(...localVectorToWorldCF.Position);
45908
- return localVectorToWorld;
46051
+ }
46052
+ class FaceKeyframeGroup extends BaseKeyframeGroup {
46053
+ controlName = "Corrugator";
46054
+ parentName = "Head";
46055
+ keyframes = [];
46056
+ getHigherKeyframe(time2) {
46057
+ const keyframe = super.getHigherKeyframe(time2);
46058
+ return keyframe ? keyframe : null;
45909
46059
  }
45910
- tick(dt, groupDesc) {
45911
- this.passedTime += dt * this.timeScale;
45912
- if (this.lockedToPart) {
45913
- for (const particle of this.particles) {
45914
- const particleCF = new CFrame(...particle.position.toVec3());
45915
- const localParticleCF = groupDesc.lastCframe.inverse().multiply(particleCF);
45916
- const newParticleCF = groupDesc.cframe.multiply(localParticleCF);
45917
- const newParticleCFOnlyOrientation = newParticleCF.clone();
45918
- newParticleCFOnlyOrientation.Position = [0, 0, 0];
45919
- particle.position = new Vector32(...newParticleCF.Position);
45920
- particle.velocity = new Vector32(...newParticleCFOnlyOrientation.multiply(new CFrame(...particle.velocity.toVec3())).Position);
46060
+ getLowerKeyframe(time2) {
46061
+ const keyframe = super.getLowerKeyframe(time2);
46062
+ return keyframe ? keyframe : null;
46063
+ }
46064
+ }
46065
+ class FloatCurveKey {
46066
+ time = 0;
46067
+ value = 0;
46068
+ interpolation = KeyInterpolationMode.Cubic;
46069
+ leftTangent = void 0;
46070
+ rightTangent = void 0;
46071
+ }
46072
+ class FloatCurve {
46073
+ keys = [];
46074
+ maxTime = 0;
46075
+ fromBuffer(arrayBuffer) {
46076
+ const view = new SimpleView(arrayBuffer);
46077
+ view.readUint32();
46078
+ const length = view.readUint32();
46079
+ for (let i = 0; i < length; i++) {
46080
+ const key = new FloatCurveKey();
46081
+ key.interpolation = view.readUint8();
46082
+ let hasLeftAndRightTangent = view.readUint8();
46083
+ let hasRightTangent = false;
46084
+ let hasLeftTangent = false;
46085
+ if (hasLeftAndRightTangent - 2 >= 0) {
46086
+ hasRightTangent = true;
46087
+ hasLeftAndRightTangent -= 2;
45921
46088
  }
45922
- }
45923
- for (const particle of this.particles) {
45924
- const acceleration = this.lockedToPart ? new Vector32(0, 0, 0) : this.acceleration;
45925
- let localAccelerationToWorld = this.vectorLocalToWorld(groupDesc.cframe, this.localAcceleration);
45926
- if (this.lockedToPart) {
45927
- localAccelerationToWorld = localAccelerationToWorld.add(this.vectorLocalToWorld(groupDesc.cframe, this.acceleration));
46089
+ if (hasLeftAndRightTangent - 1 >= 0) {
46090
+ hasLeftTangent = true;
46091
+ hasLeftAndRightTangent -= 1;
45928
46092
  }
45929
- particle.tick(dt * this.timeScale, this.drag, acceleration.add(localAccelerationToWorld));
45930
- }
45931
- for (let i = this.particles.length - 1; i >= 0; i--) {
45932
- const particle = this.particles[i];
45933
- if (particle.time >= particle.lifetime) {
45934
- this.particles.splice(i, 1);
46093
+ key.value = view.readFloat32();
46094
+ if (hasLeftTangent) {
46095
+ key.leftTangent = view.readFloat32();
46096
+ } else {
46097
+ view.readFloat32();
46098
+ }
46099
+ if (hasRightTangent) {
46100
+ key.rightTangent = view.readFloat32();
46101
+ } else {
46102
+ view.readFloat32();
45935
46103
  }
46104
+ this.keys.push(key);
45936
46105
  }
45937
- this.passedTime = specialClamp(this.passedTime, 0, 5);
45938
- while (this.passedTime >= 1 / this.rate) {
45939
- this.emit(groupDesc);
45940
- this.passedTime -= 1 / this.rate;
46106
+ view.readUint32();
46107
+ view.readUint16();
46108
+ view.readUint8();
46109
+ for (let i = 0; i < length; i++) {
46110
+ this.keys[i].time = view.readUint32() / 65536 / 9.375;
46111
+ if (this.keys[i].time > this.maxTime) {
46112
+ this.maxTime = this.keys[i].time;
46113
+ }
45941
46114
  }
46115
+ return this;
45942
46116
  }
45943
- updateResult(renderScene) {
45944
- if (!this.result || !this.instanceColorBuffer || !this.instanceOpacityBuffer || !this.instanceSeedTimeBuffer) return;
45945
- this.result.count = this.particles.length;
45946
- for (let i = 0; i < this.result.count; i++) {
45947
- const particle = this.particles[i];
45948
- const time2 = particle.time;
45949
- const normalizedTime = particle.time / particle.lifetime;
45950
- const color = this.color.getValue(normalizedTime);
45951
- const size = this.size.getValue(this.normalizeSizeKeypointTime ? normalizedTime : time2, particle.seed + 0);
45952
- const opacity = 1 - this.transparency.getValue(normalizedTime, particle.seed + 1);
45953
- this.result.setMatrixAt(i, particle.getMatrix(renderScene, size, this.orientation));
45954
- this.instanceColorBuffer.setXYZ(i, color.R, color.G, color.B);
45955
- this.instanceOpacityBuffer.setX(i, opacity);
45956
- this.instanceSeedTimeBuffer.setXY(i, particle.seed, normalizedTime);
46117
+ getLowerKey(time2) {
46118
+ let resultKey = null;
46119
+ for (const key of this.keys) {
46120
+ if (key.time <= time2) {
46121
+ if (resultKey && resultKey.time > key.time) {
46122
+ continue;
46123
+ }
46124
+ resultKey = key;
46125
+ }
45957
46126
  }
45958
- this.result.instanceMatrix.needsUpdate = true;
45959
- this.instanceColorBuffer.needsUpdate = true;
45960
- this.instanceOpacityBuffer.needsUpdate = true;
45961
- this.instanceSeedTimeBuffer.needsUpdate = true;
45962
- }
45963
- }
45964
- class EmitterGroupDesc extends RenderDesc {
45965
- lastTime = Date.now() / 1e3;
45966
- time = Date.now() / 1e3;
45967
- enabled = true;
45968
- lowerBound = new Vector32(0, 0, 0);
45969
- higherBound = new Vector32(0, 0, 0);
45970
- lastCframe = new CFrame();
45971
- cframe = new CFrame();
45972
- emitterDir = NormalId.Top;
45973
- emitterDescs = [];
45974
- //special for emitter group
45975
- getRandomLocalPos() {
45976
- const totalSize = this.higherBound.minus(this.lowerBound);
45977
- const x = Math.random() * totalSize.X + this.lowerBound.X;
45978
- const y = Math.random() * totalSize.Y + this.lowerBound.Y;
45979
- const z = Math.random() * totalSize.Z + this.lowerBound.Z;
45980
- return new Vector32(x, y, z);
45981
- }
45982
- toWorldSpace(vec) {
45983
- const vecAsCF = new CFrame(...vec.toVec3());
45984
- const worldSpace = new Vector32().fromVec3(this.cframe.multiply(vecAsCF).Position);
45985
- return worldSpace;
45986
- }
45987
- getRandomWorldPos() {
45988
- const randomWorldPos = this.toWorldSpace(this.getRandomLocalPos());
45989
- return randomWorldPos;
46127
+ return resultKey;
45990
46128
  }
45991
- getNormalQuaternionForVelocity() {
45992
- switch (this.emitterDir) {
45993
- case NormalId.Right: {
45994
- return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(1, 0, 0));
45995
- }
45996
- case NormalId.Top: {
45997
- return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, 1, 0));
45998
- }
45999
- case NormalId.Back: {
46000
- return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, 0, 1));
46001
- }
46002
- case NormalId.Left: {
46003
- return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(-1, 0, 0));
46004
- }
46005
- case NormalId.Bottom: {
46006
- return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, -1, 0));
46007
- }
46008
- case NormalId.Front:
46009
- default: {
46010
- return new Quaternion();
46129
+ getHigherKey(time2) {
46130
+ let resultKey = null;
46131
+ for (const key of this.keys) {
46132
+ if (key.time > time2) {
46133
+ if (resultKey && resultKey.time < key.time) {
46134
+ continue;
46135
+ }
46136
+ resultKey = key;
46011
46137
  }
46012
46138
  }
46139
+ return resultKey;
46013
46140
  }
46014
- createEmitter(config) {
46015
- const emitter = new EmitterDesc();
46016
- Object.assign(emitter, config);
46017
- return emitter;
46141
+ }
46142
+ class PartCurve {
46143
+ motorParent = "LowerTorso";
46144
+ motorName = "Root";
46145
+ position;
46146
+ rotationOrder = RotationOrder.XYZ;
46147
+ rotation;
46148
+ }
46149
+ class FaceCruve {
46150
+ controlName = "Corrugator";
46151
+ parentName = "Head";
46152
+ value;
46153
+ }
46154
+ function getCurveValue(time2, lowerKey, higherKey) {
46155
+ const lowerX = lowerKey;
46156
+ const higherX = higherKey;
46157
+ const keyframeTime = mapNum(time2, lowerX.time, higherX.time, 0, 1);
46158
+ if (lowerX.interpolation === KeyInterpolationMode.Constant) {
46159
+ return lowerX.value;
46160
+ } else if (lowerX.interpolation === KeyInterpolationMode.Linear) {
46161
+ return (higherX.value - lowerX.value) * keyframeTime + lowerX.value;
46162
+ } else if (lowerX.interpolation === KeyInterpolationMode.Cubic) {
46163
+ const p0 = lowerX.value;
46164
+ const p1 = higherX.value;
46165
+ const m0 = lowerX.rightTangent || 0;
46166
+ const m1 = higherX.leftTangent || 0;
46167
+ const xk = lowerX.time;
46168
+ const xk1 = higherX.time;
46169
+ return p(mapNum(time2, lowerX.time, higherX.time, 0, 1), p0, p1, m0, m1, xk, xk1);
46018
46170
  }
46019
- //inherited from RenderDesc
46020
- isSame(other) {
46021
- if (this.needsRegeneration(other)) {
46022
- return false;
46171
+ throw new Error(`Invalid interpolation type: ${lowerX.interpolation}`);
46172
+ }
46173
+ class AnimationTrack {
46174
+ //data
46175
+ trackType = "Sequence";
46176
+ keyframeGroups = [];
46177
+ //one group per motor6D, only if trackType = "Sequence"
46178
+ curves = [];
46179
+ //only if trackType = "Curve"
46180
+ keyframeTimeMap = /* @__PURE__ */ new Map();
46181
+ //frame info
46182
+ isPlaying = false;
46183
+ timePosition = 0;
46184
+ weight = 1;
46185
+ finished = true;
46186
+ //static info
46187
+ rig = void 0;
46188
+ length = 0;
46189
+ looped = false;
46190
+ priority = AnimationPriority.Core;
46191
+ shouldUpdateMotors = false;
46192
+ updateFaceControls = true;
46193
+ animatesParts = true;
46194
+ //playing info
46195
+ pOriginalWeight = 0;
46196
+ pTargetWeight = 0;
46197
+ pSpeed = 1;
46198
+ pFadedTime = 0;
46199
+ pFadeTime = 0.1;
46200
+ getNamedMotor(motorName, parentName) {
46201
+ if (!this.rig) {
46202
+ return void 0;
46023
46203
  }
46024
- return this.time === other.time;
46204
+ const parent = this.rig.FindFirstChild(parentName);
46205
+ if (parent) {
46206
+ return parent.FindFirstChild(motorName);
46207
+ }
46208
+ return void 0;
46025
46209
  }
46026
- needsRegeneration(other) {
46027
- if (this.emitterDescs.length !== other.emitterDescs.length) {
46028
- return true;
46210
+ findMotor6D(part0, part1) {
46211
+ if (!this.rig) {
46212
+ return void 0;
46029
46213
  }
46030
- for (let i = 0; i < this.emitterDescs.length; i++) {
46031
- if (!this.emitterDescs[i].needsRegeneration(other.emitterDescs[i])) {
46032
- return true;
46214
+ const foundMotor6D = part1.FindFirstChildOfClass("Motor6D");
46215
+ if (foundMotor6D && foundMotor6D.Prop("Part0") === part0 && foundMotor6D.Prop("Part1") === part1) {
46216
+ return foundMotor6D;
46217
+ } else {
46218
+ const descendants = this.rig.GetDescendants();
46219
+ for (const child of descendants) {
46220
+ if (child.className === "Motor6D") {
46221
+ if (child.Prop("Part0") === part0 && child.Prop("Part1") === part1) {
46222
+ return child;
46223
+ }
46224
+ }
46033
46225
  }
46034
46226
  }
46035
- return false;
46227
+ return void 0;
46036
46228
  }
46037
- virtualFromRenderDesc(other) {
46038
- this.time = other.time;
46039
- this.cframe = other.cframe;
46040
- this.lowerBound = other.lowerBound;
46041
- this.higherBound = other.higherBound;
46042
- this.emitterDir = other.emitterDir;
46043
- for (let i = 0; i < this.emitterDescs.length; i++) {
46044
- this.emitterDescs[i].fromEmitterDesc(other.emitterDescs[i]);
46229
+ findPartKeyframeGroup(motorName, motorParentName) {
46230
+ for (const group of this.keyframeGroups) {
46231
+ if (group instanceof PartKeyframeGroup && group.motorParent === motorParentName && group.motorName === motorName) {
46232
+ return group;
46233
+ }
46045
46234
  }
46235
+ return void 0;
46046
46236
  }
46047
- virtualTransferFrom(other) {
46048
- if (this.emitterDescs.length === other.emitterDescs.length) {
46049
- for (let i = 0; i < this.emitterDescs.length; i++) {
46050
- this.emitterDescs[i].particles = other.emitterDescs[i].particles;
46051
- this.emitterDescs[i].initialParticleCount = this.emitterDescs[i].particles.length;
46237
+ findFaceKeyframeGroup(controlName) {
46238
+ for (const group of this.keyframeGroups) {
46239
+ if (group instanceof FaceKeyframeGroup && group.controlName === controlName) {
46240
+ return group;
46052
46241
  }
46053
46242
  }
46243
+ return void 0;
46054
46244
  }
46055
- fromInstance(child) {
46056
- this.instance = child;
46057
- const parent = child.parent;
46058
- if (parent) {
46059
- if (parent.HasProperty("CFrame")) {
46060
- this.cframe = parent.Prop("CFrame");
46061
- if (parent.className === "Attachment") {
46062
- const parentParent = parent.parent;
46063
- if (parentParent && parentParent.HasProperty("CFrame")) {
46064
- this.cframe = parentParent.Prop("CFrame").multiply(this.cframe);
46065
- }
46245
+ addPartKeyframe(motorName, motorParentName, keyframe) {
46246
+ if (!keyframe) {
46247
+ return;
46248
+ }
46249
+ let group = this.findPartKeyframeGroup(motorName, motorParentName);
46250
+ if (!group) {
46251
+ group = new PartKeyframeGroup();
46252
+ group.motorParent = motorParentName;
46253
+ group.motorName = motorName;
46254
+ this.keyframeGroups.push(group);
46255
+ }
46256
+ group.keyframes.push(keyframe);
46257
+ }
46258
+ createPartKeyframe(keyframe, pose) {
46259
+ if (!pose.parent || !this.rig) {
46260
+ return [void 0, void 0, void 0];
46261
+ }
46262
+ const part0Name = pose.parent.Prop("Name");
46263
+ const part1Name = pose.Prop("Name");
46264
+ const part0 = this.rig.FindFirstChild(part0Name);
46265
+ const part1 = this.rig.FindFirstChild(part1Name);
46266
+ let partKeyframe = void 0;
46267
+ let motorName = void 0;
46268
+ let motorParentName = void 0;
46269
+ if (part0 && part1) {
46270
+ const motor = this.findMotor6D(part0, part1);
46271
+ if (motor) {
46272
+ motorName = motor.Prop("Name");
46273
+ if (motor.parent) {
46274
+ motorParentName = motor.parent.Prop("Name");
46066
46275
  }
46067
- this.lastCframe = this.cframe;
46276
+ } else {
46277
+ motorName = PartToMotorName[part1.Prop("Name")];
46278
+ motorParentName = part1.Prop("Name");
46068
46279
  }
46069
- if (parent.HasProperty("Size") || parent.HasProperty("size")) {
46070
- const size = parent.Prop("Size");
46071
- this.higherBound = size.multiply(new Vector32(0.5, 0.5, 0.5));
46072
- this.lowerBound = size.multiply(new Vector32(-0.5, -0.5, -0.5));
46280
+ if (!keyframe.HasProperty("Time")) {
46281
+ warn(false, `Invalid animation keyframe, missing property Time`, keyframe);
46282
+ return [void 0, void 0, void 0];
46283
+ }
46284
+ const time2 = keyframe.Prop("Time");
46285
+ const cf = pose.Prop("CFrame");
46286
+ partKeyframe = new PartKeyframe(time2, cf);
46287
+ if (pose.HasProperty("EasingDirection")) {
46288
+ partKeyframe.easingDirection = pose.Prop("EasingDirection");
46289
+ }
46290
+ if (pose.HasProperty("EasingStyle")) {
46291
+ partKeyframe.easingStyle = pose.Prop("EasingStyle");
46073
46292
  }
46293
+ } else {
46294
+ return [void 0, void 0, void 0];
46074
46295
  }
46075
- this.enabled = child.PropOrDefault("Enabled", true);
46076
- const className = child.className;
46077
- switch (className) {
46078
- case "ParticleEmitter":
46079
- this.fromParticleEmitter(child);
46080
- break;
46081
- case "Sparkles":
46082
- this.fromSparkles(child);
46083
- break;
46084
- case "Fire":
46085
- this.fromFire(child);
46086
- break;
46087
- case "Smoke":
46088
- this.fromSmoke(child);
46089
- break;
46296
+ if (!motorName || !motorParentName || !partKeyframe) {
46297
+ warn(false, `Missing either motor or partKeyFrame for parts: ${part0Name} ${part1Name}`);
46298
+ return [void 0, void 0, void 0];
46090
46299
  }
46091
- }
46092
- fromParticleEmitter(child) {
46093
- this.emitterDir = child.Prop("EmissionDirection");
46094
- const emitterDesc = new EmitterDesc();
46095
- if (child.HasProperty("Lifetime")) emitterDesc.lifetime = child.Prop("Lifetime");
46096
- if (child.HasProperty("Rate")) emitterDesc.rate = child.Prop("Rate");
46097
- if (child.HasProperty("SpreadAngle")) emitterDesc.spreadAngle = child.Prop("SpreadAngle");
46098
- if (child.HasProperty("ShapeInOut")) emitterDesc.shapeInOut = child.Prop("ShapeInOut");
46099
- if (child.HasProperty("Speed")) emitterDesc.speed = child.Prop("Speed");
46100
- if (child.HasProperty("Rotation")) emitterDesc.rotation = child.Prop("Rotation");
46101
- if (child.HasProperty("RotSpeed")) emitterDesc.rotationSpeed = child.Prop("RotSpeed");
46102
- if (child.HasProperty("Acceleration")) emitterDesc.acceleration = child.Prop("Acceleration");
46103
- if (child.HasProperty("Drag")) emitterDesc.drag = child.Prop("Drag");
46104
- if (child.HasProperty("TimeScale")) emitterDesc.timeScale = child.Prop("TimeScale");
46105
- if (child.HasProperty("Size")) emitterDesc.size = child.Prop("Size");
46106
- if (child.HasProperty("Color")) emitterDesc.color = child.Prop("Color");
46107
- if (child.HasProperty("Texture")) emitterDesc.texture = child.Prop("Texture");
46108
- if (child.HasProperty("Transparency")) emitterDesc.transparency = child.Prop("Transparency");
46109
- if (child.HasProperty("LightEmission")) emitterDesc.lightEmission = child.Prop("LightEmission");
46110
- emitterDesc.blending = emitterDesc.lightEmission === 0 ? NormalBlending : AdditiveBlending;
46111
- if (child.HasProperty("ZOffset")) emitterDesc.zOffset = child.Prop("ZOffset");
46112
- if (child.HasProperty("Orientation")) emitterDesc.orientation = child.Prop("Orientation");
46113
- if (child.HasProperty("LockedToPart")) emitterDesc.lockedToPart = child.Prop("LockedToPart");
46114
- this.emitterDescs.push(emitterDesc);
46115
- }
46116
- fromSparkles(child) {
46117
- this.lowerBound = new Vector32(-0.2, -0.2, -0.2);
46118
- this.higherBound = new Vector32(0.2, 0.2, 0.2);
46119
- const color = child.PropOrDefault("SparkleColor", new Color3(144 / 255, 25 / 255, 255 / 255));
46120
- this.emitterDescs.push(this.createEmitter({
46121
- texture: "rbxasset://textures/particles/sparkles_main.dds",
46122
- alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
46123
- colorTexture: "rbxasset://textures/particles/sparkles_color.dds",
46124
- drag: 0.2,
46125
- size: new NumberSequence([new NumberSequenceKeypoint(0, 0.37, 0), new NumberSequenceKeypoint(1, 0.37 + 0.65, 0)]),
46126
- speed: new NumberRange(5, 5),
46127
- rotation: new NumberRange(-90, 90),
46128
- rotationSpeed: new NumberRange(40, 100),
46129
- spreadAngle: new Vector22(100, 100),
46130
- rate: 30,
46131
- lifetime: new NumberRange(1.3, 1.3),
46132
- timeScale: child.PropOrDefault("TimeScale", 1),
46133
- color: ColorSequence.fromColor(color)
46134
- }));
46135
- this.emitterDescs.push(this.createEmitter({
46136
- texture: "rbxasset://textures/particles/sparkles_main.dds",
46137
- alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
46138
- drag: 2,
46139
- size: new NumberSequence([new NumberSequenceKeypoint(0, 0.1, 0), new NumberSequenceKeypoint(1, 0.1 + 0.34, 0)]),
46140
- speed: new NumberRange(8, 8),
46141
- rotation: new NumberRange(-90, 90),
46142
- rotationSpeed: new NumberRange(-500, 500),
46143
- spreadAngle: new Vector22(150, 150),
46144
- rate: 5,
46145
- lifetime: new NumberRange(1.7, 1.7),
46146
- timeScale: child.PropOrDefault("TimeScale", 1),
46147
- color: ColorSequence.fromColor(color)
46148
- }));
46149
- }
46150
- fromFire(child) {
46151
- const size = child.PropOrDefault("size_xml", 3) / 3.5;
46152
- const boundSize = size / 8;
46153
- const heat = child.PropOrDefault("heat_xml", 5);
46154
- const timeScale = child.PropOrDefault("TimeScale", 1);
46155
- const color = child.PropOrDefault("Color", new Color3(236 / 255, 139 / 255, 70 / 255));
46156
- const secondaryColor = child.PropOrDefault("SecondaryColor", new Color3(106 / 255, 44 / 255, 13 / 255));
46157
- this.lowerBound = new Vector32(-boundSize, -boundSize, -boundSize);
46158
- this.higherBound = new Vector32(boundSize, boundSize, boundSize);
46159
- const strongColor = color.clone();
46160
- strongColor.R *= 4;
46161
- strongColor.G *= 4;
46162
- strongColor.B *= 4;
46163
- this.emitterDescs.push(this.createEmitter({
46164
- texture: "rbxasset://textures/particles/fire_main.dds",
46165
- alphaTexture: "rbxasset://textures/particles/fire_alpha.dds",
46166
- drag: 0.4,
46167
- localAcceleration: new Vector32(0, 0.5 * (1 * size * size / 4 + 0.7 * heat), 0),
46168
- rotation: new NumberRange(-90, 90),
46169
- size: new NumberSequence([new NumberSequenceKeypoint(0, 1.1 * size, 0), new NumberSequenceKeypoint(2, Math.max(1.1 * size - 0.8 * size * 2, 0), 0)]),
46170
- speed: new NumberRange(0.4 * (0.2 * size * size + 0.2 * heat), 0.4 * (0.2 * size * size + 0.2 * heat)),
46171
- rotationSpeed: new NumberRange(100, 100),
46172
- spreadAngle: new Vector22(10, 10),
46173
- rate: 65,
46174
- lifetime: new NumberRange(1, 2),
46175
- normalizeSizeKeypointTime: false,
46176
- timeScale,
46177
- color: ColorSequence.fromColor(strongColor)
46178
- }));
46179
- const sparkSize = size * 0.2;
46180
- this.emitterDescs.push(this.createEmitter({
46181
- texture: "rbxasset://textures/particles/fire_main.dds",
46182
- alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
46183
- colorTexture: "rbxasset://textures/particles/fire_sparks_color.dds",
46184
- drag: 0.4,
46185
- localAcceleration: new Vector32(0, 0.5 * (1 * size * size / 4 + 0.7 * heat), 0),
46186
- rotation: new NumberRange(-90, 90),
46187
- size: new NumberSequence([new NumberSequenceKeypoint(0, 1.1 * sparkSize, 0), new NumberSequenceKeypoint(3, Math.max(1.1 * sparkSize - -sparkSize / 3 * 3, 0), 0)]),
46188
- speed: new NumberRange(0.4 * (0.2 * size * size + 0.2 * heat), 0.4 * (0.2 * size * size + 0.2 * heat)),
46189
- rotationSpeed: new NumberRange(100, 100),
46190
- spreadAngle: new Vector22(10, 10),
46191
- rate: 65,
46192
- lifetime: new NumberRange(1.5, 3),
46193
- normalizeSizeKeypointTime: false,
46194
- timeScale,
46195
- color: ColorSequence.fromColor(secondaryColor),
46196
- blending: AdditiveBlending
46197
- }));
46198
- }
46199
- fromSmoke(child) {
46200
- const size = child.PropOrDefault("size_xml", 1);
46201
- const endSize = 10 + size;
46202
- const timeScale = child.PropOrDefault("TimeScale", 1);
46203
- const riseVelocity = child.PropOrDefault("riseVelocity_xml", 1);
46204
- const opacity = child.PropOrDefault("opacity_xml", 0.5);
46205
- const color = child.PropOrDefault("Color", new Color3(1, 1, 1));
46206
- this.emitterDescs.push(this.createEmitter({
46207
- texture: "rbxasset://textures/particles/smoke_main.dds",
46208
- alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
46209
- drag: 0.1,
46210
- opacity,
46211
- acceleration: new Vector32(0, 0, 0.4),
46212
- size: new NumberSequence([new NumberSequenceKeypoint(0, size, 0), new NumberSequenceKeypoint(1, endSize, 0)]),
46213
- rotation: new NumberRange(-90, 90),
46214
- speed: new NumberRange(riseVelocity * 0.9, riseVelocity * 1),
46215
- rotationSpeed: new NumberRange(-20, 20),
46216
- spreadAngle: new Vector22(30, 30),
46217
- rate: 7,
46218
- lifetime: new NumberRange(5, 5),
46219
- timeScale,
46220
- color: ColorSequence.fromColor(color),
46221
- blending: NormalBlending
46222
- }));
46223
- }
46224
- dispose(renderer, scene) {
46225
- const meshes = this.results;
46226
- if (meshes) {
46227
- this.disposeMeshes(scene, meshes);
46228
- this.disposeRenderLists(renderer);
46229
- }
46230
- }
46231
- async compileResults(renderer, scene) {
46232
- const originalResults = this.results;
46233
- const resultPromises = [];
46234
- for (const emitterDesc of this.emitterDescs) {
46235
- resultPromises.push(emitterDesc.compileResult(renderer, scene));
46236
- }
46237
- this.results = [];
46238
- const compiledResults = await Promise.all(resultPromises);
46239
- for (const compiledResult of compiledResults) {
46240
- if (compiledResult instanceof Mesh) {
46241
- this.results.push(compiledResult);
46242
- } else {
46243
- this.disposeMeshes(scene, this.results);
46244
- this.disposeRenderLists(renderer);
46245
- return compiledResult;
46246
- }
46247
- }
46248
- if (originalResults) {
46249
- this.disposeMeshes(scene, originalResults);
46250
- this.disposeRenderLists(renderer);
46251
- }
46252
- return this.results;
46253
- }
46254
- updateResults() {
46255
- const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10);
46256
- this.lastTime = this.time;
46257
- for (const emitterDesc of this.emitterDescs) {
46258
- emitterDesc.tick(dt, this);
46259
- emitterDesc.updateResult(this.renderScene);
46260
- }
46261
- this.lastCframe = this.cframe.clone();
46262
- }
46263
- }
46264
- class AccessoryDescriptionWrapper extends InstanceWrapper {
46265
- static className = "AccessoryDescription";
46266
- static requiredProperties = [
46267
- "Name",
46268
- "AssetId",
46269
- "AccessoryType",
46270
- "IsLayered",
46271
- "Puffiness",
46272
- "Order",
46273
- "Position",
46274
- "Rotation",
46275
- "Scale",
46276
- "Instance"
46277
- ];
46278
- setup() {
46279
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
46280
- if (!this.instance.HasProperty("AssetId")) this.instance.addProperty(new Property("AssetId", DataType.Int64), 0n);
46281
- if (!this.instance.HasProperty("AccessoryType")) this.instance.addProperty(new Property("AccessoryType", DataType.Enum), AccessoryType.Unknown);
46282
- if (!this.instance.HasProperty("IsLayered")) this.instance.addProperty(new Property("IsLayered", DataType.Bool), false);
46283
- if (!this.instance.HasProperty("Puffiness")) this.instance.addProperty(new Property("Puffiness", DataType.Float32), 1);
46284
- if (!this.instance.HasProperty("Order")) this.instance.addProperty(new Property("Order", DataType.Int32), 1);
46285
- if (!this.instance.HasProperty("Position")) this.instance.addProperty(new Property("Position", DataType.Vector3), new Vector32(0, 0, 0));
46286
- if (!this.instance.HasProperty("Rotation")) this.instance.addProperty(new Property("Rotation", DataType.Vector3), new Vector32(0, 0, 0));
46287
- if (!this.instance.HasProperty("Scale")) this.instance.addProperty(new Property("Scale", DataType.Vector3), new Vector32(1, 1, 1));
46288
- if (!this.instance.HasProperty("Instance")) this.instance.addProperty(new Property("Instance", DataType.Referent), void 0);
46289
- }
46290
- }
46291
- const AnimationPriority = {
46292
- "Core": 1e3
46293
- };
46294
- const EasingDirection = {
46295
- "In": 0,
46296
- "Out": 1,
46297
- "InOut": 2
46298
- };
46299
- const PoseEasingStyle = {
46300
- "Linear": 0,
46301
- "Constant": 1,
46302
- "Elastic": 2,
46303
- "Cubic": 3,
46304
- "Bounce": 4,
46305
- "CubicV2": 5
46306
- };
46307
- const KeyInterpolationMode = {
46308
- "Constant": 0,
46309
- "Linear": 1,
46310
- "Cubic": 2
46311
- };
46312
- const RotationOrder = {
46313
- "XYZ": 0
46314
- };
46315
- const RotationOrderToRotationOrderName = {
46316
- 0: "XYZ",
46317
- 1: "XZY",
46318
- 2: "YZX",
46319
- 3: "YXZ",
46320
- 4: "ZXY",
46321
- 5: "ZYX"
46322
- };
46323
- function easeLinear(x) {
46324
- return x;
46325
- }
46326
- function easeConstant(x) {
46327
- return x * 0;
46328
- }
46329
- function easeInElastic(x) {
46330
- const c4 = 2 * Math.PI / 3;
46331
- return x === 0 ? 0 : x === 1 ? 1 : -Math.pow(2, 10 * x - 10) * Math.sin((x * 10 - 10.75) * c4);
46332
- }
46333
- function easeOutElastic(x) {
46334
- const c4 = 2 * Math.PI / 3;
46335
- return x === 0 ? 0 : x === 1 ? 1 : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * c4) + 1;
46336
- }
46337
- function easeInOutElastic(x) {
46338
- const c5 = 2 * Math.PI / 4.5;
46339
- return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * c5)) / 2 : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * c5) / 2 + 1;
46340
- }
46341
- function easeInCubic(x) {
46342
- return x * x * x;
46343
- }
46344
- function easeOutCubic(x) {
46345
- return 1 - Math.pow(1 - x, 3);
46346
- }
46347
- function easeInOutCubic(x) {
46348
- return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
46349
- }
46350
- function easeOutBounce(x) {
46351
- const n1 = 7.5625;
46352
- const d1 = 2.75;
46353
- if (x < 1 / d1) {
46354
- return n1 * x * x;
46355
- } else if (x < 2 / d1) {
46356
- return n1 * (x -= 1.5 / d1) * x + 0.75;
46357
- } else if (x < 2.5 / d1) {
46358
- return n1 * (x -= 2.25 / d1) * x + 0.9375;
46359
- } else {
46360
- return n1 * (x -= 2.625 / d1) * x + 0.984375;
46361
- }
46362
- }
46363
- function easeInBounce(x) {
46364
- return 1 - easeOutBounce(1 - x);
46365
- }
46366
- function easeInOutBounce(x) {
46367
- return x < 0.5 ? (1 - easeOutBounce(1 - 2 * x)) / 2 : (1 + easeOutBounce(2 * x - 1)) / 2;
46368
- }
46369
- const PartToMotorName = {
46370
- "Head": "Neck",
46371
- "UpperTorso": "Waist",
46372
- "LowerTorso": "Root",
46373
- "RightFoot": "RightAnkle",
46374
- "RightLowerLeg": "RightKnee",
46375
- "RightUpperLeg": "RightHip",
46376
- "LeftFoot": "LeftAnkle",
46377
- "LeftLowerLeg": "LeftKnee",
46378
- "LeftUpperLeg": "LeftHip",
46379
- "RightHand": "RightWrist",
46380
- "RightLowerArm": "RightElbow",
46381
- "RightUpperArm": "RightShoulder",
46382
- "LeftHand": "LeftWrist",
46383
- "LeftLowerArm": "LeftElbow",
46384
- "LeftUpperArm": "LeftShoulder"
46385
- };
46386
- const EasingFunctionMap = {
46387
- [EasingDirection.In]: {
46388
- [PoseEasingStyle.Linear]: easeLinear,
46389
- [PoseEasingStyle.Constant]: easeConstant,
46390
- [PoseEasingStyle.Elastic]: easeInElastic,
46391
- [PoseEasingStyle.Cubic]: easeInCubic,
46392
- [PoseEasingStyle.Bounce]: easeInBounce,
46393
- [PoseEasingStyle.CubicV2]: easeInCubic
46394
- },
46395
- [EasingDirection.Out]: {
46396
- [PoseEasingStyle.Linear]: easeLinear,
46397
- [PoseEasingStyle.Constant]: easeConstant,
46398
- [PoseEasingStyle.Elastic]: easeOutElastic,
46399
- [PoseEasingStyle.Cubic]: easeOutCubic,
46400
- [PoseEasingStyle.Bounce]: easeOutBounce,
46401
- [PoseEasingStyle.CubicV2]: easeOutCubic
46402
- },
46403
- [EasingDirection.InOut]: {
46404
- [PoseEasingStyle.Linear]: easeLinear,
46405
- [PoseEasingStyle.Constant]: easeConstant,
46406
- [PoseEasingStyle.Elastic]: easeInOutElastic,
46407
- [PoseEasingStyle.Cubic]: easeInOutCubic,
46408
- [PoseEasingStyle.Bounce]: easeInOutBounce,
46409
- [PoseEasingStyle.CubicV2]: easeInOutCubic
46410
- }
46411
- };
46412
- function getEasingFunction(easingDirection, easingStyle) {
46413
- const func = EasingFunctionMap[easingDirection][easingStyle];
46414
- if (!func) {
46415
- throw new Error(`No function equivalent for easingStyle: ${easingStyle}`);
46416
- }
46417
- return func;
46418
- }
46419
- function h00(t) {
46420
- return 2 * Math.pow(t, 3) - 3 * Math.pow(t, 2) + 1;
46421
- }
46422
- function h10(t) {
46423
- return Math.pow(t, 3) - 2 * Math.pow(t, 2) + t;
46424
- }
46425
- function h01(t) {
46426
- return -2 * Math.pow(t, 3) + 3 * Math.pow(t, 2);
46427
- }
46428
- function h11(t) {
46429
- return Math.pow(t, 3) - Math.pow(t, 2);
46430
- }
46431
- function p(t, p0, p1, m0, m1, xk, xk1) {
46432
- return h00(t) * p0 + h10(t) * (xk1 - xk) * m0 + h01(t) * p1 + h11(t) * (xk1 - xk) * m1;
46433
- }
46434
- function lerpCFrame(oldCFrame, newCFrame, easedTime) {
46435
- const oldPos = oldCFrame.Position;
46436
- const oldRot = oldCFrame.Orientation;
46437
- const newPos = newCFrame.Position;
46438
- const newRot = newCFrame.Orientation;
46439
- const oldEuler = new Euler(rad(oldRot[0]), rad(oldRot[1]), rad(oldRot[2]), "YXZ");
46440
- const oldQuat = new Quaternion().setFromEuler(oldEuler);
46441
- const newEuler = new Euler(rad(newRot[0]), rad(newRot[1]), rad(newRot[2]), "YXZ");
46442
- const newQuat = new Quaternion().setFromEuler(newEuler);
46443
- const resultQuat = oldQuat.slerp(newQuat, easedTime);
46444
- const resultEuler = new Euler().setFromQuaternion(resultQuat, "YXZ");
46445
- const resultOrientation = [deg(resultEuler.x), deg(resultEuler.y), deg(resultEuler.z)];
46446
- const resultX = lerp(oldPos[0], newPos[0], easedTime);
46447
- const resultY = lerp(oldPos[1], newPos[1], easedTime);
46448
- const resultZ = lerp(oldPos[2], newPos[2], easedTime);
46449
- const resultCFrame = new CFrame(resultX, resultY, resultZ);
46450
- resultCFrame.Orientation = resultOrientation;
46451
- return resultCFrame;
46452
- }
46453
- class BaseKeyframe {
46454
- time;
46455
- easingDirection = EasingDirection.In;
46456
- easingStyle = PoseEasingStyle.Linear;
46457
- constructor(time2) {
46458
- this.time = time2;
46459
- }
46460
- }
46461
- class PartKeyframe extends BaseKeyframe {
46462
- cframe;
46463
- constructor(time2, cframe) {
46464
- super(time2);
46465
- this.cframe = cframe;
46466
- }
46467
- }
46468
- class FaceKeyframe extends BaseKeyframe {
46469
- value;
46470
- constructor(time2, value) {
46471
- super(time2);
46472
- this.value = value;
46473
- }
46474
- }
46475
- class BaseKeyframeGroup {
46476
- keyframes = [];
46477
- getLowerKeyframe(time2) {
46478
- let resultKeyframe = null;
46479
- for (const keyframe of this.keyframes) {
46480
- if (keyframe.time <= time2) {
46481
- resultKeyframe = keyframe;
46482
- } else {
46483
- break;
46484
- }
46485
- }
46486
- return resultKeyframe;
46487
- }
46488
- getHigherKeyframe(time2) {
46489
- for (const keyframe of this.keyframes) {
46490
- if (keyframe.time > time2) {
46491
- return keyframe;
46492
- }
46493
- }
46494
- return null;
46495
- }
46496
- }
46497
- class PartKeyframeGroup extends BaseKeyframeGroup {
46498
- motorParent = "LowerTorso";
46499
- motorName = "Root";
46500
- keyframes = [];
46501
- getHigherKeyframe(time2) {
46502
- const keyframe = super.getHigherKeyframe(time2);
46503
- return keyframe ? keyframe : null;
46504
- }
46505
- getLowerKeyframe(time2) {
46506
- const keyframe = super.getLowerKeyframe(time2);
46507
- return keyframe ? keyframe : null;
46508
- }
46509
- }
46510
- class FaceKeyframeGroup extends BaseKeyframeGroup {
46511
- controlName = "Corrugator";
46512
- parentName = "Head";
46513
- keyframes = [];
46514
- getHigherKeyframe(time2) {
46515
- const keyframe = super.getHigherKeyframe(time2);
46516
- return keyframe ? keyframe : null;
46517
- }
46518
- getLowerKeyframe(time2) {
46519
- const keyframe = super.getLowerKeyframe(time2);
46520
- return keyframe ? keyframe : null;
46521
- }
46522
- }
46523
- class FloatCurveKey {
46524
- time = 0;
46525
- value = 0;
46526
- interpolation = KeyInterpolationMode.Cubic;
46527
- leftTangent = void 0;
46528
- rightTangent = void 0;
46529
- }
46530
- class FloatCurve {
46531
- keys = [];
46532
- maxTime = 0;
46533
- fromBuffer(arrayBuffer) {
46534
- const view = new SimpleView(arrayBuffer);
46535
- view.readUint32();
46536
- const length = view.readUint32();
46537
- for (let i = 0; i < length; i++) {
46538
- const key = new FloatCurveKey();
46539
- key.interpolation = view.readUint8();
46540
- let hasLeftAndRightTangent = view.readUint8();
46541
- let hasRightTangent = false;
46542
- let hasLeftTangent = false;
46543
- if (hasLeftAndRightTangent - 2 >= 0) {
46544
- hasRightTangent = true;
46545
- hasLeftAndRightTangent -= 2;
46546
- }
46547
- if (hasLeftAndRightTangent - 1 >= 0) {
46548
- hasLeftTangent = true;
46549
- hasLeftAndRightTangent -= 1;
46550
- }
46551
- key.value = view.readFloat32();
46552
- if (hasLeftTangent) {
46553
- key.leftTangent = view.readFloat32();
46554
- } else {
46555
- view.readFloat32();
46556
- }
46557
- if (hasRightTangent) {
46558
- key.rightTangent = view.readFloat32();
46559
- } else {
46560
- view.readFloat32();
46561
- }
46562
- this.keys.push(key);
46563
- }
46564
- view.readUint32();
46565
- view.readUint16();
46566
- view.readUint8();
46567
- for (let i = 0; i < length; i++) {
46568
- this.keys[i].time = view.readUint32() / 65536 / 9.375;
46569
- if (this.keys[i].time > this.maxTime) {
46570
- this.maxTime = this.keys[i].time;
46571
- }
46572
- }
46573
- return this;
46574
- }
46575
- getLowerKey(time2) {
46576
- let resultKey = null;
46577
- for (const key of this.keys) {
46578
- if (key.time <= time2) {
46579
- if (resultKey && resultKey.time > key.time) {
46580
- continue;
46581
- }
46582
- resultKey = key;
46583
- }
46584
- }
46585
- return resultKey;
46586
- }
46587
- getHigherKey(time2) {
46588
- let resultKey = null;
46589
- for (const key of this.keys) {
46590
- if (key.time > time2) {
46591
- if (resultKey && resultKey.time < key.time) {
46592
- continue;
46593
- }
46594
- resultKey = key;
46595
- }
46596
- }
46597
- return resultKey;
46598
- }
46599
- }
46600
- class PartCurve {
46601
- motorParent = "LowerTorso";
46602
- motorName = "Root";
46603
- position;
46604
- rotationOrder = RotationOrder.XYZ;
46605
- rotation;
46606
- }
46607
- class FaceCruve {
46608
- controlName = "Corrugator";
46609
- parentName = "Head";
46610
- value;
46611
- }
46612
- function getCurveValue(time2, lowerKey, higherKey) {
46613
- const lowerX = lowerKey;
46614
- const higherX = higherKey;
46615
- const keyframeTime = mapNum(time2, lowerX.time, higherX.time, 0, 1);
46616
- if (lowerX.interpolation === KeyInterpolationMode.Constant) {
46617
- return lowerX.value;
46618
- } else if (lowerX.interpolation === KeyInterpolationMode.Linear) {
46619
- return (higherX.value - lowerX.value) * keyframeTime + lowerX.value;
46620
- } else if (lowerX.interpolation === KeyInterpolationMode.Cubic) {
46621
- const p0 = lowerX.value;
46622
- const p1 = higherX.value;
46623
- const m0 = lowerX.rightTangent || 0;
46624
- const m1 = higherX.leftTangent || 0;
46625
- const xk = lowerX.time;
46626
- const xk1 = higherX.time;
46627
- return p(mapNum(time2, lowerX.time, higherX.time, 0, 1), p0, p1, m0, m1, xk, xk1);
46628
- }
46629
- throw new Error(`Invalid interpolation type: ${lowerX.interpolation}`);
46630
- }
46631
- class AnimationTrack {
46632
- //data
46633
- trackType = "Sequence";
46634
- keyframeGroups = [];
46635
- //one group per motor6D, only if trackType = "Sequence"
46636
- curves = [];
46637
- //only if trackType = "Curve"
46638
- keyframeTimeMap = /* @__PURE__ */ new Map();
46639
- //frame info
46640
- isPlaying = false;
46641
- timePosition = 0;
46642
- weight = 1;
46643
- finished = true;
46644
- //static info
46645
- rig = void 0;
46646
- length = 0;
46647
- looped = false;
46648
- priority = AnimationPriority.Core;
46649
- shouldUpdateMotors = false;
46650
- updateFaceControls = true;
46651
- animatesParts = true;
46652
- //playing info
46653
- pOriginalWeight = 0;
46654
- pTargetWeight = 0;
46655
- pSpeed = 1;
46656
- pFadedTime = 0;
46657
- pFadeTime = 0.1;
46658
- getNamedMotor(motorName, parentName) {
46659
- if (!this.rig) {
46660
- return void 0;
46661
- }
46662
- const parent = this.rig.FindFirstChild(parentName);
46663
- if (parent) {
46664
- return parent.FindFirstChild(motorName);
46665
- }
46666
- return void 0;
46667
- }
46668
- findMotor6D(part0, part1) {
46669
- if (!this.rig) {
46670
- return void 0;
46671
- }
46672
- const foundMotor6D = part1.FindFirstChildOfClass("Motor6D");
46673
- if (foundMotor6D && foundMotor6D.Prop("Part0") === part0 && foundMotor6D.Prop("Part1") === part1) {
46674
- return foundMotor6D;
46675
- } else {
46676
- const descendants = this.rig.GetDescendants();
46677
- for (const child of descendants) {
46678
- if (child.className === "Motor6D") {
46679
- if (child.Prop("Part0") === part0 && child.Prop("Part1") === part1) {
46680
- return child;
46681
- }
46682
- }
46683
- }
46684
- }
46685
- return void 0;
46686
- }
46687
- findPartKeyframeGroup(motorName, motorParentName) {
46688
- for (const group of this.keyframeGroups) {
46689
- if (group instanceof PartKeyframeGroup && group.motorParent === motorParentName && group.motorName === motorName) {
46690
- return group;
46691
- }
46692
- }
46693
- return void 0;
46694
- }
46695
- findFaceKeyframeGroup(controlName) {
46696
- for (const group of this.keyframeGroups) {
46697
- if (group instanceof FaceKeyframeGroup && group.controlName === controlName) {
46698
- return group;
46699
- }
46700
- }
46701
- return void 0;
46702
- }
46703
- addPartKeyframe(motorName, motorParentName, keyframe) {
46704
- if (!keyframe) {
46705
- return;
46706
- }
46707
- let group = this.findPartKeyframeGroup(motorName, motorParentName);
46708
- if (!group) {
46709
- group = new PartKeyframeGroup();
46710
- group.motorParent = motorParentName;
46711
- group.motorName = motorName;
46712
- this.keyframeGroups.push(group);
46713
- }
46714
- group.keyframes.push(keyframe);
46715
- }
46716
- createPartKeyframe(keyframe, pose) {
46717
- if (!pose.parent || !this.rig) {
46718
- return [void 0, void 0, void 0];
46719
- }
46720
- const part0Name = pose.parent.Prop("Name");
46721
- const part1Name = pose.Prop("Name");
46722
- const part0 = this.rig.FindFirstChild(part0Name);
46723
- const part1 = this.rig.FindFirstChild(part1Name);
46724
- let partKeyframe = void 0;
46725
- let motorName = void 0;
46726
- let motorParentName = void 0;
46727
- if (part0 && part1) {
46728
- const motor = this.findMotor6D(part0, part1);
46729
- if (motor) {
46730
- motorName = motor.Prop("Name");
46731
- if (motor.parent) {
46732
- motorParentName = motor.parent.Prop("Name");
46733
- }
46734
- } else {
46735
- motorName = PartToMotorName[part1.Prop("Name")];
46736
- motorParentName = part1.Prop("Name");
46737
- }
46738
- if (!keyframe.HasProperty("Time")) {
46739
- warn(false, `Invalid animation keyframe, missing property Time`, keyframe);
46740
- return [void 0, void 0, void 0];
46741
- }
46742
- const time2 = keyframe.Prop("Time");
46743
- const cf = pose.Prop("CFrame");
46744
- partKeyframe = new PartKeyframe(time2, cf);
46745
- if (pose.HasProperty("EasingDirection")) {
46746
- partKeyframe.easingDirection = pose.Prop("EasingDirection");
46747
- }
46748
- if (pose.HasProperty("EasingStyle")) {
46749
- partKeyframe.easingStyle = pose.Prop("EasingStyle");
46750
- }
46751
- } else {
46752
- return [void 0, void 0, void 0];
46753
- }
46754
- if (!motorName || !motorParentName || !partKeyframe) {
46755
- warn(false, `Missing either motor or partKeyFrame for parts: ${part0Name} ${part1Name}`);
46756
- return [void 0, void 0, void 0];
46757
- }
46758
- return [motorName, motorParentName, partKeyframe];
46300
+ return [motorName, motorParentName, partKeyframe];
46759
46301
  }
46760
46302
  addFaceKeyframe(controlName, parentName, keyframe) {
46761
46303
  if (!keyframe) {
@@ -47208,6 +46750,9 @@ class AnimatorWrapper extends InstanceWrapper {
47208
46750
  if (name === this.data.currentAnimation) {
47209
46751
  transitionTime = 0.15;
47210
46752
  }
46753
+ if (name === "jump" || name === "climb") {
46754
+ transitionTime = 0.1;
46755
+ }
47211
46756
  this.data.currentAnimation = name;
47212
46757
  let toPlayTrack = void 0;
47213
46758
  if (!name.startsWith("emote.") && !name.startsWith("id.")) {
@@ -47620,6 +47165,10 @@ class AnimatorWrapper extends InstanceWrapper {
47620
47165
  return false;
47621
47166
  }
47622
47167
  }
47168
+ const __vite_glob_0_3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47169
+ __proto__: null,
47170
+ AnimatorWrapper
47171
+ }, Symbol.toStringTag, { value: "Module" }));
47623
47172
  class AttachmentWrapper extends InstanceWrapper {
47624
47173
  static className = "Attachment";
47625
47174
  static requiredProperties = [
@@ -47640,6 +47189,29 @@ class AttachmentWrapper extends InstanceWrapper {
47640
47189
  return this.instance.Prop("CFrame");
47641
47190
  }
47642
47191
  }
47192
+ const __vite_glob_0_4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47193
+ __proto__: null,
47194
+ AttachmentWrapper
47195
+ }, Symbol.toStringTag, { value: "Module" }));
47196
+ class BasePartWrapper extends InstanceWrapper {
47197
+ static className = "BasePart";
47198
+ static requiredProperties = [
47199
+ "Name",
47200
+ "CFrame",
47201
+ "size",
47202
+ "Transparency"
47203
+ ];
47204
+ setup() {
47205
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
47206
+ if (!this.instance.HasProperty("CFrame")) this.instance.addProperty(new Property("CFrame", DataType.CFrame), new CFrame());
47207
+ if (!this.instance.HasProperty("size")) this.instance.addProperty(new Property("size", DataType.Vector3), new Vector32());
47208
+ if (!this.instance.HasProperty("Transparency")) this.instance.addProperty(new Property("Transparency", DataType.Float32), 0);
47209
+ }
47210
+ }
47211
+ const __vite_glob_0_5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47212
+ __proto__: null,
47213
+ BasePartWrapper
47214
+ }, Symbol.toStringTag, { value: "Module" }));
47643
47215
  class BodyColorsWrapper extends InstanceWrapper {
47644
47216
  static className = "BodyColors";
47645
47217
  static requiredProperties = [
@@ -47684,7 +47256,7 @@ class BodyColorsWrapper extends InstanceWrapper {
47684
47256
  };
47685
47257
  const bodyParts = [];
47686
47258
  for (const child of rig.GetChildren()) {
47687
- if (child.className === "Part" || child.className === "MeshPart") {
47259
+ if (child.w?.IsA("BasePart")) {
47688
47260
  bodyParts.push(child);
47689
47261
  }
47690
47262
  }
@@ -47699,6 +47271,10 @@ class BodyColorsWrapper extends InstanceWrapper {
47699
47271
  }
47700
47272
  }
47701
47273
  }
47274
+ const __vite_glob_0_6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47275
+ __proto__: null,
47276
+ BodyColorsWrapper
47277
+ }, Symbol.toStringTag, { value: "Module" }));
47702
47278
  class BodyPartDescriptionWrapper extends InstanceWrapper {
47703
47279
  static className = "BodyPartDescription";
47704
47280
  static requiredProperties = ["Name", "AssetId", "BodyPart", "Color", "HeadShape", "Instance"];
@@ -47711,6 +47287,10 @@ class BodyPartDescriptionWrapper extends InstanceWrapper {
47711
47287
  if (!this.instance.HasProperty("Instance")) this.instance.addProperty(new Property("Instance", DataType.Referent), void 0);
47712
47288
  }
47713
47289
  }
47290
+ const __vite_glob_0_7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47291
+ __proto__: null,
47292
+ BodyPartDescriptionWrapper
47293
+ }, Symbol.toStringTag, { value: "Module" }));
47714
47294
  class DecalWrapper extends InstanceWrapper {
47715
47295
  static className = "Decal";
47716
47296
  static requiredProperties = [
@@ -47732,6 +47312,10 @@ class DecalWrapper extends InstanceWrapper {
47732
47312
  if (!this.instance.HasProperty("UVScale")) this.instance.addProperty(new Property("UVScale", DataType.Vector2), new Vector22());
47733
47313
  }
47734
47314
  }
47315
+ const __vite_glob_0_8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47316
+ __proto__: null,
47317
+ DecalWrapper
47318
+ }, Symbol.toStringTag, { value: "Module" }));
47735
47319
  function pivot_rgb(n) {
47736
47320
  if (n > 0.04045) {
47737
47321
  n = Math.pow((n + 0.055) / 1.055, 2.4);
@@ -47872,6 +47456,10 @@ class MakeupDescriptionWrapper extends InstanceWrapper {
47872
47456
  if (!this.instance.HasProperty("Instance")) this.instance.addProperty(new Property("Instance", DataType.Referent), void 0);
47873
47457
  }
47874
47458
  }
47459
+ const __vite_glob_0_12 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
47460
+ __proto__: null,
47461
+ MakeupDescriptionWrapper
47462
+ }, Symbol.toStringTag, { value: "Module" }));
47875
47463
  function isSameAccessoryDesc(desc0, desc1) {
47876
47464
  return hasSameVal(desc0, desc1, "AssetId") && hasSameVal(desc0, desc1, "AccessoryType") && hasSameVal(desc0, desc1, "IsLayered") && hasSameVal(desc0, desc1, "Puffiness") && hasSameVal(desc0, desc1, "Order") && isSameVector3(desc0.Prop("Position"), desc1.Prop("Position")) && isSameVector3(desc0.Prop("Rotation"), desc1.Prop("Rotation")) && isSameVector3(desc0.Prop("Scale"), desc1.Prop("Scale"));
47877
47465
  }
@@ -48478,9 +48066,10 @@ class HumanoidDescriptionWrapper extends InstanceWrapper {
48478
48066
  const hrp = rig.FindFirstChild("HumanoidRootPart");
48479
48067
  if (hrp) {
48480
48068
  const cf = hrp.Prop("CFrame").clone();
48481
- cf.Position[1] = scaleInfo.stepHeight + hrp.Prop("Size").Y / 2;
48069
+ cf.Position[1] += scaleInfo.stepHeight - humanoid.Prop("HipHeight");
48482
48070
  hrp.setProperty("CFrame", cf);
48483
48071
  }
48072
+ humanoid.setProperty("HipHeight", scaleInfo.stepHeight);
48484
48073
  }
48485
48074
  for (const child of rig.GetDescendants()) {
48486
48075
  if (child.className === "Motor6D" || child.className === "Weld") {
@@ -49185,410 +48774,1220 @@ class HumanoidDescriptionWrapper extends InstanceWrapper {
49185
48774
  toChange.push(animationProp);
49186
48775
  }
49187
48776
  }
49188
- if (!animator?.HasProperty("_HasLoadedAnimation") || !animator?.Prop("_HasLoadedAnimation")) {
49189
- toChange.push("dance1");
49190
- toChange.push("dance2");
49191
- toChange.push("dance3");
49192
- toChange.push("toolnone");
49193
- if (this.instance.Prop("IdleAnimation") <= 0) toChange.push("pose");
49194
- }
49195
- miniPromises.push(this._applyAnimations(humanoid, toChange));
49196
- }
49197
- this._inheritMakeupReferences(originalDescriptionW);
49198
- if (diffs.includes("makeup")) {
49199
- miniPromises.push(this._applyMakeup(humanoid, originalDescriptionW, addedMakeup, removedMakeup));
48777
+ if (!animator?.HasProperty("_HasLoadedAnimation") || !animator?.Prop("_HasLoadedAnimation")) {
48778
+ toChange.push("dance1");
48779
+ toChange.push("dance2");
48780
+ toChange.push("dance3");
48781
+ toChange.push("toolnone");
48782
+ if (this.instance.Prop("IdleAnimation") <= 0) toChange.push("pose");
48783
+ }
48784
+ miniPromises.push(this._applyAnimations(humanoid, toChange));
48785
+ }
48786
+ this._inheritMakeupReferences(originalDescriptionW);
48787
+ if (diffs.includes("makeup")) {
48788
+ miniPromises.push(this._applyMakeup(humanoid, originalDescriptionW, addedMakeup, removedMakeup));
48789
+ }
48790
+ const miniValues = await Promise.all(miniPromises);
48791
+ if (this.cancelApply) return void 0;
48792
+ for (const value of miniValues) {
48793
+ if (value) {
48794
+ return value;
48795
+ }
48796
+ }
48797
+ if (diffs.includes("bodyPart") || diffs.includes("bodyColor")) {
48798
+ this._applyBodyColors(humanoid);
48799
+ }
48800
+ if (diffs.includes("scale") || diffs.includes("bodyPart") || diffs.includes("accessory")) {
48801
+ this._applyScale(humanoid);
48802
+ this._applyScale(humanoid);
48803
+ }
48804
+ }
48805
+ const values = await Promise.all(promises);
48806
+ if (this.cancelApply) return void 0;
48807
+ originalDescription?.Destroy();
48808
+ for (const value of values) {
48809
+ results.push(value);
48810
+ }
48811
+ for (const result of results) {
48812
+ if (result) {
48813
+ return result;
48814
+ }
48815
+ }
48816
+ this.instance.setParent(humanoid);
48817
+ return this.instance;
48818
+ }
48819
+ }
48820
+ const __vite_glob_0_10 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48821
+ __proto__: null,
48822
+ HumanoidDescriptionWrapper
48823
+ }, Symbol.toStringTag, { value: "Module" }));
48824
+ class WeldWrapperData {
48825
+ part0ChangedConnection;
48826
+ lastUpdateTime = 0;
48827
+ timeUpdates = 0;
48828
+ }
48829
+ class WeldWrapper extends InstanceWrapper {
48830
+ static className = "Weld";
48831
+ static requiredProperties = [
48832
+ "Name",
48833
+ "Enabled",
48834
+ "Part0",
48835
+ "Part1",
48836
+ "C0",
48837
+ "C1",
48838
+ "_data"
48839
+ ];
48840
+ setup() {
48841
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
48842
+ if (!this.instance.HasProperty("Enabled")) this.instance.addProperty(new Property("Enabled", DataType.Bool), true);
48843
+ if (!this.instance.HasProperty("Part0")) this.instance.addProperty(new Property("Part0", DataType.Referent), void 0);
48844
+ if (!this.instance.HasProperty("Part1")) this.instance.addProperty(new Property("Part1", DataType.Referent), void 0);
48845
+ if (!this.instance.HasProperty("C0")) this.instance.addProperty(new Property("C0", DataType.CFrame), new CFrame());
48846
+ if (!this.instance.HasProperty("C1")) this.instance.addProperty(new Property("C1", DataType.CFrame), new CFrame());
48847
+ if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new WeldWrapperData());
48848
+ }
48849
+ get data() {
48850
+ return this.instance.Prop("_data");
48851
+ }
48852
+ created() {
48853
+ if (FLAGS.LEGACY_WELD_BEHAVIOR) {
48854
+ const changedConnection = this.instance.Changed.Connect(() => {
48855
+ this.update();
48856
+ });
48857
+ const ancestryChangedConnection = this.instance.AncestryChanged.Connect(() => {
48858
+ this.update();
48859
+ });
48860
+ this.instance.addConnectionReference(changedConnection);
48861
+ this.instance.addConnectionReference(ancestryChangedConnection);
48862
+ }
48863
+ }
48864
+ preRender() {
48865
+ if (FLAGS.LEGACY_WELD_BEHAVIOR) return;
48866
+ const part0 = this.instance.Prop("Part0");
48867
+ const part1 = this.instance.Prop("Part1");
48868
+ if (part0 && part1 && part1.HasProperty("CFrame") && part0 !== part1) {
48869
+ part1.setProperty("CFrame", traverseRigCFrame(this.instance, true, true));
48870
+ }
48871
+ }
48872
+ update(affectedPart = 1) {
48873
+ if (!this.instance.parent) return;
48874
+ if (this.data.lastUpdateTime === Date.now()) {
48875
+ this.data.timeUpdates += 1;
48876
+ if (this.data.timeUpdates > 100) {
48877
+ error(this.instance);
48878
+ error(`${this.instance.className} is exhausted`);
48879
+ return;
48880
+ }
48881
+ } else {
48882
+ this.data.timeUpdates = 0;
48883
+ }
48884
+ this.data.lastUpdateTime = Date.now();
48885
+ const part0 = this.instance.Prop("Part0");
48886
+ if (part0) {
48887
+ if (this.data.part0ChangedConnection) {
48888
+ this.data.part0ChangedConnection.Disconnect();
48889
+ this.instance.removeConnectionReference(this.data.part0ChangedConnection);
48890
+ }
48891
+ }
48892
+ const part1 = this.instance.Prop("Part1");
48893
+ const C0 = this.instance.Prop("C0");
48894
+ const C1 = this.instance.Prop("C1");
48895
+ const transform = this.instance.PropOrDefault("Transform", new CFrame());
48896
+ if (part0 === part1 || !part0 || !part1) {
48897
+ return;
48898
+ }
48899
+ if (this.instance.HasProperty("Enabled") && this.instance.Prop("Enabled")) {
48900
+ if (this.instance.parent) {
48901
+ if (affectedPart === 1) {
48902
+ if (part0.HasProperty("CFrame") && part1.HasProperty("CFrame")) {
48903
+ const part0Cf = part0.Property("CFrame");
48904
+ const offset1 = C1.multiply(transform).inverse();
48905
+ const finalCF = part0Cf.multiply(C0).multiply(offset1);
48906
+ part1.setProperty("CFrame", finalCF);
48907
+ }
48908
+ }
48909
+ } else {
48910
+ warn(false, "Motor6D/Weld is missing parent");
48911
+ }
48912
+ }
48913
+ if (part0) {
48914
+ this.data.part0ChangedConnection = part0.Changed.Connect((propertyName) => {
48915
+ if (propertyName === "CFrame") {
48916
+ this.update(1);
48917
+ }
48918
+ });
48919
+ this.instance.addConnectionReference(this.data.part0ChangedConnection);
48920
+ }
48921
+ }
48922
+ }
48923
+ const __vite_glob_0_22 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48924
+ __proto__: null,
48925
+ WeldWrapper
48926
+ }, Symbol.toStringTag, { value: "Module" }));
48927
+ class ManualWeldWrapper extends WeldWrapper {
48928
+ static className = "ManualWeld";
48929
+ }
48930
+ const __vite_glob_0_13 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48931
+ __proto__: null,
48932
+ ManualWeldWrapper
48933
+ }, Symbol.toStringTag, { value: "Module" }));
48934
+ class MeshPartWrapper extends BasePartWrapper {
48935
+ static className = "MeshPart";
48936
+ static requiredProperties = [
48937
+ ...super.requiredProperties,
48938
+ "DoubleSided"
48939
+ ];
48940
+ setup() {
48941
+ super.setup();
48942
+ if (!this.instance.HasProperty("DoubleSided")) this.instance.addProperty(new Property("DoubleSided", DataType.Bool), false);
48943
+ }
48944
+ }
48945
+ const __vite_glob_0_14 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48946
+ __proto__: null,
48947
+ MeshPartWrapper
48948
+ }, Symbol.toStringTag, { value: "Module" }));
48949
+ class ModelWrapper extends InstanceWrapper {
48950
+ static className = "Model";
48951
+ static requiredProperties = ["Name", "PrimaryPart"];
48952
+ setup() {
48953
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
48954
+ if (!this.instance.HasProperty("PrimaryPart")) this.instance.addProperty(new Property("PrimaryPart", DataType.Referent), void 0);
48955
+ }
48956
+ GetModelCFrame() {
48957
+ const primaryPart = this.instance.Prop("PrimaryPart");
48958
+ if (primaryPart) {
48959
+ return primaryPart.Prop("CFrame");
48960
+ }
48961
+ throw new Error("Model has no PrimaryPart");
48962
+ }
48963
+ }
48964
+ const __vite_glob_0_15 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48965
+ __proto__: null,
48966
+ ModelWrapper
48967
+ }, Symbol.toStringTag, { value: "Module" }));
48968
+ class Motor6DWrapper extends WeldWrapper {
48969
+ static className = "Motor6D";
48970
+ static requiredProperties = [
48971
+ ...super.requiredProperties,
48972
+ "Transform"
48973
+ ];
48974
+ setup() {
48975
+ super.setup();
48976
+ if (!this.instance.HasProperty("Transform")) this.instance.addProperty(new Property("Transform", DataType.CFrame), new CFrame());
48977
+ }
48978
+ }
48979
+ const __vite_glob_0_16 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48980
+ __proto__: null,
48981
+ Motor6DWrapper
48982
+ }, Symbol.toStringTag, { value: "Module" }));
48983
+ class PartWrapper extends BasePartWrapper {
48984
+ static className = "Part";
48985
+ static requiredProperties = [
48986
+ ...super.requiredProperties,
48987
+ "shape"
48988
+ ];
48989
+ setup() {
48990
+ super.setup();
48991
+ if (!this.instance.HasProperty("shape")) this.instance.addProperty(new Property("shape", DataType.Enum), PartType.Block);
48992
+ }
48993
+ }
48994
+ const __vite_glob_0_17 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
48995
+ __proto__: null,
48996
+ PartWrapper
48997
+ }, Symbol.toStringTag, { value: "Module" }));
48998
+ class SoundWrapperData {
48999
+ audioContext;
49000
+ gainNode;
49001
+ buffer;
49002
+ playingSource;
49003
+ }
49004
+ class SoundWrapper extends InstanceWrapper {
49005
+ static className = "Sound";
49006
+ static requiredProperties = ["Name", "Looped", "Playing", "Volume", "_data"];
49007
+ setup() {
49008
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49009
+ if (!this.instance.HasProperty("Looped")) this.instance.addProperty(new Property("Looped", DataType.Bool), false);
49010
+ if (!this.instance.HasProperty("Playing")) this.instance.addProperty(new Property("Playing", DataType.Bool), false);
49011
+ if (!this.instance.HasProperty("Volume")) this.instance.addProperty(new Property("Volume", DataType.Float32), false);
49012
+ if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new SoundWrapperData());
49013
+ }
49014
+ get data() {
49015
+ return this.instance.Prop("_data");
49016
+ }
49017
+ created() {
49018
+ if (this.instance.Prop("Playing")) {
49019
+ this.Play();
49020
+ }
49021
+ this.instance.Destroying.Connect(() => {
49022
+ if (this.data.playingSource) {
49023
+ this.Stop();
49024
+ }
49025
+ this.data.audioContext = void 0;
49026
+ this.data.gainNode = void 0;
49027
+ this.data.buffer = void 0;
49028
+ });
49029
+ }
49030
+ _updateVolume() {
49031
+ if (this.data.gainNode) {
49032
+ if (this.instance.HasProperty("Volume")) {
49033
+ const volume = this.instance.Prop("Volume");
49034
+ this.data.gainNode.gain.value = volume;
49035
+ }
49036
+ }
49037
+ }
49038
+ setPlaying(value) {
49039
+ this.instance.setProperty("Playing", value);
49040
+ }
49041
+ playSource() {
49042
+ if (!this.data.audioContext || !this.data.gainNode || !this.data.buffer) return;
49043
+ this.data.playingSource = this.data.audioContext.createBufferSource();
49044
+ this.data.playingSource.buffer = this.data.buffer;
49045
+ this.data.playingSource.connect(this.data.gainNode);
49046
+ this.data.gainNode.connect(this.data.audioContext.destination);
49047
+ this._updateVolume();
49048
+ this.data.playingSource.start(0);
49049
+ this.data.playingSource.onended = (() => {
49050
+ if (this.instance.Prop("Looped")) {
49051
+ this.Play();
49052
+ } else {
49053
+ this.Stop();
49054
+ }
49055
+ });
49056
+ }
49057
+ Play() {
49058
+ if (!FLAGS.AUDIO_ENABLED) return;
49059
+ this.Stop();
49060
+ this.setPlaying(true);
49061
+ if (!this.data.audioContext) {
49062
+ this.data.audioContext = new AudioContext();
49063
+ }
49064
+ if (!this.data.gainNode) {
49065
+ this.data.gainNode = this.data.audioContext.createGain();
49066
+ }
49067
+ if (!this.data.buffer) {
49068
+ let audioUrl = void 0;
49069
+ if (this.instance.HasProperty("SoundId")) {
49070
+ audioUrl = this.instance.Prop("SoundId");
49071
+ } else if (this.instance.HasProperty("AudioContent")) {
49072
+ audioUrl = this.instance.Prop("AudioContent").uri;
49073
+ }
49074
+ if (audioUrl && audioUrl.length > 0) {
49075
+ API.Asset.GetAssetBuffer(audioUrl).then((responseBuffer) => {
49076
+ if (responseBuffer instanceof Response || !this.data.audioContext) return;
49077
+ const buffer2 = responseBuffer.slice(0);
49078
+ this.data.audioContext.decodeAudioData(buffer2).then((decodedData) => {
49079
+ if (!this.data.audioContext || !this.data.gainNode) return;
49080
+ this.data.buffer = decodedData;
49081
+ this.playSource();
49082
+ });
49083
+ });
49084
+ }
49085
+ } else if (this.data.buffer) {
49086
+ this.playSource();
49087
+ }
49088
+ }
49089
+ Stop() {
49090
+ this.setPlaying(false);
49091
+ if (this.data.playingSource) {
49092
+ this.data.playingSource.stop();
49093
+ this.data.playingSource = void 0;
49094
+ }
49095
+ }
49096
+ }
49097
+ const __vite_glob_0_19 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49098
+ __proto__: null,
49099
+ SoundWrapper
49100
+ }, Symbol.toStringTag, { value: "Module" }));
49101
+ class ScriptWrapperData {
49102
+ shouldStop = false;
49103
+ }
49104
+ class ScriptWrapper extends InstanceWrapper {
49105
+ static className = "Script";
49106
+ static requiredProperties = ["Name", "_data"];
49107
+ setup() {
49108
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49109
+ if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new ScriptWrapperData());
49110
+ }
49111
+ get data() {
49112
+ return this.instance.Prop("_data");
49113
+ }
49114
+ created() {
49115
+ this.Run();
49116
+ }
49117
+ Run() {
49118
+ switch (this.instance.Prop("Name")) {
49119
+ case "ChickenSounds":
49120
+ case "HarmonicaSounds":
49121
+ case "SoundPlayer":
49122
+ this.SoundPlayer(this.instance);
49123
+ break;
49124
+ }
49125
+ }
49126
+ //Scripts
49127
+ async SoundPlayer(script) {
49128
+ let Handle = void 0;
49129
+ if (script.parent && script.parent.Prop("Name") === "Handle") {
49130
+ Handle = script.parent;
49131
+ } else if (script.parent && script.parent.FindFirstChild("Handle")) {
49132
+ Handle = script.parent.FindFirstChild("Handle");
49133
+ }
49134
+ if (!Handle) return;
49135
+ const Hat = Handle.parent;
49136
+ if (!Hat) return;
49137
+ const Sounds = [];
49138
+ for (const child of Handle.GetDescendants()) {
49139
+ if (child.className === "Sound") {
49140
+ Sounds.push(child);
49141
+ }
49142
+ }
49143
+ function IsBeingWorn() {
49144
+ return Hat?.parent?.FindFirstChild("Humanoid");
49145
+ }
49146
+ let maxTime = 20;
49147
+ if (script.Prop("Name") === "SoundPlayer") {
49148
+ maxTime = 15;
49149
+ }
49150
+ while (true) {
49151
+ await Wait(mathRandom(5, maxTime));
49152
+ if (this.instance.destroyed || this.data.shouldStop) return;
49153
+ if (IsBeingWorn()) {
49154
+ const index = mathRandom(0, Sounds.length - 1);
49155
+ const Sound = Sounds[index];
49156
+ const soundWrapper = new SoundWrapper(Sound);
49157
+ soundWrapper.Play();
49158
+ }
49159
+ }
49160
+ }
49161
+ }
49162
+ const __vite_glob_0_18 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49163
+ __proto__: null,
49164
+ ScriptWrapper
49165
+ }, Symbol.toStringTag, { value: "Module" }));
49166
+ class ToolWrapper extends InstanceWrapper {
49167
+ static className = "Tool";
49168
+ static requiredProperties = [
49169
+ "Name",
49170
+ "Grip"
49171
+ ];
49172
+ setup() {
49173
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49174
+ if (!this.instance.HasProperty("Grip")) this.instance.addProperty(new Property("Grip", DataType.CFrame), new CFrame());
49175
+ }
49176
+ created() {
49177
+ this.instance.AncestryChanged.Connect(() => {
49178
+ this.createWeld();
49179
+ });
49180
+ }
49181
+ //doing this is actually inaccurate because tools dont create welds, but its easier
49182
+ createWeld() {
49183
+ const handle = this.instance.FindFirstChild("Handle");
49184
+ const rig = this.instance.parent;
49185
+ const grip = this.instance.PropOrDefault("Grip", new CFrame()).clone();
49186
+ if (handle) {
49187
+ const oldToolWeld = handle.FindFirstChild("ToolWeld_GripRoAvatar");
49188
+ if (oldToolWeld) {
49189
+ oldToolWeld.Destroy();
49190
+ }
49191
+ }
49192
+ const humanoid = rig?.FindFirstChildOfClass("Humanoid");
49193
+ if (handle && rig && rig.className === "Model" && humanoid) {
49194
+ const rightHand = rig.FindFirstChild("RightHand") || rig.FindFirstChild("Right Arm");
49195
+ if (rightHand) {
49196
+ for (const child of rightHand.GetDescendants()) {
49197
+ if (child.Prop("Name") === "RightGripAttachment") {
49198
+ const rightGripAttCF = child.PropOrDefault("CFrame", new CFrame()).clone();
49199
+ if (humanoid.Prop("RigType") === HumanoidRigType.R6) {
49200
+ rightGripAttCF.Orientation[0] -= 90;
49201
+ }
49202
+ const weld = new Instance("Weld");
49203
+ weld.addProperty(new Property("Name", DataType.String), "ToolWeld_GripRoAvatar");
49204
+ weld.addProperty(new Property("Archivable", DataType.Bool), true);
49205
+ weld.addProperty(new Property("C0", DataType.CFrame), rightGripAttCF);
49206
+ weld.addProperty(new Property("C1", DataType.CFrame), grip);
49207
+ weld.addProperty(new Property("Part0", DataType.Referent), child.parent);
49208
+ weld.addProperty(new Property("Part1", DataType.Referent), handle);
49209
+ weld.addProperty(new Property("Active", DataType.Bool), true);
49210
+ weld.addProperty(new Property("Enabled", DataType.Bool), false);
49211
+ weld.setParent(handle);
49212
+ weld.setProperty("Enabled", true);
49213
+ }
49214
+ }
49200
49215
  }
49201
- const miniValues = await Promise.all(miniPromises);
49202
- if (this.cancelApply) return void 0;
49203
- for (const value of miniValues) {
49204
- if (value) {
49205
- return value;
49216
+ }
49217
+ }
49218
+ }
49219
+ const __vite_glob_0_20 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49220
+ __proto__: null,
49221
+ ToolWrapper
49222
+ }, Symbol.toStringTag, { value: "Module" }));
49223
+ class WedgePartWrapper extends BasePartWrapper {
49224
+ static className = "WedgePart";
49225
+ }
49226
+ const __vite_glob_0_21 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49227
+ __proto__: null,
49228
+ WedgePartWrapper
49229
+ }, Symbol.toStringTag, { value: "Module" }));
49230
+ const modules$1 = /* @__PURE__ */ Object.assign({ "./instance/Accessory.ts": __vite_glob_0_0$1, "./instance/AccessoryDescription.ts": __vite_glob_0_1$1, "./instance/AnimationConstraint.ts": __vite_glob_0_2$1, "./instance/Animator.ts": __vite_glob_0_3, "./instance/Attachment.ts": __vite_glob_0_4, "./instance/BasePart.ts": __vite_glob_0_5, "./instance/BodyColors.ts": __vite_glob_0_6, "./instance/BodyPartDescription.ts": __vite_glob_0_7, "./instance/Decal.ts": __vite_glob_0_8, "./instance/FaceControls.ts": __vite_glob_0_9, "./instance/HumanoidDescription.ts": __vite_glob_0_10, "./instance/InstanceWrapper.ts": __vite_glob_0_11, "./instance/MakeupDescription.ts": __vite_glob_0_12, "./instance/ManualWeld.ts": __vite_glob_0_13, "./instance/MeshPart.ts": __vite_glob_0_14, "./instance/Model.ts": __vite_glob_0_15, "./instance/Motor6D.ts": __vite_glob_0_16, "./instance/Part.ts": __vite_glob_0_17, "./instance/Script.ts": __vite_glob_0_18, "./instance/Sound.ts": __vite_glob_0_19, "./instance/Tool.ts": __vite_glob_0_20, "./instance/WedgePart.ts": __vite_glob_0_21, "./instance/Weld.ts": __vite_glob_0_22 });
49231
+ function RegisterWrappers() {
49232
+ for (const module of Object.values(modules$1)) {
49233
+ for (const exprt of Object.values(module)) {
49234
+ let prototype = Object.getPrototypeOf(exprt);
49235
+ while (prototype) {
49236
+ if (prototype === InstanceWrapper) {
49237
+ exprt.register();
49238
+ break;
49206
49239
  }
49207
- }
49208
- if (diffs.includes("bodyPart") || diffs.includes("bodyColor")) {
49209
- this._applyBodyColors(humanoid);
49210
- }
49211
- if (diffs.includes("scale") || diffs.includes("bodyPart") || diffs.includes("accessory")) {
49212
- this._applyScale(humanoid);
49213
- this._applyScale(humanoid);
49240
+ prototype = Object.getPrototypeOf(prototype);
49214
49241
  }
49215
49242
  }
49216
- const values = await Promise.all(promises);
49217
- if (this.cancelApply) return void 0;
49218
- originalDescription?.Destroy();
49219
- for (const value of values) {
49220
- results.push(value);
49243
+ }
49244
+ }
49245
+ const attachmentGeometry = new SphereGeometry(0.125, 16, 8);
49246
+ class AttachmentDesc extends RenderDesc {
49247
+ static classTypes = ["Attachment"];
49248
+ visible = false;
49249
+ cframe = new CFrame();
49250
+ isSame(other) {
49251
+ return this.visible === other.visible && this.cframe.isSame(other.cframe);
49252
+ }
49253
+ needsRegeneration(other) {
49254
+ return this.visible !== other.visible;
49255
+ }
49256
+ virtualFromRenderDesc(other) {
49257
+ this.cframe = other.cframe.clone();
49258
+ }
49259
+ fromInstance(child) {
49260
+ const attachmentW = new AttachmentWrapper(child);
49261
+ this.cframe = attachmentW.getWorldCFrame();
49262
+ this.visible = child.PropOrDefault("Visible", this.visible) || FLAGS.ALWAYS_SHOW_ATTACHMENTS;
49263
+ }
49264
+ async compileResults() {
49265
+ this.results = [];
49266
+ if (this.visible) {
49267
+ const mesh = new Mesh(attachmentGeometry, new MeshLambertMaterial({ color: 65280 }));
49268
+ mesh.name = this.instance ? this.instance.PropOrDefault("Name", "Unknown") + "_Att" : "Unknown_Att";
49269
+ this.results.push(mesh);
49221
49270
  }
49222
- for (const result of results) {
49223
- if (result) {
49224
- return result;
49225
- }
49271
+ this.updateResults();
49272
+ return this.results;
49273
+ }
49274
+ updateResults() {
49275
+ if (!this.results) return;
49276
+ for (const attachment of this.results) {
49277
+ const resultCF = this.cframe;
49278
+ setTHREEObjectCF(attachment, resultCF);
49279
+ }
49280
+ }
49281
+ dispose(_renderer, scene) {
49282
+ if (!this.results) return;
49283
+ for (const result of this.results) {
49284
+ scene.remove(result);
49226
49285
  }
49227
- this.instance.setParent(humanoid);
49228
- return this.instance;
49229
49286
  }
49230
49287
  }
49231
- class WeldWrapperData {
49232
- part0ChangedConnection;
49233
- lastUpdateTime = 0;
49234
- timeUpdates = 0;
49288
+ const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49289
+ __proto__: null,
49290
+ AttachmentDesc
49291
+ }, Symbol.toStringTag, { value: "Module" }));
49292
+ const particle_vertexShader = `
49293
+ attribute vec3 instanceColor;
49294
+ attribute vec2 instanceSeedTime;
49295
+ attribute float instanceOpacity;
49296
+
49297
+ varying vec2 vUv;
49298
+ varying vec3 vInstanceColor;
49299
+ varying float vInstanceOpacity;
49300
+ varying vec2 vInstanceSeedTime;
49301
+
49302
+ uniform float uZOffset;
49303
+
49304
+ void main() {
49305
+ vUv = uv;
49306
+ vInstanceColor = instanceColor;
49307
+ vInstanceOpacity = instanceOpacity;
49308
+ vInstanceSeedTime = instanceSeedTime;
49309
+
49310
+ vec4 modelViewPosition = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
49311
+
49312
+ vec3 viewDir = normalize(modelViewPosition.xyz);
49313
+ modelViewPosition.xyz += viewDir * -uZOffset;
49314
+
49315
+ gl_Position = projectionMatrix * modelViewPosition;
49235
49316
  }
49236
- class WeldWrapper extends InstanceWrapper {
49237
- static className = "Weld";
49238
- static requiredProperties = [
49239
- "Name",
49240
- "Enabled",
49241
- "Part0",
49242
- "Part1",
49243
- "C0",
49244
- "C1",
49245
- "_data"
49246
- ];
49247
- setup() {
49248
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49249
- if (!this.instance.HasProperty("Enabled")) this.instance.addProperty(new Property("Enabled", DataType.Bool), true);
49250
- if (!this.instance.HasProperty("Part0")) this.instance.addProperty(new Property("Part0", DataType.Referent), void 0);
49251
- if (!this.instance.HasProperty("Part1")) this.instance.addProperty(new Property("Part1", DataType.Referent), void 0);
49252
- if (!this.instance.HasProperty("C0")) this.instance.addProperty(new Property("C0", DataType.CFrame), new CFrame());
49253
- if (!this.instance.HasProperty("C1")) this.instance.addProperty(new Property("C1", DataType.CFrame), new CFrame());
49254
- if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new WeldWrapperData());
49317
+ `;
49318
+ const particle_fragmentShader = `
49319
+ varying vec2 vUv;
49320
+ varying vec3 vInstanceColor;
49321
+ varying float vInstanceOpacity;
49322
+ varying vec2 vInstanceSeedTime;
49323
+
49324
+ uniform sampler2D uColorMap;
49325
+ uniform sampler2D uAlphaMap;
49326
+ uniform sampler2D uMap;
49327
+ uniform float uOpacity;
49328
+
49329
+ void main() {
49330
+ float seed = vInstanceSeedTime.x;
49331
+ float time = vInstanceSeedTime.y;
49332
+
49333
+ // Sample the texture using the UV coordinates
49334
+ vec4 texColor = texture2D(uMap, vUv);
49335
+ vec4 alphaTex = texture2D(uAlphaMap, vec2(time, seed));
49336
+ vec4 colorTex = texture2D(uColorMap, vec2(time, seed));
49337
+
49338
+ // Tint texture with our color
49339
+ vec4 tintedColor = texColor * vec4(vInstanceColor, 1.0);
49340
+
49341
+ // Apply opacity to the texture alpha
49342
+ vec4 opacityColor = tintedColor * vec4(1.0, 1.0, 1.0, uOpacity * vInstanceOpacity) * alphaTex.r;
49343
+
49344
+ // Apply that weird color things sparkles have
49345
+ vec4 finalColor = opacityColor;
49346
+ finalColor.rgb = mix(opacityColor.rgb, opacityColor.rgb * colorTex.rgb, colorTex.a);
49347
+
49348
+ gl_FragColor = finalColor;
49349
+ }
49350
+ `;
49351
+ function randomBetween(min, max) {
49352
+ return Math.random() * (max - min) + min;
49353
+ }
49354
+ function velocityFromSpread(speed, spread) {
49355
+ const theta = spread.X;
49356
+ const phi = spread.Y;
49357
+ const velocity = new Vector32(
49358
+ -speed * Math.sin(phi),
49359
+ -speed * Math.cos(phi) * Math.sin(theta),
49360
+ -speed * Math.cos(phi) * Math.cos(theta)
49361
+ );
49362
+ return velocity;
49363
+ }
49364
+ class Particle {
49365
+ lifetime;
49366
+ time = 0;
49367
+ position;
49368
+ rotation;
49369
+ velocity;
49370
+ rotationSpeed;
49371
+ seed = Math.random();
49372
+ constructor(lifetime, position, rotation, velocity, rotationSpeed) {
49373
+ this.lifetime = lifetime;
49374
+ this.position = position;
49375
+ this.rotation = rotation;
49376
+ this.velocity = velocity;
49377
+ this.rotationSpeed = rotationSpeed;
49255
49378
  }
49256
- get data() {
49257
- return this.instance.Prop("_data");
49379
+ camDistance(renderScene) {
49380
+ const cameraPos = new Vector32(...renderScene.camera.position.toArray());
49381
+ const particlePos = this.position;
49382
+ const distance2 = cameraPos.minus(particlePos).magnitude();
49383
+ return distance2;
49258
49384
  }
49259
- created() {
49260
- if (FLAGS.LEGACY_WELD_BEHAVIOR) {
49261
- const changedConnection = this.instance.Changed.Connect(() => {
49262
- this.update();
49263
- });
49264
- const ancestryChangedConnection = this.instance.AncestryChanged.Connect(() => {
49265
- this.update();
49266
- });
49267
- this.instance.addConnectionReference(changedConnection);
49268
- this.instance.addConnectionReference(ancestryChangedConnection);
49385
+ getMatrix(renderScene, size, orientation) {
49386
+ const camera = renderScene.camera;
49387
+ const particlePos = new Vector3$1(...this.position.toVec3());
49388
+ const translation = new Matrix4().makeTranslation(particlePos);
49389
+ const scale = new Matrix4().makeScale(size, size, 1);
49390
+ switch (orientation) {
49391
+ case ParticleOrientation.FacingCameraWorldUp: {
49392
+ const cameraLookVector = new Vector3$1();
49393
+ camera.getWorldDirection(cameraLookVector);
49394
+ const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), new Vector3$1(0, 1, 0), cameraLookVector);
49395
+ const _pos = new Vector3$1();
49396
+ const _scale = new Vector3$1();
49397
+ const rotationQuat = new Quaternion();
49398
+ rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
49399
+ const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
49400
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
49401
+ const offsetRotation = new Matrix4().makeRotationAxis(new Vector3$1(1, 0, 0), rad(-90));
49402
+ const offset2Rotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 1, 0), rad(180));
49403
+ const final = translation.multiply(rotation).multiply(offsetRotation).multiply(offset2Rotation).multiply(flatRotation).multiply(scale);
49404
+ return final;
49405
+ }
49406
+ case ParticleOrientation.VelocityPerpendicular: {
49407
+ const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
49408
+ const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), normalizedVelocity, new Vector3$1(0, 1, 0));
49409
+ const _pos = new Vector3$1();
49410
+ const _scale = new Vector3$1();
49411
+ const rotationQuat = new Quaternion();
49412
+ rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
49413
+ const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
49414
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
49415
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
49416
+ return final;
49417
+ }
49418
+ case ParticleOrientation.VelocityParallel: {
49419
+ const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
49420
+ const rotationParticlePosMatrix = new Matrix4().lookAt(particlePos, camera.position, normalizedVelocity);
49421
+ const _pos = new Vector3$1();
49422
+ const _scale = new Vector3$1();
49423
+ const rotationQuat = new Quaternion();
49424
+ rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
49425
+ const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
49426
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation + 90));
49427
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
49428
+ return final;
49429
+ }
49430
+ case ParticleOrientation.FacingCamera:
49431
+ default: {
49432
+ const rotation = new Matrix4().makeRotationFromQuaternion(camera.quaternion);
49433
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
49434
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
49435
+ return final;
49436
+ }
49269
49437
  }
49270
49438
  }
49271
- preRender() {
49272
- if (FLAGS.LEGACY_WELD_BEHAVIOR) return;
49273
- const part0 = this.instance.Prop("Part0");
49274
- const part1 = this.instance.Prop("Part1");
49275
- if (part0 && part1 && part1.HasProperty("CFrame") && part0 !== part1) {
49276
- part1.setProperty("CFrame", traverseRigCFrame(this.instance, true, true));
49439
+ tick(dt, drag, acceleration) {
49440
+ this.time += specialClamp(dt, 0, this.lifetime);
49441
+ this.position = this.position.add(this.velocity.multiply(new Vector32(dt, dt, dt)));
49442
+ const accMult = 0.5 * Math.pow(dt, 2);
49443
+ this.position = this.position.add(acceleration.multiply(new Vector32(accMult, accMult, accMult)));
49444
+ this.velocity = this.velocity.add(acceleration.multiply(new Vector32(dt, dt, dt)));
49445
+ const dragVal = Math.pow(2, -drag * dt);
49446
+ this.velocity = this.velocity.multiply(new Vector32(dragVal, dragVal, dragVal));
49447
+ this.rotation += this.rotationSpeed * dt;
49448
+ }
49449
+ }
49450
+ class EmitterDesc extends DisposableDesc {
49451
+ passedTime = 0;
49452
+ lockedToPart = false;
49453
+ lifetime = new NumberRange(1, 1);
49454
+ spreadAngle = new Vector22(0, 0);
49455
+ speed = new NumberRange(1, 1);
49456
+ rotation = new NumberRange(0, 0);
49457
+ rotationSpeed = new NumberRange(0, 0);
49458
+ localAcceleration = new Vector32(0, 0, 0);
49459
+ acceleration = new Vector32(0, 0, 0);
49460
+ drag = 0;
49461
+ timeScale = 1;
49462
+ orientation = ParticleOrientation.FacingCamera;
49463
+ zOffset = 0;
49464
+ offset = new Vector32();
49465
+ shapeInOut = 0;
49466
+ opacity = 1;
49467
+ lightEmission = 1;
49468
+ blending = AdditiveBlending;
49469
+ color = new ColorSequence();
49470
+ size = new NumberSequence();
49471
+ transparency = new NumberSequence([new NumberSequenceKeypoint(0, 0, 0)]);
49472
+ normalizeSizeKeypointTime = true;
49473
+ //requires recompilation
49474
+ rate = 10;
49475
+ colorTexture;
49476
+ alphaTexture;
49477
+ texture;
49478
+ //results
49479
+ instanceOpacityBuffer;
49480
+ instanceColorBuffer;
49481
+ instanceSeedTimeBuffer;
49482
+ result;
49483
+ particles = [];
49484
+ initialParticleCount = 0;
49485
+ get maxCount() {
49486
+ const calculatedMax = Math.max(Math.ceil(this.lifetime.Max * this.rate) * 2, 1);
49487
+ const particleMax = this.initialParticleCount + calculatedMax;
49488
+ return particleMax;
49489
+ }
49490
+ needsRegeneration(other) {
49491
+ return this.texture === other.texture && this.alphaTexture === other.alphaTexture && this.colorTexture === other.colorTexture && this.rate === other.rate;
49492
+ }
49493
+ isSame(other) {
49494
+ return !this.needsRegeneration(other) && this.lockedToPart === other.lockedToPart && this.lifetime.isSame(other.lifetime) && this.spreadAngle.isSame(other.spreadAngle) && this.speed.isSame(other.speed) && this.rotation.isSame(other.rotation) && this.rotationSpeed.isSame(other.rotationSpeed) && this.localAcceleration.isSame(other.localAcceleration) && this.acceleration.isSame(other.acceleration) && this.drag === other.drag && this.timeScale === other.timeScale && this.orientation === other.orientation && this.zOffset === other.zOffset && this.offset.isSame(other.offset) && this.shapeInOut === other.shapeInOut && this.opacity === other.opacity && this.lightEmission === other.lightEmission && this.blending === other.blending && this.color.isSame(other.color) && this.size.isSame(other.size) && this.transparency.isSame(other.transparency) && this.normalizeSizeKeypointTime === other.normalizeSizeKeypointTime;
49495
+ }
49496
+ fromEmitterDesc(other) {
49497
+ this.lockedToPart = other.lockedToPart;
49498
+ this.lifetime = other.lifetime.clone();
49499
+ this.rate = other.rate;
49500
+ this.spreadAngle = other.spreadAngle.clone();
49501
+ this.speed = other.speed.clone();
49502
+ this.rotation = other.rotation.clone();
49503
+ this.rotationSpeed = other.rotationSpeed.clone();
49504
+ this.localAcceleration = other.localAcceleration.clone();
49505
+ this.acceleration = other.acceleration.clone();
49506
+ this.drag = other.drag;
49507
+ this.timeScale = other.timeScale;
49508
+ this.orientation = other.orientation;
49509
+ this.zOffset = other.zOffset;
49510
+ this.offset = other.offset.clone();
49511
+ this.shapeInOut = other.shapeInOut;
49512
+ this.opacity = other.opacity;
49513
+ this.lightEmission = other.lightEmission;
49514
+ this.blending = other.blending;
49515
+ this.color = other.color.clone();
49516
+ this.size = other.size.clone();
49517
+ this.transparency = other.transparency.clone();
49518
+ this.normalizeSizeKeypointTime = other.normalizeSizeKeypointTime;
49519
+ }
49520
+ dispose(renderer, scene) {
49521
+ const mesh = this.result;
49522
+ if (mesh) {
49523
+ this.disposeMesh(scene, mesh);
49524
+ this.disposeRenderLists(renderer);
49277
49525
  }
49278
49526
  }
49279
- update(affectedPart = 1) {
49280
- if (!this.instance.parent) return;
49281
- if (this.data.lastUpdateTime === Date.now()) {
49282
- this.data.timeUpdates += 1;
49283
- if (this.data.timeUpdates > 100) {
49284
- error(this.instance);
49285
- error(`${this.instance.className} is exhausted`);
49286
- return;
49527
+ async getTexture(texture, colorSpace = SRGBColorSpace) {
49528
+ if (texture) {
49529
+ const source = texture.replace(".dds", ".png");
49530
+ const image = await API.Generic.LoadImage(source);
49531
+ if (image) {
49532
+ const texture2 = new Texture(image);
49533
+ texture2.wrapS = ClampToEdgeWrapping;
49534
+ texture2.wrapT = ClampToEdgeWrapping;
49535
+ texture2.colorSpace = colorSpace;
49536
+ texture2.needsUpdate = true;
49537
+ return texture2;
49287
49538
  }
49288
- } else {
49289
- this.data.timeUpdates = 0;
49290
49539
  }
49291
- this.data.lastUpdateTime = Date.now();
49292
- const part0 = this.instance.Prop("Part0");
49293
- if (part0) {
49294
- if (this.data.part0ChangedConnection) {
49295
- this.data.part0ChangedConnection.Disconnect();
49296
- this.instance.removeConnectionReference(this.data.part0ChangedConnection);
49540
+ return void 0;
49541
+ }
49542
+ async compileResult(renderer, scene) {
49543
+ const originalResult = this.result;
49544
+ const texturePromises = [
49545
+ this.getTexture(this.texture),
49546
+ this.getTexture(this.alphaTexture, NoColorSpace),
49547
+ this.getTexture(this.colorTexture)
49548
+ ];
49549
+ let [mapToUse, alphaMapToUse, colorMapToUse] = await Promise.all(texturePromises);
49550
+ if (!mapToUse) {
49551
+ mapToUse = new DataTexture(new Uint8Array([0, 0, 0, 0]), 1, 1, RGBAFormat);
49552
+ mapToUse.needsUpdate = true;
49553
+ }
49554
+ if (!alphaMapToUse) {
49555
+ alphaMapToUse = new DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, RGBAFormat);
49556
+ alphaMapToUse.needsUpdate = true;
49557
+ }
49558
+ if (!colorMapToUse) {
49559
+ colorMapToUse = new DataTexture(new Uint8Array([255, 255, 255, 255]), 1, 1, RGBAFormat);
49560
+ colorMapToUse.needsUpdate = true;
49561
+ }
49562
+ const geometry = new PlaneGeometry(2, 2);
49563
+ this.instanceColorBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount * 3), 3);
49564
+ geometry.setAttribute("instanceColor", this.instanceColorBuffer);
49565
+ this.instanceOpacityBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount), 1);
49566
+ geometry.setAttribute("instanceOpacity", this.instanceOpacityBuffer);
49567
+ this.instanceSeedTimeBuffer = new InstancedBufferAttribute(new Float32Array(this.maxCount), 2);
49568
+ geometry.setAttribute("instanceSeedTime", this.instanceSeedTimeBuffer);
49569
+ const material = new ShaderMaterial({
49570
+ transparent: true,
49571
+ depthWrite: false,
49572
+ side: DoubleSide,
49573
+ blending: this.blending,
49574
+ opacity: this.opacity,
49575
+ vertexShader: particle_vertexShader,
49576
+ fragmentShader: particle_fragmentShader,
49577
+ uniforms: {
49578
+ uMap: { value: mapToUse },
49579
+ uAlphaMap: { value: alphaMapToUse },
49580
+ uColorMap: { value: colorMapToUse },
49581
+ uOpacity: { value: this.opacity },
49582
+ uZOffset: { value: this.zOffset }
49297
49583
  }
49584
+ });
49585
+ this.result = new InstancedMesh(geometry, material, this.maxCount);
49586
+ this.result.name = "Particles";
49587
+ this.result.frustumCulled = false;
49588
+ if (originalResult) {
49589
+ this.disposeMesh(scene, originalResult);
49590
+ this.disposeRenderLists(renderer);
49298
49591
  }
49299
- const part1 = this.instance.Prop("Part1");
49300
- const C0 = this.instance.Prop("C0");
49301
- const C1 = this.instance.Prop("C1");
49302
- const transform = this.instance.PropOrDefault("Transform", new CFrame());
49303
- if (part0 === part1 || !part0 || !part1) {
49592
+ return this.result;
49593
+ }
49594
+ emit(groupDesc) {
49595
+ if (this.particles.length >= this.maxCount || groupDesc.enabled === false) {
49304
49596
  return;
49305
49597
  }
49306
- if (this.instance.HasProperty("Enabled") && this.instance.Prop("Enabled")) {
49307
- if (this.instance.parent) {
49308
- if (affectedPart === 1) {
49309
- if (part0.HasProperty("CFrame") && part1.HasProperty("CFrame")) {
49310
- const part0Cf = part0.Property("CFrame");
49311
- const offset1 = C1.multiply(transform).inverse();
49312
- const finalCF = part0Cf.multiply(C0).multiply(offset1);
49313
- part1.setProperty("CFrame", finalCF);
49314
- }
49315
- }
49316
- } else {
49317
- warn(false, "Motor6D/Weld is missing parent");
49598
+ const speed = randomBetween(this.speed.Min, this.speed.Max);
49599
+ const spreadX = rad((Math.random() - 0.5) * 2 * Math.abs(this.spreadAngle.X));
49600
+ const spreadY = rad((Math.random() - 0.5) * 2 * Math.abs(this.spreadAngle.Y));
49601
+ const spread = new Vector22(spreadX, spreadY);
49602
+ let velocityMultiplierScalar = 1;
49603
+ if (this.shapeInOut === ParticleEmitterShapeInOut.Inward) {
49604
+ velocityMultiplierScalar = -1;
49605
+ } else if (this.shapeInOut === ParticleEmitterShapeInOut.InAndOut) {
49606
+ velocityMultiplierScalar = Math.random() > 0.5 ? 1 : -1;
49607
+ }
49608
+ const velocityMultiplier = new Vector3$1(velocityMultiplierScalar, velocityMultiplierScalar, velocityMultiplierScalar);
49609
+ const velocityFront = velocityFromSpread(speed, spread);
49610
+ const velocityOriginal = new Vector3$1(...velocityFront.toVec3()).multiply(velocityMultiplier);
49611
+ const velocityLocal = velocityOriginal.applyQuaternion(groupDesc.getNormalQuaternionForVelocity());
49612
+ const worldVelocity = velocityLocal.applyQuaternion(new Quaternion().setFromRotationMatrix(groupDesc.cframe.getTHREEMatrix()));
49613
+ const worldVelocityRoblox = new Vector32(...worldVelocity.toArray());
49614
+ let localPos = groupDesc.getRandomLocalPos();
49615
+ localPos = localPos.add(this.offset);
49616
+ const worldPos = groupDesc.toWorldSpace(localPos);
49617
+ const particle = new Particle(
49618
+ randomBetween(this.lifetime.Min, this.lifetime.Max),
49619
+ worldPos,
49620
+ randomBetween(this.rotation.Min, this.rotation.Max),
49621
+ worldVelocityRoblox,
49622
+ randomBetween(this.rotationSpeed.Min, this.rotationSpeed.Max)
49623
+ );
49624
+ this.particles.push(particle);
49625
+ }
49626
+ vectorLocalToWorld(pivot, vector) {
49627
+ const localVectorCF = new CFrame(...vector.toVec3());
49628
+ const rotatedWorldCF = pivot.clone();
49629
+ rotatedWorldCF.Position = [0, 0, 0];
49630
+ const localVectorToWorldCF = rotatedWorldCF.multiply(localVectorCF);
49631
+ const localVectorToWorld = new Vector32(...localVectorToWorldCF.Position);
49632
+ return localVectorToWorld;
49633
+ }
49634
+ tick(dt, groupDesc) {
49635
+ this.passedTime += dt * this.timeScale;
49636
+ if (this.lockedToPart) {
49637
+ for (const particle of this.particles) {
49638
+ const particleCF = new CFrame(...particle.position.toVec3());
49639
+ const localParticleCF = groupDesc.lastCframe.inverse().multiply(particleCF);
49640
+ const newParticleCF = groupDesc.cframe.multiply(localParticleCF);
49641
+ const newParticleCFOnlyOrientation = newParticleCF.clone();
49642
+ newParticleCFOnlyOrientation.Position = [0, 0, 0];
49643
+ particle.position = new Vector32(...newParticleCF.Position);
49644
+ particle.velocity = new Vector32(...newParticleCFOnlyOrientation.multiply(new CFrame(...particle.velocity.toVec3())).Position);
49318
49645
  }
49319
49646
  }
49320
- if (part0) {
49321
- this.data.part0ChangedConnection = part0.Changed.Connect((propertyName) => {
49322
- if (propertyName === "CFrame") {
49323
- this.update(1);
49324
- }
49325
- });
49326
- this.instance.addConnectionReference(this.data.part0ChangedConnection);
49647
+ for (const particle of this.particles) {
49648
+ const acceleration = this.lockedToPart ? new Vector32(0, 0, 0) : this.acceleration;
49649
+ let localAccelerationToWorld = this.vectorLocalToWorld(groupDesc.cframe, this.localAcceleration);
49650
+ if (this.lockedToPart) {
49651
+ localAccelerationToWorld = localAccelerationToWorld.add(this.vectorLocalToWorld(groupDesc.cframe, this.acceleration));
49652
+ }
49653
+ particle.tick(dt * this.timeScale, this.drag, acceleration.add(localAccelerationToWorld));
49654
+ }
49655
+ for (let i = this.particles.length - 1; i >= 0; i--) {
49656
+ const particle = this.particles[i];
49657
+ if (particle.time >= particle.lifetime) {
49658
+ this.particles.splice(i, 1);
49659
+ }
49660
+ }
49661
+ this.passedTime = specialClamp(this.passedTime, 0, 5);
49662
+ while (this.passedTime >= 1 / this.rate) {
49663
+ this.emit(groupDesc);
49664
+ this.passedTime -= 1 / this.rate;
49327
49665
  }
49328
49666
  }
49329
- }
49330
- class ManualWeldWrapper extends WeldWrapper {
49331
- static className = "ManualWeld";
49332
- }
49333
- class ModelWrapper extends InstanceWrapper {
49334
- static className = "Model";
49335
- static requiredProperties = ["Name", "PrimaryPart"];
49336
- setup() {
49337
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49338
- if (!this.instance.HasProperty("PrimaryPart")) this.instance.addProperty(new Property("PrimaryPart", DataType.Referent), void 0);
49339
- }
49340
- GetModelCFrame() {
49341
- const primaryPart = this.instance.Prop("PrimaryPart");
49342
- if (primaryPart) {
49343
- return primaryPart.Prop("CFrame");
49667
+ updateResult(renderScene) {
49668
+ if (!this.result || !this.instanceColorBuffer || !this.instanceOpacityBuffer || !this.instanceSeedTimeBuffer) return;
49669
+ this.result.count = this.particles.length;
49670
+ for (let i = 0; i < this.result.count; i++) {
49671
+ const particle = this.particles[i];
49672
+ const time2 = particle.time;
49673
+ const normalizedTime = particle.time / particle.lifetime;
49674
+ const color = this.color.getValue(normalizedTime);
49675
+ const size = this.size.getValue(this.normalizeSizeKeypointTime ? normalizedTime : time2, particle.seed + 0);
49676
+ const opacity = 1 - this.transparency.getValue(normalizedTime, particle.seed + 1);
49677
+ this.result.setMatrixAt(i, particle.getMatrix(renderScene, size, this.orientation));
49678
+ this.instanceColorBuffer.setXYZ(i, color.R, color.G, color.B);
49679
+ this.instanceOpacityBuffer.setX(i, opacity);
49680
+ this.instanceSeedTimeBuffer.setXY(i, particle.seed, normalizedTime);
49344
49681
  }
49345
- throw new Error("Model has no PrimaryPart");
49682
+ this.result.instanceMatrix.needsUpdate = true;
49683
+ this.instanceColorBuffer.needsUpdate = true;
49684
+ this.instanceOpacityBuffer.needsUpdate = true;
49685
+ this.instanceSeedTimeBuffer.needsUpdate = true;
49346
49686
  }
49347
49687
  }
49348
- class Motor6DWrapper extends WeldWrapper {
49349
- static className = "Motor6D";
49350
- static requiredProperties = [
49351
- ...super.requiredProperties,
49352
- "Transform"
49353
- ];
49354
- setup() {
49355
- super.setup();
49356
- if (!this.instance.HasProperty("Transform")) this.instance.addProperty(new Property("Transform", DataType.CFrame), new CFrame());
49688
+ class EmitterGroupDesc extends RenderDesc {
49689
+ static classTypes = ["ParticleEmitter", "Sparkles", "Fire", "Smoke"];
49690
+ lastTime = Date.now() / 1e3;
49691
+ time = Date.now() / 1e3;
49692
+ enabled = true;
49693
+ lowerBound = new Vector32(0, 0, 0);
49694
+ higherBound = new Vector32(0, 0, 0);
49695
+ lastCframe = new CFrame();
49696
+ cframe = new CFrame();
49697
+ emitterDir = NormalId.Top;
49698
+ emitterDescs = [];
49699
+ //special for emitter group
49700
+ getRandomLocalPos() {
49701
+ const totalSize = this.higherBound.minus(this.lowerBound);
49702
+ const x = Math.random() * totalSize.X + this.lowerBound.X;
49703
+ const y = Math.random() * totalSize.Y + this.lowerBound.Y;
49704
+ const z = Math.random() * totalSize.Z + this.lowerBound.Z;
49705
+ return new Vector32(x, y, z);
49357
49706
  }
49358
- }
49359
- class SoundWrapperData {
49360
- audioContext;
49361
- gainNode;
49362
- buffer;
49363
- playingSource;
49364
- }
49365
- class SoundWrapper extends InstanceWrapper {
49366
- static className = "Sound";
49367
- static requiredProperties = ["Name", "Looped", "Playing", "Volume", "_data"];
49368
- setup() {
49369
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49370
- if (!this.instance.HasProperty("Looped")) this.instance.addProperty(new Property("Looped", DataType.Bool), false);
49371
- if (!this.instance.HasProperty("Playing")) this.instance.addProperty(new Property("Playing", DataType.Bool), false);
49372
- if (!this.instance.HasProperty("Volume")) this.instance.addProperty(new Property("Volume", DataType.Float32), false);
49373
- if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new SoundWrapperData());
49707
+ toWorldSpace(vec) {
49708
+ const vecAsCF = new CFrame(...vec.toVec3());
49709
+ const worldSpace = new Vector32().fromVec3(this.cframe.multiply(vecAsCF).Position);
49710
+ return worldSpace;
49374
49711
  }
49375
- get data() {
49376
- return this.instance.Prop("_data");
49712
+ getRandomWorldPos() {
49713
+ const randomWorldPos = this.toWorldSpace(this.getRandomLocalPos());
49714
+ return randomWorldPos;
49377
49715
  }
49378
- created() {
49379
- if (this.instance.Prop("Playing")) {
49380
- this.Play();
49381
- }
49382
- this.instance.Destroying.Connect(() => {
49383
- if (this.data.playingSource) {
49384
- this.Stop();
49716
+ getNormalQuaternionForVelocity() {
49717
+ switch (this.emitterDir) {
49718
+ case NormalId.Right: {
49719
+ return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(1, 0, 0));
49385
49720
  }
49386
- this.data.audioContext = void 0;
49387
- this.data.gainNode = void 0;
49388
- this.data.buffer = void 0;
49389
- });
49390
- }
49391
- _updateVolume() {
49392
- if (this.data.gainNode) {
49393
- if (this.instance.HasProperty("Volume")) {
49394
- const volume = this.instance.Prop("Volume");
49395
- this.data.gainNode.gain.value = volume;
49721
+ case NormalId.Top: {
49722
+ return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, 1, 0));
49723
+ }
49724
+ case NormalId.Back: {
49725
+ return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, 0, 1));
49726
+ }
49727
+ case NormalId.Left: {
49728
+ return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(-1, 0, 0));
49729
+ }
49730
+ case NormalId.Bottom: {
49731
+ return new Quaternion().setFromUnitVectors(new Vector3$1(0, 0, -1), new Vector3$1(0, -1, 0));
49732
+ }
49733
+ case NormalId.Front:
49734
+ default: {
49735
+ return new Quaternion();
49396
49736
  }
49397
49737
  }
49398
49738
  }
49399
- setPlaying(value) {
49400
- this.instance.setProperty("Playing", value);
49739
+ createEmitter(config) {
49740
+ const emitter = new EmitterDesc();
49741
+ Object.assign(emitter, config);
49742
+ return emitter;
49401
49743
  }
49402
- playSource() {
49403
- if (!this.data.audioContext || !this.data.gainNode || !this.data.buffer) return;
49404
- this.data.playingSource = this.data.audioContext.createBufferSource();
49405
- this.data.playingSource.buffer = this.data.buffer;
49406
- this.data.playingSource.connect(this.data.gainNode);
49407
- this.data.gainNode.connect(this.data.audioContext.destination);
49408
- this._updateVolume();
49409
- this.data.playingSource.start(0);
49410
- this.data.playingSource.onended = (() => {
49411
- if (this.instance.Prop("Looped")) {
49412
- this.Play();
49413
- } else {
49414
- this.Stop();
49744
+ //inherited from RenderDesc
49745
+ isSame(other) {
49746
+ if (this.needsRegeneration(other)) {
49747
+ return false;
49748
+ }
49749
+ return this.time === other.time;
49750
+ }
49751
+ needsRegeneration(other) {
49752
+ if (this.emitterDescs.length !== other.emitterDescs.length) {
49753
+ return true;
49754
+ }
49755
+ for (let i = 0; i < this.emitterDescs.length; i++) {
49756
+ if (!this.emitterDescs[i].needsRegeneration(other.emitterDescs[i])) {
49757
+ return true;
49415
49758
  }
49416
- });
49759
+ }
49760
+ return false;
49417
49761
  }
49418
- Play() {
49419
- if (!FLAGS.AUDIO_ENABLED) return;
49420
- this.Stop();
49421
- this.setPlaying(true);
49422
- if (!this.data.audioContext) {
49423
- this.data.audioContext = new AudioContext();
49762
+ virtualFromRenderDesc(other) {
49763
+ this.time = other.time;
49764
+ this.cframe = other.cframe;
49765
+ this.lowerBound = other.lowerBound;
49766
+ this.higherBound = other.higherBound;
49767
+ this.emitterDir = other.emitterDir;
49768
+ for (let i = 0; i < this.emitterDescs.length; i++) {
49769
+ this.emitterDescs[i].fromEmitterDesc(other.emitterDescs[i]);
49424
49770
  }
49425
- if (!this.data.gainNode) {
49426
- this.data.gainNode = this.data.audioContext.createGain();
49771
+ }
49772
+ virtualTransferFrom(other) {
49773
+ if (this.emitterDescs.length === other.emitterDescs.length) {
49774
+ for (let i = 0; i < this.emitterDescs.length; i++) {
49775
+ this.emitterDescs[i].particles = other.emitterDescs[i].particles;
49776
+ this.emitterDescs[i].initialParticleCount = this.emitterDescs[i].particles.length;
49777
+ }
49427
49778
  }
49428
- if (!this.data.buffer) {
49429
- let audioUrl = void 0;
49430
- if (this.instance.HasProperty("SoundId")) {
49431
- audioUrl = this.instance.Prop("SoundId");
49432
- } else if (this.instance.HasProperty("AudioContent")) {
49433
- audioUrl = this.instance.Prop("AudioContent").uri;
49779
+ }
49780
+ fromInstance(child) {
49781
+ this.instance = child;
49782
+ const parent = child.parent;
49783
+ if (parent) {
49784
+ if (parent.className === "Attachment") {
49785
+ const attachmentW = new AttachmentWrapper(parent);
49786
+ this.cframe = attachmentW.getWorldCFrame();
49787
+ } else {
49788
+ this.cframe = parent.PropOrDefault("CFrame", this.cframe).clone();
49434
49789
  }
49435
- if (audioUrl && audioUrl.length > 0) {
49436
- API.Asset.GetAssetBuffer(audioUrl).then((responseBuffer) => {
49437
- if (responseBuffer instanceof Response || !this.data.audioContext) return;
49438
- const buffer2 = responseBuffer.slice(0);
49439
- this.data.audioContext.decodeAudioData(buffer2).then((decodedData) => {
49440
- if (!this.data.audioContext || !this.data.gainNode) return;
49441
- this.data.buffer = decodedData;
49442
- this.playSource();
49443
- });
49444
- });
49790
+ this.lastCframe = this.cframe;
49791
+ if (parent.HasProperty("Size") || parent.HasProperty("size")) {
49792
+ const size = parent.Prop("Size");
49793
+ this.higherBound = size.multiply(new Vector32(0.5, 0.5, 0.5));
49794
+ this.lowerBound = size.multiply(new Vector32(-0.5, -0.5, -0.5));
49445
49795
  }
49446
- } else if (this.data.buffer) {
49447
- this.playSource();
49448
49796
  }
49449
- }
49450
- Stop() {
49451
- this.setPlaying(false);
49452
- if (this.data.playingSource) {
49453
- this.data.playingSource.stop();
49454
- this.data.playingSource = void 0;
49797
+ this.enabled = child.PropOrDefault("Enabled", true);
49798
+ const className = child.className;
49799
+ switch (className) {
49800
+ case "ParticleEmitter":
49801
+ this.fromParticleEmitter(child);
49802
+ break;
49803
+ case "Sparkles":
49804
+ this.fromSparkles(child);
49805
+ break;
49806
+ case "Fire":
49807
+ this.fromFire(child);
49808
+ break;
49809
+ case "Smoke":
49810
+ this.fromSmoke(child);
49811
+ break;
49455
49812
  }
49456
49813
  }
49457
- }
49458
- class ScriptWrapperData {
49459
- shouldStop = false;
49460
- }
49461
- class ScriptWrapper extends InstanceWrapper {
49462
- static className = "Script";
49463
- static requiredProperties = ["Name", "_data"];
49464
- setup() {
49465
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49466
- if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new ScriptWrapperData());
49814
+ fromParticleEmitter(child) {
49815
+ this.emitterDir = child.Prop("EmissionDirection");
49816
+ const emitterDesc = new EmitterDesc();
49817
+ if (child.HasProperty("Lifetime")) emitterDesc.lifetime = child.Prop("Lifetime");
49818
+ if (child.HasProperty("Rate")) emitterDesc.rate = child.Prop("Rate");
49819
+ if (child.HasProperty("SpreadAngle")) emitterDesc.spreadAngle = child.Prop("SpreadAngle");
49820
+ if (child.HasProperty("ShapeInOut")) emitterDesc.shapeInOut = child.Prop("ShapeInOut");
49821
+ if (child.HasProperty("Speed")) emitterDesc.speed = child.Prop("Speed");
49822
+ if (child.HasProperty("Rotation")) emitterDesc.rotation = child.Prop("Rotation");
49823
+ if (child.HasProperty("RotSpeed")) emitterDesc.rotationSpeed = child.Prop("RotSpeed");
49824
+ if (child.HasProperty("Acceleration")) emitterDesc.acceleration = child.Prop("Acceleration");
49825
+ if (child.HasProperty("Drag")) emitterDesc.drag = child.Prop("Drag");
49826
+ if (child.HasProperty("TimeScale")) emitterDesc.timeScale = child.Prop("TimeScale");
49827
+ if (child.HasProperty("Size")) emitterDesc.size = child.Prop("Size");
49828
+ if (child.HasProperty("Color")) emitterDesc.color = child.Prop("Color");
49829
+ if (child.HasProperty("Texture")) emitterDesc.texture = child.Prop("Texture");
49830
+ if (child.HasProperty("Transparency")) emitterDesc.transparency = child.Prop("Transparency");
49831
+ if (child.HasProperty("LightEmission")) emitterDesc.lightEmission = child.Prop("LightEmission");
49832
+ emitterDesc.blending = emitterDesc.lightEmission === 0 ? NormalBlending : AdditiveBlending;
49833
+ if (child.HasProperty("ZOffset")) emitterDesc.zOffset = child.Prop("ZOffset");
49834
+ if (child.HasProperty("Orientation")) emitterDesc.orientation = child.Prop("Orientation");
49835
+ if (child.HasProperty("LockedToPart")) emitterDesc.lockedToPart = child.Prop("LockedToPart");
49836
+ this.emitterDescs.push(emitterDesc);
49467
49837
  }
49468
- get data() {
49469
- return this.instance.Prop("_data");
49838
+ fromSparkles(child) {
49839
+ this.lowerBound = new Vector32(-0.2, -0.2, -0.2);
49840
+ this.higherBound = new Vector32(0.2, 0.2, 0.2);
49841
+ const color = child.PropOrDefault("SparkleColor", new Color3(144 / 255, 25 / 255, 255 / 255));
49842
+ this.emitterDescs.push(this.createEmitter({
49843
+ texture: "rbxasset://textures/particles/sparkles_main.dds",
49844
+ alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
49845
+ colorTexture: "rbxasset://textures/particles/sparkles_color.dds",
49846
+ drag: 0.2,
49847
+ size: new NumberSequence([new NumberSequenceKeypoint(0, 0.37, 0), new NumberSequenceKeypoint(1, 0.37 + 0.65, 0)]),
49848
+ speed: new NumberRange(5, 5),
49849
+ rotation: new NumberRange(-90, 90),
49850
+ rotationSpeed: new NumberRange(40, 100),
49851
+ spreadAngle: new Vector22(100, 100),
49852
+ rate: 30,
49853
+ lifetime: new NumberRange(1.3, 1.3),
49854
+ timeScale: child.PropOrDefault("TimeScale", 1),
49855
+ color: ColorSequence.fromColor(color)
49856
+ }));
49857
+ this.emitterDescs.push(this.createEmitter({
49858
+ texture: "rbxasset://textures/particles/sparkles_main.dds",
49859
+ alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
49860
+ drag: 2,
49861
+ size: new NumberSequence([new NumberSequenceKeypoint(0, 0.1, 0), new NumberSequenceKeypoint(1, 0.1 + 0.34, 0)]),
49862
+ speed: new NumberRange(8, 8),
49863
+ rotation: new NumberRange(-90, 90),
49864
+ rotationSpeed: new NumberRange(-500, 500),
49865
+ spreadAngle: new Vector22(150, 150),
49866
+ rate: 5,
49867
+ lifetime: new NumberRange(1.7, 1.7),
49868
+ timeScale: child.PropOrDefault("TimeScale", 1),
49869
+ color: ColorSequence.fromColor(color),
49870
+ offset: new Vector32(0, 4, 0)
49871
+ }));
49470
49872
  }
49471
- created() {
49472
- this.Run();
49873
+ fromFire(child) {
49874
+ const size = child.PropOrDefault("size_xml", 3) / 3.5;
49875
+ const boundSize = size / 8;
49876
+ const heat = child.PropOrDefault("heat_xml", 5);
49877
+ const timeScale = child.PropOrDefault("TimeScale", 1);
49878
+ const color = child.PropOrDefault("Color", new Color3(236 / 255, 139 / 255, 70 / 255));
49879
+ const secondaryColor = child.PropOrDefault("SecondaryColor", new Color3(106 / 255, 44 / 255, 13 / 255));
49880
+ this.lowerBound = new Vector32(-boundSize, -boundSize, -boundSize);
49881
+ this.higherBound = new Vector32(boundSize, boundSize, boundSize);
49882
+ const strongColor = color.clone();
49883
+ strongColor.R *= 4;
49884
+ strongColor.G *= 4;
49885
+ strongColor.B *= 4;
49886
+ this.emitterDescs.push(this.createEmitter({
49887
+ texture: "rbxasset://textures/particles/fire_main.dds",
49888
+ alphaTexture: "rbxasset://textures/particles/fire_alpha.dds",
49889
+ drag: 0.4,
49890
+ localAcceleration: new Vector32(0, 0.5 * (1 * size * size / 4 + 0.7 * heat), 0),
49891
+ rotation: new NumberRange(-90, 90),
49892
+ size: new NumberSequence([new NumberSequenceKeypoint(0, 1.1 * size, 0), new NumberSequenceKeypoint(2, Math.max(1.1 * size - 0.8 * size * 2, 0), 0)]),
49893
+ speed: new NumberRange(0.4 * (0.2 * size * size + 0.2 * heat), 0.4 * (0.2 * size * size + 0.2 * heat)),
49894
+ rotationSpeed: new NumberRange(100, 100),
49895
+ spreadAngle: new Vector22(10, 10),
49896
+ rate: 65,
49897
+ lifetime: new NumberRange(1, 2),
49898
+ normalizeSizeKeypointTime: false,
49899
+ timeScale,
49900
+ color: ColorSequence.fromColor(strongColor)
49901
+ }));
49902
+ const sparkSize = size * 0.2;
49903
+ this.emitterDescs.push(this.createEmitter({
49904
+ texture: "rbxasset://textures/particles/fire_main.dds",
49905
+ alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
49906
+ colorTexture: "rbxasset://textures/particles/fire_sparks_color.dds",
49907
+ drag: 0.4,
49908
+ localAcceleration: new Vector32(0, 0.5 * (1 * size * size / 4 + 0.7 * heat), 0),
49909
+ rotation: new NumberRange(-90, 90),
49910
+ size: new NumberSequence([new NumberSequenceKeypoint(0, 1.1 * sparkSize, 0), new NumberSequenceKeypoint(3, Math.max(1.1 * sparkSize - -sparkSize / 3 * 3, 0), 0)]),
49911
+ speed: new NumberRange(0.4 * (0.2 * size * size + 0.2 * heat), 0.4 * (0.2 * size * size + 0.2 * heat)),
49912
+ rotationSpeed: new NumberRange(100, 100),
49913
+ spreadAngle: new Vector22(10, 10),
49914
+ rate: 65,
49915
+ lifetime: new NumberRange(1.5, 3),
49916
+ normalizeSizeKeypointTime: false,
49917
+ timeScale,
49918
+ color: ColorSequence.fromColor(secondaryColor),
49919
+ blending: AdditiveBlending
49920
+ }));
49473
49921
  }
49474
- Run() {
49475
- switch (this.instance.Prop("Name")) {
49476
- case "ChickenSounds":
49477
- case "HarmonicaSounds":
49478
- case "SoundPlayer":
49479
- this.SoundPlayer(this.instance);
49480
- break;
49922
+ fromSmoke(child) {
49923
+ const size = child.PropOrDefault("size_xml", 1);
49924
+ const endSize = 10 + size;
49925
+ const timeScale = child.PropOrDefault("TimeScale", 1);
49926
+ const riseVelocity = child.PropOrDefault("riseVelocity_xml", 1);
49927
+ const opacity = child.PropOrDefault("opacity_xml", 0.5);
49928
+ const color = child.PropOrDefault("Color", new Color3(1, 1, 1));
49929
+ this.emitterDescs.push(this.createEmitter({
49930
+ texture: "rbxasset://textures/particles/smoke_main.dds",
49931
+ alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
49932
+ drag: 0.1,
49933
+ opacity,
49934
+ acceleration: new Vector32(0, 0, 0.4),
49935
+ size: new NumberSequence([new NumberSequenceKeypoint(0, size, 0), new NumberSequenceKeypoint(1, endSize, 0)]),
49936
+ rotation: new NumberRange(-90, 90),
49937
+ speed: new NumberRange(riseVelocity * 0.9, riseVelocity * 1),
49938
+ rotationSpeed: new NumberRange(-20, 20),
49939
+ spreadAngle: new Vector22(30, 30),
49940
+ rate: 7,
49941
+ lifetime: new NumberRange(5, 5),
49942
+ timeScale,
49943
+ color: ColorSequence.fromColor(color),
49944
+ blending: NormalBlending
49945
+ }));
49946
+ }
49947
+ dispose(renderer, scene) {
49948
+ const meshes = this.results;
49949
+ if (meshes) {
49950
+ this.disposeMeshes(scene, meshes);
49951
+ this.disposeRenderLists(renderer);
49481
49952
  }
49482
49953
  }
49483
- //Scripts
49484
- async SoundPlayer(script) {
49485
- let Handle = void 0;
49486
- if (script.parent && script.parent.Prop("Name") === "Handle") {
49487
- Handle = script.parent;
49488
- } else if (script.parent && script.parent.FindFirstChild("Handle")) {
49489
- Handle = script.parent.FindFirstChild("Handle");
49954
+ async compileResults(renderer, scene) {
49955
+ const originalResults = this.results;
49956
+ const resultPromises = [];
49957
+ for (const emitterDesc of this.emitterDescs) {
49958
+ resultPromises.push(emitterDesc.compileResult(renderer, scene));
49490
49959
  }
49491
- if (!Handle) return;
49492
- const Hat = Handle.parent;
49493
- if (!Hat) return;
49494
- const Sounds = [];
49495
- for (const child of Handle.GetDescendants()) {
49496
- if (child.className === "Sound") {
49497
- Sounds.push(child);
49960
+ this.results = [];
49961
+ const compiledResults = await Promise.all(resultPromises);
49962
+ for (const compiledResult of compiledResults) {
49963
+ if (compiledResult instanceof Mesh) {
49964
+ this.results.push(compiledResult);
49965
+ } else {
49966
+ this.disposeMeshes(scene, this.results);
49967
+ this.disposeRenderLists(renderer);
49968
+ return compiledResult;
49498
49969
  }
49499
49970
  }
49500
- function IsBeingWorn() {
49501
- return Hat?.parent?.FindFirstChild("Humanoid");
49502
- }
49503
- let maxTime = 20;
49504
- if (script.Prop("Name") === "SoundPlayer") {
49505
- maxTime = 15;
49506
- }
49507
- while (true) {
49508
- await Wait(mathRandom(5, maxTime));
49509
- if (this.instance.destroyed || this.data.shouldStop) return;
49510
- if (IsBeingWorn()) {
49511
- const index = mathRandom(0, Sounds.length - 1);
49512
- const Sound = Sounds[index];
49513
- const soundWrapper = new SoundWrapper(Sound);
49514
- soundWrapper.Play();
49515
- }
49971
+ if (originalResults) {
49972
+ this.disposeMeshes(scene, originalResults);
49973
+ this.disposeRenderLists(renderer);
49516
49974
  }
49975
+ return this.results;
49517
49976
  }
49518
- }
49519
- class ToolWrapper extends InstanceWrapper {
49520
- static className = "Tool";
49521
- static requiredProperties = [
49522
- "Name",
49523
- "Grip"
49524
- ];
49525
- setup() {
49526
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
49527
- if (!this.instance.HasProperty("Grip")) this.instance.addProperty(new Property("Grip", DataType.CFrame), new CFrame());
49528
- }
49529
- created() {
49530
- this.instance.AncestryChanged.Connect(() => {
49531
- this.createWeld();
49532
- });
49533
- }
49534
- //doing this is actually inaccurate because tools dont create welds, but its easier
49535
- createWeld() {
49536
- const handle = this.instance.FindFirstChild("Handle");
49537
- const rig = this.instance.parent;
49538
- const grip = this.instance.PropOrDefault("Grip", new CFrame()).clone();
49539
- if (handle) {
49540
- const oldToolWeld = handle.FindFirstChild("ToolWeld_GripRoAvatar");
49541
- if (oldToolWeld) {
49542
- oldToolWeld.Destroy();
49543
- }
49544
- }
49545
- const humanoid = rig?.FindFirstChildOfClass("Humanoid");
49546
- if (handle && rig && rig.className === "Model" && humanoid) {
49547
- const rightHand = rig.FindFirstChild("RightHand") || rig.FindFirstChild("Right Arm");
49548
- if (rightHand) {
49549
- for (const child of rightHand.GetDescendants()) {
49550
- if (child.Prop("Name") === "RightGripAttachment") {
49551
- const rightGripAttCF = child.PropOrDefault("CFrame", new CFrame()).clone();
49552
- if (humanoid.Prop("RigType") === HumanoidRigType.R6) {
49553
- rightGripAttCF.Orientation[0] -= 90;
49554
- }
49555
- const weld = new Instance("Weld");
49556
- weld.addProperty(new Property("Name", DataType.String), "ToolWeld_GripRoAvatar");
49557
- weld.addProperty(new Property("Archivable", DataType.Bool), true);
49558
- weld.addProperty(new Property("C0", DataType.CFrame), rightGripAttCF);
49559
- weld.addProperty(new Property("C1", DataType.CFrame), grip);
49560
- weld.addProperty(new Property("Part0", DataType.Referent), child.parent);
49561
- weld.addProperty(new Property("Part1", DataType.Referent), handle);
49562
- weld.addProperty(new Property("Active", DataType.Bool), true);
49563
- weld.addProperty(new Property("Enabled", DataType.Bool), false);
49564
- weld.setParent(handle);
49565
- weld.setProperty("Enabled", true);
49566
- }
49567
- }
49568
- }
49977
+ updateResults() {
49978
+ const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10);
49979
+ this.lastTime = this.time;
49980
+ for (const emitterDesc of this.emitterDescs) {
49981
+ emitterDesc.tick(dt, this);
49982
+ emitterDesc.updateResult(this.renderScene);
49569
49983
  }
49984
+ this.lastCframe = this.cframe.clone();
49570
49985
  }
49571
49986
  }
49572
- function RegisterWrappers() {
49573
- ModelWrapper.register();
49574
- ScriptWrapper.register();
49575
- SoundWrapper.register();
49576
- ToolWrapper.register();
49577
- DecalWrapper.register();
49578
- WeldWrapper.register();
49579
- Motor6DWrapper.register();
49580
- ManualWeldWrapper.register();
49581
- AttachmentWrapper.register();
49582
- AnimationConstraintWrapper.register();
49583
- AnimatorWrapper.register();
49584
- FaceControlsWrapper.register();
49585
- HumanoidDescriptionWrapper.register();
49586
- BodyPartDescriptionWrapper.register();
49587
- AccessoryDescriptionWrapper.register();
49588
- MakeupDescriptionWrapper.register();
49589
- BodyColorsWrapper.register();
49590
- AccessoryWrapper.register();
49591
- }
49987
+ const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49988
+ __proto__: null,
49989
+ EmitterGroupDesc
49990
+ }, Symbol.toStringTag, { value: "Module" }));
49592
49991
  function disposeLight(scene, light) {
49593
49992
  if (light.shadow && light.shadow.map) {
49594
49993
  light.shadow.map.dispose();
@@ -49596,6 +49995,7 @@ function disposeLight(scene, light) {
49596
49995
  scene.remove(light);
49597
49996
  }
49598
49997
  class LightDesc extends RenderDesc {
49998
+ static classTypes = ["PointLight", "SpotLight", "SurfaceLight"];
49599
49999
  enabled = true;
49600
50000
  cframe = new CFrame();
49601
50001
  shadows = false;
@@ -49659,6 +50059,7 @@ class LightDesc extends RenderDesc {
49659
50059
  switch (this.lightType) {
49660
50060
  case "point": {
49661
50061
  const pointLight = new PointLight();
50062
+ pointLight.name = this.instance?.PropOrDefault("Name", void 0) || this.instance?.className || "Light";
49662
50063
  this.results.push(
49663
50064
  pointLight
49664
50065
  /*, pointLightHelper*/
@@ -49669,7 +50070,8 @@ class LightDesc extends RenderDesc {
49669
50070
  case "surface": {
49670
50071
  const spotLight = new SpotLight();
49671
50072
  spotLight.add(spotLight.target);
49672
- this.results.push();
50073
+ spotLight.name = this.instance?.PropOrDefault("Name", void 0) || this.instance?.className || "Light";
50074
+ this.results.push(spotLight);
49673
50075
  break;
49674
50076
  }
49675
50077
  }
@@ -49725,6 +50127,25 @@ class LightDesc extends RenderDesc {
49725
50127
  }
49726
50128
  }
49727
50129
  }
50130
+ const __vite_glob_0_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50131
+ __proto__: null,
50132
+ LightDesc
50133
+ }, Symbol.toStringTag, { value: "Module" }));
50134
+ const modules = /* @__PURE__ */ Object.assign({ "./attachmentDesc.ts": __vite_glob_0_0, "./emitterGroupDesc.ts": __vite_glob_0_1, "./lightDesc.ts": __vite_glob_0_2, "./objectDesc.ts": __vite_glob_0_3$1 });
50135
+ function RegisterRenderDescs() {
50136
+ for (const module of Object.values(modules)) {
50137
+ for (const exprt of Object.values(module)) {
50138
+ let prototype = Object.getPrototypeOf(exprt);
50139
+ while (prototype) {
50140
+ if (prototype === RenderDesc) {
50141
+ exprt.register();
50142
+ break;
50143
+ }
50144
+ prototype = Object.getPrototypeOf(prototype);
50145
+ }
50146
+ }
50147
+ }
50148
+ }
49728
50149
  function disposeMesh(scene, mesh) {
49729
50150
  if (mesh.material) {
49730
50151
  const materials = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
@@ -49897,6 +50318,7 @@ class RBXRenderer {
49897
50318
  static failedToCreate = false;
49898
50319
  static error;
49899
50320
  static async boilerplateSetup() {
50321
+ RegisterRenderDescs();
49900
50322
  RegisterWrappers();
49901
50323
  createContentMap();
49902
50324
  setupWorkerPool();
@@ -50354,23 +50776,9 @@ class RBXRenderer {
50354
50776
  /**Adds an instance to the renderer or updates it */
50355
50777
  static addInstance(instance, auth, renderScene = RBXRenderer.firstScene) {
50356
50778
  if (renderScene.destroyed) return;
50357
- const isDecal = instance.className === "Decal";
50358
- const isBakedDecal = isDecal && !instance.FindFirstChildOfClass("WrapTextureTransfer");
50359
- let isFirstDecal = true;
50360
- if (isDecal && instance.parent) {
50361
- const children = instance.parent.GetChildren();
50362
- for (const child of children) {
50363
- if (child.className === "Decal" && child.FindFirstChildOfClass("WrapTextureTransfer") && child.id < instance.id) {
50364
- isFirstDecal = false;
50365
- }
50366
- }
50367
- }
50368
- if (ObjectDescClassTypes.includes(instance.className) && !isBakedDecal && (!isDecal || isFirstDecal)) {
50369
- RBXRenderer._addRenderDesc(instance, auth, ObjectDesc, renderScene);
50370
- } else if (EmitterGroupDescClassTypes.includes(instance.className)) {
50371
- RBXRenderer._addRenderDesc(instance, auth, EmitterGroupDesc, renderScene);
50372
- } else if (LightDescClassTypes.includes(instance.className)) {
50373
- RBXRenderer._addRenderDesc(instance, auth, LightDesc, renderScene);
50779
+ const RenderDescType = getRenderDescForInstance(instance);
50780
+ if (RenderDescType) {
50781
+ RBXRenderer._addRenderDesc(instance, auth, RenderDescType, renderScene);
50374
50782
  }
50375
50783
  for (const child of instance.GetChildren()) {
50376
50784
  RBXRenderer.addInstance(child, auth, renderScene);
@@ -50593,7 +51001,7 @@ function getExtentsForParts(parts, includeTransform) {
50593
51001
  let lowerExtents = new Vector32(0, 0, 0);
50594
51002
  let higherExtents = new Vector32(0, 0, 0);
50595
51003
  for (const child of parts) {
50596
- if (child.className === "Part" || child.className === "MeshPart") {
51004
+ if (child.createWrapper()?.IsA("BasePart")) {
50597
51005
  const cframe = traverseRigCFrame(child, includeTransform, true);
50598
51006
  const size = child.Prop("Size");
50599
51007
  const corners = getCorners(cframe, size);
@@ -50610,7 +51018,7 @@ function getExtents(cframe, parts) {
50610
51018
  let lowerExtents = new Vector32(0, 0, 0);
50611
51019
  let higherExtents = new Vector32(0, 0, 0);
50612
51020
  for (const child of parts) {
50613
- if (child.className === "Part" || child.className === "MeshPart") {
51021
+ if (child.createWrapper()?.IsA("BasePart")) {
50614
51022
  const partCF = child.Prop("CFrame");
50615
51023
  const partSize = child.Prop("Size");
50616
51024
  const corners = getCorners(inverseCF.multiply(partCF), partSize);
@@ -50668,7 +51076,7 @@ function getHeadExtents(rig) {
50668
51076
  function getRigExtentsWorld(rig) {
50669
51077
  const rigParts = [];
50670
51078
  for (const child of rig.GetDescendants()) {
50671
- if (child.className === "Part" || child.className === "MeshPart") {
51079
+ if (child.createWrapper()?.IsA("BasePart")) {
50672
51080
  rigParts.push(child);
50673
51081
  }
50674
51082
  }
@@ -50778,6 +51186,14 @@ class OutfitRenderer {
50778
51186
  animationFPS = 60;
50779
51187
  deltaTimeMultiplier = 1;
50780
51188
  renderScene = RBXRenderer.firstScene;
51189
+ /**Event is fired if a new outfit failed to load
51190
+ * @returns OutfitRendererErrorType
51191
+ */
51192
+ onError = new Event();
51193
+ /**Event is fired if a new outfit successfully loaded
51194
+ * @returns void
51195
+ */
51196
+ onSuccess = new Event();
50781
51197
  /**
50782
51198
  * Creates a new OutfitRenderer which makes it easy to render outfits
50783
51199
  * @param auth The authentication object, you should have one you use for everything
@@ -50811,6 +51227,7 @@ class OutfitRenderer {
50811
51227
  RBXRenderer.addInstance(this.currentRig, this.auth, this.renderScene);
50812
51228
  resolve(newRig);
50813
51229
  } else {
51230
+ this.onError.Fire("rig");
50814
51231
  resolve(result);
50815
51232
  }
50816
51233
  });
@@ -50851,6 +51268,7 @@ class OutfitRenderer {
50851
51268
  }
50852
51269
  }
50853
51270
  if (result instanceof Instance) {
51271
+ this.onSuccess.Fire();
50854
51272
  if (this.hasNewUpdate) {
50855
51273
  this.hasNewUpdate = false;
50856
51274
  this._updateOutfit();
@@ -50858,6 +51276,7 @@ class OutfitRenderer {
50858
51276
  } else {
50859
51277
  const oldHumanoidDescription = humanoid.FindFirstChildOfClass("HumanoidDescription");
50860
51278
  oldHumanoidDescription?.Destroy();
51279
+ this.onError.Fire("humanoidDescription");
50861
51280
  }
50862
51281
  });
50863
51282
  } else {
@@ -50953,6 +51372,11 @@ class OutfitRenderer {
50953
51372
  this._queuedMainAnimation = name;
50954
51373
  }
50955
51374
  }
51375
+ /**Calls destroy on the rig and stops animating, the OutfitRenderer should not be interacted with after this */
51376
+ destroy() {
51377
+ this.stopAnimating();
51378
+ this.currentRig?.Destroy();
51379
+ }
50956
51380
  }
50957
51381
  function renderToRenderTarget(width, height, renderScene) {
50958
51382
  const renderTarget = new WebGLRenderTarget(width, height, {
@@ -51140,7 +51564,6 @@ export {
51140
51564
  DefaultAnimationsR6,
51141
51565
  DefaultGetWorkerFunc,
51142
51566
  DefaultSearchData,
51143
- EmitterGroupDescClassTypes,
51144
51567
  Event,
51145
51568
  FACS,
51146
51569
  FLAGS,
@@ -51165,7 +51588,6 @@ export {
51165
51588
  LODS,
51166
51589
  LayeredAssetTypes,
51167
51590
  LayeredClothingAssetOrder,
51168
- LightDescClassTypes,
51169
51591
  LocalOutfit,
51170
51592
  MakeupAssetTypes,
51171
51593
  MakeupDescriptionWrapper,
@@ -51181,10 +51603,10 @@ export {
51181
51603
  NumberRange,
51182
51604
  NumberSequence,
51183
51605
  NumberSequenceKeypoint,
51184
- ObjectDescClassTypes,
51185
51606
  Outfit,
51186
51607
  OutfitOrigin,
51187
51608
  OutfitRenderer,
51609
+ PartType,
51188
51610
  ParticleEmitterShapeInOut,
51189
51611
  ParticleOrientation,
51190
51612
  Property,