roavatar-renderer 1.5.16 → 1.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31637,6 +31637,9 @@ class Instance {
31637
31637
  get name() {
31638
31638
  return this.Prop("Name");
31639
31639
  }
31640
+ get Parent() {
31641
+ return this.parent;
31642
+ }
31640
31643
  createWrapper() {
31641
31644
  const wrapper = GetWrapperForInstance(this);
31642
31645
  if (wrapper && !this._hasWrappered) {
@@ -34864,7 +34867,7 @@ class Outfit {
34864
34867
  staticFacialAnimation = true;
34865
34868
  }
34866
34869
  let meta = void 0;
34867
- if (assetOrder !== void 0 || assetPos || assetRot || assetScale || assetHeadShape !== void 0) {
34870
+ if (assetOrder !== void 0 || assetPos || assetRot || assetScale || assetHeadShape !== void 0 || staticFacialAnimation !== void 0) {
34868
34871
  meta = new AssetMeta();
34869
34872
  meta.order = assetOrder;
34870
34873
  meta.position = assetPos;
@@ -37492,11 +37495,15 @@ const API = {
37492
37495
  if (response instanceof ArrayBuffer) {
37493
37496
  const buffer2 = response;
37494
37497
  const mesh = new FileMesh();
37495
- await mesh.fromBuffer(buffer2);
37496
- if (FLAGS.ENABLE_API_CACHE && FLAGS.ENABLE_API_MESH_CACHE) {
37497
- CACHE.Mesh.set(cacheStr, mesh.clone());
37498
+ try {
37499
+ await mesh.fromBuffer(buffer2);
37500
+ if (FLAGS.ENABLE_API_CACHE && FLAGS.ENABLE_API_MESH_CACHE) {
37501
+ CACHE.Mesh.set(cacheStr, mesh.clone());
37502
+ }
37503
+ return mesh;
37504
+ } catch {
37505
+ return new Response();
37498
37506
  }
37499
- return mesh;
37500
37507
  } else {
37501
37508
  return response;
37502
37509
  }
@@ -50292,527 +50299,226 @@ const __vite_glob_0_20 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
50292
50299
  __proto__: null,
50293
50300
  PartWrapper
50294
50301
  }, Symbol.toStringTag, { value: "Module" }));
50295
- class SoundWrapperData {
50296
- audioContext;
50297
- gainNode;
50298
- buffer;
50299
- playingSource;
50302
+ const particle_vertexShader = (
50303
+ /*glsl*/
50304
+ `
50305
+ attribute vec3 instanceColor;
50306
+ attribute vec3 instanceSeedTime;
50307
+ attribute float instanceOpacity;
50308
+ attribute vec4 instanceFlipbook;
50309
+
50310
+ varying vec2 vUv;
50311
+ varying vec3 vInstanceColor;
50312
+ varying float vInstanceOpacity;
50313
+ varying vec3 vInstanceSeedTime;
50314
+ varying vec2 vFlipbookUv0;
50315
+ varying vec2 vFlipbookUv1;
50316
+
50317
+ uniform float uZOffset;
50318
+
50319
+ void main() {
50320
+ vUv = uv;
50321
+ vInstanceColor = instanceColor;
50322
+ vInstanceOpacity = instanceOpacity;
50323
+ vInstanceSeedTime = instanceSeedTime;
50324
+ vFlipbookUv0 = instanceFlipbook.xy;
50325
+ vFlipbookUv1 = instanceFlipbook.zw;
50326
+
50327
+ vec4 modelViewPosition = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
50328
+
50329
+ //offset position toward camera
50330
+ vec3 viewDir = normalize(modelViewPosition.xyz);
50331
+ modelViewPosition.xyz += viewDir * -uZOffset;
50332
+
50333
+ gl_Position = projectionMatrix * modelViewPosition;
50300
50334
  }
50301
- class SoundWrapper extends InstanceWrapper {
50302
- static className = "Sound";
50303
- static requiredProperties = ["Name", "Looped", "Playing", "Volume", "_data"];
50304
- setup() {
50305
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
50306
- if (!this.instance.HasProperty("Looped")) this.instance.addProperty(new Property("Looped", DataType.Bool), false);
50307
- if (!this.instance.HasProperty("Playing")) this.instance.addProperty(new Property("Playing", DataType.Bool), false);
50308
- if (!this.instance.HasProperty("Volume")) this.instance.addProperty(new Property("Volume", DataType.Float32), false);
50309
- if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new SoundWrapperData());
50335
+ `
50336
+ );
50337
+ const particle_fragmentShader = (
50338
+ /*glsl*/
50339
+ `
50340
+ //artibutes
50341
+ varying vec2 vUv;
50342
+ varying vec3 vInstanceColor;
50343
+ varying float vInstanceOpacity;
50344
+ varying vec3 vInstanceSeedTime;
50345
+ varying vec2 vFlipbookUv0;
50346
+ varying vec2 vFlipbookUv1;
50347
+
50348
+ //textures
50349
+ uniform sampler2D uColorMap;
50350
+ uniform sampler2D uAlphaMap;
50351
+ uniform sampler2D uMap;
50352
+
50353
+ //uniforms
50354
+ uniform float uLightInfluence;
50355
+ uniform float uOpacity;
50356
+ uniform vec2 uFlipbookSize;
50357
+
50358
+ //light uniforms
50359
+ struct DirectionalLight {
50360
+ vec3 direction;
50361
+ vec3 color;
50362
+ };
50363
+ uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];
50364
+
50365
+ uniform vec3 ambientLightColor;
50366
+
50367
+ void main() {
50368
+ float seed = vInstanceSeedTime.x;
50369
+ float time = vInstanceSeedTime.y;
50370
+ float flipbookFrameTime = vInstanceSeedTime.z;
50371
+
50372
+ // Sample the texture using the UV coordinates (for both frames)
50373
+ vec4 texColor0 = texture2D(uMap, vUv * uFlipbookSize + vFlipbookUv0);
50374
+ vec4 texColor1 = texture2D(uMap, vUv * uFlipbookSize + vFlipbookUv1);
50375
+
50376
+ float frameTransition = mod(time, flipbookFrameTime) / flipbookFrameTime;
50377
+ vec4 texColor = texColor0 * (1.0 - frameTransition) + texColor1 * frameTransition;
50378
+
50379
+ vec4 alphaTex = texture2D(uAlphaMap, vec2(time, seed));
50380
+ vec4 colorTex = texture2D(uColorMap, vec2(time, seed));
50381
+
50382
+ // Tint texture with our color
50383
+ vec4 tintedColor = texColor * vec4(vInstanceColor, 1.0);
50384
+
50385
+ // Apply opacity to the texture alpha
50386
+ vec4 opacityColor = tintedColor * vec4(1.0, 1.0, 1.0, uOpacity * vInstanceOpacity) * alphaTex.r;
50387
+
50388
+ //#ADDITIVE_INSERT
50389
+
50390
+ // Apply that weird color things sparkles have
50391
+ vec4 finalColor = opacityColor;
50392
+ finalColor.rgb = mix(opacityColor.rgb, opacityColor.rgb * colorTex.rgb, colorTex.a);
50393
+
50394
+ // Apply lighting
50395
+ vec3 light = ambientLightColor;
50396
+ #if NUM_DIR_LIGHTS > 0
50397
+ for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
50398
+ light += directionalLights[i].color;
50399
+ }
50400
+ #endif
50401
+
50402
+ finalColor = vec4(mix(finalColor.rgb, finalColor.rgb * light, uLightInfluence), finalColor.a);
50403
+
50404
+ gl_FragColor = finalColor;
50405
+ }
50406
+ `
50407
+ );
50408
+ const particle_fragmentShader_additive = particle_fragmentShader.replace(
50409
+ "//#ADDITIVE_INSERT",
50410
+ /*glsl*/
50411
+ `
50412
+ if (opacityColor.r + opacityColor.g + opacityColor.b <= 0.05) {
50413
+ discard;
50414
+ }`
50415
+ );
50416
+ function randomBetween(min, max) {
50417
+ return Math.random() * (max - min) + min;
50418
+ }
50419
+ function velocityFromSpread(speed, spread) {
50420
+ const theta = spread.X;
50421
+ const phi = spread.Y;
50422
+ const velocity = new Vector32(
50423
+ -speed * Math.sin(phi),
50424
+ -speed * Math.cos(phi) * Math.sin(theta),
50425
+ -speed * Math.cos(phi) * Math.cos(theta)
50426
+ );
50427
+ return velocity;
50428
+ }
50429
+ class Particle {
50430
+ lifetime;
50431
+ time = 0;
50432
+ position;
50433
+ rotation;
50434
+ velocity;
50435
+ rotationSpeed;
50436
+ seed = Math.random();
50437
+ constructor(lifetime, position, rotation, velocity, rotationSpeed) {
50438
+ this.lifetime = lifetime;
50439
+ this.position = position;
50440
+ this.rotation = rotation;
50441
+ this.velocity = velocity;
50442
+ this.rotationSpeed = rotationSpeed;
50310
50443
  }
50311
- get data() {
50312
- return this.instance.Prop("_data");
50444
+ get intSeed() {
50445
+ return Math.floor(this.seed * 1e6);
50313
50446
  }
50314
- created() {
50315
- if (this.instance.Prop("Playing")) {
50316
- this.Play();
50317
- }
50318
- this.instance.Destroying.Connect(() => {
50319
- if (this.data.playingSource) {
50320
- this.Stop();
50321
- }
50322
- this.data.audioContext = void 0;
50323
- this.data.gainNode = void 0;
50324
- this.data.buffer = void 0;
50325
- });
50447
+ camDistance(renderScene) {
50448
+ const cameraPos = new Vector32(...renderScene.camera.position.toArray());
50449
+ const particlePos = this.position;
50450
+ const distance2 = cameraPos.minus(particlePos).magnitude();
50451
+ return distance2;
50326
50452
  }
50327
- _updateVolume() {
50328
- if (this.data.gainNode) {
50329
- if (this.instance.HasProperty("Volume")) {
50330
- const volume = this.instance.Prop("Volume");
50331
- this.data.gainNode.gain.value = volume;
50332
- }
50333
- }
50334
- }
50335
- setPlaying(value) {
50336
- this.instance.setProperty("Playing", value);
50337
- }
50338
- playSource() {
50339
- if (!this.data.audioContext || !this.data.gainNode || !this.data.buffer) return;
50340
- this.data.playingSource = this.data.audioContext.createBufferSource();
50341
- this.data.playingSource.buffer = this.data.buffer;
50342
- this.data.playingSource.connect(this.data.gainNode);
50343
- this.data.gainNode.connect(this.data.audioContext.destination);
50344
- this._updateVolume();
50345
- this.data.playingSource.start(0);
50346
- this.data.playingSource.onended = (() => {
50347
- if (this.instance.Prop("Looped")) {
50348
- this.Play();
50349
- } else {
50350
- this.Stop();
50351
- }
50352
- });
50353
- }
50354
- Play() {
50355
- if (!FLAGS.AUDIO_ENABLED) return;
50356
- this.Stop();
50357
- this.setPlaying(true);
50358
- if (!this.data.audioContext) {
50359
- this.data.audioContext = new AudioContext();
50360
- }
50361
- if (!this.data.gainNode) {
50362
- this.data.gainNode = this.data.audioContext.createGain();
50363
- }
50364
- if (!this.data.buffer) {
50365
- let audioUrl = void 0;
50366
- if (this.instance.HasProperty("SoundId")) {
50367
- audioUrl = this.instance.Prop("SoundId");
50368
- } else if (this.instance.HasProperty("AudioContent")) {
50369
- audioUrl = this.instance.Prop("AudioContent").uri;
50370
- }
50371
- if (audioUrl && audioUrl.length > 0) {
50372
- API.Asset.GetAssetBuffer(audioUrl).then((responseBuffer) => {
50373
- if (responseBuffer instanceof Response || !this.data.audioContext) return;
50374
- const buffer2 = responseBuffer.slice(0);
50375
- this.data.audioContext.decodeAudioData(buffer2).then((decodedData) => {
50376
- if (!this.data.audioContext || !this.data.gainNode) return;
50377
- this.data.buffer = decodedData;
50378
- this.playSource();
50379
- });
50380
- });
50381
- }
50382
- } else if (this.data.buffer) {
50383
- this.playSource();
50384
- }
50385
- }
50386
- Stop() {
50387
- this.setPlaying(false);
50388
- if (this.data.playingSource) {
50389
- this.data.playingSource.stop();
50390
- this.data.playingSource = void 0;
50391
- }
50392
- }
50393
- }
50394
- const __vite_glob_0_22 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50395
- __proto__: null,
50396
- SoundWrapper
50397
- }, Symbol.toStringTag, { value: "Module" }));
50398
- class ScriptWrapperData {
50399
- shouldStop = false;
50400
- }
50401
- class ScriptWrapper extends InstanceWrapper {
50402
- static className = "Script";
50403
- static requiredProperties = ["Name", "_data"];
50404
- setup() {
50405
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
50406
- if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new ScriptWrapperData());
50407
- }
50408
- get data() {
50409
- return this.instance.Prop("_data");
50410
- }
50411
- created() {
50412
- this.Run();
50413
- }
50414
- Run() {
50415
- switch (this.instance.Prop("Name")) {
50416
- case "ChickenSounds":
50417
- case "HarmonicaSounds":
50418
- case "SoundPlayer":
50419
- this.SoundPlayer(this.instance);
50420
- break;
50421
- }
50422
- }
50423
- //Scripts
50424
- async SoundPlayer(script) {
50425
- let Handle = void 0;
50426
- if (script.parent && script.parent.Prop("Name") === "Handle") {
50427
- Handle = script.parent;
50428
- } else if (script.parent && script.parent.FindFirstChild("Handle")) {
50429
- Handle = script.parent.FindFirstChild("Handle");
50430
- }
50431
- if (!Handle) return;
50432
- const Hat = Handle.parent;
50433
- if (!Hat) return;
50434
- const Sounds = [];
50435
- for (const child of Handle.GetDescendants()) {
50436
- if (child.className === "Sound") {
50437
- Sounds.push(child);
50438
- }
50439
- }
50440
- function IsBeingWorn() {
50441
- return Hat?.parent?.FindFirstChild("Humanoid");
50442
- }
50443
- let maxTime = 20;
50444
- if (script.Prop("Name") === "SoundPlayer") {
50445
- maxTime = 15;
50446
- }
50447
- while (true) {
50448
- await Wait(mathRandom(5, maxTime));
50449
- if (this.instance.destroyed || this.data.shouldStop) return;
50450
- if (IsBeingWorn()) {
50451
- const index = mathRandom(0, Sounds.length - 1);
50452
- const Sound = Sounds[index];
50453
- const soundWrapper = new SoundWrapper(Sound);
50454
- soundWrapper.Play();
50455
- }
50456
- }
50457
- }
50458
- }
50459
- const __vite_glob_0_21 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50460
- __proto__: null,
50461
- ScriptWrapper
50462
- }, Symbol.toStringTag, { value: "Module" }));
50463
- class ToolWrapper extends InstanceWrapper {
50464
- static className = "Tool";
50465
- static requiredProperties = [
50466
- "Name",
50467
- "Grip"
50468
- ];
50469
- setup() {
50470
- if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
50471
- if (!this.instance.HasProperty("Grip")) this.instance.addProperty(new Property("Grip", DataType.CFrame), new CFrame());
50472
- }
50473
- created() {
50474
- this.instance.AncestryChanged.Connect(() => {
50475
- this.createWeld();
50476
- });
50477
- }
50478
- //doing this is actually inaccurate because tools dont create welds, but its easier
50479
- createWeld() {
50480
- const handle = this.instance.FindFirstChild("Handle");
50481
- const rig = this.instance.parent;
50482
- const grip = this.instance.PropOrDefault("Grip", new CFrame()).clone();
50483
- if (handle) {
50484
- const oldToolWeld = handle.FindFirstChild("ToolWeld_GripRoAvatar");
50485
- if (oldToolWeld) {
50486
- oldToolWeld.Destroy();
50487
- }
50488
- }
50489
- const humanoid = rig?.FindFirstChildOfClass("Humanoid");
50490
- if (handle && rig && rig.className === "Model" && humanoid) {
50491
- const rightHand = rig.FindFirstChild("RightHand") || rig.FindFirstChild("Right Arm");
50492
- if (rightHand) {
50493
- for (const child of rightHand.GetDescendants()) {
50494
- if (child.Prop("Name") === "RightGripAttachment") {
50495
- const rightGripAttCF = child.PropOrDefault("CFrame", new CFrame()).clone();
50496
- if (humanoid.Prop("RigType") === HumanoidRigType.R6) {
50497
- rightGripAttCF.Orientation[0] -= 90;
50498
- }
50499
- const weld = new Instance("Weld");
50500
- weld.addProperty(new Property("Name", DataType.String), "ToolWeld_GripRoAvatar");
50501
- weld.addProperty(new Property("Archivable", DataType.Bool), true);
50502
- weld.addProperty(new Property("C0", DataType.CFrame), rightGripAttCF);
50503
- weld.addProperty(new Property("C1", DataType.CFrame), grip);
50504
- weld.addProperty(new Property("Part0", DataType.Referent), child.parent);
50505
- weld.addProperty(new Property("Part1", DataType.Referent), handle);
50506
- weld.addProperty(new Property("Active", DataType.Bool), true);
50507
- weld.addProperty(new Property("Enabled", DataType.Bool), false);
50508
- weld.setParent(handle);
50509
- weld.setProperty("Enabled", true);
50510
- }
50511
- }
50512
- }
50513
- }
50514
- }
50515
- }
50516
- const __vite_glob_0_23 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50517
- __proto__: null,
50518
- ToolWrapper
50519
- }, Symbol.toStringTag, { value: "Module" }));
50520
- class WedgePartWrapper extends BasePartWrapper {
50521
- static className = "WedgePart";
50522
- }
50523
- const __vite_glob_0_24 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50524
- __proto__: null,
50525
- WedgePartWrapper
50526
- }, Symbol.toStringTag, { value: "Module" }));
50527
- class WeldWrapper extends JointInstanceWrapper {
50528
- static className = "Weld";
50529
- }
50530
- const __vite_glob_0_25 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50531
- __proto__: null,
50532
- WeldWrapper
50533
- }, Symbol.toStringTag, { value: "Module" }));
50534
- 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/Bone.ts": __vite_glob_0_8, "./instance/Constraint.ts": __vite_glob_0_9, "./instance/Decal.ts": __vite_glob_0_10, "./instance/FaceControls.ts": __vite_glob_0_11, "./instance/HumanoidDescription.ts": __vite_glob_0_12, "./instance/InstanceWrapper.ts": __vite_glob_0_13, "./instance/JointInstance.ts": __vite_glob_0_14, "./instance/MakeupDescription.ts": __vite_glob_0_15, "./instance/ManualWeld.ts": __vite_glob_0_16, "./instance/MeshPart.ts": __vite_glob_0_17, "./instance/Model.ts": __vite_glob_0_18, "./instance/Motor6D.ts": __vite_glob_0_19, "./instance/Part.ts": __vite_glob_0_20, "./instance/Script.ts": __vite_glob_0_21, "./instance/Sound.ts": __vite_glob_0_22, "./instance/Tool.ts": __vite_glob_0_23, "./instance/WedgePart.ts": __vite_glob_0_24, "./instance/Weld.ts": __vite_glob_0_25 });
50535
- function RegisterWrappers() {
50536
- for (const module of Object.values(modules$1)) {
50537
- for (const exprt of Object.values(module)) {
50538
- let prototype = Object.getPrototypeOf(exprt);
50539
- while (prototype) {
50540
- if (prototype === InstanceWrapper) {
50541
- exprt.register();
50542
- break;
50543
- }
50544
- prototype = Object.getPrototypeOf(prototype);
50545
- }
50546
- }
50547
- }
50548
- }
50549
- const attachmentGeometry = new SphereGeometry(0.125, 16, 8);
50550
- class AttachmentDesc extends RenderDesc {
50551
- static classTypes = ["Attachment"];
50552
- visible = false;
50553
- cframe = new CFrame();
50554
- isSame(other) {
50555
- return this.visible === other.visible && this.cframe.isSame(other.cframe);
50556
- }
50557
- needsRegeneration(other) {
50558
- return this.visible !== other.visible;
50559
- }
50560
- virtualFromRenderDesc(other) {
50561
- this.cframe = other.cframe.clone();
50562
- }
50563
- fromInstance(child) {
50564
- const attachmentW = new AttachmentWrapper(child);
50565
- this.cframe = attachmentW.getWorldCFrame();
50566
- this.visible = child.PropOrDefault("Visible", this.visible) || FLAGS.ALWAYS_SHOW_ATTACHMENTS;
50567
- }
50568
- async compileResults() {
50569
- this.results = [];
50570
- if (this.visible) {
50571
- const mesh = new Mesh(attachmentGeometry, new MeshLambertMaterial({ color: 65280 }));
50572
- mesh.name = this.instance ? this.instance.PropOrDefault("Name", "Unknown") + "_Att" : "Unknown_Att";
50573
- this.results.push(mesh);
50574
- }
50575
- this.updateResults();
50576
- return this.results;
50577
- }
50578
- updateResults() {
50579
- if (!this.results) return;
50580
- for (const attachment of this.results) {
50581
- const resultCF = this.cframe;
50582
- setTHREEObjectCF(attachment, resultCF);
50583
- }
50584
- }
50585
- dispose(_renderer, scene) {
50586
- if (!this.results) return;
50587
- for (const result of this.results) {
50588
- scene.remove(result);
50589
- }
50590
- }
50591
- }
50592
- const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50593
- __proto__: null,
50594
- AttachmentDesc
50595
- }, Symbol.toStringTag, { value: "Module" }));
50596
- const particle_vertexShader = (
50597
- /*glsl*/
50598
- `
50599
- attribute vec3 instanceColor;
50600
- attribute vec3 instanceSeedTime;
50601
- attribute float instanceOpacity;
50602
- attribute vec4 instanceFlipbook;
50603
-
50604
- varying vec2 vUv;
50605
- varying vec3 vInstanceColor;
50606
- varying float vInstanceOpacity;
50607
- varying vec3 vInstanceSeedTime;
50608
- varying vec2 vFlipbookUv0;
50609
- varying vec2 vFlipbookUv1;
50610
-
50611
- uniform float uZOffset;
50612
-
50613
- void main() {
50614
- vUv = uv;
50615
- vInstanceColor = instanceColor;
50616
- vInstanceOpacity = instanceOpacity;
50617
- vInstanceSeedTime = instanceSeedTime;
50618
- vFlipbookUv0 = instanceFlipbook.xy;
50619
- vFlipbookUv1 = instanceFlipbook.zw;
50620
-
50621
- vec4 modelViewPosition = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
50622
-
50623
- //offset position toward camera
50624
- vec3 viewDir = normalize(modelViewPosition.xyz);
50625
- modelViewPosition.xyz += viewDir * -uZOffset;
50626
-
50627
- gl_Position = projectionMatrix * modelViewPosition;
50628
- }
50629
- `
50630
- );
50631
- const particle_fragmentShader = (
50632
- /*glsl*/
50633
- `
50634
- //artibutes
50635
- varying vec2 vUv;
50636
- varying vec3 vInstanceColor;
50637
- varying float vInstanceOpacity;
50638
- varying vec3 vInstanceSeedTime;
50639
- varying vec2 vFlipbookUv0;
50640
- varying vec2 vFlipbookUv1;
50641
-
50642
- //textures
50643
- uniform sampler2D uColorMap;
50644
- uniform sampler2D uAlphaMap;
50645
- uniform sampler2D uMap;
50646
-
50647
- //uniforms
50648
- uniform float uLightInfluence;
50649
- uniform float uOpacity;
50650
- uniform vec2 uFlipbookSize;
50651
-
50652
- //light uniforms
50653
- struct DirectionalLight {
50654
- vec3 direction;
50655
- vec3 color;
50656
- };
50657
- uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];
50658
-
50659
- uniform vec3 ambientLightColor;
50660
-
50661
- void main() {
50662
- float seed = vInstanceSeedTime.x;
50663
- float time = vInstanceSeedTime.y;
50664
- float flipbookFrameTime = vInstanceSeedTime.z;
50665
-
50666
- // Sample the texture using the UV coordinates (for both frames)
50667
- vec4 texColor0 = texture2D(uMap, vUv * uFlipbookSize + vFlipbookUv0);
50668
- vec4 texColor1 = texture2D(uMap, vUv * uFlipbookSize + vFlipbookUv1);
50669
-
50670
- float frameTransition = mod(time, flipbookFrameTime) / flipbookFrameTime;
50671
- vec4 texColor = texColor0 * (1.0 - frameTransition) + texColor1 * frameTransition;
50672
-
50673
- vec4 alphaTex = texture2D(uAlphaMap, vec2(time, seed));
50674
- vec4 colorTex = texture2D(uColorMap, vec2(time, seed));
50675
-
50676
- // Tint texture with our color
50677
- vec4 tintedColor = texColor * vec4(vInstanceColor, 1.0);
50678
-
50679
- // Apply opacity to the texture alpha
50680
- vec4 opacityColor = tintedColor * vec4(1.0, 1.0, 1.0, uOpacity * vInstanceOpacity) * alphaTex.r;
50681
-
50682
- //#ADDITIVE_INSERT
50683
-
50684
- // Apply that weird color things sparkles have
50685
- vec4 finalColor = opacityColor;
50686
- finalColor.rgb = mix(opacityColor.rgb, opacityColor.rgb * colorTex.rgb, colorTex.a);
50687
-
50688
- // Apply lighting
50689
- vec3 light = ambientLightColor;
50690
- #if NUM_DIR_LIGHTS > 0
50691
- for (int i = 0; i < NUM_DIR_LIGHTS; i++) {
50692
- light += directionalLights[i].color;
50693
- }
50694
- #endif
50695
-
50696
- finalColor = vec4(mix(finalColor.rgb, finalColor.rgb * light, uLightInfluence), finalColor.a);
50697
-
50698
- gl_FragColor = finalColor;
50699
- }
50700
- `
50701
- );
50702
- const particle_fragmentShader_additive = particle_fragmentShader.replace(
50703
- "//#ADDITIVE_INSERT",
50704
- /*glsl*/
50705
- `
50706
- if (opacityColor.r + opacityColor.g + opacityColor.b <= 0.05) {
50707
- discard;
50708
- }`
50709
- );
50710
- function randomBetween(min, max) {
50711
- return Math.random() * (max - min) + min;
50712
- }
50713
- function velocityFromSpread(speed, spread) {
50714
- const theta = spread.X;
50715
- const phi = spread.Y;
50716
- const velocity = new Vector32(
50717
- -speed * Math.sin(phi),
50718
- -speed * Math.cos(phi) * Math.sin(theta),
50719
- -speed * Math.cos(phi) * Math.cos(theta)
50720
- );
50721
- return velocity;
50722
- }
50723
- class Particle {
50724
- lifetime;
50725
- time = 0;
50726
- position;
50727
- rotation;
50728
- velocity;
50729
- rotationSpeed;
50730
- seed = Math.random();
50731
- constructor(lifetime, position, rotation, velocity, rotationSpeed) {
50732
- this.lifetime = lifetime;
50733
- this.position = position;
50734
- this.rotation = rotation;
50735
- this.velocity = velocity;
50736
- this.rotationSpeed = rotationSpeed;
50737
- }
50738
- get intSeed() {
50739
- return Math.floor(this.seed * 1e6);
50740
- }
50741
- camDistance(renderScene) {
50742
- const cameraPos = new Vector32(...renderScene.camera.position.toArray());
50743
- const particlePos = this.position;
50744
- const distance2 = cameraPos.minus(particlePos).magnitude();
50745
- return distance2;
50746
- }
50747
- getMatrix(renderScene, size, orientation, squash) {
50748
- const camera = renderScene.camera;
50749
- const particlePos = new Vector3$1(...this.position.toVec3());
50750
- const translation = new Matrix4().makeTranslation(particlePos);
50751
- const sizeX = squash > 0 ? size / (1 + squash) : size * (1 - squash);
50752
- const sizeY = squash > 0 ? size * (1 + squash) : size / (1 - squash);
50753
- const scale = new Matrix4().makeScale(sizeX, sizeY, 1);
50754
- switch (orientation) {
50755
- case ParticleOrientation.FacingCameraWorldUp: {
50756
- const cameraLookVector = new Vector3$1();
50757
- camera.getWorldDirection(cameraLookVector);
50758
- const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), new Vector3$1(0, 1, 0), cameraLookVector);
50759
- const _pos = new Vector3$1();
50760
- const _scale = new Vector3$1();
50761
- const rotationQuat = new Quaternion();
50762
- rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
50763
- const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
50764
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50765
- const offsetRotation = new Matrix4().makeRotationAxis(new Vector3$1(1, 0, 0), rad(-90));
50766
- const offset2Rotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 1, 0), rad(180));
50767
- const final = translation.multiply(rotation).multiply(offsetRotation).multiply(offset2Rotation).multiply(flatRotation).multiply(scale);
50768
- return final;
50769
- }
50770
- case ParticleOrientation.VelocityPerpendicular: {
50771
- const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
50772
- const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), normalizedVelocity, new Vector3$1(0, 1, 0));
50773
- const _pos = new Vector3$1();
50774
- const _scale = new Vector3$1();
50775
- const rotationQuat = new Quaternion();
50776
- rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
50777
- const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
50778
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50779
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50780
- return final;
50781
- }
50782
- case ParticleOrientation.VelocityParallel: {
50783
- const toCamera = new Vector3$1(0, 0, -1).applyQuaternion(camera.quaternion);
50784
- const velocityVector = new Vector3$1(...this.velocity.toVec3());
50785
- const vY = velocityVector.normalize();
50786
- const vX = new Vector3$1().crossVectors(toCamera.normalize(), vY).normalize();
50787
- const vZ = new Vector3$1().crossVectors(vX, vY).normalize();
50788
- const rotation = new Matrix4().set(
50789
- vX.x,
50790
- vY.x,
50791
- vZ.x,
50792
- 0,
50793
- vX.y,
50794
- vY.y,
50795
- vZ.y,
50796
- 0,
50797
- vX.z,
50798
- vY.z,
50799
- vZ.z,
50800
- 0,
50801
- 0,
50802
- 0,
50803
- 0,
50804
- 1
50805
- );
50806
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation + 90));
50807
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50808
- return final;
50809
- }
50810
- case ParticleOrientation.FacingCamera:
50811
- default: {
50812
- const rotation = new Matrix4().makeRotationFromQuaternion(camera.quaternion);
50813
- const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50814
- const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50815
- return final;
50453
+ getMatrix(renderScene, size, orientation, squash) {
50454
+ const camera = renderScene.camera;
50455
+ const particlePos = new Vector3$1(...this.position.toVec3());
50456
+ const translation = new Matrix4().makeTranslation(particlePos);
50457
+ const sizeX = squash > 0 ? size / (1 + squash) : size * (1 - squash);
50458
+ const sizeY = squash > 0 ? size * (1 + squash) : size / (1 - squash);
50459
+ const scale = new Matrix4().makeScale(sizeX, sizeY, 1);
50460
+ switch (orientation) {
50461
+ case ParticleOrientation.FacingCameraWorldUp: {
50462
+ const cameraLookVector = new Vector3$1();
50463
+ camera.getWorldDirection(cameraLookVector);
50464
+ const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), new Vector3$1(0, 1, 0), cameraLookVector);
50465
+ const _pos = new Vector3$1();
50466
+ const _scale = new Vector3$1();
50467
+ const rotationQuat = new Quaternion();
50468
+ rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
50469
+ const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
50470
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50471
+ const offsetRotation = new Matrix4().makeRotationAxis(new Vector3$1(1, 0, 0), rad(-90));
50472
+ const offset2Rotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 1, 0), rad(180));
50473
+ const final = translation.multiply(rotation).multiply(offsetRotation).multiply(offset2Rotation).multiply(flatRotation).multiply(scale);
50474
+ return final;
50475
+ }
50476
+ case ParticleOrientation.VelocityPerpendicular: {
50477
+ const normalizedVelocity = new Vector3$1(...this.velocity.normalize().toVec3());
50478
+ const rotationParticlePosMatrix = new Matrix4().lookAt(new Vector3$1(0, 0, 0), normalizedVelocity, new Vector3$1(0, 1, 0));
50479
+ const _pos = new Vector3$1();
50480
+ const _scale = new Vector3$1();
50481
+ const rotationQuat = new Quaternion();
50482
+ rotationParticlePosMatrix.decompose(_pos, rotationQuat, _scale);
50483
+ const rotation = new Matrix4().makeRotationFromQuaternion(rotationQuat);
50484
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50485
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50486
+ return final;
50487
+ }
50488
+ case ParticleOrientation.VelocityParallel: {
50489
+ const toCamera = new Vector3$1(0, 0, -1).applyQuaternion(camera.quaternion);
50490
+ const velocityVector = new Vector3$1(...this.velocity.toVec3());
50491
+ const vY = velocityVector.normalize();
50492
+ const vX = new Vector3$1().crossVectors(toCamera.normalize(), vY).normalize();
50493
+ const vZ = new Vector3$1().crossVectors(vX, vY).normalize();
50494
+ const rotation = new Matrix4().set(
50495
+ vX.x,
50496
+ vY.x,
50497
+ vZ.x,
50498
+ 0,
50499
+ vX.y,
50500
+ vY.y,
50501
+ vZ.y,
50502
+ 0,
50503
+ vX.z,
50504
+ vY.z,
50505
+ vZ.z,
50506
+ 0,
50507
+ 0,
50508
+ 0,
50509
+ 0,
50510
+ 1
50511
+ );
50512
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation + 90));
50513
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50514
+ return final;
50515
+ }
50516
+ case ParticleOrientation.FacingCamera:
50517
+ default: {
50518
+ const rotation = new Matrix4().makeRotationFromQuaternion(camera.quaternion);
50519
+ const flatRotation = new Matrix4().makeRotationAxis(new Vector3$1(0, 0, 1), rad(this.rotation));
50520
+ const final = translation.multiply(rotation).multiply(flatRotation).multiply(scale);
50521
+ return final;
50816
50522
  }
50817
50523
  }
50818
50524
  }
@@ -51050,8 +50756,8 @@ class EmitterDesc extends DisposableDesc {
51050
50756
  }
51051
50757
  return this.result;
51052
50758
  }
51053
- emit(groupDesc) {
51054
- if (this.particles.length >= this.maxCount || groupDesc.enabled === false) {
50759
+ emit(groupDesc, force = false) {
50760
+ if (this.particles.length >= this.maxCount || groupDesc.enabled === false && !force) {
51055
50761
  return;
51056
50762
  }
51057
50763
  const speed = randomBetween(this.speed.Min, this.speed.Max);
@@ -51249,6 +50955,7 @@ class EmitterGroupDesc extends RenderDesc {
51249
50955
  this.lowerBound = other.lowerBound;
51250
50956
  this.higherBound = other.higherBound;
51251
50957
  this.emitterDir = other.emitterDir;
50958
+ this.enabled = other.enabled;
51252
50959
  for (let i = 0; i < this.emitterDescs.length; i++) {
51253
50960
  this.emitterDescs[i].fromEmitterDesc(other.emitterDescs[i]);
51254
50961
  }
@@ -51412,83 +51119,598 @@ class EmitterGroupDesc extends RenderDesc {
51412
51119
  blending: AdditiveBlending
51413
51120
  }));
51414
51121
  }
51415
- fromSmoke(child) {
51416
- const size = child.PropOrDefault("size_xml", 1);
51417
- const endSize = 10 + size;
51418
- const timeScale = child.PropOrDefault("TimeScale", 1);
51419
- const riseVelocity = child.PropOrDefault("riseVelocity_xml", 1);
51420
- const opacity = child.PropOrDefault("opacity_xml", 0.5);
51421
- const color = child.PropOrDefault("Color", new Color3(1, 1, 1));
51422
- this.emitterDescs.push(this.createEmitter({
51423
- texture: "rbxasset://textures/particles/smoke_main.dds",
51424
- alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
51425
- drag: 0.1,
51426
- opacity,
51427
- acceleration: new Vector32(0, 0, 0.4),
51428
- size: new NumberSequence([new NumberSequenceKeypoint(0, size, 0), new NumberSequenceKeypoint(1, endSize, 0)]),
51429
- rotation: new NumberRange(-90, 90),
51430
- speed: new NumberRange(riseVelocity * 0.9, riseVelocity * 1),
51431
- rotationSpeed: new NumberRange(-20, 20),
51432
- spreadAngle: new Vector22(30, 30),
51433
- rate: 7,
51434
- lifetime: new NumberRange(5, 5),
51435
- timeScale,
51436
- color: ColorSequence.fromColor(color),
51437
- blending: NormalBlending,
51438
- lightInfluence: 1
51439
- }));
51122
+ fromSmoke(child) {
51123
+ const size = child.PropOrDefault("size_xml", 1);
51124
+ const endSize = 10 + size;
51125
+ const timeScale = child.PropOrDefault("TimeScale", 1);
51126
+ const riseVelocity = child.PropOrDefault("riseVelocity_xml", 1);
51127
+ const opacity = child.PropOrDefault("opacity_xml", 0.5);
51128
+ const color = child.PropOrDefault("Color", new Color3(1, 1, 1));
51129
+ this.emitterDescs.push(this.createEmitter({
51130
+ texture: "rbxasset://textures/particles/smoke_main.dds",
51131
+ alphaTexture: "rbxasset://textures/particles/common_alpha.dds",
51132
+ drag: 0.1,
51133
+ opacity,
51134
+ acceleration: new Vector32(0, 0, 0.4),
51135
+ size: new NumberSequence([new NumberSequenceKeypoint(0, size, 0), new NumberSequenceKeypoint(1, endSize, 0)]),
51136
+ rotation: new NumberRange(-90, 90),
51137
+ speed: new NumberRange(riseVelocity * 0.9, riseVelocity * 1),
51138
+ rotationSpeed: new NumberRange(-20, 20),
51139
+ spreadAngle: new Vector22(30, 30),
51140
+ rate: 7,
51141
+ lifetime: new NumberRange(5, 5),
51142
+ timeScale,
51143
+ color: ColorSequence.fromColor(color),
51144
+ blending: NormalBlending,
51145
+ lightInfluence: 1
51146
+ }));
51147
+ }
51148
+ dispose(renderer, scene) {
51149
+ const meshes = this.results;
51150
+ if (meshes) {
51151
+ this.disposeMeshes(scene, meshes);
51152
+ this.disposeRenderLists(renderer);
51153
+ }
51154
+ }
51155
+ async compileResults(renderer, scene) {
51156
+ const originalResults = this.results;
51157
+ const resultPromises = [];
51158
+ for (const emitterDesc of this.emitterDescs) {
51159
+ resultPromises.push(emitterDesc.compileResult(renderer, scene));
51160
+ }
51161
+ this.results = [];
51162
+ const compiledResults = await Promise.all(resultPromises);
51163
+ for (const compiledResult of compiledResults) {
51164
+ if (compiledResult instanceof Mesh) {
51165
+ this.results.push(compiledResult);
51166
+ } else {
51167
+ this.disposeMeshes(scene, this.results);
51168
+ this.disposeRenderLists(renderer);
51169
+ return compiledResult;
51170
+ }
51171
+ }
51172
+ if (originalResults) {
51173
+ this.disposeMeshes(scene, originalResults);
51174
+ this.disposeRenderLists(renderer);
51175
+ }
51176
+ if (FLAGS.PARTICLES_START_FULL) {
51177
+ for (const emitterDesc of this.emitterDescs) {
51178
+ for (let i = 0; i < Math.min(emitterDesc.lifetime.Max * 2 * FLAGS.PARTICLES_START_FULL_FRAMERATE, FLAGS.PARTICLES_START_FULL * FLAGS.PARTICLES_START_FULL_FRAMERATE); i++) {
51179
+ emitterDesc.tick(1 / FLAGS.PARTICLES_START_FULL_FRAMERATE, this);
51180
+ }
51181
+ emitterDesc.updateResult(this.renderScene);
51182
+ }
51183
+ }
51184
+ return this.results;
51185
+ }
51186
+ updateResults() {
51187
+ const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10) * FLAGS.RENDERER_DELTA_TIME_MULTIPLIER;
51188
+ this.lastTime = this.time;
51189
+ for (const emitterDesc of this.emitterDescs) {
51190
+ emitterDesc.tick(dt, this);
51191
+ emitterDesc.updateResult(this.renderScene);
51192
+ }
51193
+ this.lastCframe = this.cframe.clone();
51194
+ }
51195
+ }
51196
+ const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51197
+ __proto__: null,
51198
+ EmitterGroupDesc
51199
+ }, Symbol.toStringTag, { value: "Module" }));
51200
+ class ParticleEmitterWrapper extends InstanceWrapper {
51201
+ static className = "ParticleEmitter";
51202
+ static requiredProperties = [
51203
+ "Name"
51204
+ ];
51205
+ setup() {
51206
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
51207
+ }
51208
+ Emit(count = 16) {
51209
+ const renderDescs = RBXRenderer.getRenderDescs(this.instance);
51210
+ for (const renderDesc of renderDescs) {
51211
+ if (renderDesc instanceof EmitterGroupDesc) {
51212
+ for (const emitterDesc of renderDesc.emitterDescs) {
51213
+ for (let i = 0; i < count; i++) {
51214
+ emitterDesc.emit(renderDesc, true);
51215
+ }
51216
+ }
51217
+ }
51218
+ }
51219
+ }
51220
+ }
51221
+ const __vite_glob_0_21 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51222
+ __proto__: null,
51223
+ ParticleEmitterWrapper
51224
+ }, Symbol.toStringTag, { value: "Module" }));
51225
+ class SoundWrapperData {
51226
+ audioContext;
51227
+ gainNode;
51228
+ buffer;
51229
+ playingSource;
51230
+ }
51231
+ class SoundWrapper extends InstanceWrapper {
51232
+ static className = "Sound";
51233
+ static requiredProperties = ["Name", "Looped", "Playing", "Volume", "_data"];
51234
+ setup() {
51235
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
51236
+ if (!this.instance.HasProperty("Looped")) this.instance.addProperty(new Property("Looped", DataType.Bool), false);
51237
+ if (!this.instance.HasProperty("Playing")) this.instance.addProperty(new Property("Playing", DataType.Bool), false);
51238
+ if (!this.instance.HasProperty("Volume")) this.instance.addProperty(new Property("Volume", DataType.Float32), false);
51239
+ if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new SoundWrapperData());
51240
+ }
51241
+ get data() {
51242
+ return this.instance.Prop("_data");
51243
+ }
51244
+ created() {
51245
+ if (this.instance.Prop("Playing")) {
51246
+ this.Play();
51247
+ }
51248
+ this.instance.Destroying.Connect(() => {
51249
+ if (this.data.playingSource) {
51250
+ this.Stop();
51251
+ }
51252
+ this.data.audioContext = void 0;
51253
+ this.data.gainNode = void 0;
51254
+ this.data.buffer = void 0;
51255
+ });
51256
+ }
51257
+ _updateVolume() {
51258
+ if (this.data.gainNode) {
51259
+ if (this.instance.HasProperty("Volume")) {
51260
+ const volume = this.instance.Prop("Volume");
51261
+ this.data.gainNode.gain.value = volume;
51262
+ }
51263
+ }
51264
+ }
51265
+ setPlaying(value) {
51266
+ this.instance.setProperty("Playing", value);
51267
+ }
51268
+ playSource() {
51269
+ if (!this.data.audioContext || !this.data.gainNode || !this.data.buffer) return;
51270
+ this.data.playingSource = this.data.audioContext.createBufferSource();
51271
+ this.data.playingSource.buffer = this.data.buffer;
51272
+ this.data.playingSource.connect(this.data.gainNode);
51273
+ this.data.gainNode.connect(this.data.audioContext.destination);
51274
+ this._updateVolume();
51275
+ this.data.playingSource.start(0);
51276
+ this.data.playingSource.onended = (() => {
51277
+ if (this.instance.Prop("Looped")) {
51278
+ this.Play();
51279
+ } else {
51280
+ this.Stop();
51281
+ }
51282
+ });
51283
+ }
51284
+ Play() {
51285
+ if (!FLAGS.AUDIO_ENABLED) return;
51286
+ this.Stop();
51287
+ this.setPlaying(true);
51288
+ if (!this.data.audioContext) {
51289
+ this.data.audioContext = new AudioContext();
51290
+ }
51291
+ if (!this.data.gainNode) {
51292
+ this.data.gainNode = this.data.audioContext.createGain();
51293
+ }
51294
+ if (!this.data.buffer) {
51295
+ let audioUrl = void 0;
51296
+ if (this.instance.HasProperty("SoundId")) {
51297
+ audioUrl = this.instance.Prop("SoundId");
51298
+ } else if (this.instance.HasProperty("AudioContent")) {
51299
+ audioUrl = this.instance.Prop("AudioContent").uri;
51300
+ }
51301
+ if (audioUrl && audioUrl.length > 0) {
51302
+ API.Asset.GetAssetBuffer(audioUrl).then((responseBuffer) => {
51303
+ if (responseBuffer instanceof Response || !this.data.audioContext) return;
51304
+ const buffer2 = responseBuffer.slice(0);
51305
+ this.data.audioContext.decodeAudioData(buffer2).then((decodedData) => {
51306
+ if (!this.data.audioContext || !this.data.gainNode) return;
51307
+ this.data.buffer = decodedData;
51308
+ this.playSource();
51309
+ });
51310
+ });
51311
+ }
51312
+ } else if (this.data.buffer) {
51313
+ this.playSource();
51314
+ }
51315
+ }
51316
+ Stop() {
51317
+ this.setPlaying(false);
51318
+ if (this.data.playingSource) {
51319
+ this.data.playingSource.stop();
51320
+ this.data.playingSource = void 0;
51321
+ }
51322
+ }
51323
+ }
51324
+ const __vite_glob_0_23 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51325
+ __proto__: null,
51326
+ SoundWrapper
51327
+ }, Symbol.toStringTag, { value: "Module" }));
51328
+ class ScriptWrapperData {
51329
+ shouldStop = false;
51330
+ }
51331
+ class ScriptWrapper extends InstanceWrapper {
51332
+ static className = "Script";
51333
+ static requiredProperties = ["Name", "_data"];
51334
+ setup() {
51335
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
51336
+ if (!this.instance.HasProperty("_data")) this.instance.addProperty(new Property("_data", DataType.NonSerializable), new ScriptWrapperData());
51337
+ }
51338
+ get data() {
51339
+ return this.instance.Prop("_data");
51440
51340
  }
51441
- dispose(renderer, scene) {
51442
- const meshes = this.results;
51443
- if (meshes) {
51444
- this.disposeMeshes(scene, meshes);
51445
- this.disposeRenderLists(renderer);
51341
+ created() {
51342
+ this.Run();
51343
+ }
51344
+ Run() {
51345
+ switch (this.instance.Prop("Name")) {
51346
+ case "ChickenSounds":
51347
+ case "HarmonicaSounds":
51348
+ case "SoundPlayer":
51349
+ this.SoundPlayer(this.instance);
51350
+ break;
51351
+ case "HatScript2.0":
51352
+ this.HatScript20(this.instance);
51353
+ break;
51446
51354
  }
51447
51355
  }
51448
- async compileResults(renderer, scene) {
51449
- const originalResults = this.results;
51450
- const resultPromises = [];
51451
- for (const emitterDesc of this.emitterDescs) {
51452
- resultPromises.push(emitterDesc.compileResult(renderer, scene));
51356
+ //Scripts
51357
+ async SoundPlayer(script) {
51358
+ let Handle = void 0;
51359
+ if (script.parent && script.parent.Prop("Name") === "Handle") {
51360
+ Handle = script.parent;
51361
+ } else if (script.parent && script.parent.FindFirstChild("Handle")) {
51362
+ Handle = script.parent.FindFirstChild("Handle");
51453
51363
  }
51454
- this.results = [];
51455
- const compiledResults = await Promise.all(resultPromises);
51456
- for (const compiledResult of compiledResults) {
51457
- if (compiledResult instanceof Mesh) {
51458
- this.results.push(compiledResult);
51364
+ if (!Handle) return;
51365
+ const Hat = Handle.parent;
51366
+ if (!Hat) return;
51367
+ const Sounds = [];
51368
+ for (const child of Handle.GetDescendants()) {
51369
+ if (child.className === "Sound") {
51370
+ Sounds.push(child);
51371
+ }
51372
+ }
51373
+ function IsBeingWorn() {
51374
+ return Hat?.parent?.FindFirstChild("Humanoid");
51375
+ }
51376
+ let maxTime = 20;
51377
+ if (script.Prop("Name") === "SoundPlayer") {
51378
+ maxTime = 15;
51379
+ }
51380
+ while (true) {
51381
+ await Wait(mathRandom(5, maxTime));
51382
+ if (this.instance.destroyed || this.data.shouldStop) return;
51383
+ if (IsBeingWorn()) {
51384
+ const index = mathRandom(0, Sounds.length - 1);
51385
+ const Sound = Sounds[index];
51386
+ const soundWrapper = new SoundWrapper(Sound);
51387
+ soundWrapper.Play();
51388
+ }
51389
+ }
51390
+ }
51391
+ async HatScript20(script) {
51392
+ const now = /* @__PURE__ */ new Date();
51393
+ const month = now.getMonth();
51394
+ const day = now.getDay();
51395
+ const data = this.data;
51396
+ let hw;
51397
+ let tg;
51398
+ let xm;
51399
+ let bd;
51400
+ let pt;
51401
+ let vt;
51402
+ let af;
51403
+ if (month == 10 && day > 21) {
51404
+ hw = true;
51405
+ } else if (month == 11 && day > 19) {
51406
+ tg = true;
51407
+ } else if (month == 12 && day > 17 && day < 28) {
51408
+ xm = true;
51409
+ } else if (month == 9 && day == 1) {
51410
+ bd = true;
51411
+ } else if (month == 3 && day > 11 && day < 20) {
51412
+ pt = true;
51413
+ } else if (month == 2 && day > 8 && day < 17) {
51414
+ vt = true;
51415
+ } else if (month == 4 && day == 1) {
51416
+ af = true;
51417
+ }
51418
+ let emitter = script.parent?.Child("ParticleEmitter");
51419
+ const burst = script.parent?.Child("Burst");
51420
+ async function snowBlower() {
51421
+ const snow1 = script.parent?.Child("Snowflake1");
51422
+ const snow2 = script.parent?.Child("Snowflake2");
51423
+ while (true) {
51424
+ await Wait(Math.random() * 5);
51425
+ if (script.destroyed || data.shouldStop) return;
51426
+ snow1?.setProperty("Enabled", false);
51427
+ snow2?.setProperty("Enabled", true);
51428
+ await Wait(Math.random() * 5);
51429
+ if (script.destroyed || data.shouldStop) return;
51430
+ snow1?.setProperty("Enabled", true);
51431
+ snow2?.setProperty("Enabled", false);
51432
+ if (Math.random() > 0.97) {
51433
+ snow1?.setProperty("Enabled", false);
51434
+ await Wait(4);
51435
+ if (script.destroyed || data.shouldStop) return;
51436
+ (snow1?.w).Emit(22);
51437
+ await Wait(Math.random());
51438
+ if (script.destroyed || data.shouldStop) return;
51439
+ (snow2?.w).Emit(22);
51440
+ await Wait(2);
51441
+ if (script.destroyed || data.shouldStop) return;
51442
+ }
51443
+ }
51444
+ }
51445
+ async function leafBlower() {
51446
+ const leaf1 = script.parent?.Child("Leaf1");
51447
+ const leaf2 = script.parent?.Child("Leaf2");
51448
+ while (true) {
51449
+ await Wait(Math.random() * 5);
51450
+ if (script.destroyed || data.shouldStop) return;
51451
+ leaf1?.setProperty("Enabled", false);
51452
+ leaf2?.setProperty("Enabled", true);
51453
+ await Wait(Math.random() * 5);
51454
+ if (script.destroyed || data.shouldStop) return;
51455
+ leaf1?.setProperty("Enabled", true);
51456
+ leaf2?.setProperty("Enabled", false);
51457
+ if (Math.random() > 0.97) {
51458
+ leaf1?.setProperty("Enabled", false);
51459
+ await Wait(4);
51460
+ if (script.destroyed || data.shouldStop) return;
51461
+ (leaf1?.w).Emit(22);
51462
+ await Wait(Math.random());
51463
+ if (script.destroyed || data.shouldStop) return;
51464
+ (leaf2?.w).Emit(22);
51465
+ await Wait(2);
51466
+ if (script.destroyed || data.shouldStop) return;
51467
+ }
51468
+ }
51469
+ }
51470
+ async function cloverBlower() {
51471
+ const leaf1 = script.parent?.Child("Clover1");
51472
+ const leaf2 = script.parent?.Child("Clover2");
51473
+ while (true) {
51474
+ await Wait(Math.random() * 5);
51475
+ if (script.destroyed || data.shouldStop) return;
51476
+ leaf1?.setProperty("Enabled", false);
51477
+ leaf2?.setProperty("Enabled", true);
51478
+ await Wait(Math.random() * 5);
51479
+ if (script.destroyed || data.shouldStop) return;
51480
+ leaf1?.setProperty("Enabled", true);
51481
+ leaf2?.setProperty("Enabled", false);
51482
+ if (Math.random() > 0.97) {
51483
+ leaf1?.setProperty("Enabled", false);
51484
+ await Wait(4);
51485
+ if (script.destroyed || data.shouldStop) return;
51486
+ (leaf1?.w).Emit(22);
51487
+ await Wait(Math.random());
51488
+ if (script.destroyed || data.shouldStop) return;
51489
+ (leaf2?.w).Emit(22);
51490
+ await Wait(2);
51491
+ if (script.destroyed || data.shouldStop) return;
51492
+ }
51493
+ }
51494
+ }
51495
+ if (hw) {
51496
+ emitter?.setProperty("Enabled", false);
51497
+ emitter = script.parent?.Child("Hallow");
51498
+ if (script.parent?.parent?.IsA("MeshPart")) {
51499
+ script.parent?.parent?.setProperty("TextureID", "rbxassetid://6991166143");
51459
51500
  } else {
51460
- this.disposeMeshes(scene, this.results);
51461
- this.disposeRenderLists(renderer);
51462
- return compiledResult;
51501
+ script.parent?.parent?.Child("Mesh")?.setProperty("TextureId", "rbxassetid://6991166143");
51502
+ }
51503
+ } else if (tg) {
51504
+ if (script.parent?.parent?.IsA("MeshPart")) {
51505
+ script.parent?.parent?.setProperty("TextureID", "rbxassetid://6991393806");
51506
+ } else {
51507
+ script.parent?.parent?.Child("Mesh")?.setProperty("TextureId", "rbxassetid://6991393806");
51508
+ }
51509
+ leafBlower();
51510
+ } else if (xm) {
51511
+ emitter?.setProperty("Enabled", false);
51512
+ emitter = script.parent?.Child("Snowflake3");
51513
+ snowBlower();
51514
+ } else if (bd) {
51515
+ emitter?.setProperty("Enabled", false);
51516
+ emitter = script.parent?.Child("Confetti");
51517
+ if (script.parent?.parent?.IsA("MeshPart")) {
51518
+ script.parent?.parent?.setProperty("TextureID", "rbxassetid://2399316028");
51519
+ } else {
51520
+ script.parent?.parent?.Child("Mesh")?.setProperty("TextureId", "rbxassetid://2399316028");
51521
+ }
51522
+ } else if (pt) {
51523
+ if (script.Parent?.Parent?.IsA("MeshPart")) {
51524
+ script.parent?.parent?.setProperty("TextureID", "rbxassetid://2399447918");
51525
+ } else {
51526
+ script.parent?.parent?.Child("Mesh")?.setProperty("TextureId", "rbxassetid://2399447918");
51527
+ }
51528
+ cloverBlower();
51529
+ } else if (vt) {
51530
+ emitter?.setProperty("Enabled", false);
51531
+ emitter = script.Parent?.Child("Heart");
51532
+ if (script.Parent?.Parent?.IsA("MeshPart")) {
51533
+ script.parent?.parent?.setProperty("TextureID", "rbxassetid://2399448372");
51534
+ } else {
51535
+ script.parent?.parent?.Child("Mesh")?.setProperty("TextureId", "rbxassetid://2399448372");
51463
51536
  }
51537
+ } else if (af) {
51538
+ emitter?.setProperty("Enabled", false);
51539
+ emitter = script.Parent?.Child("Hats");
51540
+ script.Parent?.Child("Smokescreen")?.setProperty("Enabled", true);
51541
+ script.Parent?.Parent?.setProperty("Transparency", 1);
51464
51542
  }
51465
- if (originalResults) {
51466
- this.disposeMeshes(scene, originalResults);
51467
- this.disposeRenderLists(renderer);
51543
+ while (true) {
51544
+ await Wait(1.3);
51545
+ if (script.destroyed || data.shouldStop) return;
51546
+ emitter?.setProperty("Enabled", false);
51547
+ await Wait(0.8);
51548
+ if (script.destroyed || data.shouldStop) return;
51549
+ emitter?.setProperty("Enabled", true);
51550
+ const rando = Math.random();
51551
+ if (rando > 0.97) {
51552
+ emitter?.setProperty("Enabled", false);
51553
+ await Wait(4);
51554
+ if (script.destroyed || data.shouldStop) return;
51555
+ burst?.setProperty("Enabled", true);
51556
+ await Wait(2);
51557
+ if (script.destroyed || data.shouldStop) return;
51558
+ burst?.setProperty("Enabled", false);
51559
+ emitter?.setProperty("Enabled", true);
51560
+ } else if (rando > 0.969) {
51561
+ emitter?.setProperty("Enabled", false);
51562
+ await Wait(4);
51563
+ if (script.destroyed || data.shouldStop) return;
51564
+ for (const v of script.Parent?.GetChildren() || []) {
51565
+ if (v.IsA("ParticleEmitter")) {
51566
+ v.w.Emit(mathRandom(6, 10));
51567
+ await Wait(0.5);
51568
+ if (script.destroyed || data.shouldStop) return;
51569
+ }
51570
+ }
51571
+ await Wait(2);
51572
+ if (script.destroyed || data.shouldStop) return;
51573
+ emitter?.setProperty("Enabled", true);
51574
+ }
51468
51575
  }
51469
- if (FLAGS.PARTICLES_START_FULL) {
51470
- for (const emitterDesc of this.emitterDescs) {
51471
- for (let i = 0; i < Math.min(emitterDesc.lifetime.Max * 2 * FLAGS.PARTICLES_START_FULL_FRAMERATE, FLAGS.PARTICLES_START_FULL * FLAGS.PARTICLES_START_FULL_FRAMERATE); i++) {
51472
- emitterDesc.tick(1 / FLAGS.PARTICLES_START_FULL_FRAMERATE, this);
51576
+ }
51577
+ }
51578
+ const __vite_glob_0_22 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51579
+ __proto__: null,
51580
+ ScriptWrapper
51581
+ }, Symbol.toStringTag, { value: "Module" }));
51582
+ class ToolWrapper extends InstanceWrapper {
51583
+ static className = "Tool";
51584
+ static requiredProperties = [
51585
+ "Name",
51586
+ "Grip"
51587
+ ];
51588
+ setup() {
51589
+ if (!this.instance.HasProperty("Name")) this.instance.addProperty(new Property("Name", DataType.String), this.instance.className);
51590
+ if (!this.instance.HasProperty("Grip")) this.instance.addProperty(new Property("Grip", DataType.CFrame), new CFrame());
51591
+ }
51592
+ created() {
51593
+ this.instance.AncestryChanged.Connect(() => {
51594
+ this.createWeld();
51595
+ });
51596
+ }
51597
+ //doing this is actually inaccurate because tools dont create welds, but its easier
51598
+ createWeld() {
51599
+ const handle = this.instance.FindFirstChild("Handle");
51600
+ const rig = this.instance.parent;
51601
+ const grip = this.instance.PropOrDefault("Grip", new CFrame()).clone();
51602
+ if (handle) {
51603
+ const oldToolWeld = handle.FindFirstChild("ToolWeld_GripRoAvatar");
51604
+ if (oldToolWeld) {
51605
+ oldToolWeld.Destroy();
51606
+ }
51607
+ }
51608
+ const humanoid = rig?.FindFirstChildOfClass("Humanoid");
51609
+ if (handle && rig && rig.className === "Model" && humanoid) {
51610
+ const rightHand = rig.FindFirstChild("RightHand") || rig.FindFirstChild("Right Arm");
51611
+ if (rightHand) {
51612
+ for (const child of rightHand.GetDescendants()) {
51613
+ if (child.Prop("Name") === "RightGripAttachment") {
51614
+ const rightGripAttCF = child.PropOrDefault("CFrame", new CFrame()).clone();
51615
+ if (humanoid.Prop("RigType") === HumanoidRigType.R6) {
51616
+ rightGripAttCF.Orientation[0] -= 90;
51617
+ }
51618
+ const weld = new Instance("Weld");
51619
+ weld.addProperty(new Property("Name", DataType.String), "ToolWeld_GripRoAvatar");
51620
+ weld.addProperty(new Property("Archivable", DataType.Bool), true);
51621
+ weld.addProperty(new Property("C0", DataType.CFrame), rightGripAttCF);
51622
+ weld.addProperty(new Property("C1", DataType.CFrame), grip);
51623
+ weld.addProperty(new Property("Part0", DataType.Referent), child.parent);
51624
+ weld.addProperty(new Property("Part1", DataType.Referent), handle);
51625
+ weld.addProperty(new Property("Active", DataType.Bool), true);
51626
+ weld.addProperty(new Property("Enabled", DataType.Bool), false);
51627
+ weld.setParent(handle);
51628
+ weld.setProperty("Enabled", true);
51629
+ }
51473
51630
  }
51474
- emitterDesc.updateResult(this.renderScene);
51475
51631
  }
51476
51632
  }
51633
+ }
51634
+ }
51635
+ const __vite_glob_0_24 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51636
+ __proto__: null,
51637
+ ToolWrapper
51638
+ }, Symbol.toStringTag, { value: "Module" }));
51639
+ class WedgePartWrapper extends BasePartWrapper {
51640
+ static className = "WedgePart";
51641
+ }
51642
+ const __vite_glob_0_25 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51643
+ __proto__: null,
51644
+ WedgePartWrapper
51645
+ }, Symbol.toStringTag, { value: "Module" }));
51646
+ class WeldWrapper extends JointInstanceWrapper {
51647
+ static className = "Weld";
51648
+ }
51649
+ const __vite_glob_0_26 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51650
+ __proto__: null,
51651
+ WeldWrapper
51652
+ }, Symbol.toStringTag, { value: "Module" }));
51653
+ 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/Bone.ts": __vite_glob_0_8, "./instance/Constraint.ts": __vite_glob_0_9, "./instance/Decal.ts": __vite_glob_0_10, "./instance/FaceControls.ts": __vite_glob_0_11, "./instance/HumanoidDescription.ts": __vite_glob_0_12, "./instance/InstanceWrapper.ts": __vite_glob_0_13, "./instance/JointInstance.ts": __vite_glob_0_14, "./instance/MakeupDescription.ts": __vite_glob_0_15, "./instance/ManualWeld.ts": __vite_glob_0_16, "./instance/MeshPart.ts": __vite_glob_0_17, "./instance/Model.ts": __vite_glob_0_18, "./instance/Motor6D.ts": __vite_glob_0_19, "./instance/Part.ts": __vite_glob_0_20, "./instance/ParticleEmitter.ts": __vite_glob_0_21, "./instance/Script.ts": __vite_glob_0_22, "./instance/Sound.ts": __vite_glob_0_23, "./instance/Tool.ts": __vite_glob_0_24, "./instance/WedgePart.ts": __vite_glob_0_25, "./instance/Weld.ts": __vite_glob_0_26 });
51654
+ function RegisterWrappers() {
51655
+ for (const module of Object.values(modules$1)) {
51656
+ for (const exprt of Object.values(module)) {
51657
+ let prototype = Object.getPrototypeOf(exprt);
51658
+ while (prototype) {
51659
+ if (prototype === InstanceWrapper) {
51660
+ exprt.register();
51661
+ break;
51662
+ }
51663
+ prototype = Object.getPrototypeOf(prototype);
51664
+ }
51665
+ }
51666
+ }
51667
+ }
51668
+ const attachmentGeometry = new SphereGeometry(0.125, 16, 8);
51669
+ class AttachmentDesc extends RenderDesc {
51670
+ static classTypes = ["Attachment"];
51671
+ visible = false;
51672
+ cframe = new CFrame();
51673
+ isSame(other) {
51674
+ return this.visible === other.visible && this.cframe.isSame(other.cframe);
51675
+ }
51676
+ needsRegeneration(other) {
51677
+ return this.visible !== other.visible;
51678
+ }
51679
+ virtualFromRenderDesc(other) {
51680
+ this.cframe = other.cframe.clone();
51681
+ }
51682
+ fromInstance(child) {
51683
+ const attachmentW = new AttachmentWrapper(child);
51684
+ this.cframe = attachmentW.getWorldCFrame();
51685
+ this.visible = child.PropOrDefault("Visible", this.visible) || FLAGS.ALWAYS_SHOW_ATTACHMENTS;
51686
+ }
51687
+ async compileResults() {
51688
+ this.results = [];
51689
+ if (this.visible) {
51690
+ const mesh = new Mesh(attachmentGeometry, new MeshLambertMaterial({ color: 65280 }));
51691
+ mesh.name = this.instance ? this.instance.PropOrDefault("Name", "Unknown") + "_Att" : "Unknown_Att";
51692
+ this.results.push(mesh);
51693
+ }
51694
+ this.updateResults();
51477
51695
  return this.results;
51478
51696
  }
51479
51697
  updateResults() {
51480
- const dt = specialClamp(this.time - this.lastTime, 0, 1 / 10) * FLAGS.RENDERER_DELTA_TIME_MULTIPLIER;
51481
- this.lastTime = this.time;
51482
- for (const emitterDesc of this.emitterDescs) {
51483
- emitterDesc.tick(dt, this);
51484
- emitterDesc.updateResult(this.renderScene);
51698
+ if (!this.results) return;
51699
+ for (const attachment of this.results) {
51700
+ const resultCF = this.cframe;
51701
+ setTHREEObjectCF(attachment, resultCF);
51702
+ }
51703
+ }
51704
+ dispose(_renderer, scene) {
51705
+ if (!this.results) return;
51706
+ for (const result of this.results) {
51707
+ scene.remove(result);
51485
51708
  }
51486
- this.lastCframe = this.cframe.clone();
51487
51709
  }
51488
51710
  }
51489
- const __vite_glob_0_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51711
+ const __vite_glob_0_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51490
51712
  __proto__: null,
51491
- EmitterGroupDesc
51713
+ AttachmentDesc
51492
51714
  }, Symbol.toStringTag, { value: "Module" }));
51493
51715
  function disposeLight(scene, light) {
51494
51716
  if (light.shadow && light.shadow.map) {
@@ -52337,6 +52559,14 @@ class RBXRenderer {
52337
52559
  RBXRenderer.removeInstance(child, renderScene);
52338
52560
  }
52339
52561
  }
52562
+ static getRenderDescs(instance) {
52563
+ const renderDescs = [];
52564
+ for (const renderScene of RBXRenderer.scenes) {
52565
+ const renderDesc = renderScene.renderDescs.get(instance);
52566
+ if (renderDesc) renderDescs.push(renderDesc);
52567
+ }
52568
+ return renderDescs;
52569
+ }
52340
52570
  static _addRenderDesc(instance, auth, DescClass, renderScene) {
52341
52571
  if (!RBXRenderer.renderer) return;
52342
52572
  const oldDesc = renderScene.renderDescs.get(instance);