diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..398605c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [master] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: yarn + + - run: yarn install --frozen-lockfile + + - run: yarn build + + - uses: actions/configure-pages@v5 + + - uses: actions/upload-pages-artifact@v3 + with: + path: docs + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/deploy-pages@v4 + id: deployment diff --git a/.gitignore b/.gitignore index 98599df..251ce6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,23 @@ -*node_modules \ No newline at end of file +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/README.md b/README.md index 680bae4..b476303 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# Varun Nadgir \ No newline at end of file +# Varun Nadgir Portfolio Website + +Interactive solar system simulation made with Vite and React-three-fiber diff --git a/blog/12notematrix.html b/blog/12notematrix.html deleted file mode 100644 index a67c90f..0000000 --- a/blog/12notematrix.html +++ /dev/null @@ -1,82 +0,0 @@ - - - -
- - -In general, composed music follows certain tonal rules that guide the composer when writing chord - progressions, melody lines, and entire harmonies. The word "tonal" usually implies some notes are more prominent - than others, such as the root (I) or the dominant (V). However, in atonal music, no note is used more often than - another, meaning there is no root. This 12x12 atonal matrix gives us a way to write music so that this - rule can be followed.
-First, the composer has to select the "initial row": a 12-note sequence that uses each of the 12 notes in - Western music only once. Second, the inverse of this row is placed in the first column. To find the inverse, - first we assign numerical values to the notes in our initial row. That is, the root is called 0, one half step - up is 1, another half step is 2, and so on until 11. The value placed in the inverse column will simply be (12 - - initial row). Third, all other cells are filled in by adding up the top-most row value with the left-most column - value. Remember that this is mod12, so any sum larger than 12 is replaced with the proper value. Now that a - number value has been put into every cell of this matrix, we can convert it back to notes to make it more - readible. This completed matrix is what we can now use to write an atonal piece.
-Rules: -
Because of the way we generated the matrix, these rules ensure that no note gets used more than another, - meaning no note can be considered the root. For more information, as well as a sound clip and images, check out - The Carolingian Realm. -
If you would like to change the 12-note matrix, click here to open the document and change it directly. You must change the original row
- to your own 12-tone sequence (using each note only once), and then change the Legend to reflect the new
- numerical assignments. Then the final matrix will change on its own. Once you've done that, well... that's the
- easy part. The hard part is actually writing something that sounds good!
In this blog series, I'd like to walk you through the development of my UE5 puzzle game prototype. Using - Blueprints and some assets from the Epic Games Marketplace, I took a simple idea and turned it into a - fully functional color puzzle. I'll give a high level overview of the structure and logic of the puzzle, as well as - provide videos of the progress made during each iteration. At the end, I'll share my full walkthrough video so you - can see all of the node graphs in full detail if you are intersted. Hope you enjoy!
- - i. Introduction
-
- The rules of the game are simple: set the individual R, G, and B color channels so that they mix into the target - color (chosen randomly). If the player's color is close enough (based on a tolerance we can set), the player - succeeds.
- -By keeping the basic rules and win condition of this puzzle brief and straightforward, I wanted to use this project - as an opportunity to get hands-on with a variety of tools and features in Unreal Engine 5. Being somewhat new to - the engine, but otherwise comfortable with graphics, I wanted to see how multiple Actors can communicate. - Additionally, I hoped to create a visually pleasing shader/material to complement the puzzle scenario.
- -Using Unreal Engine 5.3.2, I began with the basic third-person template with Quinn as my ThirdPersonCharacter. I - created a new empty level and set up a few Input Actions: Z (Crank Down), X (Crank Up), and E - (Interact). For now, I am using the default world lighting that Unreal provides and have given myself a large plane - to stand on, which means I have an empty level that I can run around in as Quinn.
- -To reach the image above, we'll take this in stages. Let's first get the basic game logic working!
-There are a few things our puzzle needs to do at minimum. We need to generate a random color when the level - starts, we need to let the player control the three independent color channels, and we need to be checking if the - combination of those color channels matches the random color we generated. Using Unreal's GameState Actor, we can - achieve a lot of this!
- -I first created a Blueprint for an Actor called ColorPicker. This would be a generic Actor that holds a valve that - can be spun by the player. As the parent Actor, it carries only rotation logic; but if we create three instances of - it, then allow them to independently control three different GameState variables, we can keep our node graphs clean. - Below is a clip of the generic ColorPicker responding to the Player when they are within the interaction range.
- - - -Next we have to set the GameState up with the variables we want to track. To keep it brief, we need to track six - float values that are between 0.0 and 1.0. Three of them are static and determine the color the Player must create, - and three of them are initialized to an abritrary value. By hooking up the Z and X keys to the independent - ColorPickers, we can allow the Player to control those three values. In the clip below, notice the details pane and - how the values are changing in accordance with the Player's input.
- - - -Next, let's actually use these GameState values to affect the scene! By creating a base material that defines - a fluid aesthetic, we can then create Dynamic Material Instances so that the same liquid effect can be given - different base colors.
- -Just like the Blueprints, I give a full breakdown of my final material effect in my walkthrough video, so I - encourage you to check that out if interested. Essentially, I played around with various combinations of noise - patterns to create an effect that looked like a liquid and wanted it to be interesting enough to work during - this testing phase. By using Event Dispatchers, I was able to use the ColorPickers to inform the separate material - instances to update their base color, which I had exposed as a Vector Parameter. Below you can see a clip of my - three ColorPickers being used to update the colors of several materials.
- - - -After getting this communication in place, I was able to take some time to play with some different arrangements - and meshes. Ultimately, I decided I wanted to have three falling streams of liquid mixing into a single pool. Below - is a clip that shows the basic idea I am going for.
- - - -Now comes one of the super fun parts of the project - developing the shader!
- -After a couple of iterations, I stumbled on a visual style that stuck out to me. The clip below shows an early - stage of the style I would proceed with.
- - - -Not only do we want the shader to mimic a fluid somewhat, we also want to sell the illusion of there being one - continuous body of liquid. Here, I chose to add some color lerping near the bottoms of the falling streams, making - the transition between meshes appear smoother. I also went with a world position offset effect to make the - liquid appear as if it were bubbling, which added some activity to the liquid so it didn't appear flat. On top of - that, I wanted to provide additional feedback in the form of a UI progress bar. This would give the player an even - better idea of how close they were getting to the right answer. The below clips include a percentage in the bar, - which I ultimately did not keep in the final.
- - - - -With the shader effect coming together, I started to brainstorm a scene and environment that would complement it. - The first that came to mind was an alchemist's lab or a sewer. Thanks to the rotating free assets in the Epic Games - Marketplace, I was fortunate to have some set pieces and prefabs that fit this idea ready to use. I also found some - free SFX for things like the sound of steam releasing or ambient water drops. With all of these elements, the level - really started coming alive. See the clip below for the first demo in the new environment.
- - - -In addition to some background props to help set the scene, I have also updated the ColorPickers to appear as pipes - so that they are more convincing. Although I continued to tweak and adjust things past this point, it is safe to say - we have achieved our original goals! Having connected all of these parts together in my first prototype, I am very - happy with the progress I've made. In the next and final post, I'll do an overview of the project architecture, talk - about some of the final tweaks I made, and share my final walkthrough video with you so you can see it all in - detail. Thanks for reading!
- -To visualize the communication of parts, here is a sequence diagram of the running game loop. The classes in this - diagram are the Blueprints, and the processes being run are functions or events found within them. Click to enlarge - the diagram.
- -
-
- The diagram only contains the actions and events that are crucial to the game loop and resolution of the win - condition; to see everything in detail, please watch the full walkthrough video. In it, I describe the project - in its entirety and walk through every node graph.
- - - -Thanks for reading to the end! This project was a blast to work on, since it let me use a bunch of different parts - of Unreal Engine that I hadn't explored before. Having set up character input, dynamic materials, and cross-actor - communication in this project, I'm excited to play around in game engines and DCC software further. For now, I - appreciate you following along and I hope you enjoyed!
- -About Me
- An introduction to who I am and what I do
-
UE5 Color Puzzle
- How to create a puzzle game using UE5 Blueprints
-
Hexagonal Tiling with Unreal Engine
- How to make a procedural hex grid using UE5 and C++
-
Making Art with Processing
- Learning how to make art with Java
-
Roadtrip2020
- A writeup of my incredible cross country trip
-
LoL Item Masher
- Now outdated, this was a fun app to make during a hackathon
- (opens in new tab)
-
Atonal Matrix
- How to create atonal music using the 12-tone matrix
-
Short Story
- An undergrad assignment I'm proud of
- Warning: Explicit language
-
Processing is an incredible application, allowing users to create amazing visuals in both 2D and 3D with just some - knowledge of Java. In this blog series, I will be documenting my learning journey, both to "think aloud" as - well as to share the cool things I make. If you'd like to follow along and learn with me, go ahead and download Processing on your machine.
- i. Introduction



Before I begin, let me also shout out two amazing resources I've been using to learn. It's always good to read the - docs - and Processing has pretty high quality ones - but this journey has been made so much more fun thanks to Daniel Shiffman and his channel The Coding Train. You'll see his name on a lot - of the Processing docs, and he has put an insane amount of effort into making hundreds of videos to teach you the - fundamentals of Processing and even programming in general. In particular, I watched almost the entirety of his Coding - Challenges playlist, and I still refer back to a handful of them when trying to brainstorm new creations.
- -The other creator I must thank is thedotisblack. On his channel, you can dive right into some incredibly cool animations and see - how he makes them. I've picked up a few neat tricks from what he's shared and I'm sure I will be inspired by him - again. Sometimes when I am stumped, I'll just browse through his videos to remind myself of the kinds of things I - hope to create and hop right back in!
- -Since I am still pretty early in my journey, there are bound to be other resources and creators I find along the - way. If you - come across any art or artist you'd like to share with me, feel free to send me a message or email!
- -Now... let's get to it!
-When creating animations with Processing, there are two core functions that need to be invoked - setup() - and - draw(). In the setup() function, we can do things like set the canvas dimensions, assign values to - global variables, - instantiate objects for later manipulation, and any other steps that need to happen on or before the first frame. - Then, - in draw(), we can apply transformations, scaling, variable recalculation, and lots more to bring the canvas - to life. - Each unit of time in our case here is a single frame, or one whole execution of the draw() function. -
- -
-// setup function
-void setup() {
- size(600, 600);
- background(0);
- ellipse(width/2, height/2, 100, 100);
-}
-
-// render function
-void draw() {
- // what do we want to make happen?
-}
-
- In this example, we're setting our canvas to 600px by 600px and giving it a black background. Although the default - color mode is RGB and usually requires 3 values, we can shorthand black and white with 0 and 255 respectively. When - creating the ellipse, you'll notice I used variables called width and height without ever creating or - assigning them. That's because Processing holds on to a number of system variables as well - width and - height being the dimensions of the canvas itself. By setting the center of the ellipse to half the width and - height of the canvas, we ensure it will be centered in our view even if we were to set the dimensions to something - other than (600, 600). -
- -
We've drawn our first shape to the canvas! Now to make it do something interesting. Why not make it slide to the - right and then wrap back around to the left side for a simple and satisfying loop? Here's how we might achieve that. -
- -
-int x, y;
-int speed = 5;
-
-// setup function
-void setup() {
- size(600, 600);
- background(0);
- x = width/2;
- y = height/2;
-}
-
-// render function
-void draw() {
- ellipse(x, y, 100, 100);
- x += speed;
- if (x >= width) {
- x = 0;
- }
-}
-
- Now, we initialize some variables globally, since we would like to change them later on within the draw() - scope. The variables x and y are set to half the width and height so that we can simplify our - formulas, while speed is set to an arbitrary value of 5. We can play with this one to adjust how quickly the - circle will slide.
- -This time around, we create our ellipse within draw() because we want to be able to change where we place it - and draw its new location each frame. We also add a check for when x goes beyond the width of the canvas, - setting it back to 0 which would send it back to the left side. Everything seems about right, so then how does it - look?
- -
Wait a second... ah, that's right. Currently, when we draw new frames, they are being overlaid on each other and - creating this trailing effect. It looks cool, but wasn't quite what we wanted. Luckily, this is an easy fix.
- -
-int x, y;
-int speed = 5;
-
-// setup function
-void setup() {
- size(600, 600);
- background(0);
- x = width/2;
- y = height/2;
-}
-
-// render function
-void draw() {
- background(0);
- ellipse(x, y, 100, 100);
- x += speed;
- if (x >= width) {
- x = 0;
- }
-}
-
- All that is needed here is a background(0) in the render loop. Now, before new circles are drawn, the entire - canvas will be set to a black background again. This should now give us the desired effect.
- -
Excellent!
- -As we'll see in later entries, both methods can be utilised depending on the context and type of effect we are - going for. Next time, we'll look at the map() function for rescaling values as well as the random() - function for some of its clever uses. Thanks for reading and see you in the next one!
-Now that we have a basic grasp of the two core functions and getting a shape on screen, why not try to make - something truly generative? One of the first examples I learned was to create a raining effect, so let's go through - that together. Let's first try and get a basic shape to fall from the top of the screen to the bottom, and then - extend that logic.
- -
-float x, y; // starting position of the shape
-float len = 10; // length of the shape
-float speed = 5; // fall speed
-
-void setup() {
- size(600, 480);
- x = width/2;
- y = 0;
-}
-
-void draw() {
- background(200);
- strokeWeight(4);
- stroke(0, 0, 200);
- line(x, y, x, y+len);
- y += speed;
-}
-
-
This gives us a line segment drawn in the center of the screen with weight 4, and it falls at a rate of 5 pixels - per frame. If we want to extend this to mimic falling rain, then we can use this basic behavior in the form of a - Drop class. To do this in Processing, we just create a new tab and name it Drop. Instead of creating global - variables in our main file, we can instead have these be inherent properties of a Drop. At time of creation, we can - assign a Drop a new starting height, fall speed, stroke weight, or really anything we want.
- -
-class Drop {
- float x = random(width); // random horizontal position
- float y = random(-500, -100); // random height, can be offscreen
- float z = random(0, 20); // create sense of depth
- float len = map(z, 0, 20, 10, 20); // length of Drop
- float yspeed = map(z, 0, 20, 4, 10); // speed of Drop
-
- // fall & reset method
- void fall() {
- y = y + yspeed;
-
- if (y > height) {
- y = random(-200, -100);
- yspeed = map(z, 0, 20, 4, 10);
- }
- }
-
- // display method
- void show() {
- float thick = map(z, 0, 20, 1, 3);
- strokeWeight(thick);
- stroke(0, 0, 200);
- line(x, y, x, y+len);
- }
-}
-
- Two functions are doing a lot of the heavy lifting in here - random() and map(). The random() - function gives us a number in the given range of two arguments, or a number from 0 to the given single argument. It - is being used in this class for multiple purposes, such as giving the Drop a random starting position, both - horizontally and vertically. These values are such that a new Drop may start well offscreen before passing through - the visible canvas. The value of z here lets us do some neat tricks to create a sense of depth despite - rendering in 2D, with the use of the map() function. To use this function, we tell it a value, its original - range, and then the new range to which to scale it. This means we can take the value of z and use it to - inform multiple features of the Drop, like its stroke weight and fall speed, allowing us to give each Drop a - separated, staggered animation for falling.
- -Now that we've defined the class and its methods, we can go back to our main script to initialize, draw, and update - a large number of Drops. Since most of our behavior and logic is stored in the Drop class, we should have pretty - simple setup() and draw() functions.
- -
-// initialize array of 500 Drop objects
-Drop[] drops = new Drop[500];
-
-// setup function
-void setup() {
- size(600, 480);
-
- // loop through and create a new Drop for every index
- for (int i = 0; i < drops.length; i++) {
- drops[i] = new Drop();
- }
-}
-
-// render function
-void draw() {
- background(200);
-
- // each frame, show and update the new location
- for (int i = 0; i < drops.length; i++) {
- drops[i].show();
- drops[i].fall();
- }
-}
-
-
If you were to run this in Processing, it would appear to rain endlessly. Unfortunately, having to export to gif - means I have to use a limited number of frames. In fact, this may even motivate a shift over to p5.js at some point, - the Javascript library built to support a lot of the same functionality as Processing. However, before moving on, - there are still more fundamentals to Processing to discuss!
- -Now that we've built and utilized a Class, we can certainly imagine how dynamic some of our creations can be. Just - like random() and map(), there are lots of functions available to us that are simple in concept, yet - lead to awesome results. Next time, we'll take a look at involving a morphing color palette. Additionally, we'll - even try to solve the problem of having limited frames for gif uploads - is there a way we can ensure a smooth loop - in a limited frame count?
- -Thanks for reading and see you next time!
- -Technically, we've already achived a smooth loop in one of our first examples - the white circle moving right then - reseting to the left. Let's take a quick look at it again to see how it was achieved.
- -
Remember when I told you that Processing provides us with a number of system variables? It's time I introduce the - frameCount variable, a counter that is incremented by Processing for us on every render cycle of the - draw() function. In the case of the moving circle, I knew I would achieve a loop at 120 frames, based on the - width of the canvas and the travel speed (x displacement). By having Processing export a .png image every frame, I - can hard stop the program after 120 images, and then use some other method of stitching them together into a gif (I - use ezgif.com). -
- -The uses of frameCount don't stop there - it can even be leveraged for some great artistic generations using - colors. You may have once seen colors expressed in a color wheel, showing how various hues can blend into each other - seamlessly and eventually loop back to the start. If we can somehow make use of this seamless transitioning, then we - should be able to have our colors loop as well.
- -
-// setup function
-void setup() {
- size(600, 600);
- colorMode(HSB); // hue, saturation, brightness
-}
-
-// render function
-void draw() {
- background(0);
- float shift = map(frameCount%60, 0, 60, 0, 255);
-
- for (int r = 900; r > 0; r -= 20) {
- strokeWeight(4);
- stroke((r+shift)%255, 255, 255);
- noFill();
- ellipse(width/2, height/2, r, r);
- }
-
- // uncomment to export
- // saveFrame("output/gif-"+nf(frameCount, 3)+".png");
-
- // if (frameCount == 60) {
- // exit();
- // }
-}
-
-
Couple of things to note - the default color mode in Processing is RGB, where the color is based on values of red, - green, and blue. By using color mode HSB, we instead need to provide a hue, saturation, and brightness. In this - mode, going from 0 to 255 lets us traverse the "color wheel", meaning it can neatly loop. The other clever trick - being used is the modulo operator in combination with the map() function. With this, we are telling - Processing that we want to divide the current frameCount by 60, and use this remainder to inform what color - to use. This means, every 60 frames, we should traverse the color wheel one time. To export, we would just - un-comment the lines at the bottom and our images would save in an /output folder of our sketch.
- -All in all, the output is pretty mesmerizing! Since our loop has the radius of each concentric circle decreasing by - 20, what would happen if we create a new set of circles offset from these and have the colors of those propogate - outwards instead of inwards? Something like this:
- -
-// setup function
-void setup() {
- size(600, 600);
- colorMode(HSB);
-}
-
-// render function
-void draw() {
- background(0);
- float shift = map(frameCount%60, 0, 60, 0, 255);
-
- for (int r = 900; r > 0; r -= 20) {
- strokeWeight(4);
- stroke((r+shift)%255, 255, 255);
- noFill();
- ellipse(width/2, height/2, r, r);
- }
-
- for (int r = 10; r < 900; r += 20) {
- strokeWeight(4);
- stroke((r+255-shift)%255, 255, 255);
- noFill();
- ellipse(width/2, height/2, r, r);
- }
-
- // uncomment to export
- // saveFrame("output/gif-"+nf(frameCount, 3)+".png");
-
- // if (frameCount == 60) {
- // exit();
- // }
-}
-
-
Now that is cool! And all just in 60 frames!
- -I am still currently going through some videos of my own, so no concrete plans yet on the subject of the next - entry. At the moment, I am playing around with map generation, noise algorithms, and cellular automata, but with - such a vast number of ideas and topics to play with, it's hard to pick just a few! But as always, thank you for - reading and I'll see you in the next one.
- -I've been playing around with 3D more recently, and now that I've made something cool enough to share, I thought it - would be nice to show you how it works in code and I will do my best to walk you through how to make something like - this on your own! - One change you might notice immediately in the code below is the addition of a new argument in the size() - function - this is - how we tell Processing to use a 3D renderer, in this case P3D.
- -
-// setup function
-void setup() {
- size(800, 800, P3D); // use 3D renderer
- colorMode(HSB); // hue, saturation, brightness
-}
-
-// render function
-void draw() {
- background(0);
- translate(width/2, height/2); // translate origin to center
-
- rotateX(radians(60)); // comment this line out for 2D top view
-
- noFill();
- strokeWeight(3);
-
- for (int i = 0; i < 55; i++) {
- // define line color using frame count and circle position
- float strokeCol = map(sin(radians(frameCount + i * 10)), -1, 1, 0, 255);
- stroke(strokeCol, 255, 255);
-
- // beginShape & endShape for custom shapes
- beginShape();
- for (int j = 0; j < 360; j += 5) {
- int rad = i * 5;
- float x = rad * cos(radians(j));
- float y = rad * sin(radians(j));
- float z = sin(radians(frameCount + i * 10)) * 200;
- vertex(x, y, z);
- }
- endShape(CLOSE);
- }
-}
-
- Here is what this sketch will look like if we comment out the rotateX() function, meaning our sketch is - still functionally 2D like the others. This is basically our "top view".
- -
First, you can probably notice a similar pattern to a previous post where I use the global variable - frameCount to inform my sketch on what to color something. By also using the loop variable i, it can - also be offset by the position of the shape itself. Next, instead of calling ellipse() like I have before, I - am instead using beginShape() and endShape(), a pair of functions that can be used to define a custom - shape with calls to vertex() between them. In this example, I am using the loop variable j to - increment around the radius and place a vertex at a number of equally spaced points. The CLOSE argument - simply tells Processing to close off the shape by connecting the final vertex with the first one. A smaller - increment means more vertices, meaning our shape is closer to resembling a circle. I encourage you to try this with - larger increments, or even dynamic increments to see what sort of shapes and patterns you might get! -
- -Now let's have our big reveal. By applying rotateX() (and remember, we have to supply our angle in radians), - we tell our renderer to perform the necessary transformations for the illusion of depth. Now our Z axis comes fully - into view.
- -
Another satisfying and smooth loop! Thanks to the oscillatory nature of the sine function, we are able to capture - the entirety of one phase, export our frames, and stitch it together into a nice gif!
- -Entries here are currently on hold as I pursue a few other projects. In fact, I recommend checking out the rest of my blog or portfolio for other WIP or completed demos!
-Day 1: September 26, 2020 (Philadelphia PA)
-Day 2: September 27, 2020 (Cave City KY)
-Day 3: September 28, 2020 (Memphis TN, Hot Springs AK)
-Day 4: September 29, 2020 (Hot Springs AK)
-Day 5: September 30, 2020 (Dallas TX, Carlsbad NM)
-Day 6: October 1, 2020 (Lincoln National Forest, White - Sands National Park, Albuquerque NM)
-Day 7: October 2, 2020 (Painted Desert / Petrified Forest - National Park)
-Day 8: October 3, 2020 (Moab UT, Canyonlands National Park - / Island in the Sky)
-Day 9: October 4, 2020 (Salt Lake City UT, Reno NV)
-Day 10: October 5, 2020 (Lake Tahoe CA, Oakland CA)
-Final: Final Thoughts
-And we're off! My travelmates came by to pick me up just after noon, and our first stop was... my parent's house! - Since our first major stop on the trip was Philly to see my brother, I couldn't possibly leave without - bringing him some of mom's homecooked food. After chatting and getting some last minute travel tips from my parents, - we left for real.
-It's a pretty normal drive, one I've done a number of times with my family already. In fact, the drive went even - more smoothly than I had expected. For some reason, I was under the impression the drive to Philly would be - around 6 hours, but in fact it's closer to 4.5. We just stopped once in New Haven, after which I took to the wheel - to bring us the rest of the way to my brother's new place.
- -
Upon reaching his apartment, I had to admit to the rest that I hadn't eaten yet. It must have been how late I - stayed up the night before and just my general sense of excitement, but yeah - it occurred to me shortly before - arriving that I was actually very hungry. Fortunately, my brother and I have made it a habit to get halal food - cart every time I visit, and this time was no exception. After picking up our dinner, we continued walking - around Philly to a spot called Cira Green. It's a nice little park on a roof with music, a large TV screen, - spots for picnicking, and a good view of the streets below.
- - -After eating, it was time to vibe out back at the apartment. The thing about hanging out with a brother you - don't get to see often - you don't even necessarily have to be doing anything in particular to enjoy the time - together. We had some drinks, talked about our plans for the rest of our trip / his semester, watched some bad - movies, and eventually slept after a fun night together.
- -
Our first big stretch of driving was going to be the next day...
-Not too many pictures taken today. After all, it was a long 11.5 hour drive to Cave City, KY - most of which I - spent in the back seat resting up for my turn. We drove through Columbus and Cincinnati, OH, where I eventually took - night shift and got us to the motel in Kentucky. Definitely not as homey as my brother's place. However, we had - officially passed through into Central Time!
- -
And honestly, that's about it. We called it a night as soon as we got there and prepared for a shorter, but still - significant, drive the next day. Unfortunately for our Mammoth Cave plans, we found out that a large storm would be - passing through the area. Not wanting to get stuck in the thunder, lightning, and poor driving conditions that would - accompany it, we chose to just push on ahead. Funnily enough, that same storm ended up passing through MA and - visited our friends and family back home.
- -In the morning, our complimentary breakfast consisted of a granola bar, an apple, a cinnamon cake, and a bottle of - water. Since the motel couldn't provide breakfast in their lobby, they were simply handing out lunchbags of assorted - breakfast things. Not particularly excited about the foodstuffs they included, we decided that there's no reason to - turn down free drinking water for a long trip, so we took our lunchbags and headed to get breakfast at a Cracker - Barrel nearby. -
- -
It was okay. The real highlight was seeing someone open carrying while paying for their breakfast. Wouldn't want - to be anywhere near that man's bacon, that's for sure.
-Now I know I cheated a little bit by including today's breakfast in yesterday's post, but that's just how - uneventful yesterday was. Today, we have pictures again! Following breakfast, we began on our 4.5 hour drive down to - Memphis, TN, a place known for Elvis, rock & roll, blues, and the lively Beale St.
- -
Ah right, we're in a pandemic. While disappointing that the streets weren't full of people and the sound of music, - it was a uniquely bizarre and special experience being one of just a handful of groups of people there. And lucky - for us, the sound of music wasn't missing for long.
- -In a little cutout next to King's Palace Cafe, there was a live band playing the blues to a small crowd of people - - socially distanced at separate tables, of course. What a find this was! It made me realize just how long it had - been since my last live show, which honestly I can't remember. It might have been Marc Rebillet at the Sinclair? I - dunno.
- -
Seriously, I can't tell you just how awesome it was, to be able to just relax with a beer and listen to some live - blues outdoors. On this unusually quiet street, there were still people trying to liven things up, and doing it as - safely as they could. After a beer and a few jams, we decided it was time to head back to the car to continue the - drive to Arkansas, making sure to tip the band as we left.
- -On our way back to the car, we also found a little music shop. I bought my first vinyl (Radiohead - OK Computer - OKNOTOK), and a couple of gifts for musician friends back home. It would be a couple of days before I realized, "Oh, - yeah, I should get a record player, huh?" We also made sure to say bye to Elvis before leaving.
- -
The drive to Hot Springs, AK would be another 3 hours from Memphis. It was evening/night shift, so my turn to - drive now. It was a fairly quiet drive for the majority of it, elevating to hauntingly quiet as we reached closer to - Hot Springs. For about 45 minutes off of the interstate, we just went down winding roads to get to our inn.
- -
Once we arrived at our room, we decided it would be a good idea to stay here for two nights. We had just spent two - very long days driving - why not stay and enjoy Hot Springs National Park and get a chance to sleep in for a night? - Once suggested, it was heartily agreed upon by everyone, and so we hopped in bed, excited to not have to drive the - next day.
- -Finally - rest day. Although, like any other day, we got into the car first thing in the morning, the key - difference today would be the short 10 minute drive to Hot Springs downtown. A nice, quiet town with a lot of - history, it was our first experience actually out and about in a new place. What a great idea to dodge the storm in - Kentucky - the weather here was beautiful.
- -
You can actually get drinking water straight from the hot springs that give the town its name. Full of minerals - and just under boiling temp, something about it was extremely satisfying. Locals and visitors alike gathered around - the literal watering hole to fill their jugs and cartons, and later on during our walk, we found another fountain - sourced from a cool water spring.
- -
At one time a popular vacation spot for American elite, Hot Springs AK is famous for its bathhouses. On Bathhouse - Row, you can find a number of old buildings, some of which retain their architecture but have been repurposed into - lodging or eateries, while a couple of others are still actively in business as bathhouses. Unfortunately for us, - they only provide their bath and massage services from Thursday to Sunday, and it was Wednesday. Unlucky, but it's - fine. This just means the massage after the trip will be that much better.
- -We went up a short but steep trail to the Hot Springs Mountain Tower, where we got a nice 360 view of the - surrounding area. Kind of reminded me of the view from Sugarloaf back in Sunderland MA. Funnily enough, there's - another Sugarloaf here in Hot Springs. See if you can spot the rollercoaster/theme park among the trees in the first - pic.
- -
On our way back down from the observation tower, we actually caught a glimpse of some of the spring water pouring - through cracks in the stones, creating a small pool. This was very nice, because of our incorrect initial assumption - that a place called Hot Springs would have large outdoor hot springs. A consolation prize.
- -After a great day of walking around town and some light hiking, we treated ourselves to some pizza and beer at the - Grateful Head. The rest of the night would be fairly low-key, taking extra time to make sure all of our stuff was - packed. The next day would be a significant bit of driving again - New Mexico to be the goal.
-After a full day to ourselves, free from driving, we hit the road again with a renewed vigor. Before the trip, we - had questions on how we would handle long stretches of driving, but after making it this far, we knew there was - nothing to worry about. Our first stop today was Dallas, about 4.5 hours from Hot Springs and a good spot to stop - for lunch. The hottest day yet, we finally hit 33 C (91 F) as we entered the Texas border.
- -
Our stop for lunch was a place called Pepe & Mito's, a local Tex-Mex restaurant that did not disappoint. I would - have taken a picture of my chimichanga, but I ate it too fast. We walked around for a little bit to take in the heat - and the fact that we had made it down to Texas and were nearing the meat of our trip. Back in 2011 or 12, I had done - the drive from MA to Fort Worth with another friend, so it was very cool how I could recognize some of the highways - and scenery.
- -The next leg of the trip was completely new for me, and it would be approximately 7 hours to Carlsbad, NM. This - drive was one of the best of the trip - fields of wind turbines as far as the eye can see, an orange sunset in the - distance, and barely any traffic. And the scenery was no less amazing once we hit nighttime, either, since all the - wind turbines in the distance turned into little red flashing lights. At one point, the entire horizon became a - dotted line of little warning lights blinking in sync with each other.
- -When we got off the main interstate, it was rather surprising that this new single lane highway still had a speed - limit of 75. Out here were fields of oil rigs and exhaust pipes that looked like massive candles, which could be - seen flickering from miles away since there were no streetlights. As we passed into New Mexico, our scenery did not - change at all. However, as we got closer to our destination, we passed through some small towns every so often. It - was at the edge of one of these small towns that we found our night's lodging - Karbani Inn.
- -
What appeared to be a metal box in the middle of nowhere, was the genius that was Karbani Inn. A bunch of metal - shipping containers repurposed with plumbing and electricity, it was honestly a very cozy accommodation. We spent - the night planning our stops for the next few days, while drinking beers under a clear night sky. It wasn't too long - before we were visited by a cute furry friend.
- -
Initially surprised that we would run into what appeared to be a very well-fed stray, we found out later it was - actually the owner's cat. Despite our offerings of chips, crackers, and pieces of fruit, he was focused on getting - into one of the trash bins. Meowing non-stop, he finally made it to the McDonald's bag in the trash, only to find - out it was empty. Perhaps too ashamed to accept our snacks after that, he left after a few more meows. Ultimately, - we decided we would drive through Lincoln National Forest to get to White Sands National Park the next day.
- -
After a tasty breakfast burrito from the food cart near the Inn, we set off.
-Happy October!
- -Despite waking up slightly late today, we still managed to make good time leaving Karbani Inn. We'd be driving - through some winding mountain paths today, so we made sure to use our daylight hours well. Our first stop would be - Cloudcroft, NM, a small village up in Lincoln National Forest where people like to ski and enjoy the mountain views. -
- -
Only 2.5 hours out of Carlsbad, the drive was beautiful. After driving through the flat terrain of Texas, it was - wonderful to be back up in higher elevation. Since we wanted to spend most of our day at White Sands, we didn't stop - to check out the town or the hiking spots around here, but we did go to one of the viewpoints up there. Sierra - Blanca Viewpoint up in Cloudcroft gives a great view over to Sierra Blanca's peak, which is about 30 miles away. -
- -
The drive back down the other side of Lincoln National Forest was a nice break for our little car, as it could be - heard struggling up some of the steep grades earlier. The views of the mountainside and beyond were marvelous - - while New England surely does have mountain views and hiking, the views down below are certainly not the same. - Rather than the trees and hills we have at home, the sights below were sand and desert. The ride from Cloudcroft - down to White Sands was just under an hour. Although we could see hints of the white sand as we approached the park - entrance, we didn't quite grasp the scale of it until we got into the park itself.
- -
Needless to say, this park was one of the first awe-inspiring visits of the trip thus far. Never had I seen - anything like this. The day was brutally hot, yet the white sand was cool to the touch. Visitors were sledding down - the dunes, families were having picnics, and the general atmosphere here was magical. Depending where you got out of - your car, the entire horizon would be white. And on a day like today, there was hardly a cloud in the sky. We spent - a good few hours in the picnic area, snacking on fruit and crackers and thinking about where we wanted to go next. -
- -It was at this time we had our first communication breakdown. When we started to realize that it would simply not - be possible to hit all of our planned spots in the remaining days of the trip, it became difficult deciding which - places to cut and which to keep. An awkward silence lingered over our group as we slowly finished our snacks, and we - eventually decided to put off the final decision until we reached Albuquerque. A decent midpoint between our - remaining route options, Albuquerque was a reasonable place to stop for the night.
- -The drive to Albuquerque was about 4 hours from White Sands, and fortunately for us, it was a full harvest moon - tonight. Not only did we get a beautiful sunset, but shortly after, we got to witness the cresting of the moon along - the mountain range on the horizon. It was enormous, and I only wish we were able to get a picture of it. Thankfully, - this sight did raise our spirits a bit from earlier. After getting dinner at Cheba Hut Toasted Subs in Albuquerque, - we called it for the night and decided to plan our day in the morning.
- -After some discussion in the morning, we eventually decided that the Petrified Forest was a stop we could not - miss, although we would still have to skip the Grand Canyon and Zion National Park. Unfortunate, but it would was a - necessary sacrifice to make good time on the rest of the trip. From Albuquerque, the trip would be about 3.5 hours - along the historic Route 66, now I-40. The Petrified Forest is actually found within a larger landmark known as the - Painted Desert. Aptly named, the layers of sand and stone had shades of blue/lavender, red/orange, grey, and likely - more at other strata. Honestly, it's hard to put into words the beauty and wonder of this place, so I'll just let - the pictures speak for themselves. Enjoy.
- -
I wish I had more to say about the Painted Desert / Petrified Forest, other than to go there if you ever have the - chance. Despite the number of hours we spent there, there was still more we could have seen, but unfortunately we - had to prepare to leave since the park was preparing to close soon. At the picnic area near the exit, we took some - time to make noodles on our portable propane stove - it was quite the janky setup. But there's something special - about the taste of roadside noodles made in a rush.
- -Our next stop was Canyonlands in Utah, so we started our approximately 4 hour drive. This night gave us a bit of a - scare, since we were struggling to find lodging. Every place we called was completely booked and meant that we would - have to continue driving into the night. Finally, in Blanding, UT, we were able to secure the final two rooms at the - Four Corners Inn. Up until now, I could safely that the Petrified Forest was my favourite stop of the trip. It - wouldn't be long for something to rival it, though, since tomorrow we would be seeing Canyonlands.
-Good morning, Utah! To be completely honest, I had no idea what was in store for the day. Of course, I've looked - at pictures of popular parks and landscapes around the United States, but they had always existed as isolated spots - in my brain. It wasn't until this trip that I actually understood the scale and how they connected. Utah is - humongous, and everywhere you look there are mountains, whether near or in the distance. In our excitement to - explore the Canyonlands, we didn't realize right away that our GPS target wasn't quite where we wanted to go (we - just put in "Canyonlands" and went where it took us lol). No doubt, it was spectacular. Our altitude dropped - significantly as we drove through these cliffs, but this was primarily a hiking and climbing area for people with - serious gear. We drove around the south end of the park for a couple hours before circling back.
- -
On the way to Moab, we saw signs for Wilson Arch, a sandstone structure named after Joe Wilson, a pioneer who - lived nearby. It was impossible to miss, and we decided it would be a fun stop to walk around and hike for a little - bit.
- -
There were a lot of families enjoying the simpler approaches, meanwhile other daredevils were belaying each other - down from the top of the arch. We hiked up to the base of the arch and enjoyed the shade and the company of someone - else's dog, looking out at the view. It was really cool how this was right along the highway, no official entrance, - no line to get in, just nature. After spending about an hour up here, we continued on to Moab.
- -Moab is a neat little town. In some ways, it reminded me a little bit of Northampton, MA. We stopped for food in - town and to top up on some supplies, and also got some extra food to-go for dinner since we were still considering - camping somewhere potentially. On the way to Island in the Sky, we also drove up to Arches National Park. However, - once we saw the approach from down below, we decided it was not something the car would be able to handle. I think - maybe we could have done it, but it will remain one of the trip's unanswered questions.
- -
Hello from Island in the Sky. There aren't many selfies from this trip, so I hope you extra enjoy this one. The - entire park exists on a large plateau from which you can view all of the surrounding area. Once you go through the - park entrance, there are just miles of cliffside road. Serpentining through these roads was an exhilerating - experience, as a lot of the curves had no guardrails. You simply had to control your vehicle's speed and turn - carefully. Every so often, there were viewpoints to stop at, which we did. I even got to climb a few rocks for - better views.
- -
After taking in the whole park, we reminded ourselves that we still needed to look into the possibility of camping - somewhere, if that was still our plan. To no one's surprise, all of the camping spots within the park had been - reserved. While there are some free campgrounds along highways, they are also first come first serve, meaning they - are generally packed if you aren't there well before sundown. Our plan to camp would not pan out, so we chose to - drive onward to Provo, UT - just south of Salt Lake City. On the way, we decided if we couldn't camp, we could at - least have dinner outside as the sun set. And where better to do that than on the side of a single lane highway? -
- -
After a quick meal, we drove on. Tomorrow, we'd be checking out the Salt Lake itself before taking on a huge drive - over to Reno, NV. The end of the trip was closing in fast.
- -Before embarking on the long journey to Reno, we stopped at Penny Ann's Cafe for a hearty breakfast, and even had - to pack our remaining pancakes to go. Afterwards, we went to the Great Salt Lake itself to check out the marina and - the beach. Looking at reviews of the place, there was a common theme of "it's nice but it smells awful," and boy did - it live up to that. Lots of the beach had dried up and large colonies of tiny flies carpeted the sand. Taking steps - through the sand caused them all to disperse in sync, almost like dust in the wind. Check out my second selfie of - the trip.
- -
As we returned to our car to head out, we started talking to an older couple that was cleaning their RV in the - parking lot. We clearly looked like travelers, and they were amazed we were here from so far away. It was nice to - talk to some local folks and drop the "us and them". Honestly, that's one of the biggest lessons from this trip. - News and social media tend to feed us a lot of negativity, but there really are normal people everywhere. Hopefully - we don't forget that.
- -Back in the car, we prepared for a long 8ish hour drive. Normally, I had been taking the evening/night shift for - driving, but today I wanted to drive first. With the sun beating down through the driver side window, I got us about - 4-5 hours through the trip in almost a single shot. The speed limit for a lot of this highway was 80 mph. Now don't - tell anyone, but I miiiiight have hit 110 mph at one point. After the mountains in Utah, there was a large stretch - of just pure desert. For miles and miles, nothing could be seen in the distance except for more road.
- -Come nighttime, we made it to Reno, NV. We joked about wanting to go do some penny slots and $1 blackjack, but - truthfully, we were way too tired to do anything like that. Instead, we found a nice spot for dinner with a lot of - different options. I got myself an authentic and delicious thali at a place called... Thali. With one payment, I got - free roti and rice refills with my amazing plate of food.
- -
After dinner, we called it for the night. Tomorrow would be our final day of exploration and adventure, so we - wanted to be fully awake and ready.
-From Reno, we headed out for Lake Tahoe. Right on the border of NV and CA, we would officially be passing into - California today. We made plans to pick up breakfast from Ernie's Coffee Shop, a busy spot among all the other - attractions in Tahoe and about an hour away. After arriving and picking up our food, we entered into the actual park - areas, and sat down to eat along the water at Pope Beach. Honestly, I don't think I'll ever see water as clear as - what you can find here at Lake Tahoe. Even as the light waves splashed up onto shore, the view of the bottom was - completely clean and unobstructed.
- -
We sat and enjoyed the water here for about an hour before cleaning up to go drive around the loop a bit more. - Around the lake are many hiking and beach spots, so our plan was to drive clockwise for a bit, staying on the - California side. Occasionally, we'd stop at viewpoints along the way, sometimes even trekking into the woods further - just for fun. It was pretty busy up here for a Monday, at least to my untrained eye. Perhaps it should be even more - busy here were it not for the pandemic. We passed a number of large houses built along the mountainside, likely - priced at several millions. Something tells me those houses are worth every penny, considering the views here.
- -
We continued on to Meek's Bay, another beach, where we sat on the rocks for another half hour. It was a great - relaxing experience, meditating there. Taking in all the sounds of this wonderful place, it was very calming and - helped to round out and balance the exciting and hectic past few days. After we took it all in, we decided it was - time to continue.
- -The last leg of our trip would take us through the mountains, with lots of warning signs for the steep grades we'd - have to endure. The car groaned as some points, but it was only a little bit farther now. At one point, we got stuck - in traffic due to two completely independent accidents. One car with a few minor dents had pulled over on the side - of the road, waiting for some sort of assistance. However, he was going to have to wait - further down the road was - a massive accident involving an 18-wheeler. The front of this truck appeared to have exploded - metal pieces lay - strewn all over the road and the parts of the truck that were still intact were charred and black. It took a while - to make it past, but once we did, it was smooth sailing.
- -Our trip finally came to a close 3.5 hours later, when we arrived in Oakland. We pulled in to our Airbnb and took - a while to finally realize that the trip was over. It was honestly a bit sad, as the last few days had been some of - the most spectacular of the trip. I was still riding the high of being able to see so much of the country I'd been - waiting to see, and so it was tough to accept that I'd be heading home soon. But arriving here was not all bad! - Tomorrow would be my free day here in the Bay Area, and so I'd made plans to borrow the car and see some other - friends.
- -Technically Day 11:
- -On my free day, I met with one of our family friends for lunch, and then met with two of my online friends for - dinner. In between, I stopped by Presidio Park in San Francisco, hoping to get some sort of view of the Golden Gate - Bridge. Unfortunately, it was an extremely foggy day, so all I could hear were the sounds of the ocean waves and - occasional fog horns. Not a big deal - I'd already seen the Golden Gate Bridge a few times on previous trips, and - the park had a certain charm of its own when shrouded in fog. I arrived back at the Airbnb in the middle of the - night and went straight to bed. Tomorrow would be a day of no schedule, no driving, and relaxing only. Well, and - packing for my flight the following day.
- -
And so that brings my trip to a close. After a short, bittersweet plane ride back to MA, I met up with my parents. - The first thing I did upon arriving home was to take a shower, trying to keep whatever germs I'd brought from across - the country to a minimum. We enjoyed a nice dinner together and I shared a lot of the pictures I shared with you all - here.
- -1. Hot Springs National Park - 2. White Sands National Park - 3. Petrified Forest National Park (Painted Desert) - 4. Canyonlands National Park (Island in the Sky)
- -1. Beale Street, Memphis TN - 2. Lincoln National Forest - 3. Great Salt Lake - 4. Tahoe National Forest
- -So after a collective ~70 hours of driving, passing through 15 states, and approximately 4.9k - miles traveled, I can now say that I've driven across the country. This is an experience I recommend to anyone - and everyone, especially if you've only lived in a coastal city. The country is enormous and, though I'd seen - pictures and read about them, these sights and landmarks always felt so distant until now. I will absolutely be - doing a trip like this again, hopefully sooner rather than later, because who knows when such an opportunity will - come by again. I'm eternally grateful to my friends for inviting me on this trip with them, as these are memories - that I will have forever. I hope you've enjoyed my recollection of the trip, I've certainly enjoyed reliving it - through blogging. Hope to have some more exciting stuff for you all soon.
- -Peace!
- -In this blog series, we will look at how to create procedural hexagonal tile grids in Unreal Engine 5. I'll do my - best - to explain what details I can, but will assume some basic familiarity with Unreal Engine and C++ (or any language, - really). If you are more comfortable working with Blueprints in Unreal, you should still be able to follow along! -
- - i. Introduction

As someone new to Unreal but familiar with coding, I felt more of a pull towards C++ development over learning - Blueprints. I've also been playing a lot of Civilization 5 and 6 around the time of writing this, and so I've had - the picture of hexagon maps in my head and thought it'd be a good exercise to get some practice with the engine. I - won't be getting into environment - setup in this series, but do keep in mind that setting up Unreal Engine with your code editor of choice may take - some time and troubleshooting. In my case, I am using Visual Studio Code and Unreal Engine 5.4.4. I also created my - own regular hexagon tile in Blender and exported it for use in Unreal, which I recommend doing for full control of - the tile, but I'm sure you can also find one online somewhere. -
- -I'd also like to point you to two great resources that helped me. The first is this video from Gisli's game - development channel. He creates a tool that generates a hexagonal grid using Blueprints and shows the whole process, - and the higher level concepts are still relevant when working with C++. The other is this blog post from Red Blob Games. This - is likely the best blog post around for understand how hex tiling works and the numerous ways you can set up - coordinate systems with them (a bit overkill for this project but exciting to learn nonetheless).
- -The key takeaway: the dimensions of a regular hexagon make it so you cannot simply offset by a - single width value to get proper tiling - with some trigonometry, you would find that you need to use sqrt(3) - somewhere depending on if you are using - flat-top or pointy-top orientation. We'll be working with flat-top orientation here, but the formulae and logic can - be easily repurposed to work with pointy-top.
- -Now, let's get into it!
- -First, let's define a simple HexTile class. This class represents a single hexagonal tile, which we will provide - with - a mesh and material. By using C++ to expose these variables to Unreal Engine's editor, we can use Unreal's UI to - find and assign these easily. To create the class, we need to define a HexTile.h and a HexTile.cpp. The first is a - header - file where we declare variables, functions, and expose things to the editor. The second is where we define the class - logic. Let's take a look at both real quick:
- - -
-#pragma once
-
-#include "CoreMinimal.h"
-#include "GameFramework/Actor.h"
-#include "HexTile.generated.h"
-
-// allcaps methods are for interfacing UE5
-
-// initialize as a subclass of Actor
-UCLASS()
-class TILETACTICS_API AHexTile : public AActor
-{
- GENERATED_BODY()
-
-public:
- AHexTile();
-
- // lets you assign a mesh in the editor
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Hex Tile")
- UStaticMeshComponent* MeshComponent;
-
- // setter method for the material
- UFUNCTION(BlueprintCallable, Category = "Hex Tile")
- void SetTileMaterial(UMaterialInterface* MyMaterial);
-
- // setter method for the mesh
- UFUNCTION(BlueprintCallable, Category = "Hex Tile")
- void SetTileMesh(UStaticMesh* NewMesh);
-
-// these are inherited from Actor
-protected:
- virtual void BeginPlay() override;
- virtual void OnConstruction(const FTransform& Transform) override;
-};
-
-
-#include "HexTile.h"
-
-// constructor
-AHexTile::AHexTile()
-{
- PrimaryActorTick.bCanEverTick = false; // disable tick for performance
-
- MeshComponent = CreateDefaultSubobject(TEXT("MeshComponent"));
- RootComponent = MeshComponent;
-}
-
-// called when simulation starts
-void AHexTile::BeginPlay()
-{
- Super::BeginPlay();
-}
-
-// called when actor spawns or is changed
-void AHexTile::OnConstruction(const FTransform& Transform)
-{
- Super::OnConstruction(Transform);
-}
-
-// this sets the tile mesh to the given mesh
-void AHexTile::SetTileMesh(UStaticMesh* NewMesh)
-{
- if (NewMesh)
- {
- MeshComponent->SetStaticMesh(NewMesh);
- }
-}
-
-// this sets the tile material to the given material
-void AHexTile::SetTileMaterial(UMaterialInterface* MyMaterial)
-{
- if (MyMaterial)
- {
- MeshComponent->SetMaterial(0, MyMaterial);
- }
-}
-
- The parts in all caps in the header file are UE functions for interfacing with the editor and determining what to expose, while the rest is basically boilerplate code. In the cpp file, we write the rest of our logic. With these set, we are able to use the UI of Unreal to control variables or function calls without needing to recompile the code. However, changing any core functionality or global constants will likely require a recompile or a refactor to expose it to the editor as well. Not necessarily impossible, but just something to think about.
- -Next, we want to make an Actor that behaves as the grid origin or generator - something that does the math of positioning the tiles and then spawns them accordingly. We will give this Actor the ability to use the Tile's setter functions to change how to look as well. In fact, we can get pretty creative with what we expose to the editor here and come up with our own custom constants or variables. This is the part that can contain a lot of math, so let's do the fun part of showing the demo first 😏
- -
What you're seeing here is a hex grid with an adjustable width and height, which is then performing the act of spawning the tiles where needed. This is being done when a custom button is pressed, but you can also refactor this to happen every frame (and in turn, more expensive). The dark black floor material was just a stock material picked from the default asset library. We can call this Actor the HexGridOrigin, indicating that it is the (0, 0) coordinate of the 2D grid. Just like in the Tile class where we had to provide the mesh and material through the editor, we can provide these to the HexGridOrigin as well, which can then apply different textures based on rules we come up with. We'll look at noise and heights in the next one, where I'll share the full .h and .cpp code for the HexGridOrigin class.
- -See you there!
- -To build off from the last post, let's give these tiles a height using Perlin noise, and then use that to determine what material to apply. We'll also theorycraft some other variables we could introduce to add some spice to the map generation. First off, let me share the header and cpp files for the HexGridOrigin class. If you're just skimming through, you probably want to see the AHexGridOrigin::BuildGrid() function in the .cpp file.
- -
-#pragma once
-
-#include "CoreMinimal.h"
-#include "GameFramework/Actor.h"
-#include "HexTile.h"
-#include "HexGridOrigin.generated.h"
-
-// custom rendering type
-UENUM(BlueprintType)
-enum class EHexGridMode : uint8
-{
- Tile UMETA(DisplayName = "Tile"),
- Fill UMETA(DisplayName = "Fill")
-};
-
-UCLASS()
-class TILETACTICS_API AHexGridOrigin : public AActor
-{
- GENERATED_BODY()
-
-public:
- AHexGridOrigin();
-
- // set class of HexTile in editor
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- TSubclassOf HexTileClass;
-
- // set all materials that will be needed
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid Materials")
- UMaterialInterface *GrassMaterial;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid Materials")
- UMaterialInterface *StoneMaterial;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid Materials")
- UMaterialInterface *SnowMaterial;
-
- // ...
- // add any more material options here
-
- // set mesh that will be passed to HexTile
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Tile")
- UStaticMesh *TileMesh;
-
- // grid properties
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- int32 GridWidth;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- int32 GridHeight;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- float GridSpacing;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid", meta = (Delta = "0.01"))
- float NoiseStrength;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- int32 ZScaling;
-
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hex Grid")
- EHexGridMode GridMode;
-
- // array to keep track of spawned HexTile actors
- UPROPERTY()
- TArray SpawnedTiles;
-
- // buttons
- UFUNCTION(BlueprintCallable, Category = "Hex Grid", CallInEditor)
- void BuildGrid();
-
- UFUNCTION(BlueprintCallable, Category = "Hex Grid", CallInEditor)
- void ClearGrid();
-
-protected:
- virtual void BeginPlay() override;
-};
-
-
-
-#include "HexGridOrigin.h"
-#include "HexTile.h"
-#include "Kismet/KismetMathLibrary.h"
-
-// constructor
-AHexGridOrigin::AHexGridOrigin()
-{
- // don't need per tick calcs
- PrimaryActorTick.bCanEverTick = false;
-
- // initial grid settings
- GridMode = EHexGridMode::Tile;
- GridWidth = 5;
- GridHeight = 5;
- GridSpacing = 100.0f;
- NoiseStrength = 0.1f;
- ZScaling = 10;
-}
-
-// when simulation starts
-void AHexGridOrigin::BeginPlay()
-{
- Super::BeginPlay();
-
- BuildGrid();
-}
-
-// this does the whole thing
-void AHexGridOrigin::BuildGrid()
-{
- // clear previous tiles
- for (AHexTile *Tile : SpawnedTiles)
- {
- if (Tile)
- {
- Tile->Destroy();
- }
- }
- SpawnedTiles.Empty();
-
- // calculate X and Y spacing
- float YSpacing = GridSpacing * 1.5f;
- float XSpacing = FMath::Sqrt(3.0f) * GridSpacing;
-
- // set clamp ranges for noise and scaling
- float MinNoiseValue = 0.1f;
- float MaxNoiseValue = 1.0f;
- float MinZScale = 0.1f;
-
- for (int32 y = 0; y < GridHeight; ++y)
- {
- for (int32 x = 0; x < GridWidth; ++x)
- {
- float XPos = x * XSpacing;
- float YPos = y * YSpacing;
-
- // odd row offset
- if (y % 2 != 0)
- {
- XPos += (XSpacing / 2.0f);
- }
-
- // store the X and Y of the centerpoint, Z comes later
- FVector CenterPoint(XPos, YPos, 0.0f);
-
- // get a noise value
- float NoiseValue = FMath::PerlinNoise2D(FVector2D(CenterPoint.X, CenterPoint.Y) * NoiseStrength);
- NoiseValue = FMath::Clamp(NoiseValue, MinNoiseValue, MaxNoiseValue); // clamp it
-
- float RoundedZ = UKismetMathLibrary::Round(NoiseValue * 20.0f) * 0.05f; // round it
- if (HexTileClass)
- {
- AHexTile *NewTile = GetWorld()->SpawnActor(HexTileClass, CenterPoint, FRotator::ZeroRotator);
- if (NewTile)
- {
- NewTile->SetTileMesh(TileMesh);
-
- // grid mode branches
- if (GridMode == EHexGridMode::Tile)
- {
- // Tile Mode: set the tile's center at the Z point
- CenterPoint.Z = RoundedZ * ZScaling;
- NewTile->SetActorLocation(CenterPoint);
- }
- else if (GridMode == EHexGridMode::Fill)
- {
- // Fill Mode: scale the mesh up to the Z point
- FVector NewScale = NewTile->GetActorScale3D();
- NewScale.Z = FMath::Max(RoundedZ * ZScaling, MinZScale);
- NewTile->SetActorScale3D(NewScale);
- }
-
- // use the Z height to determine material
- UMaterialInterface *TileMaterial;
- if (RoundedZ < 0.33f) // low thresh
- {
- TileMaterial = GrassMaterial;
- }
- else if (RoundedZ < 0.55f) // middle thresh
- {
- TileMaterial = StoneMaterial;
- }
- else // high
- {
- TileMaterial = SnowMaterial;
- }
-
- NewTile->SetTileMaterial(TileMaterial);
- SpawnedTiles.Add(NewTile);
- }
- }
- }
- }
-}
-
-// destroys all actors
-void AHexGridOrigin::ClearGrid()
-{
- for (AHexTile *Tile : SpawnedTiles)
- {
- if (Tile)
- {
- Tile->Destroy();
- }
- }
- SpawnedTiles.Empty();
-}
-
-
-
Beyond Perlin noise, we also added: -
Until next time!
- -V&&P());){var he=x.callback;if(typeof he=="function"){x.callback=null,v=x.priorityLevel;var ve=he(x.expirationTime<=V);if(V=a.unstable_now(),typeof ve=="function"){x.callback=ve,U(V),$=!0;break t}x===t(p)&&n(p),U(V)}else n(p);x=t(p)}if(x!==null)$=!0;else{var Y=t(m);Y!==null&&ue(I,Y.startTime-V),$=!1}}break e}finally{x=null,v=J,S=!1}$=void 0}}finally{$?se():z=!1}}}var se;if(typeof N=="function")se=function(){N(W)};else if(typeof MessageChannel<"u"){var ae=new MessageChannel,ce=ae.port2;ae.port1.onmessage=W,se=function(){ce.postMessage(null)}}else se=function(){A(W,0)};function ue(V,$){j=A(function(){V(a.unstable_now())},$)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(V){V.callback=null},a.unstable_forceFrameRate=function(V){0>V||125he?(V.sortIndex=J,e(m,V),t(p)===null&&V===t(m)&&(T?(D(j),j=-1):T=!0,ue(I,J-he))):(V.sortIndex=ve,e(p,V),M||S||(M=!0,z||(z=!0,se()))),V},a.unstable_shouldYield=P,a.unstable_wrapCallback=function(V){var $=v;return function(){var J=v;v=$;try{return V.apply(this,arguments)}finally{v=J}}}})(n2)),n2}var I_;function bT(){return I_||(I_=1,t2.exports=vT()),t2.exports}var i2={exports:{}},Ba={};var F_;function _T(){if(F_)return Ba;F_=1;var a=bh();function e(p){var m="https://react.dev/errors/"+p;if(1 "u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),i2.exports=_T(),i2.exports}var H_;function AT(){if(H_)return t0;H_=1;var a=bT(),e=bh(),t=ST();function n(i){var r="https://react.dev/errors/"+i;if(1 ve||(i.current=he[ve],he[ve]=null,ve--)}function Te(i,r){ve++,he[ve]=i.current,i.current=r}var Ne=Y(null),Qe=Y(null),le=Y(null),xe=Y(null);function Ge(i,r){switch(Te(le,r),Te(Qe,i),Te(Ne,null),r.nodeType){case 9:case 11:i=(i=r.documentElement)&&(i=i.namespaceURI)?n_(i):0;break;default:if(i=r.tagName,r=r.namespaceURI)r=n_(r),i=i_(r,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}oe(Ne),Te(Ne,i)}function et(){oe(Ne),oe(Qe),oe(le)}function at(i){i.memoizedState!==null&&Te(xe,i);var r=Ne.current,u=i_(r,i.type);r!==u&&(Te(Qe,i),Te(Ne,u))}function lt(i){Qe.current===i&&(oe(Ne),oe(Qe)),xe.current===i&&(oe(xe),Kp._currentValue=J)}var Rt,yt;function Ue(i){if(Rt===void 0)try{throw Error()}catch(u){var r=u.stack.trim().match(/\n( *(at )?)/);Rt=r&&r[1]||"",yt=-1 )":-1 b||ie[h]!==Se[b]){var Le=` +`+ie[h].replace(" at new "," at ");return i.displayName&&Le.includes(" ")&&(Le=Le.replace(" ",i.displayName)),Le}while(1<=h&&0<=b);break}}}finally{Z=!1,Error.prepareStackTrace=u}return(u=i?i.displayName||i.name:"")?Ue(u):""}function Xe(i,r){switch(i.tag){case 26:case 27:case 5:return Ue(i.type);case 16:return Ue("Lazy");case 13:return i.child!==r&&r!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return ke(i.type,!1);case 11:return ke(i.type.render,!1);case 1:return ke(i.type,!0);case 31:return Ue("Activity");default:return""}}function tt(i){try{var r="",u=null;do r+=Xe(i,u),u=i,i=i.return;while(i);return r}catch(h){return` +Error generating stack: `+h.message+` +`+h.stack}}var qe=Object.prototype.hasOwnProperty,ot=a.unstable_scheduleCallback,nt=a.unstable_cancelCallback,ht=a.unstable_shouldYield,K=a.unstable_requestPaint,F=a.unstable_now,ye=a.unstable_getCurrentPriorityLevel,Oe=a.unstable_ImmediatePriority,Pe=a.unstable_UserBlockingPriority,Re=a.unstable_NormalPriority,Mt=a.unstable_LowPriority,ct=a.unstable_IdlePriority,wt=a.log,_t=a.unstable_setDisableYieldValue,je=null,Ye=null;function St(i){if(typeof wt=="function"&&_t(i),Ye&&typeof Ye.setStrictMode=="function")try{Ye.setStrictMode(je,i)}catch{}}var te=Math.clz32?Math.clz32:ee,Ae=Math.log,Ze=Math.LN2;function ee(i){return i>>>=0,i===0?32:31-(Ae(i)/Ze|0)|0}var Ke=256,Je=262144,it=4194304;function We(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Ie(i,r,u){var h=i.pendingLanes;if(h===0)return 0;var b=0,E=i.suspendedLanes,L=i.pingedLanes;i=i.warmLanes;var k=h&134217727;return k!==0?(h=k&~E,h!==0?b=We(h):(L&=k,L!==0?b=We(L):u||(u=k&~i,u!==0&&(b=We(u))))):(k=h&~E,k!==0?b=We(k):L!==0?b=We(L):u||(u=h&~i,u!==0&&(b=We(u)))),b===0?0:r!==0&&r!==b&&(r&E)===0&&(E=b&-b,u=r&-r,E>=u||E===32&&(u&4194048)!==0)?r:b}function ft(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function Tt(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ln(){var i=it;return it<<=1,(it&62914560)===0&&(it=4194304),i}function Qt(i){for(var r=[],u=0;31>u;u++)r.push(i);return r}function $n(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ei(i,r,u,h,b,E){var L=i.pendingLanes;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=u,i.entangledLanes&=u,i.errorRecoveryDisabledLanes&=u,i.shellSuspendCounter=0;var k=i.entanglements,ie=i.expirationTimes,Se=i.hiddenUpdates;for(u=L&~u;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var Sr=/[\n"\\]/g;function Hn(i){return i.replace(Sr,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Qs(i,r,u,h,b,E,L,k){i.name="",L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"?i.type=L:i.removeAttribute("type"),r!=null?L==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+fn(r)):i.value!==""+fn(r)&&(i.value=""+fn(r)):L!=="submit"&&L!=="reset"||i.removeAttribute("value"),r!=null?wi(i,L,fn(r)):u!=null?wi(i,L,fn(u)):h!=null&&i.removeAttribute("value"),b==null&&E!=null&&(i.defaultChecked=!!E),b!=null&&(i.checked=b&&typeof b!="function"&&typeof b!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?i.name=""+fn(k):i.removeAttribute("name")}function kn(i,r,u,h,b,E,L,k){if(E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"&&(i.type=E),r!=null||u!=null){if(!(E!=="submit"&&E!=="reset"||r!=null)){Bn(i);return}u=u!=null?""+fn(u):"",r=r!=null?""+fn(r):u,k||r===i.value||(i.value=r),i.defaultValue=r}h=h??b,h=typeof h!="function"&&typeof h!="symbol"&&!!h,i.checked=k?i.checked:!!h,i.defaultChecked=!!h,L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(i.name=L),Bn(i)}function wi(i,r,u){r==="number"&&bi(i.ownerDocument)===i||i.defaultValue===""+u||(i.defaultValue=""+u)}function Ti(i,r,u,h){if(i=i.options,r){r={};for(var b=0;b "u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Df=!1;if($s)try{var tu={};Object.defineProperty(tu,"passive",{get:function(){Df=!0}}),window.addEventListener("test",tu,tu),window.removeEventListener("test",tu,tu)}catch{Df=!1}var ao=null,Nf=null,so=null;function Of(){if(so)return so;var i,r=Nf,u=r.length,h,b="value"in ao?ao.value:ao.textContent,E=b.length;for(i=0;i=lo),lu=" ",Vh=!1;function Bf(i,r){switch(i){case"keyup":return kh.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yl(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var co=!1;function If(i,r){switch(i){case"compositionend":return Yl(r);case"keypress":return r.which!==32?null:(Vh=!0,lu);case"textInput":return i=r.data,i===lu&&Vh?null:i;default:return null}}function Sm(i,r){if(co)return i==="compositionend"||!al&&Bf(i,r)?(i=Of(),so=Nf=ao=null,co=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1 =r)return{node:u,offset:r-i};i=h}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=Wh(u)}}function jf(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?jf(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Hf(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=bi(i.document);r instanceof i.HTMLIFrameElement;){try{var u=typeof r.contentWindow.location.href=="string"}catch{u=!1}if(u)i=r.contentWindow;else break;r=bi(i.document)}return r}function Jl(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var Tm=$s&&"documentMode"in document&&11>=document.documentMode,$l=null,kf=null,ec=null,qa=!1;function Vf(i,r,u){var h=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;qa||$l==null||$l!==bi(h)||(h=$l,"selectionStart"in h&&Jl(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),ec&&Ql(ec,h)||(ec=h,h=hg(kf,"onSelect"),0 >=L,b-=L,ir=1<<32-te(r)+b|u<rn?(_n=Ct,Ct=null):_n=Ct.sibling;var zn=we(me,Ct,_e[rn],Fe);if(zn===null){Ct===null&&(Ct=_n);break}i&&Ct&&zn.alternate===null&&r(me,Ct),re=E(zn,re,rn),Ln===null?Pt=zn:Ln.sibling=zn,Ln=zn,Ct=_n}if(rn===_e.length)return u(me,Ct),mn&&Tr(me,rn),Pt;if(Ct===null){for(;rn<_e.length;rn++)Ct=Ve(me,_e[rn],Fe),Ct!==null&&(re=E(Ct,re,rn),Ln===null?Pt=Ct:Ln.sibling=Ct,Ln=Ct);return mn&&Tr(me,rn),Pt}for(Ct=h(Ct);rn<_e.length;rn++)_n=De(Ct,me,rn,_e[rn],Fe),_n!==null&&(i&&_n.alternate!==null&&Ct.delete(_n.key===null?rn:_n.key),re=E(_n,re,rn),Ln===null?Pt=_n:Ln.sibling=_n,Ln=_n);return i&&Ct.forEach(function(Rc){return r(me,Rc)}),mn&&Tr(me,rn),Pt}function jt(me,re,_e,Fe){if(_e==null)throw Error(n(151));for(var Pt=null,Ln=null,Ct=re,rn=re=0,_n=null,zn=_e.next();Ct!==null&&!zn.done;rn++,zn=_e.next()){Ct.index>rn?(_n=Ct,Ct=null):_n=Ct.sibling;var Rc=we(me,Ct,zn.value,Fe);if(Rc===null){Ct===null&&(Ct=_n);break}i&&Ct&&Rc.alternate===null&&r(me,Ct),re=E(Rc,re,rn),Ln===null?Pt=Rc:Ln.sibling=Rc,Ln=Rc,Ct=_n}if(zn.done)return u(me,Ct),mn&&Tr(me,rn),Pt;if(Ct===null){for(;!zn.done;rn++,zn=_e.next())zn=Ve(me,zn.value,Fe),zn!==null&&(re=E(zn,re,rn),Ln===null?Pt=zn:Ln.sibling=zn,Ln=zn);return mn&&Tr(me,rn),Pt}for(Ct=h(Ct);!zn.done;rn++,zn=_e.next())zn=De(Ct,me,rn,zn.value,Fe),zn!==null&&(i&&zn.alternate!==null&&Ct.delete(zn.key===null?rn:zn.key),re=E(zn,re,rn),Ln===null?Pt=zn:Ln.sibling=zn,Ln=zn);return i&&Ct.forEach(function(hT){return r(me,hT)}),mn&&Tr(me,rn),Pt}function Wn(me,re,_e,Fe){if(typeof _e=="object"&&_e!==null&&_e.type===T&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case S:e:{for(var Pt=_e.key;re!==null;){if(re.key===Pt){if(Pt=_e.type,Pt===T){if(re.tag===7){u(me,re.sibling),Fe=b(re,_e.props.children),Fe.return=me,me=Fe;break e}}else if(re.elementType===Pt||typeof Pt=="object"&&Pt!==null&&Pt.$$typeof===q&&pl(Pt)===re.type){u(me,re.sibling),Fe=b(re,_e.props),bu(Fe,_e),Fe.return=me,me=Fe;break e}u(me,re);break}else r(me,re);re=re.sibling}_e.type===T?(Fe=wr(_e.props.children,me.mode,Fe,_e.key),Fe.return=me,me=Fe):(Fe=hu(_e.type,_e.key,_e.props,null,me.mode,Fe),bu(Fe,_e),Fe.return=me,me=Fe)}return L(me);case M:e:{for(Pt=_e.key;re!==null;){if(re.key===Pt)if(re.tag===4&&re.stateNode.containerInfo===_e.containerInfo&&re.stateNode.implementation===_e.implementation){u(me,re.sibling),Fe=b(re,_e.children||[]),Fe.return=me,me=Fe;break e}else{u(me,re);break}else r(me,re);re=re.sibling}Fe=Ls(_e,me.mode,Fe),Fe.return=me,me=Fe}return L(me);case q:return _e=pl(_e),Wn(me,re,_e,Fe)}if(ue(_e))return Et(me,re,_e,Fe);if(se(_e)){if(Pt=se(_e),typeof Pt!="function")throw Error(n(150));return _e=Pt.call(_e),jt(me,re,_e,Fe)}if(typeof _e.then=="function")return Wn(me,re,td(_e),Fe);if(_e.$$typeof===N)return Wn(me,re,yu(me,_e),Fe);_u(me,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint"?(_e=""+_e,re!==null&&re.tag===6?(u(me,re.sibling),Fe=b(re,_e),Fe.return=me,me=Fe):(u(me,re),Fe=Wf(_e,me.mode,Fe),Fe.return=me,me=Fe),L(me)):u(me,re)}return function(me,re,_e,Fe){try{Mo=0;var Pt=Wn(me,re,_e,Fe);return Ao=null,Pt}catch(Ct){if(Ct===So||Ct===Bs)throw Ct;var Ln=fa(29,Ct,null,me.mode);return Ln.lanes=Fe,Ln.return=me,Ln}finally{}}}var ml=cc(!0),zm=cc(!1),Eo=!1;function up(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fp(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function rr(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Ur(i,r,u){var h=i.updateQueue;if(h===null)return null;if(h=h.shared,(vn&2)!==0){var b=h.pending;return b===null?r.next=r:(r.next=b.next,b.next=r),h.pending=r,r=ac(i),Yf(i,null,u),r}return du(i,h,r,u),ac(i)}function wo(i,r,u){if(r=r.updateQueue,r!==null&&(r=r.shared,(u&4194048)!==0)){var h=r.lanes;h&=i.pendingLanes,u|=h,r.lanes=u,Qo(i,u)}}function nd(i,r){var u=i.updateQueue,h=i.alternate;if(h!==null&&(h=h.updateQueue,u===h)){var b=null,E=null;if(u=u.firstBaseUpdate,u!==null){do{var L={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};E===null?b=E=L:E=E.next=L,u=u.next}while(u!==null);E===null?b=E=r:E=E.next=r}else b=E=r;u={baseState:h.baseState,firstBaseUpdate:b,lastBaseUpdate:E,shared:h.shared,callbacks:h.callbacks},i.updateQueue=u;return}i=u.lastBaseUpdate,i===null?u.firstBaseUpdate=r:i.next=r,u.lastBaseUpdate=r}var dp=!1;function Su(){if(dp){var i=Ps;if(i!==null)throw i}}function gl(i,r,u,h){dp=!1;var b=i.updateQueue;Eo=!1;var E=b.firstBaseUpdate,L=b.lastBaseUpdate,k=b.shared.pending;if(k!==null){b.shared.pending=null;var ie=k,Se=ie.next;ie.next=null,L===null?E=Se:L.next=Se,L=ie;var Le=i.alternate;Le!==null&&(Le=Le.updateQueue,k=Le.lastBaseUpdate,k!==L&&(k===null?Le.firstBaseUpdate=Se:k.next=Se,Le.lastBaseUpdate=ie))}if(E!==null){var Ve=b.baseState;L=0,Le=Se=ie=null,k=E;do{var we=k.lane&-536870913,De=we!==k.lane;if(De?(pn&we)===we:(h&we)===we){we!==0&&we===Or&&(dp=!0),Le!==null&&(Le=Le.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var Et=i,jt=k;we=r;var Wn=u;switch(jt.tag){case 1:if(Et=jt.payload,typeof Et=="function"){Ve=Et.call(Wn,Ve,we);break e}Ve=Et;break e;case 3:Et.flags=Et.flags&-65537|128;case 0:if(Et=jt.payload,we=typeof Et=="function"?Et.call(Wn,Ve,we):Et,we==null)break e;Ve=x({},Ve,we);break e;case 2:Eo=!0}}we=k.callback,we!==null&&(i.flags|=64,De&&(i.flags|=8192),De=b.callbacks,De===null?b.callbacks=[we]:De.push(we))}else De={lane:we,tag:k.tag,payload:k.payload,callback:k.callback,next:null},Le===null?(Se=Le=De,ie=Ve):Le=Le.next=De,L|=we;if(k=k.next,k===null){if(k=b.shared.pending,k===null)break;De=k,k=De.next,De.next=null,b.lastBaseUpdate=De,b.shared.pending=null}}while(!0);Le===null&&(ie=Ve),b.baseState=ie,b.firstBaseUpdate=Se,b.lastBaseUpdate=Le,E===null&&(b.shared.lanes=0),as|=L,i.lanes=L,i.memoizedState=Ve}}function or(i,r){if(typeof i!="function")throw Error(n(191,i));i.call(r)}function Xi(i,r){var u=i.callbacks;if(u!==null)for(i.callbacks=null,i=0;i E?E:8;var L=V.T,k={};V.T=k,Tu(i,!1,r,u);try{var ie=b(),Se=V.S;if(Se!==null&&Se(k,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Le=op(ie,h);fc(i,r,Le,ga(i))}else fc(i,r,h,ga(i))}catch(Ve){fc(i,r,{then:function(){},status:"rejected",reason:Ve},ga())}finally{$.p=E,L!==null&&k.types!==null&&(L.types=k.types),V.T=L}}function Sv(){}function zp(i,r,u,h){if(i.tag!==5)throw Error(n(476));var b=eg(i).queue;Lp(i,b,r,J,u===null?Sv:function(){return Pp(i),u(h)})}function eg(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:J,baseState:J,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:J},next:null};var u={};return r.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:u},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Pp(i){var r=eg(i);r.next===null&&(r=i.alternate.memoizedState),fc(i,r.next.queue,{},ga())}function Bp(){return Fi(Kp)}function qi(){return hi().memoizedState}function Ip(){return hi().memoizedState}function Av(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var u=ga();i=rr(u);var h=Ur(r,i,u);h!==null&&(c(h,r,u),wo(h,r,u)),r={cache:ap()},i.payload=r;return}r=r.return}}function Mv(i,r,u){var h=ga();u={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Pr(i)?xl(r,u):(u=ic(i,r,u,h),u!==null&&(c(u,i,h),Da(u,r,h)))}function tg(i,r,u){var h=ga();fc(i,r,u,h)}function fc(i,r,u,h){var b={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(Pr(i))xl(r,b);else{var E=i.alternate;if(i.lanes===0&&(E===null||E.lanes===0)&&(E=r.lastRenderedReducer,E!==null))try{var L=r.lastRenderedState,k=E(L,u);if(b.hasEagerState=!0,b.eagerState=k,Kn(k,L))return du(i,r,b,0),On===null&&go(),!1}catch{}finally{}if(u=ic(i,r,b,h),u!==null)return c(u,i,h),Da(u,r,h),!0}return!1}function Tu(i,r,u,h){if(h={lane:2,revertLane:Cv(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Pr(i)){if(r)throw Error(n(479))}else r=ic(i,u,h,2),r!==null&&c(r,i,2)}function Pr(i){var r=i.alternate;return i===kt||r!==null&&r===kt}function xl(i,r){lr=ad=!0;var u=i.pending;u===null?r.next=r:(r.next=u.next,u.next=r),i.pending=r}function Da(i,r,u){if((u&4194048)!==0){var h=r.lanes;h&=i.pendingLanes,u|=h,r.lanes=u,Qo(i,u)}}var Cu={readContext:Fi,use:rd,useCallback:ai,useContext:ai,useEffect:ai,useImperativeHandle:ai,useLayoutEffect:ai,useInsertionEffect:ai,useMemo:ai,useReducer:ai,useRef:ai,useState:ai,useDebugValue:ai,useDeferredValue:ai,useTransition:ai,useSyncExternalStore:ai,useId:ai,useHostTransitionStatus:ai,useFormState:ai,useActionState:ai,useOptimistic:ai,useMemoCache:ai,useCacheRefresh:ai};Cu.useEffectEvent=ai;var ng={readContext:Fi,use:rd,useCallback:function(i,r){return pa().memoizedState=[i,r===void 0?null:r],i},useContext:Fi,useEffect:Km,useImperativeHandle:function(i,r,u){u=u!=null?u.concat([i]):null,fd(4194308,4,Rp.bind(null,r,i),u)},useLayoutEffect:function(i,r){return fd(4194308,4,i,r)},useInsertionEffect:function(i,r){fd(4,2,i,r)},useMemo:function(i,r){var u=pa();r=r===void 0?null:r;var h=i();if(yl){St(!0);try{i()}finally{St(!1)}}return u.memoizedState=[h,r],h},useReducer:function(i,r,u){var h=pa();if(u!==void 0){var b=u(r);if(yl){St(!0);try{u(r)}finally{St(!1)}}}else b=r;return h.memoizedState=h.baseState=b,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:b},h.queue=i,i=i.dispatch=Mv.bind(null,kt,i),[h.memoizedState,i]},useRef:function(i){var r=pa();return i={current:i},r.memoizedState=i},useState:function(i){i=wu(i);var r=i.queue,u=tg.bind(null,kt,r);return r.dispatch=u,[i.memoizedState,u]},useDebugValue:pd,useDeferredValue:function(i,r){var u=pa();return Op(u,i,r)},useTransition:function(){var i=wu(!1);return i=Lp.bind(null,kt,i.queue,!0,!1),pa().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,u){var h=kt,b=pa();if(mn){if(u===void 0)throw Error(n(407));u=u()}else{if(u=r(),On===null)throw Error(n(349));(pn&127)!==0||Fm(h,r,u)}b.memoizedState=u;var E={value:u,getSnapshot:r};return b.queue=E,Km(Ep.bind(null,h,E,i),[i]),h.flags|=2048,uc(9,{destroy:void 0},Mp.bind(null,h,E,u,r),null),u},useId:function(){var i=pa(),r=On.identifierPrefix;if(mn){var u=ar,h=ir;u=(h&~(1<<32-te(h)-1)).toString(32)+u,r="_"+r+"R_"+u,u=sd++,0<\/script>",E=E.removeChild(E.firstChild);break;case"select":E=typeof h.is=="string"?L.createElement("select",{is:h.is}):L.createElement("select"),h.multiple?E.multiple=!0:h.size&&(E.size=h.size);break;default:E=typeof h.is=="string"?L.createElement(b,{is:h.is}):L.createElement(b)}}E[nn]=r,E[fi]=h;e:for(L=r.child;L!==null;){if(L.tag===5||L.tag===6)E.appendChild(L.stateNode);else if(L.tag!==4&&L.tag!==27&&L.child!==null){L.child.return=L,L=L.child;continue}if(L===r)break e;for(;L.sibling===null;){if(L.return===null||L.return===r)break e;L=L.return}L.sibling.return=L.return,L=L.sibling}r.stateNode=E;e:switch(ya(E,b,h),b){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&Oa(r)}}return Pn(r),Do(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,u),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==h&&Oa(r);else{if(typeof h!="string"&&r.stateNode===null)throw Error(n(166));if(i=le.current,ul(r)){if(i=r.stateNode,u=r.memoizedProps,h=null,b=Bi,b!==null)switch(b.tag){case 27:case 5:h=b.memoizedProps}i[nn]=r,i=!!(i.nodeValue===u||h!==null&&h.suppressHydrationWarning===!0||e_(i.nodeValue,u)),i||hn(r,!0)}else i=pg(i).createTextNode(h),i[nn]=r,r.stateNode=i}return Pn(r),null;case 31:if(u=r.memoizedState,i===null||i.memoizedState!==null){if(h=ul(r),u!==null){if(i===null){if(!h)throw Error(n(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(557));i[nn]=r}else fl(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Pn(r),i=!1}else u=ep(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),i=!0;if(!i)return r.flags&256?(Za(r),r):(Za(r),null);if((r.flags&128)!==0)throw Error(n(558))}return Pn(r),null;case 13:if(h=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(b=ul(r),h!==null&&h.dehydrated!==null){if(i===null){if(!b)throw Error(n(318));if(b=r.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(n(317));b[nn]=r}else fl(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Pn(r),b=!1}else b=ep(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=b),b=!0;if(!b)return r.flags&256?(Za(r),r):(Za(r),null)}return Za(r),(r.flags&128)!==0?(r.lanes=u,r):(u=h!==null,i=i!==null&&i.memoizedState!==null,u&&(h=r.child,b=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(b=h.alternate.memoizedState.cachePool.pool),E=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(E=h.memoizedState.cachePool.pool),E!==b&&(h.flags|=2048)),u!==i&&u&&(r.child.flags|=8192),xc(r,r.updateQueue),Pn(r),null);case 4:return et(),i===null&&Ov(r.stateNode.containerInfo),Pn(r),null;case 10:return ys(r.type),Pn(r),null;case 19:if(oe(ii),h=r.memoizedState,h===null)return Pn(r),null;if(b=(r.flags&128)!==0,E=h.rendering,E===null)if(b)Iu(h,!1);else{if(Un!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(E=id(i),E!==null){for(r.flags|=128,Iu(h,!1),i=E.updateQueue,r.updateQueue=i,xc(r,i),r.subtreeFlags=0,i=u,u=r.child;u!==null;)na(u,i),u=u.sibling;return Te(ii,ii.current&1|2),mn&&Tr(r,h.treeForkCount),r.child}i=i.sibling}h.tail!==null&&F()>rs&&(r.flags|=128,b=!0,Iu(h,!1),r.lanes=4194304)}else{if(!b)if(i=id(E),i!==null){if(r.flags|=128,b=!0,i=i.updateQueue,r.updateQueue=i,xc(r,i),Iu(h,!0),h.tail===null&&h.tailMode==="hidden"&&!E.alternate&&!mn)return Pn(r),null}else 2*F()-h.renderingStartTime>rs&&u!==536870912&&(r.flags|=128,b=!0,Iu(h,!1),r.lanes=4194304);h.isBackwards?(E.sibling=r.child,r.child=E):(i=h.last,i!==null?i.sibling=E:r.child=E,h.last=E)}return h.tail!==null?(i=h.tail,h.rendering=i,h.tail=i.sibling,h.renderingStartTime=F(),i.sibling=null,u=ii.current,Te(ii,b?u&1|2:u&1),mn&&Tr(r,h.treeForkCount),i):(Pn(r),null);case 22:case 23:return Za(r),aa(),h=r.memoizedState!==null,i!==null?i.memoizedState!==null!==h&&(r.flags|=8192):h&&(r.flags|=8192),h?(u&536870912)!==0&&(r.flags&128)===0&&(Pn(r),r.subtreeFlags&6&&(r.flags|=8192)):Pn(r),u=r.updateQueue,u!==null&&xc(r,u.retryQueue),u=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(u=i.memoizedState.cachePool.pool),h=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(h=r.memoizedState.cachePool.pool),h!==u&&(r.flags|=2048),i!==null&&oe(_o),null;case 24:return u=null,i!==null&&(u=i.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),ys(Ot),Pn(r),null;case 25:return null;case 30:return null}throw Error(n(156,r.tag))}function vd(i,r){switch(vo(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return ys(Ot),et(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return lt(r),null;case 31:if(r.memoizedState!==null){if(Za(r),r.alternate===null)throw Error(n(340));fl()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(Za(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));fl()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return oe(ii),null;case 4:return et(),null;case 10:return ys(r.type),null;case 22:case 23:return Za(r),aa(),i!==null&&oe(_o),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return ys(Ot),null;case 25:return null;default:return null}}function bl(i,r){switch(vo(r),r.tag){case 3:ys(Ot),et();break;case 26:case 27:case 5:lt(r);break;case 4:et();break;case 31:r.memoizedState!==null&&Za(r);break;case 13:Za(r);break;case 19:oe(ii);break;case 10:ys(r.type);break;case 22:case 23:Za(r),aa(),i!==null&&oe(_o);break;case 24:ys(Ot)}}function fr(i,r){try{var u=r.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var b=h.next;u=b;do{if((u.tag&i)===i){h=void 0;var E=u.create,L=u.inst;h=E(),L.destroy=h}u=u.next}while(u!==b)}}catch(k){Vn(r,r.return,k)}}function _s(i,r,u){try{var h=r.updateQueue,b=h!==null?h.lastEffect:null;if(b!==null){var E=b.next;h=E;do{if((h.tag&i)===i){var L=h.inst,k=L.destroy;if(k!==void 0){L.destroy=void 0,b=r;var ie=u,Se=k;try{Se()}catch(Le){Vn(b,ie,Le)}}}h=h.next}while(h!==E)}}catch(Le){Vn(r,r.return,Le)}}function No(i){var r=i.updateQueue;if(r!==null){var u=i.stateNode;try{Xi(r,u)}catch(h){Vn(i,i.return,h)}}}function kp(i,r,u){u.props=Yi(i.type,i.memoizedProps),u.state=i.memoizedState;try{u.componentWillUnmount()}catch(h){Vn(i,r,h)}}function dr(i,r){try{var u=i.ref;if(u!==null){switch(i.tag){case 26:case 27:case 5:var h=i.stateNode;break;case 30:h=i.stateNode;break;default:h=i.stateNode}typeof u=="function"?i.refCleanup=u(h):u.current=h}}catch(b){Vn(i,r,b)}}function ns(i,r){var u=i.ref,h=i.refCleanup;if(u!==null)if(typeof h=="function")try{h()}catch(b){Vn(i,r,b)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof u=="function")try{u(null)}catch(b){Vn(i,r,b)}else u.current=null}function is(i){var r=i.type,u=i.memoizedProps,h=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":u.autoFocus&&h.focus();break e;case"img":u.src?h.src=u.src:u.srcSet&&(h.srcset=u.srcSet)}}catch(b){Vn(i,i.return,b)}}function Ss(i,r,u){try{var h=i.stateNode;Bw(h,i.type,u,r),h[fi]=r}catch(b){Vn(i,i.return,b)}}function Si(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Mc(i.type)||i.tag===4}function hr(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Si(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Mc(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function Jt(i,r,u){var h=i.tag;if(h===5||h===6)i=i.stateNode,r?(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u).insertBefore(i,r):(r=u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,r.appendChild(i),u=u._reactRootContainer,u!=null||r.onclick!==null||(r.onclick=Js));else if(h!==4&&(h===27&&Mc(i.type)&&(u=i.stateNode,r=null),i=i.child,i!==null))for(Jt(i,r,u),i=i.sibling;i!==null;)Jt(i,r,u),i=i.sibling}function Tn(i,r,u){var h=i.tag;if(h===5||h===6)i=i.stateNode,r?u.insertBefore(i,r):u.appendChild(i);else if(h!==4&&(h===27&&Mc(i.type)&&(u=i.stateNode),i=i.child,i!==null))for(Tn(i,r,u),i=i.sibling;i!==null;)Tn(i,r,u),i=i.sibling}function pi(i){var r=i.stateNode,u=i.memoizedProps;try{for(var h=i.type,b=r.attributes;b.length;)r.removeAttributeNode(b[0]);ya(r,h,u),r[nn]=i,r[fi]=u}catch(E){Vn(i,i.return,E)}}var As=!1,Jn=!1,Ir=!1,Fu=typeof WeakSet=="function"?WeakSet:Set,ri=null;function vc(i,r){if(i=i.containerInfo,zv=_g,i=Hf(i),Jl(i)){if("selectionStart"in i)var u={start:i.selectionStart,end:i.selectionEnd};else e:{u=(u=i.ownerDocument)&&u.defaultView||window;var h=u.getSelection&&u.getSelection();if(h&&h.rangeCount!==0){u=h.anchorNode;var b=h.anchorOffset,E=h.focusNode;h=h.focusOffset;try{u.nodeType,E.nodeType}catch{u=null;break e}var L=0,k=-1,ie=-1,Se=0,Le=0,Ve=i,we=null;t:for(;;){for(var De;Ve!==u||b!==0&&Ve.nodeType!==3||(k=L+b),Ve!==E||h!==0&&Ve.nodeType!==3||(ie=L+h),Ve.nodeType===3&&(L+=Ve.nodeValue.length),(De=Ve.firstChild)!==null;)we=Ve,Ve=De;for(;;){if(Ve===i)break t;if(we===u&&++Se===b&&(k=L),we===E&&++Le===h&&(ie=L),(De=Ve.nextSibling)!==null)break;Ve=we,we=Ve.parentNode}Ve=De}u=k===-1||ie===-1?null:{start:k,end:ie}}else u=null}u=u||{start:0,end:0}}else u=null;for(Pv={focusedElem:i,selectionRange:u},_g=!1,ri=r;ri!==null;)if(r=ri,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,ri=i;else for(;ri!==null;){switch(r=ri,E=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(u=0;u title"))),ya(E,h,u),E[nn]=i,be(E),h=E;break e;case"link":var L=y_("link","href",b).get(h+(u.href||""));if(L){for(var k=0;k Wn&&(L=Wn,Wn=jt,jt=L);var me=Zh(k,jt),re=Zh(k,Wn);if(me&&re&&(De.rangeCount!==1||De.anchorNode!==me.node||De.anchorOffset!==me.offset||De.focusNode!==re.node||De.focusOffset!==re.offset)){var _e=Ve.createRange();_e.setStart(me.node,me.offset),De.removeAllRanges(),jt>Wn?(De.addRange(_e),De.extend(re.node,re.offset)):(_e.setEnd(re.node,re.offset),De.addRange(_e))}}}}for(Ve=[],De=k;De=De.parentNode;)De.nodeType===1&&Ve.push({element:De,left:De.scrollLeft,top:De.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k u?32:u,V.T=null,u=Ml,Ml=null;var E=Vs,L=Ms;if(ti=0,os=Vs=null,Ms=0,(vn&6)!==0)throw Error(n(331));var k=vn;if(vn|=4,Al(E.current),ei(E,E.current,L,u),vn=k,Gp(0,!1),Ye&&typeof Ye.onPostCommitFiberRoot=="function")try{Ye.onPostCommitFiberRoot(je,E)}catch{}return!0}finally{$.p=b,V.T=h,Gr(i,r)}}function k1(i,r,u){r=Ta(u,r),r=jp(i.stateNode,r,2),i=Ur(i,r,2),i!==null&&($n(i,2),zo(i))}function Vn(i,r,u){if(i.tag===3)k1(i,i,u);else for(;r!==null;){if(r.tag===3){k1(r,i,u);break}else if(r.tag===1){var h=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(pr===null||!pr.has(h))){i=Ta(u,i),u=pc(2),h=Ur(r,u,2),h!==null&&(Na(u,h,r,i),$n(h,2),zo(h));break}}r=r.return}}function Ev(i,r,u){var h=i.pingCache;if(h===null){h=i.pingCache=new Ed;var b=new Set;h.set(r,b)}else b=h.get(r),b===void 0&&(b=new Set,h.set(r,b));b.has(u)||(Fn=!0,b.add(u),i=Mw.bind(null,i,r,u),r.then(i,i))}function Mw(i,r,u){var h=i.pingCache;h!==null&&h.delete(r),i.pingedLanes|=i.suspendedLanes&u,i.warmLanes&=~u,On===i&&(pn&u)===u&&(Un===4||Un===3&&(pn&62914560)===pn&&300>F()-kr?(vn&2)===0&&ge(i,0):Hs|=u,ss===pn&&(ss=0)),zo(i)}function V1(i,r){r===0&&(r=ln()),i=yo(i,r),i!==null&&($n(i,r),zo(i))}function Ew(i){var r=i.memoizedState,u=0;r!==null&&(u=r.retryLane),V1(i,u)}function ww(i,r){var u=0;switch(i.tag){case 31:case 13:var h=i.stateNode,b=i.memoizedState;b!==null&&(u=b.retryLane);break;case 19:h=i.stateNode;break;case 22:h=i.stateNode._retryCache;break;default:throw Error(n(314))}h!==null&&h.delete(r),V1(i,u)}function Tw(i,r){return ot(i,r)}var ug=null,Cd=null,wv=!1,fg=!1,Tv=!1,Ac=0;function zo(i){i!==Cd&&i.next===null&&(Cd===null?ug=Cd=i:Cd=Cd.next=i),fg=!0,wv||(wv=!0,Rw())}function Gp(i,r){if(!Tv&&fg){Tv=!0;do for(var u=!1,h=ug;h!==null;){if(i!==0){var b=h.pendingLanes;if(b===0)var E=0;else{var L=h.suspendedLanes,k=h.pingedLanes;E=(1<<31-te(42|i)+1)-1,E&=b&~(L&~k),E=E&201326741?E&201326741|1:E?E|2:0}E!==0&&(u=!0,Y1(h,E))}else E=pn,E=Ie(h,h===On?E:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(E&3)===0||ft(h,E)||(u=!0,Y1(h,E));h=h.next}while(u);Tv=!1}}function Cw(){G1()}function G1(){fg=wv=!1;var i=0;Ac!==0&&Fw()&&(i=Ac);for(var r=F(),u=null,h=ug;h!==null;){var b=h.next,E=X1(h,r);E===0?(h.next=null,u===null?ug=b:u.next=b,b===null&&(Cd=u)):(u=h,(i!==0||(E&3)!==0)&&(fg=!0)),h=b}ti!==0&&ti!==5||Gp(i),Ac!==0&&(Ac=0)}function X1(i,r){for(var u=i.suspendedLanes,h=i.pingedLanes,b=i.expirationTimes,E=i.pendingLanes&-62914561;0 k)break;var Le=ie.transferSize,Ve=ie.initiatorType;Le&&t_(Ve)&&(ie=ie.responseEnd,L+=Le*(ie "u"?null:document;function h_(i,r,u){var h=Rd;if(h&&typeof r=="string"&&r){var b=Hn(r);b='link[rel="'+i+'"][href="'+b+'"]',typeof u=="string"&&(b+='[crossorigin="'+u+'"]'),d_.has(b)||(d_.add(b),i={rel:i,crossOrigin:u,href:r},h.querySelector(b)===null&&(r=h.createElement("link"),ya(r,"link",i),be(r),h.head.appendChild(r)))}}function Ww(i){Cl.D(i),h_("dns-prefetch",i,null)}function Zw(i,r){Cl.C(i,r),h_("preconnect",i,r)}function Kw(i,r,u){Cl.L(i,r,u);var h=Rd;if(h&&i&&r){var b='link[rel="preload"][as="'+Hn(r)+'"]';r==="image"&&u&&u.imageSrcSet?(b+='[imagesrcset="'+Hn(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(b+='[imagesizes="'+Hn(u.imageSizes)+'"]')):b+='[href="'+Hn(i)+'"]';var E=b;switch(r){case"style":E=Dd(i);break;case"script":E=Nd(i)}gr.has(E)||(i=x({rel:"preload",href:r==="image"&&u&&u.imageSrcSet?void 0:i,as:r},u),gr.set(E,i),h.querySelector(b)!==null||r==="style"&&h.querySelector(Wp(E))||r==="script"&&h.querySelector(Zp(E))||(r=h.createElement("link"),ya(r,"link",i),be(r),h.head.appendChild(r)))}}function Qw(i,r){Cl.m(i,r);var u=Rd;if(u&&i){var h=r&&typeof r.as=="string"?r.as:"script",b='link[rel="modulepreload"][as="'+Hn(h)+'"][href="'+Hn(i)+'"]',E=b;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":E=Nd(i)}if(!gr.has(E)&&(i=x({rel:"modulepreload",href:i},r),gr.set(E,i),u.querySelector(b)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(Zp(E)))return}h=u.createElement("link"),ya(h,"link",i),be(h),u.head.appendChild(h)}}}function Jw(i,r,u){Cl.S(i,r,u);var h=Rd;if(h&&i){var b=Ee(h).hoistableStyles,E=Dd(i);r=r||"default";var L=b.get(E);if(!L){var k={loading:0,preload:null};if(L=h.querySelector(Wp(E)))k.loading=5;else{i=x({rel:"stylesheet",href:i,"data-precedence":r},u),(u=gr.get(E))&&Vv(i,u);var ie=L=h.createElement("link");be(ie),ya(ie,"link",i),ie._p=new Promise(function(Se,Le){ie.onload=Se,ie.onerror=Le}),ie.addEventListener("load",function(){k.loading|=1}),ie.addEventListener("error",function(){k.loading|=2}),k.loading|=4,gg(L,r,h)}L={type:"stylesheet",instance:L,count:1,state:k},b.set(E,L)}}}function $w(i,r){Cl.X(i,r);var u=Rd;if(u&&i){var h=Ee(u).hoistableScripts,b=Nd(i),E=h.get(b);E||(E=u.querySelector(Zp(b)),E||(i=x({src:i,async:!0},r),(r=gr.get(b))&&Gv(i,r),E=u.createElement("script"),be(E),ya(E,"link",i),u.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},h.set(b,E))}}function eT(i,r){Cl.M(i,r);var u=Rd;if(u&&i){var h=Ee(u).hoistableScripts,b=Nd(i),E=h.get(b);E||(E=u.querySelector(Zp(b)),E||(i=x({src:i,async:!0,type:"module"},r),(r=gr.get(b))&&Gv(i,r),E=u.createElement("script"),be(E),ya(E,"link",i),u.head.appendChild(E)),E={type:"script",instance:E,count:1,state:null},h.set(b,E))}}function p_(i,r,u,h){var b=(b=le.current)?mg(b):null;if(!b)throw Error(n(446));switch(i){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(r=Dd(u.href),u=Ee(b).hoistableStyles,h=u.get(r),h||(h={type:"style",instance:null,count:0,state:null},u.set(r,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){i=Dd(u.href);var E=Ee(b).hoistableStyles,L=E.get(i);if(L||(b=b.ownerDocument||b,L={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},E.set(i,L),(E=b.querySelector(Wp(i)))&&!E._p&&(L.instance=E,L.state.loading=5),gr.has(i)||(u={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},gr.set(i,u),E||tT(b,i,u,L.state))),r&&h===null)throw Error(n(528,""));return L}if(r&&h!==null)throw Error(n(529,""));return null;case"script":return r=u.async,u=u.src,typeof u=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Nd(u),u=Ee(b).hoistableScripts,h=u.get(r),h||(h={type:"script",instance:null,count:0,state:null},u.set(r,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,i))}}function Dd(i){return'href="'+Hn(i)+'"'}function Wp(i){return'link[rel="stylesheet"]['+i+"]"}function m_(i){return x({},i,{"data-precedence":i.precedence,precedence:null})}function tT(i,r,u,h){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?h.loading=1:(r=i.createElement("link"),h.preload=r,r.addEventListener("load",function(){return h.loading|=1}),r.addEventListener("error",function(){return h.loading|=2}),ya(r,"link",u),be(r),i.head.appendChild(r))}function Nd(i){return'[src="'+Hn(i)+'"]'}function Zp(i){return"script[async]"+i}function g_(i,r,u){if(r.count++,r.instance===null)switch(r.type){case"style":var h=i.querySelector('style[data-href~="'+Hn(u.href)+'"]');if(h)return r.instance=h,be(h),h;var b=x({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return h=(i.ownerDocument||i).createElement("style"),be(h),ya(h,"style",b),gg(h,u.precedence,i),r.instance=h;case"stylesheet":b=Dd(u.href);var E=i.querySelector(Wp(b));if(E)return r.state.loading|=4,r.instance=E,be(E),E;h=m_(u),(b=gr.get(b))&&Vv(h,b),E=(i.ownerDocument||i).createElement("link"),be(E);var L=E;return L._p=new Promise(function(k,ie){L.onload=k,L.onerror=ie}),ya(E,"link",h),r.state.loading|=4,gg(E,u.precedence,i),r.instance=E;case"script":return E=Nd(u.src),(b=i.querySelector(Zp(E)))?(r.instance=b,be(b),b):(h=u,(b=gr.get(E))&&(h=x({},u),Gv(h,b)),i=i.ownerDocument||i,b=i.createElement("script"),be(b),ya(b,"link",h),i.head.appendChild(b),r.instance=b);case"void":return null;default:throw Error(n(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(h=r.instance,r.state.loading|=4,gg(h,u.precedence,i));return r.instance}function gg(i,r,u){for(var h=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=h.length?h[h.length-1]:null,E=b,L=0;L title"):null)}function nT(i,r,u){if(u===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function v_(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function iT(i,r,u,h){if(u.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var b=Dd(h.href),E=r.querySelector(Wp(b));if(E){r=E._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=xg.bind(i),r.then(i,i)),u.state.loading|=4,u.instance=E,be(E);return}E=r.ownerDocument||r,h=m_(h),(b=gr.get(b))&&Vv(h,b),E=E.createElement("link"),be(E);var L=E;L._p=new Promise(function(k,ie){L.onload=k,L.onerror=ie}),ya(E,"link",h),u.instance=E}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(u,r),(r=u.state.preload)&&(u.state.loading&3)===0&&(i.count++,u=xg.bind(i),r.addEventListener("load",u),r.addEventListener("error",u))}}var Xv=0;function aT(i,r){return i.stylesheets&&i.count===0&&bg(i,i.stylesheets),0 Xv?50:800)+r);return i.unsuspend=u,function(){i.unsuspend=null,clearTimeout(h),clearTimeout(b)}}:null}function xg(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)bg(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var vg=null;function bg(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,vg=new Map,r.forEach(sT,i),vg=null,xg.call(i))}function sT(i,r){if(!(r.state.loading&4)){var u=vg.get(i);if(u)var h=u.get(null);else{u=new Map,vg.set(i,u);for(var b=i.querySelectorAll("link[data-precedence],style[data-precedence]"),E=0;E "u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),e2.exports=AT(),e2.exports}var gA=MT();const yA=Q.createContext(null),ET=({children:a})=>{const[e,t]=Q.useState(!1),[n,s]=Q.useState(null),[o,f]=Q.useState(0),d=()=>f(m=>m+1),p=Q.useMemo(()=>({cameraLockedOnPlanet:e,setCameraLockedOnPlanet:t,activePlanetId:n,setActivePlanetId:s,homeRecenterToken:o,requestHomeRecenter:d}),[e,n,o]);return R.jsx(yA.Provider,{value:p,children:a})},Rx=()=>{const a=Q.useContext(yA);if(!a)throw new Error("usePlanetUI must be used within PlanetUIProvider");return a},xA=Q.createContext(null),wT=({children:a})=>{const[e,t]=Q.useState(!1),[n,s]=Q.useState(!0),[o,f]=Q.useState(!1),[d,p]=Q.useState(!0),[m,y]=Q.useState(!1),[x,v]=Q.useState("low"),[S,M]=Q.useState(!0),[T,w]=Q.useState("off"),[A,D]=Q.useState(!1),N=Q.useMemo(()=>({paused:e,setPaused:t,togglePaused:()=>t(U=>!U),showOrbits:n,setShowOrbits:s,toggleShowOrbits:()=>s(U=>!U),settingsOpen:o,setSettingsOpen:f,toggleSettingsOpen:()=>f(U=>!U),shadowsEnabled:d,setShadowsEnabled:p,toggleShadowsEnabled:()=>p(U=>!U),debugEnabled:m,setDebugEnabled:y,toggleDebugEnabled:()=>y(U=>!U),quality:x,setQuality:v,toggleQuality:()=>v(U=>U==="low"?"medium":U==="medium"?"high":"low"),throttlePhysics:T,setThrottlePhysics:w,toggleThrottlePhysics:()=>w(U=>U==="off"?"light":U==="light"?"aggressive":"off"),domHeavyActive:A,setDomHeavyActive:D,showMoons:S,setShowMoons:M,toggleShowMoons:()=>M(U=>!U)}),[e,n,o,d,m,x,S,T,A]);return R.jsx(xA.Provider,{value:N,children:a})},eo=()=>{const a=Q.useContext(xA);if(!a)throw new Error("useSettings must be used within a SettingsProvider");return a},vA=Q.createContext(null),TT=({children:a,measurementId:e})=>{const t=(...v)=>{typeof window<"u"&&typeof window.gtag=="function"&&window.gtag(...v)},n=Q.useCallback(v=>{t("event","navigate",{destination:v})},[]),s=Q.useCallback(v=>{v&&t("event","select_planet",{planet_id:v})},[]),o=Q.useCallback((v,S)=>{t("event","open_overlay",{type:v,id:S})},[]),f=Q.useCallback((v,S)=>{t("event","close_overlay",{type:v,id:S})},[]),d=Q.useCallback((v,S)=>{t("event","external_click",{platform:v,url:S})},[]),p=Q.useCallback((v,S)=>{t("event","setting_change",{setting:v,value:String(S)})},[]),m=Q.useCallback((v,S)=>{e&&t("config",e,{page_path:v,page_title:S||document.title})},[e]),y=Q.useCallback((v,S={})=>{e&&t("event",v,S)},[e]),x=Q.useMemo(()=>({trackPageView:m,trackEvent:y,trackNavigation:n,trackPlanetSelect:s,trackOverlayOpen:o,trackOverlayClose:f,trackExternalLink:d,trackSettingToggle:p}),[m,y,n,s,o,f,d,p]);return R.jsx(vA.Provider,{value:x,children:a})},bf=()=>{const a=Q.useContext(vA);if(!a)throw new Error("useGTag must be used within a GTagProvider");return a};var a2={exports:{}},Rl={};var V_;function CT(){return V_||(V_=1,Rl.ConcurrentRoot=1,Rl.ContinuousEventPriority=8,Rl.DefaultEventPriority=32,Rl.DiscreteEventPriority=2,Rl.IdleEventPriority=268435456,Rl.LegacyRoot=0,Rl.NoEventPriority=0),Rl}var G_;function RT(){return G_||(G_=1,a2.exports=CT()),a2.exports}var Cy=RT();const _h="181",af={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},sf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},bA=0,mb=1,_A=2,DT=3,SA=0,Dx=1,v0=2,Zr=3,Hl=0,Ma=1,Qr=2,Go=0,df=1,Uy=2,gb=3,yb=4,AA=5,Ic=100,MA=101,EA=102,wA=103,TA=104,CA=200,RA=201,DA=202,NA=203,Ly=204,zy=205,OA=206,UA=207,LA=208,zA=209,PA=210,BA=211,IA=212,FA=213,jA=214,Py=0,By=1,Iy=2,yf=3,Fy=4,jy=5,Hy=6,ky=7,Z0=0,HA=1,kA=2,Xo=0,VA=1,GA=2,XA=3,Hb=4,qA=5,YA=6,WA=7,xb="attached",ZA="detached",Nx=300,kl=301,Hc=302,D0=303,N0=304,Sh=306,O0=1e3,Aa=1001,U0=1002,Ea=1003,kb=1004,NT=1004,ih=1005,OT=1005,Ui=1006,b0=1007,UT=1007,ko=1008,LT=1008,xr=1009,Vb=1010,Gb=1011,lh=1012,Ox=1013,Vl=1014,Rs=1015,_f=1016,Ux=1017,Lx=1018,ch=1020,Xb=35902,qb=35899,Yb=1021,Wb=1022,Ha=1023,uh=1026,fh=1027,zx=1028,K0=1029,Px=1030,Bx=1031,zT=1032,Ix=1033,_0=33776,S0=33777,A0=33778,M0=33779,Vy=35840,Gy=35841,Xy=35842,qy=35843,Yy=36196,Wy=37492,Zy=37496,Ky=37808,Qy=37809,Jy=37810,$y=37811,ex=37812,tx=37813,nx=37814,ix=37815,ax=37816,sx=37817,rx=37818,ox=37819,lx=37820,cx=37821,ux=36492,fx=36494,dx=36495,hx=36283,px=36284,mx=36285,gx=36286,KA=2200,QA=2201,JA=2202,L0=2300,yx=2301,Ry=2302,lf=2400,cf=2401,z0=2402,Fx=2500,Zb=2501,PT=0,BT=1,IT=2,$A=3200,eM=3201,FT=3202,jT=3203,Xc=0,tM=1,Il="",_a="srgb",kc="srgb-linear",P0="linear",Gn="srgb",HT=0,rf=7680,kT=7681,VT=7682,GT=7683,XT=34055,qT=34056,YT=5386,WT=512,ZT=513,KT=514,QT=515,JT=516,$T=517,eC=518,vb=519,nM=512,iM=513,aM=514,Kb=515,sM=516,rM=517,oM=518,lM=519,B0=35044,hf=35048,tC=35040,nC=35045,iC=35049,aC=35041,sC=35046,rC=35050,oC=35042,lC="100",bb="300 es",Ws=2e3,dh=2001,cC={COMPUTE:"compute",RENDER:"render"},uC={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},fC={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function cM(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}const dC={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ah(a,e){return new dC[a](e)}function I0(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function uM(){const a=I0("canvas");return a.style.display="block",a}const X_={};let Vc=null;function hC(a){Vc=a}function pC(){return Vc}function F0(...a){const e="THREE."+a.shift();Vc?Vc("log",e,...a):console.log(e,...a)}function mt(...a){const e="THREE."+a.shift();Vc?Vc("warn",e,...a):console.warn(e,...a)}function Yt(...a){const e="THREE."+a.shift();Vc?Vc("error",e,...a):console.error(e,...a)}function hh(...a){const e=a.join(" ");e in X_||(X_[e]=!0,mt(...a))}function mC(a,e,t){return new Promise(function(n,s){function o(){switch(a.clientWaitSync(e,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:s();break;case a.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}let Zo=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const o=s.indexOf(t);o!==-1&&s.splice(o,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let o=0,f=s.length;o >8&255]+Ia[a>>16&255]+Ia[a>>24&255]+"-"+Ia[e&255]+Ia[e>>8&255]+"-"+Ia[e>>16&15|64]+Ia[e>>24&255]+"-"+Ia[t&63|128]+Ia[t>>8&255]+"-"+Ia[t>>16&255]+Ia[t>>24&255]+Ia[n&255]+Ia[n>>8&255]+Ia[n>>16&255]+Ia[n>>24&255]).toLowerCase()}function Xt(a,e,t){return Math.max(e,Math.min(t,a))}function Qb(a,e){return(a%e+e)%e}function gC(a,e,t,n,s){return n+(a-e)*(s-n)/(t-e)}function yC(a,e,t){return a!==e?(t-a)/(e-a):0}function E0(a,e,t){return(1-t)*a+t*e}function xC(a,e,t,n){return E0(a,e,1-Math.exp(-t*n))}function vC(a,e=1){return e-Math.abs(Qb(a,e*2)-e)}function bC(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function _C(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function SC(a,e){return a+Math.floor(Math.random()*(e-a+1))}function AC(a,e){return a+Math.random()*(e-a)}function MC(a){return a*(.5-Math.random())}function EC(a){a!==void 0&&(q_=a);let e=q_+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function wC(a){return a*pf}function TC(a){return a*ph}function CC(a){return(a&a-1)===0&&a!==0}function RC(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function DC(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function NC(a,e,t,n,s){const o=Math.cos,f=Math.sin,d=o(t/2),p=f(t/2),m=o((e+n)/2),y=f((e+n)/2),x=o((e-n)/2),v=f((e-n)/2),S=o((n-e)/2),M=f((n-e)/2);switch(s){case"XYX":a.set(d*y,p*x,p*v,d*m);break;case"YZY":a.set(p*v,d*y,p*x,d*m);break;case"ZXZ":a.set(p*x,p*v,d*y,d*m);break;case"XZX":a.set(d*y,p*M,p*S,d*m);break;case"YXY":a.set(p*S,d*y,p*M,d*m);break;case"ZYZ":a.set(p*M,p*S,d*y,d*m);break;default:mt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function fs(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function an(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}const Q0={DEG2RAD:pf,RAD2DEG:ph,generateUUID:Ks,clamp:Xt,euclideanModulo:Qb,mapLinear:gC,inverseLerp:yC,lerp:E0,damp:xC,pingpong:vC,smoothstep:bC,smootherstep:_C,randInt:SC,randFloat:AC,randFloatSpread:MC,seededRandom:EC,degToRad:wC,radToDeg:TC,isPowerOfTwo:CC,ceilPowerOfTwo:RC,floorPowerOfTwo:DC,setQuaternionFromProperEuler:NC,normalize:an,denormalize:fs};class ze{constructor(e=0,t=0){ze.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Xt(this.x,e.x,t.x),this.y=Xt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Xt(this.x,e,t),this.y=Xt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Xt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),o=this.x-e.x,f=this.y-e.y;return this.x=o*n-f*s+e.x,this.y=o*s+f*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ka{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,o,f,d){let p=n[s+0],m=n[s+1],y=n[s+2],x=n[s+3],v=o[f+0],S=o[f+1],M=o[f+2],T=o[f+3];if(d<=0){e[t+0]=p,e[t+1]=m,e[t+2]=y,e[t+3]=x;return}if(d>=1){e[t+0]=v,e[t+1]=S,e[t+2]=M,e[t+3]=T;return}if(x!==T||p!==v||m!==S||y!==M){let w=p*v+m*S+y*M+x*T;w<0&&(v=-v,S=-S,M=-M,T=-T,w=-w);let A=1-d;if(w<.9995){const D=Math.acos(w),N=Math.sin(D);A=Math.sin(A*D)/N,d=Math.sin(d*D)/N,p=p*A+v*d,m=m*A+S*d,y=y*A+M*d,x=x*A+T*d}else{p=p*A+v*d,m=m*A+S*d,y=y*A+M*d,x=x*A+T*d;const D=1/Math.sqrt(p*p+m*m+y*y+x*x);p*=D,m*=D,y*=D,x*=D}}e[t]=p,e[t+1]=m,e[t+2]=y,e[t+3]=x}static multiplyQuaternionsFlat(e,t,n,s,o,f){const d=n[s],p=n[s+1],m=n[s+2],y=n[s+3],x=o[f],v=o[f+1],S=o[f+2],M=o[f+3];return e[t]=d*M+y*x+p*S-m*v,e[t+1]=p*M+y*v+m*x-d*S,e[t+2]=m*M+y*S+d*v-p*x,e[t+3]=y*M-d*x-p*v-m*S,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,o=e._z,f=e._order,d=Math.cos,p=Math.sin,m=d(n/2),y=d(s/2),x=d(o/2),v=p(n/2),S=p(s/2),M=p(o/2);switch(f){case"XYZ":this._x=v*y*x+m*S*M,this._y=m*S*x-v*y*M,this._z=m*y*M+v*S*x,this._w=m*y*x-v*S*M;break;case"YXZ":this._x=v*y*x+m*S*M,this._y=m*S*x-v*y*M,this._z=m*y*M-v*S*x,this._w=m*y*x+v*S*M;break;case"ZXY":this._x=v*y*x-m*S*M,this._y=m*S*x+v*y*M,this._z=m*y*M+v*S*x,this._w=m*y*x-v*S*M;break;case"ZYX":this._x=v*y*x-m*S*M,this._y=m*S*x+v*y*M,this._z=m*y*M-v*S*x,this._w=m*y*x+v*S*M;break;case"YZX":this._x=v*y*x+m*S*M,this._y=m*S*x+v*y*M,this._z=m*y*M-v*S*x,this._w=m*y*x-v*S*M;break;case"XZY":this._x=v*y*x-m*S*M,this._y=m*S*x-v*y*M,this._z=m*y*M+v*S*x,this._w=m*y*x+v*S*M;break;default:mt("Quaternion: .setFromEuler() encountered an unknown order: "+f)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],o=t[8],f=t[1],d=t[5],p=t[9],m=t[2],y=t[6],x=t[10],v=n+d+x;if(v>0){const S=.5/Math.sqrt(v+1);this._w=.25/S,this._x=(y-p)*S,this._y=(o-m)*S,this._z=(f-s)*S}else if(n>d&&n>x){const S=2*Math.sqrt(1+n-d-x);this._w=(y-p)/S,this._x=.25*S,this._y=(s+f)/S,this._z=(o+m)/S}else if(d>x){const S=2*Math.sqrt(1+d-n-x);this._w=(o-m)/S,this._x=(s+f)/S,this._y=.25*S,this._z=(p+y)/S}else{const S=2*Math.sqrt(1+x-n-d);this._w=(f-s)/S,this._x=(o+m)/S,this._y=(p+y)/S,this._z=.25*S}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Xt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,o=e._z,f=e._w,d=t._x,p=t._y,m=t._z,y=t._w;return this._x=n*y+f*d+s*m-o*p,this._y=s*y+f*p+o*d-n*m,this._z=o*y+f*m+n*p-s*d,this._w=f*y-n*d-s*p-o*m,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,s=e._y,o=e._z,f=e._w,d=this.dot(e);d<0&&(n=-n,s=-s,o=-o,f=-f,d=-d);let p=1-t;if(d<.9995){const m=Math.acos(d),y=Math.sin(m);p=Math.sin(p*m)/y,t=Math.sin(t*m)/y,this._x=this._x*p+n*t,this._y=this._y*p+s*t,this._z=this._z*p+o*t,this._w=this._w*p+f*t,this._onChangeCallback()}else this._x=this._x*p+n*t,this._y=this._y*p+s*t,this._z=this._z*p+o*t,this._w=this._w*p+f*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class X{constructor(e=0,t=0,n=0){X.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Y_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Y_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*s,this.y=o[1]*t+o[4]*n+o[7]*s,this.z=o[2]*t+o[5]*n+o[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,o=e.elements,f=1/(o[3]*t+o[7]*n+o[11]*s+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*s+o[12])*f,this.y=(o[1]*t+o[5]*n+o[9]*s+o[13])*f,this.z=(o[2]*t+o[6]*n+o[10]*s+o[14])*f,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,o=e.x,f=e.y,d=e.z,p=e.w,m=2*(f*s-d*n),y=2*(d*t-o*s),x=2*(o*n-f*t);return this.x=t+p*m+f*x-d*y,this.y=n+p*y+d*m-o*x,this.z=s+p*x+o*y-f*m,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s,this.y=o[1]*t+o[5]*n+o[9]*s,this.z=o[2]*t+o[6]*n+o[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Xt(this.x,e.x,t.x),this.y=Xt(this.y,e.y,t.y),this.z=Xt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Xt(this.x,e,t),this.y=Xt(this.y,e,t),this.z=Xt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,o=e.z,f=t.x,d=t.y,p=t.z;return this.x=s*p-o*d,this.y=o*f-n*p,this.z=n*d-s*f,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return s2.copy(this).projectOnVector(e),this.sub(s2)}reflect(e){return this.sub(s2.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Xt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const s2=new X,Y_=new ka;class en{constructor(e,t,n,s,o,f,d,p,m){en.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,o,f,d,p,m)}set(e,t,n,s,o,f,d,p,m){const y=this.elements;return y[0]=e,y[1]=s,y[2]=d,y[3]=t,y[4]=o,y[5]=p,y[6]=n,y[7]=f,y[8]=m,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,f=n[0],d=n[3],p=n[6],m=n[1],y=n[4],x=n[7],v=n[2],S=n[5],M=n[8],T=s[0],w=s[3],A=s[6],D=s[1],N=s[4],U=s[7],I=s[2],z=s[5],j=s[8];return o[0]=f*T+d*D+p*I,o[3]=f*w+d*N+p*z,o[6]=f*A+d*U+p*j,o[1]=m*T+y*D+x*I,o[4]=m*w+y*N+x*z,o[7]=m*A+y*U+x*j,o[2]=v*T+S*D+M*I,o[5]=v*w+S*N+M*z,o[8]=v*A+S*U+M*j,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],f=e[4],d=e[5],p=e[6],m=e[7],y=e[8];return t*f*y-t*d*m-n*o*y+n*d*p+s*o*m-s*f*p}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],f=e[4],d=e[5],p=e[6],m=e[7],y=e[8],x=y*f-d*m,v=d*p-y*o,S=m*o-f*p,M=t*x+n*v+s*S;if(M===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/M;return e[0]=x*T,e[1]=(s*m-y*n)*T,e[2]=(d*n-s*f)*T,e[3]=v*T,e[4]=(y*t-s*p)*T,e[5]=(s*o-d*t)*T,e[6]=S*T,e[7]=(n*p-m*t)*T,e[8]=(f*t-n*o)*T,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,o,f,d){const p=Math.cos(o),m=Math.sin(o);return this.set(n*p,n*m,-n*(p*f+m*d)+f+e,-s*m,s*p,-s*(-m*f+p*d)+d+t,0,0,1),this}scale(e,t){return this.premultiply(r2.makeScale(e,t)),this}rotate(e){return this.premultiply(r2.makeRotation(-e)),this}translate(e,t){return this.premultiply(r2.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const r2=new en,W_=new en().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Z_=new en().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function OC(){const a={enabled:!0,workingColorSpace:kc,spaces:{},convert:function(s,o,f){return this.enabled===!1||o===f||!o||!f||(this.spaces[o].transfer===Gn&&(s.r=jl(s.r),s.g=jl(s.g),s.b=jl(s.b)),this.spaces[o].primaries!==this.spaces[f].primaries&&(s.applyMatrix3(this.spaces[o].toXYZ),s.applyMatrix3(this.spaces[f].fromXYZ)),this.spaces[f].transfer===Gn&&(s.r=rh(s.r),s.g=rh(s.g),s.b=rh(s.b))),s},workingToColorSpace:function(s,o){return this.convert(s,this.workingColorSpace,o)},colorSpaceToWorking:function(s,o){return this.convert(s,o,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Il?P0:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,o=this.workingColorSpace){return s.fromArray(this.spaces[o].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,o,f){return s.copy(this.spaces[o].toXYZ).multiply(this.spaces[f].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,o){return hh("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(s,o)},toWorkingColorSpace:function(s,o){return hh("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(s,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return a.define({[kc]:{primaries:e,whitePoint:n,transfer:P0,toXYZ:W_,fromXYZ:Z_,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:_a},outputColorSpaceConfig:{drawingBufferColorSpace:_a}},[_a]:{primaries:e,whitePoint:n,transfer:Gn,toXYZ:W_,fromXYZ:Z_,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:_a}}}),a}const wn=OC();function jl(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function rh(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let Ud;class fM{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Ud===void 0&&(Ud=I0("canvas")),Ud.width=e.width,Ud.height=e.height;const s=Ud.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Ud}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=I0("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),o=s.data;for(let f=0;f 1),this.pmremVersion=0}get width(){return this.source.getSize(l2).x}get height(){return this.source.getSize(l2).y}get depth(){return this.source.getSize(l2).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){mt(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){mt(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Nx)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case O0:e.x=e.x-Math.floor(e.x);break;case Aa:e.x=e.x<0?0:1;break;case U0:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case O0:e.y=e.y-Math.floor(e.y);break;case Aa:e.y=e.y<0?0:1;break;case U0:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}ui.DEFAULT_IMAGE=null;ui.DEFAULT_MAPPING=Nx;ui.DEFAULT_ANISOTROPY=1;class un{constructor(e=0,t=0,n=0,s=1){un.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,o=this.w,f=e.elements;return this.x=f[0]*t+f[4]*n+f[8]*s+f[12]*o,this.y=f[1]*t+f[5]*n+f[9]*s+f[13]*o,this.z=f[2]*t+f[6]*n+f[10]*s+f[14]*o,this.w=f[3]*t+f[7]*n+f[11]*s+f[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,o;const p=e.elements,m=p[0],y=p[4],x=p[8],v=p[1],S=p[5],M=p[9],T=p[2],w=p[6],A=p[10];if(Math.abs(y-v)<.01&&Math.abs(x-T)<.01&&Math.abs(M-w)<.01){if(Math.abs(y+v)<.1&&Math.abs(x+T)<.1&&Math.abs(M+w)<.1&&Math.abs(m+S+A-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const N=(m+1)/2,U=(S+1)/2,I=(A+1)/2,z=(y+v)/4,j=(x+T)/4,q=(M+w)/4;return N>U&&N>I?N<.01?(n=0,s=.707106781,o=.707106781):(n=Math.sqrt(N),s=z/n,o=j/n):U>I?U<.01?(n=.707106781,s=0,o=.707106781):(s=Math.sqrt(U),n=z/s,o=q/s):I<.01?(n=.707106781,s=.707106781,o=0):(o=Math.sqrt(I),n=j/o,s=q/o),this.set(n,s,o,t),this}let D=Math.sqrt((w-M)*(w-M)+(x-T)*(x-T)+(v-y)*(v-y));return Math.abs(D)<.001&&(D=1),this.x=(w-M)/D,this.y=(x-T)/D,this.z=(v-y)/D,this.w=Math.acos((m+S+A-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Xt(this.x,e.x,t.x),this.y=Xt(this.y,e.y,t.y),this.z=Xt(this.z,e.z,t.z),this.w=Xt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Xt(this.x,e,t),this.y=Xt(this.y,e,t),this.z=Xt(this.z,e,t),this.w=Xt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Jb extends Zo{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ui,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new un(0,0,e,t),this.scissorTest=!1,this.viewport=new un(0,0,e,t);const s={width:e,height:t,depth:n.depth},o=new ui(s);this.textures=[];const f=n.count;for(let d=0;d 1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t =this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Xr),Xr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(n0),Rg.subVectors(this.max,n0),Ld.subVectors(e.a,n0),zd.subVectors(e.b,n0),Pd.subVectors(e.c,n0),Dc.subVectors(zd,Ld),Nc.subVectors(Pd,zd),ku.subVectors(Ld,Pd);let t=[0,-Dc.z,Dc.y,0,-Nc.z,Nc.y,0,-ku.z,ku.y,Dc.z,0,-Dc.x,Nc.z,0,-Nc.x,ku.z,0,-ku.x,-Dc.y,Dc.x,0,-Nc.y,Nc.x,0,-ku.y,ku.x,0];return!c2(t,Ld,zd,Pd,Rg)||(t=[1,0,0,0,1,0,0,0,1],!c2(t,Ld,zd,Pd,Rg))?!1:(Dg.crossVectors(Dc,Nc),t=[Dg.x,Dg.y,Dg.z],c2(t,Ld,zd,Pd,Rg))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Xr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Xr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Dl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Dl=[new X,new X,new X,new X,new X,new X,new X,new X],Xr=new X,Cg=new Zi,Ld=new X,zd=new X,Pd=new X,Dc=new X,Nc=new X,ku=new X,n0=new X,Rg=new X,Dg=new X,Vu=new X;function c2(a,e,t,n,s){for(let o=0,f=a.length-3;o<=f;o+=3){Vu.fromArray(a,o);const d=s.x*Math.abs(Vu.x)+s.y*Math.abs(Vu.y)+s.z*Math.abs(Vu.z),p=e.dot(Vu),m=t.dot(Vu),y=n.dot(Vu);if(Math.max(-Math.max(p,m,y),Math.min(p,m,y))>d)return!1}return!0}const BC=new Zi,i0=new X,u2=new X;class Ki{constructor(e=new X,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):BC.setFromPoints(e).getCenter(n);let s=0;for(let o=0,f=e.length;o this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;i0.subVectors(e,this.center);const t=i0.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(i0,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(u2.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(i0.copy(e.center).add(u2)),this.expandByPoint(i0.copy(e.center).sub(u2))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Nl=new X,f2=new X,Ng=new X,Oc=new X,d2=new X,Og=new X,h2=new X;class Sf{constructor(e=new X,t=new X(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Nl)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Nl.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Nl.copy(this.origin).addScaledVector(this.direction,t),Nl.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){f2.copy(e).add(t).multiplyScalar(.5),Ng.copy(t).sub(e).normalize(),Oc.copy(this.origin).sub(f2);const o=e.distanceTo(t)*.5,f=-this.direction.dot(Ng),d=Oc.dot(this.direction),p=-Oc.dot(Ng),m=Oc.lengthSq(),y=Math.abs(1-f*f);let x,v,S,M;if(y>0)if(x=f*p-d,v=f*d-p,M=o*y,x>=0)if(v>=-M)if(v<=M){const T=1/y;x*=T,v*=T,S=x*(x+f*v+2*d)+v*(f*x+v+2*p)+m}else v=o,x=Math.max(0,-(f*v+d)),S=-x*x+v*(v+2*p)+m;else v=-o,x=Math.max(0,-(f*v+d)),S=-x*x+v*(v+2*p)+m;else v<=-M?(x=Math.max(0,-(-f*o+d)),v=x>0?-o:Math.min(Math.max(-o,-p),o),S=-x*x+v*(v+2*p)+m):v<=M?(x=0,v=Math.min(Math.max(-o,-p),o),S=v*(v+2*p)+m):(x=Math.max(0,-(f*o+d)),v=x>0?o:Math.min(Math.max(-o,-p),o),S=-x*x+v*(v+2*p)+m);else v=f>0?-o:o,x=Math.max(0,-(f*v+d)),S=-x*x+v*(v+2*p)+m;return n&&n.copy(this.origin).addScaledVector(this.direction,x),s&&s.copy(f2).addScaledVector(Ng,v),S}intersectSphere(e,t){Nl.subVectors(e.center,this.origin);const n=Nl.dot(this.direction),s=Nl.dot(Nl)-n*n,o=e.radius*e.radius;if(s>o)return null;const f=Math.sqrt(o-s),d=n-f,p=n+f;return p<0?null:d<0?this.at(p,t):this.at(d,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,o,f,d,p;const m=1/this.direction.x,y=1/this.direction.y,x=1/this.direction.z,v=this.origin;return m>=0?(n=(e.min.x-v.x)*m,s=(e.max.x-v.x)*m):(n=(e.max.x-v.x)*m,s=(e.min.x-v.x)*m),y>=0?(o=(e.min.y-v.y)*y,f=(e.max.y-v.y)*y):(o=(e.max.y-v.y)*y,f=(e.min.y-v.y)*y),n>f||o>s||((o>n||isNaN(n))&&(n=o),(f =0?(d=(e.min.z-v.z)*x,p=(e.max.z-v.z)*x):(d=(e.max.z-v.z)*x,p=(e.min.z-v.z)*x),n>p||d>s)||((d>n||n!==n)&&(n=d),(p=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Nl)!==null}intersectTriangle(e,t,n,s,o){d2.subVectors(t,e),Og.subVectors(n,e),h2.crossVectors(d2,Og);let f=this.direction.dot(h2),d;if(f>0){if(s)return null;d=1}else if(f<0)d=-1,f=-f;else return null;Oc.subVectors(this.origin,e);const p=d*this.direction.dot(Og.crossVectors(Oc,Og));if(p<0)return null;const m=d*this.direction.dot(d2.cross(Oc));if(m<0||p+m>f)return null;const y=-d*Oc.dot(h2);return y<0?null:this.at(y/f,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Gt{constructor(e,t,n,s,o,f,d,p,m,y,x,v,S,M,T,w){Gt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,o,f,d,p,m,y,x,v,S,M,T,w)}set(e,t,n,s,o,f,d,p,m,y,x,v,S,M,T,w){const A=this.elements;return A[0]=e,A[4]=t,A[8]=n,A[12]=s,A[1]=o,A[5]=f,A[9]=d,A[13]=p,A[2]=m,A[6]=y,A[10]=x,A[14]=v,A[3]=S,A[7]=M,A[11]=T,A[15]=w,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Gt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,s=1/Bd.setFromMatrixColumn(e,0).length(),o=1/Bd.setFromMatrixColumn(e,1).length(),f=1/Bd.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*f,t[9]=n[9]*f,t[10]=n[10]*f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,o=e.z,f=Math.cos(n),d=Math.sin(n),p=Math.cos(s),m=Math.sin(s),y=Math.cos(o),x=Math.sin(o);if(e.order==="XYZ"){const v=f*y,S=f*x,M=d*y,T=d*x;t[0]=p*y,t[4]=-p*x,t[8]=m,t[1]=S+M*m,t[5]=v-T*m,t[9]=-d*p,t[2]=T-v*m,t[6]=M+S*m,t[10]=f*p}else if(e.order==="YXZ"){const v=p*y,S=p*x,M=m*y,T=m*x;t[0]=v+T*d,t[4]=M*d-S,t[8]=f*m,t[1]=f*x,t[5]=f*y,t[9]=-d,t[2]=S*d-M,t[6]=T+v*d,t[10]=f*p}else if(e.order==="ZXY"){const v=p*y,S=p*x,M=m*y,T=m*x;t[0]=v-T*d,t[4]=-f*x,t[8]=M+S*d,t[1]=S+M*d,t[5]=f*y,t[9]=T-v*d,t[2]=-f*m,t[6]=d,t[10]=f*p}else if(e.order==="ZYX"){const v=f*y,S=f*x,M=d*y,T=d*x;t[0]=p*y,t[4]=M*m-S,t[8]=v*m+T,t[1]=p*x,t[5]=T*m+v,t[9]=S*m-M,t[2]=-m,t[6]=d*p,t[10]=f*p}else if(e.order==="YZX"){const v=f*p,S=f*m,M=d*p,T=d*m;t[0]=p*y,t[4]=T-v*x,t[8]=M*x+S,t[1]=x,t[5]=f*y,t[9]=-d*y,t[2]=-m*y,t[6]=S*x+M,t[10]=v-T*x}else if(e.order==="XZY"){const v=f*p,S=f*m,M=d*p,T=d*m;t[0]=p*y,t[4]=-x,t[8]=m*y,t[1]=v*x+T,t[5]=f*y,t[9]=S*x-M,t[2]=M*x-S,t[6]=d*y,t[10]=T*x+v}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(IC,e,FC)}lookAt(e,t,n){const s=this.elements;return Gs.subVectors(e,t),Gs.lengthSq()===0&&(Gs.z=1),Gs.normalize(),Uc.crossVectors(n,Gs),Uc.lengthSq()===0&&(Math.abs(n.z)===1?Gs.x+=1e-4:Gs.z+=1e-4,Gs.normalize(),Uc.crossVectors(n,Gs)),Uc.normalize(),Ug.crossVectors(Gs,Uc),s[0]=Uc.x,s[4]=Ug.x,s[8]=Gs.x,s[1]=Uc.y,s[5]=Ug.y,s[9]=Gs.y,s[2]=Uc.z,s[6]=Ug.z,s[10]=Gs.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,o=this.elements,f=n[0],d=n[4],p=n[8],m=n[12],y=n[1],x=n[5],v=n[9],S=n[13],M=n[2],T=n[6],w=n[10],A=n[14],D=n[3],N=n[7],U=n[11],I=n[15],z=s[0],j=s[4],q=s[8],B=s[12],P=s[1],W=s[5],se=s[9],ae=s[13],ce=s[2],ue=s[6],V=s[10],$=s[14],J=s[3],he=s[7],ve=s[11],Y=s[15];return o[0]=f*z+d*P+p*ce+m*J,o[4]=f*j+d*W+p*ue+m*he,o[8]=f*q+d*se+p*V+m*ve,o[12]=f*B+d*ae+p*$+m*Y,o[1]=y*z+x*P+v*ce+S*J,o[5]=y*j+x*W+v*ue+S*he,o[9]=y*q+x*se+v*V+S*ve,o[13]=y*B+x*ae+v*$+S*Y,o[2]=M*z+T*P+w*ce+A*J,o[6]=M*j+T*W+w*ue+A*he,o[10]=M*q+T*se+w*V+A*ve,o[14]=M*B+T*ae+w*$+A*Y,o[3]=D*z+N*P+U*ce+I*J,o[7]=D*j+N*W+U*ue+I*he,o[11]=D*q+N*se+U*V+I*ve,o[15]=D*B+N*ae+U*$+I*Y,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],s=e[8],o=e[12],f=e[1],d=e[5],p=e[9],m=e[13],y=e[2],x=e[6],v=e[10],S=e[14],M=e[3],T=e[7],w=e[11],A=e[15];return M*(+o*p*x-s*m*x-o*d*v+n*m*v+s*d*S-n*p*S)+T*(+t*p*S-t*m*v+o*f*v-s*f*S+s*m*y-o*p*y)+w*(+t*m*x-t*d*S-o*f*x+n*f*S+o*d*y-n*m*y)+A*(-s*d*y-t*p*x+t*d*v+s*f*x-n*f*v+n*p*y)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],o=e[3],f=e[4],d=e[5],p=e[6],m=e[7],y=e[8],x=e[9],v=e[10],S=e[11],M=e[12],T=e[13],w=e[14],A=e[15],D=x*w*m-T*v*m+T*p*S-d*w*S-x*p*A+d*v*A,N=M*v*m-y*w*m-M*p*S+f*w*S+y*p*A-f*v*A,U=y*T*m-M*x*m+M*d*S-f*T*S-y*d*A+f*x*A,I=M*x*p-y*T*p-M*d*v+f*T*v+y*d*w-f*x*w,z=t*D+n*N+s*U+o*I;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const j=1/z;return e[0]=D*j,e[1]=(T*v*o-x*w*o-T*s*S+n*w*S+x*s*A-n*v*A)*j,e[2]=(d*w*o-T*p*o+T*s*m-n*w*m-d*s*A+n*p*A)*j,e[3]=(x*p*o-d*v*o-x*s*m+n*v*m+d*s*S-n*p*S)*j,e[4]=N*j,e[5]=(y*w*o-M*v*o+M*s*S-t*w*S-y*s*A+t*v*A)*j,e[6]=(M*p*o-f*w*o-M*s*m+t*w*m+f*s*A-t*p*A)*j,e[7]=(f*v*o-y*p*o+y*s*m-t*v*m-f*s*S+t*p*S)*j,e[8]=U*j,e[9]=(M*x*o-y*T*o-M*n*S+t*T*S+y*n*A-t*x*A)*j,e[10]=(f*T*o-M*d*o+M*n*m-t*T*m-f*n*A+t*d*A)*j,e[11]=(y*d*o-f*x*o-y*n*m+t*x*m+f*n*S-t*d*S)*j,e[12]=I*j,e[13]=(y*T*s-M*x*s+M*n*v-t*T*v-y*n*w+t*x*w)*j,e[14]=(M*d*s-f*T*s-M*n*p+t*T*p+f*n*w-t*d*w)*j,e[15]=(f*x*s-y*d*s+y*n*p-t*x*p-f*n*v+t*d*v)*j,this}scale(e){const t=this.elements,n=e.x,s=e.y,o=e.z;return t[0]*=n,t[4]*=s,t[8]*=o,t[1]*=n,t[5]*=s,t[9]*=o,t[2]*=n,t[6]*=s,t[10]*=o,t[3]*=n,t[7]*=s,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),o=1-n,f=e.x,d=e.y,p=e.z,m=o*f,y=o*d;return this.set(m*f+n,m*d-s*p,m*p+s*d,0,m*d+s*p,y*d+n,y*p-s*f,0,m*p-s*d,y*p+s*f,o*p*p+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,o,f){return this.set(1,n,o,0,e,1,f,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,o=t._x,f=t._y,d=t._z,p=t._w,m=o+o,y=f+f,x=d+d,v=o*m,S=o*y,M=o*x,T=f*y,w=f*x,A=d*x,D=p*m,N=p*y,U=p*x,I=n.x,z=n.y,j=n.z;return s[0]=(1-(T+A))*I,s[1]=(S+U)*I,s[2]=(M-N)*I,s[3]=0,s[4]=(S-U)*z,s[5]=(1-(v+A))*z,s[6]=(w+D)*z,s[7]=0,s[8]=(M+N)*j,s[9]=(w-D)*j,s[10]=(1-(v+T))*j,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;let o=Bd.set(s[0],s[1],s[2]).length();const f=Bd.set(s[4],s[5],s[6]).length(),d=Bd.set(s[8],s[9],s[10]).length();this.determinant()<0&&(o=-o),e.x=s[12],e.y=s[13],e.z=s[14],qr.copy(this);const m=1/o,y=1/f,x=1/d;return qr.elements[0]*=m,qr.elements[1]*=m,qr.elements[2]*=m,qr.elements[4]*=y,qr.elements[5]*=y,qr.elements[6]*=y,qr.elements[8]*=x,qr.elements[9]*=x,qr.elements[10]*=x,t.setFromRotationMatrix(qr),n.x=o,n.y=f,n.z=d,this}makePerspective(e,t,n,s,o,f,d=Ws,p=!1){const m=this.elements,y=2*o/(t-e),x=2*o/(n-s),v=(t+e)/(t-e),S=(n+s)/(n-s);let M,T;if(p)M=o/(f-o),T=f*o/(f-o);else if(d===Ws)M=-(f+o)/(f-o),T=-2*f*o/(f-o);else if(d===dh)M=-f/(f-o),T=-f*o/(f-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+d);return m[0]=y,m[4]=0,m[8]=v,m[12]=0,m[1]=0,m[5]=x,m[9]=S,m[13]=0,m[2]=0,m[6]=0,m[10]=M,m[14]=T,m[3]=0,m[7]=0,m[11]=-1,m[15]=0,this}makeOrthographic(e,t,n,s,o,f,d=Ws,p=!1){const m=this.elements,y=2/(t-e),x=2/(n-s),v=-(t+e)/(t-e),S=-(n+s)/(n-s);let M,T;if(p)M=1/(f-o),T=f/(f-o);else if(d===Ws)M=-2/(f-o),T=-(f+o)/(f-o);else if(d===dh)M=-1/(f-o),T=-o/(f-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+d);return m[0]=y,m[4]=0,m[8]=0,m[12]=v,m[1]=0,m[5]=x,m[9]=0,m[13]=S,m[2]=0,m[6]=0,m[10]=M,m[14]=T,m[3]=0,m[7]=0,m[11]=0,m[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Bd=new X,qr=new Gt,IC=new X(0,0,0),FC=new X(1,1,1),Uc=new X,Ug=new X,Gs=new X,K_=new Gt,Q_=new ka;class ds{constructor(e=0,t=0,n=0,s=ds.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,o=s[0],f=s[4],d=s[8],p=s[1],m=s[5],y=s[9],x=s[2],v=s[6],S=s[10];switch(t){case"XYZ":this._y=Math.asin(Xt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(-y,S),this._z=Math.atan2(-f,o)):(this._x=Math.atan2(v,m),this._z=0);break;case"YXZ":this._x=Math.asin(-Xt(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(d,S),this._z=Math.atan2(p,m)):(this._y=Math.atan2(-x,o),this._z=0);break;case"ZXY":this._x=Math.asin(Xt(v,-1,1)),Math.abs(v)<.9999999?(this._y=Math.atan2(-x,S),this._z=Math.atan2(-f,m)):(this._y=0,this._z=Math.atan2(p,o));break;case"ZYX":this._y=Math.asin(-Xt(x,-1,1)),Math.abs(x)<.9999999?(this._x=Math.atan2(v,S),this._z=Math.atan2(p,o)):(this._x=0,this._z=Math.atan2(-f,m));break;case"YZX":this._z=Math.asin(Xt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(-y,m),this._y=Math.atan2(-x,o)):(this._x=0,this._y=Math.atan2(d,S));break;case"XZY":this._z=Math.asin(-Xt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(v,m),this._y=Math.atan2(d,o)):(this._x=Math.atan2(-y,S),this._y=0);break;default:mt("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return K_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(K_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Q_.setFromEuler(this),this.setFromQuaternion(Q_,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ds.DEFAULT_ORDER="XYZ";class mh{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1< 1){for(let t=0;t 1){for(let n=0;n 0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(d=>({...d,boundingBox:d.boundingBox?d.boundingBox.toJSON():void 0,boundingSphere:d.boundingSphere?d.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(d=>({...d})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function o(d,p){return d[p.uuid]===void 0&&(d[p.uuid]=p.toJSON(e)),p.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=o(e.geometries,this.geometry);const d=this.geometry.parameters;if(d!==void 0&&d.shapes!==void 0){const p=d.shapes;if(Array.isArray(p))for(let m=0,y=p.length;m 0){s.children=[];for(let d=0;d 0){s.animations=[];for(let d=0;d 0&&(n.geometries=d),p.length>0&&(n.materials=p),m.length>0&&(n.textures=m),y.length>0&&(n.images=y),x.length>0&&(n.shapes=x),v.length>0&&(n.skeletons=v),S.length>0&&(n.animations=S),M.length>0&&(n.nodes=M)}return n.object=s,n;function f(d){const p=[];for(const m in d){const y=d[m];delete y.metadata,p.push(y)}return p}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n 0?s.multiplyScalar(1/Math.sqrt(o)):s.set(0,0,0)}static getBarycoord(e,t,n,s,o){Yr.subVectors(s,t),Ul.subVectors(n,t),m2.subVectors(e,t);const f=Yr.dot(Yr),d=Yr.dot(Ul),p=Yr.dot(m2),m=Ul.dot(Ul),y=Ul.dot(m2),x=f*m-d*d;if(x===0)return o.set(0,0,0),null;const v=1/x,S=(m*p-d*y)*v,M=(f*y-d*p)*v;return o.set(1-S-M,M,S)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Ll)===null?!1:Ll.x>=0&&Ll.y>=0&&Ll.x+Ll.y<=1}static getInterpolation(e,t,n,s,o,f,d,p){return this.getBarycoord(e,t,n,s,Ll)===null?(p.x=0,p.y=0,"z"in p&&(p.z=0),"w"in p&&(p.w=0),null):(p.setScalar(0),p.addScaledVector(o,Ll.x),p.addScaledVector(f,Ll.y),p.addScaledVector(d,Ll.z),p)}static getInterpolatedAttribute(e,t,n,s,o,f){return v2.setScalar(0),b2.setScalar(0),_2.setScalar(0),v2.fromBufferAttribute(e,t),b2.fromBufferAttribute(e,n),_2.fromBufferAttribute(e,s),f.setScalar(0),f.addScaledVector(v2,o.x),f.addScaledVector(b2,o.y),f.addScaledVector(_2,o.z),f}static isFrontFacing(e,t,n,s){return Yr.subVectors(n,t),Ul.subVectors(e,t),Yr.cross(Ul).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yr.subVectors(this.c,this.b),Ul.subVectors(this.a,this.b),Yr.cross(Ul).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Cs.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Cs.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,o){return Cs.getInterpolation(e,this.a,this.b,this.c,t,n,s,o)}containsPoint(e){return Cs.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Cs.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,o=this.c;let f,d;jd.subVectors(s,n),Hd.subVectors(o,n),g2.subVectors(e,n);const p=jd.dot(g2),m=Hd.dot(g2);if(p<=0&&m<=0)return t.copy(n);y2.subVectors(e,s);const y=jd.dot(y2),x=Hd.dot(y2);if(y>=0&&x<=y)return t.copy(s);const v=p*x-y*m;if(v<=0&&p>=0&&y<=0)return f=p/(p-y),t.copy(n).addScaledVector(jd,f);x2.subVectors(e,o);const S=jd.dot(x2),M=Hd.dot(x2);if(M>=0&&S<=M)return t.copy(o);const T=S*m-p*M;if(T<=0&&m>=0&&M<=0)return d=m/(m-M),t.copy(n).addScaledVector(Hd,d);const w=y*M-S*x;if(w<=0&&x-y>=0&&S-M>=0)return i3.subVectors(o,s),d=(x-y)/(x-y+(S-M)),t.copy(s).addScaledVector(i3,d);const A=1/(w+T+v);return f=T*A,d=v*A,t.copy(n).addScaledVector(jd,f).addScaledVector(Hd,d)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const dM={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Lc={h:0,s:0,l:0},zg={h:0,s:0,l:0};function S2(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}class gt{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_a){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,wn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=wn.workingColorSpace){return this.r=e,this.g=t,this.b=n,wn.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=wn.workingColorSpace){if(e=Qb(e,1),t=Xt(t,0,1),n=Xt(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,f=2*n-o;this.r=S2(f,o,e+1/3),this.g=S2(f,o,e),this.b=S2(f,o,e-1/3)}return wn.colorSpaceToWorking(this,s),this}setStyle(e,t=_a){function n(o){o!==void 0&&parseFloat(o)<1&&mt("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const f=s[1],d=s[2];switch(f){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(d))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:mt("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=s[1],f=o.length;if(f===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(f===6)return this.setHex(parseInt(o,16),t);mt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=_a){const n=dM[e.toLowerCase()];return n!==void 0?this.setHex(n,t):mt("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=jl(e.r),this.g=jl(e.g),this.b=jl(e.b),this}copyLinearToSRGB(e){return this.r=rh(e.r),this.g=rh(e.g),this.b=rh(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_a){return wn.workingToColorSpace(Fa.copy(this),e),Math.round(Xt(Fa.r*255,0,255))*65536+Math.round(Xt(Fa.g*255,0,255))*256+Math.round(Xt(Fa.b*255,0,255))}getHexString(e=_a){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=wn.workingColorSpace){wn.workingToColorSpace(Fa.copy(this),t);const n=Fa.r,s=Fa.g,o=Fa.b,f=Math.max(n,s,o),d=Math.min(n,s,o);let p,m;const y=(d+f)/2;if(d===f)p=0,m=0;else{const x=f-d;switch(m=y<=.5?x/(f+d):x/(2-f-d),f){case n:p=(s-o)/x+(s 0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){mt(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){mt(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==df&&(n.blending=this.blending),this.side!==Hl&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ly&&(n.blendSrc=this.blendSrc),this.blendDst!==zy&&(n.blendDst=this.blendDst),this.blendEquation!==Ic&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==yf&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==vb&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==rf&&(n.stencilFail=this.stencilFail),this.stencilZFail!==rf&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==rf&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(o){const f=[];for(const d in o){const p=o[d];delete p.metadata,f.push(p)}return f}if(t){const o=s(e.textures),f=s(e.images);o.length>0&&(n.textures=o),f.length>0&&(n.images=f)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let o=0;o!==s;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class qc extends Va{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new gt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Z0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Fl=XC();function XC(){const a=new ArrayBuffer(4),e=new Float32Array(a),t=new Uint32Array(a),n=new Uint32Array(512),s=new Uint32Array(512);for(let p=0;p<256;++p){const m=p-127;m<-27?(n[p]=0,n[p|256]=32768,s[p]=24,s[p|256]=24):m<-14?(n[p]=1024>>-m-14,n[p|256]=1024>>-m-14|32768,s[p]=-m-1,s[p|256]=-m-1):m<=15?(n[p]=m+15<<10,n[p|256]=m+15<<10|32768,s[p]=13,s[p|256]=13):m<128?(n[p]=31744,n[p|256]=64512,s[p]=24,s[p|256]=24):(n[p]=31744,n[p|256]=64512,s[p]=13,s[p|256]=13)}const o=new Uint32Array(2048),f=new Uint32Array(64),d=new Uint32Array(64);for(let p=1;p<1024;++p){let m=p<<13,y=0;for(;(m&8388608)===0;)m<<=1,y-=8388608;m&=-8388609,y+=947912704,o[p]=m|y}for(let p=1024;p<2048;++p)o[p]=939524096+(p-1024<<13);for(let p=1;p<31;++p)f[p]=p<<23;f[31]=1199570944,f[32]=2147483648;for(let p=33;p<63;++p)f[p]=2147483648+(p-32<<23);f[63]=3347054592;for(let p=1;p<64;++p)p!==32&&(d[p]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:s,mantissaTable:o,exponentTable:f,offsetTable:d}}function ws(a){Math.abs(a)>65504&&mt("DataUtils.toHalfFloat(): Value out of range."),a=Xt(a,-65504,65504),Fl.floatView[0]=a;const e=Fl.uint32View[0],t=e>>23&511;return Fl.baseTable[t]+((e&8388607)>>Fl.shiftTable[t])}function g0(a){const e=a>>10;return Fl.uint32View[0]=Fl.mantissaTable[Fl.offsetTable[e]+(a&1023)]+Fl.exponentTable[e],Fl.floatView[0]}class qC{static toHalfFloat(e){return ws(e)}static fromHalfFloat(e){return g0(e)}}const Hi=new X,Pg=new ze;let YC=0;class jn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:YC++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=B0,this.updateRanges=[],this.gpuType=Rs,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,o=this.itemSize;s t.count&&mt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new X(-1/0,-1/0,-1/0),new X(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n 0&&(e.userData=this.userData),this.parameters!==void 0){const p=this.parameters;for(const m in p)p[m]!==void 0&&(e[m]=p[m]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const p in n){const m=n[p];e.data.attributes[p]=m.toJSON(e.data)}const s={};let o=!1;for(const p in this.morphAttributes){const m=this.morphAttributes[p],y=[];for(let x=0,v=m.length;x0&&(s[p]=y,o=!0)}o&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const f=this.groups;f.length>0&&(e.data.groups=JSON.parse(JSON.stringify(f)));const d=this.boundingSphere;return d!==null&&(e.data.boundingSphere=d.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const m in s){const y=s[m];this.setAttribute(m,y.clone(t))}const o=e.morphAttributes;for(const m in o){const y=[],x=o[m];for(let v=0,S=x.length;v 0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,f=s.length;o(e.far-e.near)**2))&&(a3.copy(o).invert(),Gu.copy(e.ray).applyMatrix4(a3),!(n.boundingBox!==null&&Gu.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Gu)))}_computeIntersections(e,t,n){let s;const o=this.geometry,f=this.material,d=o.index,p=o.attributes.position,m=o.attributes.uv,y=o.attributes.uv1,x=o.attributes.normal,v=o.groups,S=o.drawRange;if(d!==null)if(Array.isArray(f))for(let M=0,T=v.length;M t.far?null:{distance:m,point:kg.clone(),object:a}}function Vg(a,e,t,n,s,o,f,d,p,m){a.getVertexPosition(d,Ig),a.getVertexPosition(p,Fg),a.getVertexPosition(m,jg);const y=t4(a,e,t,n,Ig,Fg,jg,r3);if(y){const x=new X;Cs.getBarycoord(r3,Ig,Fg,jg,x),s&&(y.uv=Cs.getInterpolatedAttribute(s,d,p,m,x,new ze)),o&&(y.uv1=Cs.getInterpolatedAttribute(o,d,p,m,x,new ze)),f&&(y.normal=Cs.getInterpolatedAttribute(f,d,p,m,x,new X),y.normal.dot(n.direction)>0&&y.normal.multiplyScalar(-1));const v={a:d,b:p,c:m,normal:new X,materialIndex:0};Cs.getNormal(Ig,Fg,jg,v.normal),y.face=v,y.barycoord=x}return y}class Af extends tn{constructor(e=1,t=1,n=1,s=1,o=1,f=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:o,depthSegments:f};const d=this;s=Math.floor(s),o=Math.floor(o),f=Math.floor(f);const p=[],m=[],y=[],x=[];let v=0,S=0;M("z","y","x",-1,-1,n,t,e,f,o,0),M("z","y","x",1,-1,n,t,-e,f,o,1),M("x","z","y",1,1,e,n,t,s,f,2),M("x","z","y",1,-1,e,n,-t,s,f,3),M("x","y","z",1,-1,e,t,n,s,o,4),M("x","y","z",-1,-1,e,t,-n,s,o,5),this.setIndex(p),this.setAttribute("position",new At(m,3)),this.setAttribute("normal",new At(y,3)),this.setAttribute("uv",new At(x,2));function M(T,w,A,D,N,U,I,z,j,q,B){const P=U/j,W=I/q,se=U/2,ae=I/2,ce=z/2,ue=j+1,V=q+1;let $=0,J=0;const he=new X;for(let ve=0;ve 0?1:-1,y.push(he.x,he.y,he.z),x.push(oe/j),x.push(1-ve/q),$+=1}}for(let ve=0;ve 0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class kx extends Rn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=Ws,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const zc=new X,o3=new ze,l3=new ze;class xi extends kx{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ph*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(pf*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ph*2*Math.atan(Math.tan(pf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){zc.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(zc.x,zc.y).multiplyScalar(-e/zc.z),zc.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(zc.x,zc.y).multiplyScalar(-e/zc.z)}getViewSize(e,t){return this.getViewBounds(e,o3,l3),t.subVectors(l3,o3)}setViewOffset(e,t,n,s,o,f){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=o,this.view.height=f,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(pf*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,o=-.5*s;const f=this.view;if(this.view!==null&&this.view.enabled){const p=f.fullWidth,m=f.fullHeight;o+=f.offsetX*s/p,t-=f.offsetY*n/m,s*=f.width/p,n*=f.height/m}const d=this.filmOffset;d!==0&&(o+=e*d/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Vd=-90,Gd=1;class pM extends Rn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new xi(Vd,Gd,e,t);s.layers=this.layers,this.add(s);const o=new xi(Vd,Gd,e,t);o.layers=this.layers,this.add(o);const f=new xi(Vd,Gd,e,t);f.layers=this.layers,this.add(f);const d=new xi(Vd,Gd,e,t);d.layers=this.layers,this.add(d);const p=new xi(Vd,Gd,e,t);p.layers=this.layers,this.add(p);const m=new xi(Vd,Gd,e,t);m.layers=this.layers,this.add(m)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,o,f,d,p]=t;for(const m of t)this.remove(m);if(e===Ws)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),f.up.set(0,0,1),f.lookAt(0,-1,0),d.up.set(0,1,0),d.lookAt(0,0,1),p.up.set(0,1,0),p.lookAt(0,0,-1);else if(e===dh)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),f.up.set(0,0,-1),f.lookAt(0,-1,0),d.up.set(0,-1,0),d.lookAt(0,0,1),p.up.set(0,-1,0),p.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const m of t)this.add(m),m.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,f,d,p,m,y]=this.children,x=e.getRenderTarget(),v=e.getActiveCubeFace(),S=e.getActiveMipmapLevel(),M=e.xr.enabled;e.xr.enabled=!1;const T=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,s),e.render(t,o),e.setRenderTarget(n,1,s),e.render(t,f),e.setRenderTarget(n,2,s),e.render(t,d),e.setRenderTarget(n,3,s),e.render(t,p),e.setRenderTarget(n,4,s),e.render(t,m),n.texture.generateMipmaps=T,e.setRenderTarget(n,5,s),e.render(t,y),e.setRenderTarget(x,v,S),e.xr.enabled=M,n.texture.needsPMREMUpdate=!0}}class J0 extends ui{constructor(e=[],t=kl,n,s,o,f,d,p,m,y){super(e,t,n,s,o,f,d,p,m,y),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class mM extends Wo{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new J0(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include+ #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Af(5,5,5),o=new hs({name:"CubemapFromEquirect",uniforms:gh(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ma,blending:Go});o.uniforms.tEquirect.value=t;const f=new Li(s,o),d=t.minFilter;return t.minFilter===ko&&(t.minFilter=Ui),new pM(1,10,this).update(e,f),t.minFilter=d,f.geometry.dispose(),f.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const o=e.getRenderTarget();for(let f=0;f<6;f++)e.setRenderTarget(this,f),e.clear(t,n,s);e.setRenderTarget(o)}}class sh extends Rn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const s4={type:"move"};class Dy{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sh,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sh,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new X,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new X),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sh,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new X,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new X),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,o=null,f=null;const d=this._targetRay,p=this._grip,m=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(m&&e.hand){f=!0;for(const T of e.hand.values()){const w=t.getJointPose(T,n),A=this._getHandJoint(m,T);w!==null&&(A.matrix.fromArray(w.transform.matrix),A.matrix.decompose(A.position,A.rotation,A.scale),A.matrixWorldNeedsUpdate=!0,A.jointRadius=w.radius),A.visible=w!==null}const y=m.joints["index-finger-tip"],x=m.joints["thumb-tip"],v=y.position.distanceTo(x.position),S=.02,M=.005;m.inputState.pinching&&v>S+M?(m.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!m.inputState.pinching&&v<=S-M&&(m.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else p!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(p.matrix.fromArray(o.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,o.linearVelocity?(p.hasLinearVelocity=!0,p.linearVelocity.copy(o.linearVelocity)):p.hasLinearVelocity=!1,o.angularVelocity?(p.hasAngularVelocity=!0,p.angularVelocity.copy(o.angularVelocity)):p.hasAngularVelocity=!1));d!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&o!==null&&(s=o),s!==null&&(d.matrix.fromArray(s.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,s.linearVelocity?(d.hasLinearVelocity=!0,d.linearVelocity.copy(s.linearVelocity)):d.hasLinearVelocity=!1,s.angularVelocity?(d.hasAngularVelocity=!0,d.angularVelocity.copy(s.angularVelocity)):d.hasAngularVelocity=!1,this.dispatchEvent(s4)))}return d!==null&&(d.visible=s!==null),p!==null&&(p.visible=o!==null),m!==null&&(m.visible=f!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new sh;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Vx{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new gt(e),this.density=t}clone(){return new Vx(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Gx{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new gt(e),this.near=t,this.far=n}clone(){return new Gx(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class t1 extends Rn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ds,this.environmentIntensity=1,this.environmentRotation=new ds,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class Xx{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=B0,this.updateRanges=[],this.version=0,this.uuid=Ks()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,o=this.stride;s e.far||t.push({distance:p,point:r0.clone(),uv:Cs.getInterpolation(r0,Gg,l0,Xg,c3,E2,u3,new ze),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function qg(a,e,t,n,s,o){Wd.subVectors(a,t).addScalar(.5).multiply(n),s!==void 0?(o0.x=o*Wd.x-s*Wd.y,o0.y=s*Wd.x+o*Wd.y):o0.copy(Wd),a.copy(e),a.x+=o0.x,a.y+=o0.y,a.applyMatrix4(gM)}const Yg=new X,f3=new X;class xM extends Rn{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,s=t.length;n 0){let n,s;for(n=1,s=t.length;n0){Yg.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(Yg);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Yg.setFromMatrixPosition(e.matrixWorld),f3.setFromMatrixPosition(this.matrixWorld);const n=Yg.distanceTo(f3)/e.zoom;t[0].object.visible=!0;let s,o;for(s=1,o=t.length;s=f)t[s-1].object.visible=!1,t[s].object.visible=!0;else break}for(this._currentLevel=s-1;s 1?null:t.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||u4.getNormalMatrix(e),s=this.coplanarPoint(C2).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(o),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Xu=new Ki,f4=new ze(.5,.5),Kg=new X;class Ah{constructor(e=new Bl,t=new Bl,n=new Bl,s=new Bl,o=new Bl,f=new Bl){this.planes=[e,t,n,s,o,f]}set(e,t,n,s,o,f){const d=this.planes;return d[0].copy(e),d[1].copy(t),d[2].copy(n),d[3].copy(s),d[4].copy(o),d[5].copy(f),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ws,n=!1){const s=this.planes,o=e.elements,f=o[0],d=o[1],p=o[2],m=o[3],y=o[4],x=o[5],v=o[6],S=o[7],M=o[8],T=o[9],w=o[10],A=o[11],D=o[12],N=o[13],U=o[14],I=o[15];if(s[0].setComponents(m-f,S-y,A-M,I-D).normalize(),s[1].setComponents(m+f,S+y,A+M,I+D).normalize(),s[2].setComponents(m+d,S+x,A+T,I+N).normalize(),s[3].setComponents(m-d,S-x,A-T,I-N).normalize(),n)s[4].setComponents(p,v,w,U).normalize(),s[5].setComponents(m-p,S-v,A-w,I-U).normalize();else if(s[4].setComponents(m-p,S-v,A-w,I-U).normalize(),t===Ws)s[5].setComponents(m+p,S+v,A+w,I+U).normalize();else if(t===dh)s[5].setComponents(p,v,w,U).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Xu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Xu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Xu)}intersectsSprite(e){Xu.center.set(0,0,0);const t=f4.distanceTo(e.center);return Xu.radius=.7071067811865476+t,Xu.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xu)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n) 0?e.max.x:e.min.x,Kg.y=s.normal.y>0?e.max.y:e.min.y,Kg.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Kg)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Po=new Gt,Bo=new Ah;class Yx{constructor(){this.coordinateSystem=Ws}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const d=o[this.index];f.push(d),this.index++,d.start=e,d.count=t,d.z=n,d.index=s}reset(){this.list.length=0,this.index=0}}const Es=new Gt,m4=new gt(1,1,1),b3=new Ah,g4=new Yx,Qg=new Zi,qu=new Ki,f0=new X,_3=new X,y4=new X,D2=new p4,ja=new Li,Jg=[];function x4(a,e,t=0){const n=e.itemSize;if(a.isInterleavedBufferAttribute||a.array.constructor!==e.array.constructor){const s=a.count;for(let o=0;o 65535?new Uint32Array(s):new Uint16Array(s);t.setIndex(new jn(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const s=e.getAttribute(n),o=t.getAttribute(n);if(s.itemSize!==o.itemSize||s.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Zi);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,s=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(R2),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=n):(s=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;Es.identity().toArray(o.image.data,s*16),o.needsUpdate=!0;const f=this._colorsTexture;return f&&(m4.toArray(f.image.data,s*4),f.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const f=e.getIndex();if(f!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=n===-1?f.count:n),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let p;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(R2),p=this._availableGeometryIds.shift(),o[p]=s):(p=this._geometryCount,this._geometryCount++,o.push(s)),this.setGeometryAt(p,e),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,p}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,s=n.getIndex()!==null,o=n.getIndex(),f=t.getIndex(),d=this._geometryInfo[e];if(s&&f.count>d.reservedIndexCount||t.attributes.position.count>d.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const p=d.vertexStart,m=d.reservedVertexCount;d.vertexCount=t.getAttribute("position").count;for(const y in n.attributes){const x=t.getAttribute(y),v=n.getAttribute(y);x4(x,v,p);const S=x.itemSize;for(let M=x.count,T=m;M=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let s=0,o=n.length;s d).sort((f,d)=>n[f].vertexStart-n[d].vertexStart),o=this.geometry;for(let f=0,d=n.length;f =this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingBox===null){const o=new Zi,f=n.index,d=n.attributes.position;for(let p=s.start,m=s.start+s.count;p =this._geometryCount)return null;const n=this.geometry,s=this._geometryInfo[e];if(s.boundingSphere===null){const o=new Ki;this.getBoundingBoxAt(e,Qg),Qg.getCenter(o.center);const f=n.index,d=n.attributes.position;let p=0;for(let m=s.start,y=s.start+s.count;m d.active);if(Math.max(...n.map(d=>d.vertexStart+d.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(p=>p.indexStart+p.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new tn,this._initializeGeometry(o));const f=this.geometry;o.index&&Yu(o.index.array,f.index.array);for(const d in o.attributes)Yu(o.attributes[d].array,f.attributes[d].array)}raycast(e,t){const n=this._instanceInfo,s=this._geometryInfo,o=this.matrixWorld,f=this.geometry;ja.material=this.material,ja.geometry.index=f.index,ja.geometry.attributes=f.attributes,ja.geometry.boundingBox===null&&(ja.geometry.boundingBox=new Zi),ja.geometry.boundingSphere===null&&(ja.geometry.boundingSphere=new Ki);for(let d=0,p=n.length;d ({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,s,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const f=s.getIndex(),d=f===null?1:f.array.BYTES_PER_ELEMENT,p=this._instanceInfo,m=this._multiDrawStarts,y=this._multiDrawCounts,x=this._geometryInfo,v=this.perObjectFrustumCulled,S=this._indirectTexture,M=S.image.data,T=n.isArrayCamera?g4:b3;v&&!n.isArrayCamera&&(Es.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),b3.setFromProjectionMatrix(Es,n.coordinateSystem,n.reversedDepth));let w=0;if(this.sortObjects){Es.copy(this.matrixWorld).invert(),f0.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Es),_3.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Es);for(let N=0,U=p.length;N0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,f=s.length;o
n)return;N2.applyMatrix4(a.matrixWorld);const m=e.ray.origin.distanceTo(N2);if(!(m e.far))return{distance:m,point:A3.clone().applyMatrix4(a.matrixWorld),index:f,face:null,faceIndex:null,barycoord:null,object:a}}const M3=new X,E3=new X;class Ko extends Gc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,o=t.count;s 0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,f=s.length;o s.far)return;o.push({distance:m,distanceToRay:Math.sqrt(d),point:p,index:e,face:null,faceIndex:null,barycoord:null,object:f})}}class SM extends ui{constructor(e,t,n,s,o=Ui,f=Ui,d,p,m){super(e,t,n,s,o,f,d,p,m),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const y=this;function x(){y.needsUpdate=!0,y._requestVideoFrameCallbackId=e.requestVideoFrameCallback(x)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(x))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class v4 extends SM{constructor(e,t,n,s,o,f,d,p){super({},e,t,n,s,o,f,d,p),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class b4 extends ui{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ea,this.minFilter=Ea,this.generateMipmaps=!1,this.needsUpdate=!0}}class Zx extends ui{constructor(e,t,n,s,o,f,d,p,m,y,x,v){super(null,f,d,p,m,y,s,o,x,v),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class _4 extends Zx{constructor(e,t,n,s,o,f){super(e,t,n,o,f),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=Aa,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class S4 extends Zx{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,kl),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class A4 extends ui{constructor(e,t,n,s,o,f,d,p,m){super(e,t,n,s,o,f,d,p,m),this.isCanvasTexture=!0,this.needsUpdate=!0}}class r1 extends ui{constructor(e,t,n=Vl,s,o,f,d=Ea,p=Ea,m,y=uh,x=1){if(y!==uh&&y!==fh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const v={width:e,height:t,depth:x};super(v,s,o,f,d,p,y,n,m),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Fc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class o1 extends ui{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Kx extends tn{constructor(e=1,t=1,n=4,s=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:s,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),s=Math.max(3,Math.floor(s)),o=Math.max(1,Math.floor(o));const f=[],d=[],p=[],m=[],y=t/2,x=Math.PI/2*e,v=t,S=2*x+v,M=n*2+o,T=s+1,w=new X,A=new X;for(let D=0;D<=M;D++){let N=0,U=0,I=0,z=0;if(D<=n){const B=D/n,P=B*Math.PI/2;U=-y-e*Math.cos(P),I=e*Math.sin(P),z=-e*Math.cos(P),N=B*x}else if(D<=n+o){const B=(D-n)/o;U=-y+B*t,I=e,z=0,N=x+B*v}else{const B=(D-n-o)/n,P=B*Math.PI/2;U=y+e*Math.sin(P),I=e*Math.cos(P),z=e*Math.sin(P),N=x+v+B*x}const j=Math.max(0,Math.min(1,N/S));let q=0;D===0?q=.5/s:D===M&&(q=-.5/s);for(let B=0;B<=s;B++){const P=B/s,W=P*Math.PI*2,se=Math.sin(W),ae=Math.cos(W);A.x=-I*ae,A.y=U,A.z=I*se,d.push(A.x,A.y,A.z),w.set(-I*ae,z,I*se),w.normalize(),p.push(w.x,w.y,w.z),m.push(P+q,j)}if(D>0){const B=(D-1)*T;for(let P=0;P 0&&N(!0),t>0&&N(!1)),this.setIndex(y),this.setAttribute("position",new At(x,3)),this.setAttribute("normal",new At(v,3)),this.setAttribute("uv",new At(S,2));function D(){const U=new X,I=new X;let z=0;const j=(t-e)/n;for(let q=0;q<=o;q++){const B=[],P=q/o,W=P*(t-e)+e;for(let se=0;se<=s;se++){const ae=se/s,ce=ae*p+d,ue=Math.sin(ce),V=Math.cos(ce);I.x=W*ue,I.y=-P*n+w,I.z=W*V,x.push(I.x,I.y,I.z),U.set(ue,j,V).normalize(),v.push(U.x,U.y,U.z),S.push(ae,1-P),B.push(M++)}T.push(B)}for(let q=0;q0||B!==0)&&(y.push(P,W,ae),z+=3),(t>0||B!==o-1)&&(y.push(W,se,ae),z+=3)}m.addGroup(A,z,0),A+=z}function N(U){const I=M,z=new ze,j=new X;let q=0;const B=U===!0?e:t,P=U===!0?1:-1;for(let se=1;se<=s;se++)x.push(0,w*P,0),v.push(0,P,0),S.push(.5,.5),M++;const W=M;for(let se=0;se<=s;se++){const ce=se/s*p+d,ue=Math.cos(ce),V=Math.sin(ce);j.x=B*V,j.y=w*P,j.z=B*ue,x.push(j.x,j.y,j.z),v.push(0,P,0),z.x=ue*.5+.5,z.y=V*.5*P+.5,S.push(z.x,z.y),M++}for(let se=0;se.9&&j<.1&&(N<.2&&(f[D+0]+=1),U<.2&&(f[D+2]+=1),I<.2&&(f[D+4]+=1))}}function v(D){o.push(D.x,D.y,D.z)}function S(D,N){const U=D*3;N.x=e[U+0],N.y=e[U+1],N.z=e[U+2]}function M(){const D=new X,N=new X,U=new X,I=new X,z=new ze,j=new ze,q=new ze;for(let B=0,P=0;B0)p=s-1;else{p=s;break}if(s=p,n[s]===f)return s/(o-1);const y=n[s],v=n[s+1]-y,S=(f-y)/v;return(s+S)/(o-1)}getTangent(e,t){let s=e-1e-4,o=e+1e-4;s<0&&(s=0),o>1&&(o=1);const f=this.getPoint(s),d=this.getPoint(o),p=t||(f.isVector2?new ze:new X);return p.copy(d).sub(f).normalize(),p}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new X,s=[],o=[],f=[],d=new X,p=new Gt;for(let S=0;S<=e;S++){const M=S/e;s[S]=this.getTangentAt(M,new X)}o[0]=new X,f[0]=new X;let m=Number.MAX_VALUE;const y=Math.abs(s[0].x),x=Math.abs(s[0].y),v=Math.abs(s[0].z);y<=m&&(m=y,n.set(1,0,0)),x<=m&&(m=x,n.set(0,1,0)),v<=m&&n.set(0,0,1),d.crossVectors(s[0],n).normalize(),o[0].crossVectors(s[0],d),f[0].crossVectors(s[0],o[0]);for(let S=1;S<=e;S++){if(o[S]=o[S-1].clone(),f[S]=f[S-1].clone(),d.crossVectors(s[S-1],s[S]),d.length()>Number.EPSILON){d.normalize();const M=Math.acos(Xt(s[S-1].dot(s[S]),-1,1));o[S].applyMatrix4(p.makeRotationAxis(d,M))}f[S].crossVectors(s[S],o[S])}if(t===!0){let S=Math.acos(Xt(o[0].dot(o[e]),-1,1));S/=e,s[0].dot(d.crossVectors(o[0],o[e]))>0&&(S=-S);for(let M=1;M<=e;M++)o[M].applyMatrix4(p.makeRotationAxis(s[M],S*M)),f[M].crossVectors(s[M],o[M])}return{tangents:s,normals:o,binormals:f}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class $x extends to{constructor(e=0,t=0,n=1,s=1,o=0,f=Math.PI*2,d=!1,p=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=s,this.aStartAngle=o,this.aEndAngle=f,this.aClockwise=d,this.aRotation=p}getPoint(e,t=new ze){const n=t,s=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const f=Math.abs(o) s;)o-=s;o 0?0:(Math.floor(Math.abs(d)/o)+1)*o:p===0&&d===o-1&&(d=o-2,p=1);let m,y;this.closed||d>0?m=s[(d-1)%o]:(ry.subVectors(s[0],s[1]).add(s[0]),m=ry);const x=s[d%o],v=s[(d+1)%o];if(this.closed||d+2 s.length-2?s.length-1:f+1],x=s[f>s.length-3?s.length-1:f+2];return n.set(C3(d,p.x,m.x,y.x,x.x),C3(d,p.y,m.y,y.y,x.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t =n){const f=s[o]-n,d=this.curves[o],p=d.getLength(),m=p===0?0:1-f/p;return d.getPointAt(m,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,s=this.curves.length;n 1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const x=m.getPoint(0);x.equals(this.currentPoint)||this.lineTo(x.x,x.y)}this.curves.push(m);const y=m.getPoint(1);return this.currentPoint.copy(y),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class mf extends _x{constructor(e){super(e),this.uuid=Ks(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,s=this.holes.length;n 80*t){d=a[0],p=a[1];let y=d,x=p;for(let v=t;vy&&(y=S),M>x&&(x=M)}m=Math.max(y-d,x-p),m=m!==0?32767/m:0}return H0(o,f,t,d,p,m,0),f}function RM(a,e,t,n,s){let o;if(s===Y4(a,e,t,n)>0)for(let f=e;f=e;f-=n)o=R3(f/n|0,a[f],a[f+1],o);return o&&xh(o,o.next)&&(V0(o),o=o.next),o}function xf(a,e){if(!a)return a;e||(e=a);let t=a,n;do if(n=!1,!t.steiner&&(xh(t,t.next)||vi(t.prev,t,t.next)===0)){if(V0(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function H0(a,e,t,n,s,o,f){if(!a)return;!f&&o&&H4(a,n,s,o);let d=a;for(;a.prev!==a.next;){const p=a.prev,m=a.next;if(o?U4(a,n,s,o):O4(a)){e.push(p.i,a.i,m.i),V0(a),a=m.next,d=m.next;continue}if(a=m,a===d){f?f===1?(a=L4(xf(a),e),H0(a,e,t,n,s,o,2)):f===2&&z4(a,e,t,n,s,o):H0(xf(a),e,t,n,s,o,1);break}}}function O4(a){const e=a.prev,t=a,n=a.next;if(vi(e,t,n)>=0)return!1;const s=e.x,o=t.x,f=n.x,d=e.y,p=t.y,m=n.y,y=Math.min(s,o,f),x=Math.min(d,p,m),v=Math.max(s,o,f),S=Math.max(d,p,m);let M=n.next;for(;M!==e;){if(M.x>=y&&M.x<=v&&M.y>=x&&M.y<=S&&y0(s,d,o,p,f,m,M.x,M.y)&&vi(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function U4(a,e,t,n){const s=a.prev,o=a,f=a.next;if(vi(s,o,f)>=0)return!1;const d=s.x,p=o.x,m=f.x,y=s.y,x=o.y,v=f.y,S=Math.min(d,p,m),M=Math.min(y,x,v),T=Math.max(d,p,m),w=Math.max(y,x,v),A=Sb(S,M,e,t,n),D=Sb(T,w,e,t,n);let N=a.prevZ,U=a.nextZ;for(;N&&N.z>=A&&U&&U.z<=D;){if(N.x>=S&&N.x<=T&&N.y>=M&&N.y<=w&&N!==s&&N!==f&&y0(d,y,p,x,m,v,N.x,N.y)&&vi(N.prev,N,N.next)>=0||(N=N.prevZ,U.x>=S&&U.x<=T&&U.y>=M&&U.y<=w&&U!==s&&U!==f&&y0(d,y,p,x,m,v,U.x,U.y)&&vi(U.prev,U,U.next)>=0))return!1;U=U.nextZ}for(;N&&N.z>=A;){if(N.x>=S&&N.x<=T&&N.y>=M&&N.y<=w&&N!==s&&N!==f&&y0(d,y,p,x,m,v,N.x,N.y)&&vi(N.prev,N,N.next)>=0)return!1;N=N.prevZ}for(;U&&U.z<=D;){if(U.x>=S&&U.x<=T&&U.y>=M&&U.y<=w&&U!==s&&U!==f&&y0(d,y,p,x,m,v,U.x,U.y)&&vi(U.prev,U,U.next)>=0)return!1;U=U.nextZ}return!0}function L4(a,e){let t=a;do{const n=t.prev,s=t.next.next;!xh(n,s)&&NM(n,t,t.next,s)&&k0(n,s)&&k0(s,n)&&(e.push(n.i,t.i,s.i),V0(t),V0(t.next),t=a=s),t=t.next}while(t!==a);return xf(t)}function z4(a,e,t,n,s,o){let f=a;do{let d=f.next.next;for(;d!==f.prev;){if(f.i!==d.i&&G4(f,d)){let p=OM(f,d);f=xf(f,f.next),p=xf(p,p.next),H0(f,e,t,n,s,o,0),H0(p,e,t,n,s,o,0);return}d=d.next}f=f.next}while(f!==a)}function P4(a,e,t,n){const s=[];for(let o=0,f=e.length;o =t.next.y&&t.next.y!==t.y){const x=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=n&&x>o&&(o=x,f=t.x =t.x&&t.x>=p&&n!==t.x&&DM(s f.x||t.x===f.x&&j4(f,t)))&&(f=t,y=x)}t=t.next}while(t!==d);return f}function j4(a,e){return vi(a.prev,a,e.prev)<0&&vi(e.next,a,a.next)<0}function H4(a,e,t,n){let s=a;do s.z===0&&(s.z=Sb(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==a);s.prevZ.nextZ=null,s.prevZ=null,k4(s)}function k4(a){let e,t=1;do{let n=a,s;a=null;let o=null;for(e=0;n;){e++;let f=n,d=0;for(let m=0;m 0||p>0&&f;)d!==0&&(p===0||!f||n.z<=f.z)?(s=n,n=n.nextZ,d--):(s=f,f=f.nextZ,p--),o?o.nextZ=s:a=s,s.prevZ=o,o=s;n=f}o.nextZ=null,t*=2}while(e>1);return a}function Sb(a,e,t,n,s){return a=(a-t)*s|0,e=(e-n)*s|0,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,a|e<<1}function V4(a){let e=a,t=a;do(e.x =(a-f)*(o-d)&&(a-f)*(n-d)>=(t-f)*(e-d)&&(t-f)*(o-d)>=(s-f)*(n-d)}function y0(a,e,t,n,s,o,f,d){return!(a===f&&e===d)&&DM(a,e,t,n,s,o,f,d)}function G4(a,e){return a.next.i!==e.i&&a.prev.i!==e.i&&!X4(a,e)&&(k0(a,e)&&k0(e,a)&&q4(a,e)&&(vi(a.prev,a,e.prev)||vi(a,e.prev,e))||xh(a,e)&&vi(a.prev,a,a.next)>0&&vi(e.prev,e,e.next)>0)}function vi(a,e,t){return(e.y-a.y)*(t.x-e.x)-(e.x-a.x)*(t.y-e.y)}function xh(a,e){return a.x===e.x&&a.y===e.y}function NM(a,e,t,n){const s=ly(vi(a,e,t)),o=ly(vi(a,e,n)),f=ly(vi(t,n,a)),d=ly(vi(t,n,e));return!!(s!==o&&f!==d||s===0&&oy(a,t,e)||o===0&&oy(a,n,e)||f===0&&oy(t,a,n)||d===0&&oy(t,e,n))}function oy(a,e,t){return e.x<=Math.max(a.x,t.x)&&e.x>=Math.min(a.x,t.x)&&e.y<=Math.max(a.y,t.y)&&e.y>=Math.min(a.y,t.y)}function ly(a){return a>0?1:a<0?-1:0}function X4(a,e){let t=a;do{if(t.i!==a.i&&t.next.i!==a.i&&t.i!==e.i&&t.next.i!==e.i&&NM(t,t.next,a,e))return!0;t=t.next}while(t!==a);return!1}function k0(a,e){return vi(a.prev,a,a.next)<0?vi(a,e,a.next)>=0&&vi(a,a.prev,e)>=0:vi(a,e,a.prev)<0||vi(a,a.next,e)<0}function q4(a,e){let t=a,n=!1;const s=(a.x+e.x)/2,o=(a.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&s<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==a);return n}function OM(a,e){const t=Ab(a.i,a.x,a.y),n=Ab(e.i,e.x,e.y),s=a.next,o=e.prev;return a.next=e,e.prev=a,t.next=s,s.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function R3(a,e,t,n){const s=Ab(a,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function V0(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function Ab(a,e,t){return{i:a,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Y4(a,e,t,n){let s=0;for(let o=e,f=t-n;o 2&&a[e-1].equals(a[0])&&a.pop()}function N3(a,e){for(let t=0;t Number.EPSILON){const Oe=Math.sqrt(F),Pe=Math.sqrt(ht*ht+K*K),Re=Z.x-nt/Oe,Mt=Z.y+ot/Oe,ct=ke.x-K/Pe,wt=ke.y+ht/Pe,_t=((ct-Re)*K-(wt-Mt)*ht)/(ot*K-nt*ht);Xe=Re+ot*_t-Ue.x,tt=Mt+nt*_t-Ue.y;const je=Xe*Xe+tt*tt;if(je<=2)return new ze(Xe,tt);qe=Math.sqrt(je/2)}else{let Oe=!1;ot>Number.EPSILON?ht>Number.EPSILON&&(Oe=!0):ot<-Number.EPSILON?ht<-Number.EPSILON&&(Oe=!0):Math.sign(nt)===Math.sign(K)&&(Oe=!0),Oe?(Xe=-nt,tt=ot,qe=Math.sqrt(F)):(Xe=ot,tt=nt,qe=Math.sqrt(F/2))}return new ze(Xe/qe,tt/qe)}const he=[];for(let Ue=0,Z=ue.length,ke=Z-1,Xe=Ue+1;Ue =0;Ue--){const Z=Ue/w,ke=S*Math.cos(Z*Math.PI/2),Xe=M*Math.sin(Z*Math.PI/2)+T;for(let tt=0,qe=ue.length;tt =0;){const Xe=ke;let tt=ke-1;tt<0&&(tt=Ue.length-1);for(let qe=0,ot=y+w*2;qe 0)&&S.push(N,U,z),(A!==n-1||p 0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class PM extends Va{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new gt(16777215),this.specular=new gt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xc,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Z0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class BM extends Va{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new gt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xc,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class IM extends Va{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xc,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class FM extends Va{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new gt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xc,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ds,this.combine=Z0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class g1 extends Va{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=$A,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class y1 extends Va{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class jM extends Va{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new gt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xc,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class HM extends ps{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function uf(a,e){return!a||a.constructor===e?a:typeof e.BYTES_PER_ELEMENT=="number"?new e(a):Array.prototype.slice.call(a)}function kM(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function VM(a){function e(s,o){return a[s]-a[o]}const t=a.length,n=new Array(t);for(let s=0;s!==t;++s)n[s]=s;return n.sort(e),n}function Mb(a,e,t){const n=a.length,s=new a.constructor(n);for(let o=0,f=0;f!==n;++o){const d=t[o]*e;for(let p=0;p!==e;++p)s[f++]=a[d+p]}return s}function x1(a,e,t,n){let s=1,o=a[0];for(;o!==void 0&&o[n]===void 0;)o=a[s++];if(o===void 0)return;let f=o[n];if(f!==void 0)if(Array.isArray(f))do f=o[n],f!==void 0&&(e.push(o.time),t.push(...f)),o=a[s++];while(o!==void 0);else if(f.toArray!==void 0)do f=o[n],f!==void 0&&(e.push(o.time),f.toArray(t,t.length)),o=a[s++];while(o!==void 0);else do f=o[n],f!==void 0&&(e.push(o.time),t.push(f)),o=a[s++];while(o!==void 0)}function J4(a,e,t,n,s=30){const o=a.clone();o.name=e;const f=[];for(let p=0;p =n)){x.push(m.times[S]);for(let T=0;T o.tracks[p].times[0]&&(d=o.tracks[p].times[0]);for(let p=0;p =d.times[M]){const A=M*x+y,D=A+x-y;T=d.values.slice(A,D)}else{const A=d.createInterpolant(),D=y,N=x-y;A.evaluate(o),T=A.resultBuffer.slice(D,N)}p==="quaternion"&&new ka().fromArray(T).normalize().conjugate().toArray(T);const w=m.times.length;for(let A=0;A =o)){const d=t[1];e =o)break t}f=n,n=0;break n}break e}for(;n >>1;e t;)--f;if(++f,o!==0||f!==s){o>=f&&(f=Math.max(f,1),o=f-1);const d=this.getValueSize();this.times=n.slice(o,f),this.values=this.values.slice(o*d,f*d)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Yt("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,s=this.values,o=n.length;o===0&&(Yt("KeyframeTrack: Track is empty.",this),e=!1);let f=null;for(let d=0;d!==o;d++){const p=n[d];if(typeof p=="number"&&isNaN(p)){Yt("KeyframeTrack: Time is not a valid number.",this,d,p),e=!1;break}if(f!==null&&f>p){Yt("KeyframeTrack: Out of order keys.",this,d,p,f),e=!1;break}f=p}if(s!==void 0&&kM(s))for(let d=0,p=s.length;d!==p;++d){const m=s[d];if(isNaN(m)){Yt("KeyframeTrack: Value is not a valid number.",this,d,m),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Ry,o=e.length-1;let f=1;for(let d=1;d 0){e[f]=e[o];for(let d=o*n,p=f*n,m=0;m!==n;++m)t[p+m]=t[d+m];++f}return f!==e.length?(this.times=e.slice(0,f),this.values=t.slice(0,f*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}br.prototype.ValueTypeName="";br.prototype.TimeBufferType=Float32Array;br.prototype.ValueBufferType=Float32Array;br.prototype.DefaultInterpolation=yx;class Mf extends br{constructor(e,t,n){super(e,t,n)}}Mf.prototype.ValueTypeName="bool";Mf.prototype.ValueBufferType=Array;Mf.prototype.DefaultInterpolation=L0;Mf.prototype.InterpolantFactoryMethodLinear=void 0;Mf.prototype.InterpolantFactoryMethodSmooth=void 0;class b1 extends br{constructor(e,t,n,s){super(e,t,n,s)}}b1.prototype.ValueTypeName="color";class G0 extends br{constructor(e,t,n,s){super(e,t,n,s)}}G0.prototype.ValueTypeName="number";class qM extends im{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){const o=this.resultBuffer,f=this.sampleValues,d=this.valueSize,p=(n-t)/(s-t);let m=e*d;for(let y=m+d;m!==y;m+=4)ka.slerpFlat(o,0,f,m-d,f,m,p);return o}}class am extends br{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new qM(this.times,this.values,this.getValueSize(),e)}}am.prototype.ValueTypeName="quaternion";am.prototype.InterpolantFactoryMethodSmooth=void 0;class Ef extends br{constructor(e,t,n){super(e,t,n)}}Ef.prototype.ValueTypeName="string";Ef.prototype.ValueBufferType=Array;Ef.prototype.DefaultInterpolation=L0;Ef.prototype.InterpolantFactoryMethodLinear=void 0;Ef.prototype.InterpolantFactoryMethodSmooth=void 0;class X0 extends br{constructor(e,t,n,s){super(e,t,n,s)}}X0.prototype.ValueTypeName="vector";class q0{constructor(e="",t=-1,n=[],s=Fx){this.name=e,this.tracks=n,this.duration=t,this.blendMode=s,this.uuid=Ks(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,s=1/(e.fps||1);for(let f=0,d=n.length;f!==d;++f)t.push(nR(n[f]).scale(s));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o.userData=JSON.parse(e.userData||"{}"),o}static toJSON(e){const t=[],n=e.tracks,s={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let o=0,f=n.length;o!==f;++o)t.push(br.toJSON(n[o]));return s}static CreateFromMorphTargetSequence(e,t,n,s){const o=t.length,f=[];for(let d=0;d 1){const x=y[1];let v=s[x];v||(s[x]=v=[]),v.push(m)}}const f=[];for(const d in s)f.push(this.CreateFromMorphTargetSequence(d,s[d],t,n));return f}static parseAnimation(e,t){if(mt("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Yt("AnimationClip: No animation in JSONLoader data."),null;const n=function(x,v,S,M,T){if(S.length!==0){const w=[],A=[];x1(S,w,A,M),w.length!==0&&T.push(new x(v,w,A))}},s=[],o=e.name||"default",f=e.fps||30,d=e.blendMode;let p=e.length||-1;const m=e.hierarchy||[];for(let x=0;x {t&&t(o),this.manager.itemEnd(e)},0),o;if(zl[e]!==void 0){zl[e].push({onLoad:t,onProgress:n,onError:s});return}zl[e]=[],zl[e].push({onLoad:t,onProgress:n,onError:s});const f=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),d=this.mimeType,p=this.responseType;fetch(f).then(m=>{if(m.status===200||m.status===0){if(m.status===0&&mt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||m.body===void 0||m.body.getReader===void 0)return m;const y=zl[e],x=m.body.getReader(),v=m.headers.get("X-File-Size")||m.headers.get("Content-Length"),S=v?parseInt(v):0,M=S!==0;let T=0;const w=new ReadableStream({start(A){D();function D(){x.read().then(({done:N,value:U})=>{if(N)A.close();else{T+=U.byteLength;const I=new ProgressEvent("progress",{lengthComputable:M,loaded:T,total:S});for(let z=0,j=y.length;z {A.error(N)})}}});return new Response(w)}else throw new iR(`fetch for "${m.url}" responded with ${m.status}: ${m.statusText}`,m)}).then(m=>{switch(p){case"arraybuffer":return m.arrayBuffer();case"blob":return m.blob();case"document":return m.text().then(y=>new DOMParser().parseFromString(y,d));case"json":return m.json();default:if(d==="")return m.text();{const x=/charset="?([^;"\s]*)"?/i.exec(d),v=x&&x[1]?x[1].toLowerCase():void 0,S=new TextDecoder(v);return m.arrayBuffer().then(M=>S.decode(M))}}}).then(m=>{Vo.add(`file:${e}`,m);const y=zl[e];delete zl[e];for(let x=0,v=y.length;x {const y=zl[e];if(y===void 0)throw this.manager.itemError(e),m;delete zl[e];for(let x=0,v=y.length;x {this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class aR extends Ds{constructor(e){super(e)}load(e,t,n,s){const o=this,f=new Gl(this.manager);f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(d){try{t(o.parse(JSON.parse(d)))}catch(p){s?s(p):Yt(p),o.manager.itemError(e)}},n,s)}parse(e){const t=[];for(let n=0;n 0:s.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const o in e.uniforms){const f=e.uniforms[o];switch(s.uniforms[o]={},f.type){case"t":s.uniforms[o].value=n(f.value);break;case"c":s.uniforms[o].value=new gt().setHex(f.value);break;case"v2":s.uniforms[o].value=new ze().fromArray(f.value);break;case"v3":s.uniforms[o].value=new X().fromArray(f.value);break;case"v4":s.uniforms[o].value=new un().fromArray(f.value);break;case"m3":s.uniforms[o].value=new en().fromArray(f.value);break;case"m4":s.uniforms[o].value=new Gt().fromArray(f.value);break;default:s.uniforms[o].value=f.value}}if(e.defines!==void 0&&(s.defines=e.defines),e.vertexShader!==void 0&&(s.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(s.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(s.glslVersion=e.glslVersion),e.extensions!==void 0)for(const o in e.extensions)s.extensions[o]=e.extensions[o];if(e.lights!==void 0&&(s.lights=e.lights),e.clipping!==void 0&&(s.clipping=e.clipping),e.size!==void 0&&(s.size=e.size),e.sizeAttenuation!==void 0&&(s.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(s.map=n(e.map)),e.matcap!==void 0&&(s.matcap=n(e.matcap)),e.alphaMap!==void 0&&(s.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(s.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(s.bumpScale=e.bumpScale),e.normalMap!==void 0&&(s.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(s.normalMapType=e.normalMapType),e.normalScale!==void 0){let o=e.normalScale;Array.isArray(o)===!1&&(o=[o,o]),s.normalScale=new ze().fromArray(o)}return e.displacementMap!==void 0&&(s.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(s.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(s.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(s.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(s.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(s.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(s.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(s.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(s.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(s.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(s.envMap=n(e.envMap)),e.envMapRotation!==void 0&&s.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(s.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(s.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(s.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(s.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(s.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(s.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(s.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(s.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(s.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(s.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(s.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(s.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(s.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(s.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=n(e.sheenRoughnessMap)),s}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return cv.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:UM,SpriteMaterial:n1,RawShaderMaterial:LM,ShaderMaterial:hs,PointsMaterial:Wx,MeshPhysicalMaterial:zM,MeshStandardMaterial:m1,MeshPhongMaterial:PM,MeshToonMaterial:BM,MeshNormalMaterial:IM,MeshLambertMaterial:FM,MeshDepthMaterial:g1,MeshDistanceMaterial:y1,MeshBasicMaterial:qc,MeshMatcapMaterial:jM,LineDashedMaterial:HM,LineBasicMaterial:ps,Material:Va};return new t[e]}}class Eb{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class A1 extends tn{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class nE extends Ds{constructor(e){super(e)}load(e,t,n,s){const o=this,f=new Gl(o.manager);f.setPath(o.path),f.setRequestHeader(o.requestHeader),f.setWithCredentials(o.withCredentials),f.load(e,function(d){try{t(o.parse(JSON.parse(d)))}catch(p){s?s(p):Yt(p),o.manager.itemError(e)}},n,s)}parse(e){const t={},n={};function s(S,M){if(t[M]!==void 0)return t[M];const w=S.interleavedBuffers[M],A=o(S,w.buffer),D=ah(w.type,A),N=new Xx(D,w.stride);return N.uuid=w.uuid,t[M]=N,N}function o(S,M){if(n[M]!==void 0)return n[M];const w=S.arrayBuffers[M],A=new Uint32Array(w).buffer;return n[M]=A,A}const f=e.isInstancedBufferGeometry?new A1:new tn,d=e.data.index;if(d!==void 0){const S=ah(d.type,d.array);f.setIndex(new jn(S,1))}const p=e.data.attributes;for(const S in p){const M=p[S];let T;if(M.isInterleavedBufferAttribute){const w=s(e.data,M.data);T=new Zs(w,M.itemSize,M.offset,M.normalized)}else{const w=ah(M.type,M.array),A=M.isInstancedBufferAttribute?yh:jn;T=new A(w,M.itemSize,M.normalized)}M.name!==void 0&&(T.name=M.name),M.usage!==void 0&&T.setUsage(M.usage),f.setAttribute(S,T)}const m=e.data.morphAttributes;if(m)for(const S in m){const M=m[S],T=[];for(let w=0,A=M.length;w0){const p=new _1(t);o=new Y0(p),o.setCrossOrigin(this.crossOrigin);for(let m=0,y=e.length;m 0){s=new Y0(this.manager),s.setCrossOrigin(this.crossOrigin);for(let f=0,d=e.length;f {let w=null,A=null;return T.boundingBox!==void 0&&(w=new Zi().fromJSON(T.boundingBox)),T.boundingSphere!==void 0&&(A=new Ki().fromJSON(T.boundingSphere)),{...T,boundingBox:w,boundingSphere:A}}),f._instanceInfo=e.instanceInfo,f._availableInstanceIds=e._availableInstanceIds,f._availableGeometryIds=e._availableGeometryIds,f._nextIndexStart=e.nextIndexStart,f._nextVertexStart=e.nextVertexStart,f._geometryCount=e.geometryCount,f._maxInstanceCount=e.maxInstanceCount,f._maxVertexCount=e.maxVertexCount,f._maxIndexCount=e.maxIndexCount,f._geometryInitialized=e.geometryInitialized,f._matricesTexture=m(e.matricesTexture.uuid),f._indirectTexture=m(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(f._colorsTexture=m(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(f.boundingSphere=new Ki().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(f.boundingBox=new Zi().fromJSON(e.boundingBox));break;case"LOD":f=new xM;break;case"Line":f=new Gc(d(e.geometry),p(e.material));break;case"LineLoop":f=new bM(d(e.geometry),p(e.material));break;case"LineSegments":f=new Ko(d(e.geometry),p(e.material));break;case"PointCloud":case"Points":f=new _M(d(e.geometry),p(e.material));break;case"Sprite":f=new yM(p(e.material));break;case"Group":f=new sh;break;case"Bone":f=new a1;break;default:f=new Rn}if(f.uuid=e.uuid,e.name!==void 0&&(f.name=e.name),e.matrix!==void 0?(f.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(f.matrixAutoUpdate=e.matrixAutoUpdate),f.matrixAutoUpdate&&f.matrix.decompose(f.position,f.quaternion,f.scale)):(e.position!==void 0&&f.position.fromArray(e.position),e.rotation!==void 0&&f.rotation.fromArray(e.rotation),e.quaternion!==void 0&&f.quaternion.fromArray(e.quaternion),e.scale!==void 0&&f.scale.fromArray(e.scale)),e.up!==void 0&&f.up.fromArray(e.up),e.castShadow!==void 0&&(f.castShadow=e.castShadow),e.receiveShadow!==void 0&&(f.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(f.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(f.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(f.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(f.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&f.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(f.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(f.visible=e.visible),e.frustumCulled!==void 0&&(f.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(f.renderOrder=e.renderOrder),e.userData!==void 0&&(f.userData=e.userData),e.layers!==void 0&&(f.layers.mask=e.layers),e.children!==void 0){const v=e.children;for(let S=0;S "u"&&mt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&mt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,s){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,f=Vo.get(`image-bitmap:${e}`);if(f!==void 0){if(o.manager.itemStart(e),f.then){f.then(m=>{if(I2.has(f)===!0)s&&s(I2.get(f)),o.manager.itemError(e),o.manager.itemEnd(e);else return t&&t(m),o.manager.itemEnd(e),m});return}return setTimeout(function(){t&&t(f),o.manager.itemEnd(e)},0),f}const d={};d.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",d.headers=this.requestHeader,d.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const p=fetch(e,d).then(function(m){return m.blob()}).then(function(m){return createImageBitmap(m,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(m){return Vo.add(`image-bitmap:${e}`,m),t&&t(m),o.manager.itemEnd(e),m}).catch(function(m){s&&s(m),I2.set(p,m),Vo.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});Vo.add(`image-bitmap:${e}`,p),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let cy;class M1{static getContext(){return cy===void 0&&(cy=new(window.AudioContext||window.webkitAudioContext)),cy}static setContext(e){cy=e}}class pR extends Ds{constructor(e){super(e)}load(e,t,n,s){const o=this,f=new Gl(this.manager);f.setResponseType("arraybuffer"),f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(p){try{const m=p.slice(0);M1.getContext().decodeAudioData(m,function(x){t(x)}).catch(d)}catch(m){d(m)}},n,s);function d(p){s?s(p):Yt(p),o.manager.itemError(e)}}}const F3=new Gt,j3=new Gt,Wu=new Gt;class mR{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new xi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new xi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Wu.copy(e.projectionMatrix);const s=t.eyeSep/2,o=s*t.near/t.focus,f=t.near*Math.tan(pf*t.fov*.5)/t.zoom;let d,p;j3.elements[12]=-s,F3.elements[12]=s,d=-f*t.aspect+o,p=f*t.aspect+o,Wu.elements[0]=2*t.near/(p-d),Wu.elements[8]=(p+d)/(p-d),this.cameraL.projectionMatrix.copy(Wu),d=-f*t.aspect-o,p=f*t.aspect-o,Wu.elements[0]=2*t.near/(p-d),Wu.elements[8]=(p+d)/(p-d),this.cameraR.projectionMatrix.copy(Wu)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(j3),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(F3)}}class iE extends xi{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class E1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Zu=new X,F2=new ka,gR=new X,Ku=new X,Qu=new X;class yR extends Rn{constructor(){super(),this.type="AudioListener",this.context=M1.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new E1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Zu,F2,gR),Ku.set(0,0,-1).applyQuaternion(F2),Qu.set(0,1,0).applyQuaternion(F2),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Zu.x,n),t.positionY.linearRampToValueAtTime(Zu.y,n),t.positionZ.linearRampToValueAtTime(Zu.z,n),t.forwardX.linearRampToValueAtTime(Ku.x,n),t.forwardY.linearRampToValueAtTime(Ku.y,n),t.forwardZ.linearRampToValueAtTime(Ku.z,n),t.upX.linearRampToValueAtTime(Qu.x,n),t.upY.linearRampToValueAtTime(Qu.y,n),t.upZ.linearRampToValueAtTime(Qu.z,n)}else t.setPosition(Zu.x,Zu.y,Zu.z),t.setOrientation(Ku.x,Ku.y,Ku.z,Qu.x,Qu.y,Qu.z)}}class aE extends Rn{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){mt("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){mt("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){mt("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){mt("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e 0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e 0&&this._mixBufferRegionAdditive(n,s,this._addIndex*t,1,t);for(let p=t,m=t+t;p!==m;++p)if(n[p]!==n[p+t]){d.setValue(n,s);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,s=n*this._origIndex;e.getValue(t,s);for(let o=n,f=s;o!==f;++o)t[o]=t[s+o%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n =.5)for(let f=0;f!==o;++f)e[t+f]=e[n+f]}_slerp(e,t,n,s){ka.slerpFlat(e,t,e,t,e,n,s)}_slerpAdditive(e,t,n,s,o){const f=this._workIndex*o;ka.multiplyQuaternionsFlat(e,f,e,t,e,n),ka.slerpFlat(e,t,e,t,e,f,s)}_lerp(e,t,n,s,o){const f=1-s;for(let d=0;d!==o;++d){const p=t+d;e[p]=e[p]*f+e[n+d]*s}}_lerpAdditive(e,t,n,s,o){for(let f=0;f!==o;++f){const d=t+f;e[d]=e[d]+e[n+f]*s}}}const w1="\\[\\]\\.:\\/",_R=new RegExp("["+w1+"]","g"),T1="[^"+w1+"]",SR="[^"+w1.replace("\\.","")+"]",AR=/((?:WC+[\/:])*)/.source.replace("WC",T1),MR=/(WCOD+)?/.source.replace("WCOD",SR),ER=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",T1),wR=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",T1),TR=new RegExp("^"+AR+MR+ER+wR+"$"),CR=["material","materials","bones","map"];class RR{constructor(e,t,n){const s=n||Cn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,o=n.length;s!==o;++s)n[s].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Cn{constructor(e,t,n){this.path=t,this.parsedPath=n||Cn.parseTrackName(t),this.node=Cn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Cn.Composite(e,t,n):new Cn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_R,"")}static parseTrackName(e){const t=TR.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const o=n.nodeName.substring(s+1);CR.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let f=0;f =o){const x=o++,v=e[x];t[v.uuid]=y,e[y]=v,t[m]=x,e[x]=p;for(let S=0,M=s;S!==M;++S){const T=n[S],w=T[x],A=T[y];T[y]=w,T[x]=A}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,s=n.length;let o=this.nCachedObjects_,f=e.length;for(let d=0,p=arguments.length;d!==p;++d){const m=arguments[d],y=m.uuid,x=t[y];if(x!==void 0)if(delete t[y],x 0&&(t[S.uuid]=x),e[x]=S,e.pop();for(let M=0,T=s;M!==T;++M){const w=n[M];w[x]=w[v],w.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let s=n[e];const o=this._bindings;if(s!==void 0)return o[s];const f=this._paths,d=this._parsedPaths,p=this._objects,m=p.length,y=this.nCachedObjects_,x=new Array(m);s=o.length,n[e]=s,f.push(e),d.push(t),o.push(x);for(let v=y,S=p.length;v!==S;++v){const M=p[v];x[v]=new Cn(M,e,t)}return x}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const s=this._paths,o=this._parsedPaths,f=this._bindings,d=f.length-1,p=f[d],m=e[d];t[m]=n,f[n]=p,f.pop(),o[n]=o[d],o.pop(),s[n]=s[d],s.pop()}}}class rE{constructor(e,t,n=null,s=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=s;const o=t.tracks,f=o.length,d=new Array(f),p={endingStart:lf,endingEnd:lf};for(let m=0;m!==f;++m){const y=o[m].createInterpolant(null);d[m]=y,y.settings=p}this._interpolantSettings=p,this._interpolants=d,this._propertyBindings=new Array(f),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=QA,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const s=this._clip.duration,o=e._clip.duration,f=o/s,d=s/o;e.warp(1,f,t),this.warp(d,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const s=this._mixer,o=s.time,f=this.timeScale;let d=this._timeScaleInterpolant;d===null&&(d=s._lendControlInterpolant(),this._timeScaleInterpolant=d);const p=d.parameterPositions,m=d.sampleValues;return p[0]=o,p[1]=o+n,m[0]=e/f,m[1]=t/f,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,s){if(!this.enabled){this._updateWeight(e);return}const o=this._startTime;if(o!==null){const p=(e-o)*n;p<0||n===0?t=0:(this._startTime=null,t=n*p)}t*=this._updateTimeScale(e);const f=this._updateTime(t),d=this._updateWeight(e);if(d>0){const p=this._interpolants,m=this._propertyBindings;switch(this.blendMode){case Zb:for(let y=0,x=p.length;y!==x;++y)p[y].evaluate(f),m[y].accumulateAdditive(d);break;case Fx:default:for(let y=0,x=p.length;y!==x;++y)p[y].evaluate(f),m[y].accumulate(s,d)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const s=n.evaluate(e)[0];t*=s,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let s=this.time+e,o=this._loopCount;const f=n===JA;if(e===0)return o===-1?s:f&&(o&1)===1?t-s:s;if(n===KA){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,f)):this._setEndings(this.repetitions===0,!0,f)),s>=t||s<0){const d=Math.floor(s/t);s-=t*d,o+=Math.abs(d);const p=this.repetitions-o;if(p<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=e>0?t:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(p===1){const m=e<0;this._setEndings(m,!m,f)}else this._setEndings(!1,!1,f);this._loopCount=o,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d})}}else this.time=s;if(f&&(o&1)===1)return t-s}return s}_setEndings(e,t,n){const s=this._interpolantSettings;n?(s.endingStart=cf,s.endingEnd=cf):(e?s.endingStart=this.zeroSlopeAtStart?cf:lf:s.endingStart=z0,t?s.endingEnd=this.zeroSlopeAtEnd?cf:lf:s.endingEnd=z0)}_scheduleFading(e,t,n){const s=this._mixer,o=s.time;let f=this._weightInterpolant;f===null&&(f=s._lendControlInterpolant(),this._weightInterpolant=f);const d=f.parameterPositions,p=f.sampleValues;return d[0]=o,p[0]=t,d[1]=o+e,p[1]=n,this}}const NR=new Float32Array(1);class OR extends Zo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,s=e._clip.tracks,o=s.length,f=e._propertyBindings,d=e._interpolants,p=n.uuid,m=this._bindingsByRootAndName;let y=m[p];y===void 0&&(y={},m[p]=y);for(let x=0;x!==o;++x){const v=s[x],S=v.name;let M=y[S];if(M!==void 0)++M.referenceCount,f[x]=M;else{if(M=f[x],M!==void 0){M._cacheIndex===null&&(++M.referenceCount,this._addInactiveBinding(M,p,S));continue}const T=t&&t._propertyBindings[x].binding.parsedPath;M=new sE(Cn.create(n,S,T),v.ValueTypeName,v.getValueSize()),++M.referenceCount,this._addInactiveBinding(M,p,S),f[x]=M}d[x].resultBuffer=M.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,s=e._clip.uuid,o=this._actionsByClip[s];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,s,n)}const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,s=t.length;n!==s;++n){const o=t[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t =0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,s=this.time+=e,o=Math.sign(e),f=this._accuIndex^=1;for(let m=0;m!==n;++m)t[m]._update(s,e,o,f);const d=this._bindings,p=this._nActiveBindings;for(let m=0;m!==p;++m)d[m].apply(f);return this}setTime(e){this.time=0;for(let t=0;t =this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,G3).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const X3=new X,uy=new X,Qd=new X,Jd=new X,j2=new X,HR=new X,kR=new X;class lE{constructor(e=new X,t=new X){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){X3.subVectors(e,this.start),uy.subVectors(this.end,this.start);const n=uy.dot(uy);let o=uy.dot(X3)/n;return t&&(o=Xt(o,0,1)),o}closestPointToPoint(e,t,n){const s=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(s).add(this.start)}distanceSqToLine3(e,t=HR,n=kR){const s=10000000000000001e-32;let o,f;const d=this.start,p=e.start,m=this.end,y=e.end;Qd.subVectors(m,d),Jd.subVectors(y,p),j2.subVectors(d,p);const x=Qd.dot(Qd),v=Jd.dot(Jd),S=Jd.dot(j2);if(x<=s&&v<=s)return t.copy(d),n.copy(p),t.sub(n),t.dot(t);if(x<=s)o=0,f=S/v,f=Xt(f,0,1);else{const M=Qd.dot(j2);if(v<=s)f=0,o=Xt(-M/x,0,1);else{const T=Qd.dot(Jd),w=x*v-T*T;w!==0?o=Xt((T*S-M*v)/w,0,1):o=0,f=(T*o+S)/v,f<0?(f=0,o=Xt(-M/x,0,1)):f>1&&(f=1,o=Xt((T-M)/x,0,1))}}return t.copy(d).add(Qd.multiplyScalar(o)),n.copy(p).add(Jd.multiplyScalar(f)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const q3=new X;class VR extends Rn{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new tn,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let f=0,d=1,p=32;f 1)for(let x=0;x
.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Q3.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Q3,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class n5 extends Ko{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new tn;s.setAttribute("position",new At(t,3)),s.setAttribute("color",new At(n,3));const o=new ps({vertexColors:!0,toneMapped:!1});super(s,o),this.type="AxesHelper"}setColors(e,t,n){const s=new gt,o=this.geometry.attributes.color.array;return s.set(e),s.toArray(o,0),s.toArray(o,3),s.set(t),s.toArray(o,6),s.toArray(o,9),s.set(n),s.toArray(o,12),s.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class i5{constructor(){this.type="ShapePath",this.color=new gt,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new _x,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,s){return this.currentPath.quadraticCurveTo(e,t,n,s),this}bezierCurveTo(e,t,n,s,o,f){return this.currentPath.bezierCurveTo(e,t,n,s,o,f),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(A){const D=[];for(let N=0,U=A.length;NNumber.EPSILON){if(P<0&&(j=D[z],B=-B,q=D[I],P=-P),A.y q.y)continue;if(A.y===j.y){if(A.x===j.x)return!0}else{const W=P*(A.x-j.x)-B*(A.y-j.y);if(W===0)return!0;if(W<0)continue;U=!U}}else{if(A.y!==j.y)continue;if(q.x<=A.x&&A.x<=j.x||j.x<=A.x&&A.x<=q.x)return!0}}return U}const s=Jr.isClockWise,o=this.subPaths;if(o.length===0)return[];let f,d,p;const m=[];if(o.length===1)return d=o[0],p=new mf,p.curves=d.curves,m.push(p),m;let y=!s(o[0].getPoints());y=e?!y:y;const x=[],v=[];let S=[],M=0,T;v[M]=void 0,S[M]=[];for(let A=0,D=o.length;A 1){let A=!1,D=0;for(let N=0,U=v.length;N0&&A===!1&&(S=x)}let w;for(let A=0,D=v.length;A e?(a.repeat.x=1,a.repeat.y=t/e,a.offset.x=0,a.offset.y=(1-a.repeat.y)/2):(a.repeat.x=e/t,a.repeat.y=1,a.offset.x=(1-a.repeat.x)/2,a.offset.y=0),a}function r5(a,e){const t=a.image&&a.image.width?a.image.width/a.image.height:1;return t>e?(a.repeat.x=e/t,a.repeat.y=1,a.offset.x=(1-a.repeat.x)/2,a.offset.y=0):(a.repeat.x=1,a.repeat.y=t/e,a.offset.x=0,a.offset.y=(1-a.repeat.y)/2),a}function o5(a){return a.repeat.x=1,a.repeat.y=1,a.offset.x=0,a.offset.y=0,a}function Tb(a,e,t,n){const s=l5(n);switch(t){case Yb:return a*e;case zx:return a*e/s.components*s.byteLength;case K0:return a*e/s.components*s.byteLength;case Px:return a*e*2/s.components*s.byteLength;case Bx:return a*e*2/s.components*s.byteLength;case Wb:return a*e*3/s.components*s.byteLength;case Ha:return a*e*4/s.components*s.byteLength;case Ix:return a*e*4/s.components*s.byteLength;case _0:case S0:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case A0:case M0:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Gy:case qy:return Math.max(a,16)*Math.max(e,8)/4;case Vy:case Xy:return Math.max(a,8)*Math.max(e,8)/2;case Yy:case Wy:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*8;case Zy:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Ky:return Math.floor((a+3)/4)*Math.floor((e+3)/4)*16;case Qy:return Math.floor((a+4)/5)*Math.floor((e+3)/4)*16;case Jy:return Math.floor((a+4)/5)*Math.floor((e+4)/5)*16;case $y:return Math.floor((a+5)/6)*Math.floor((e+4)/5)*16;case ex:return Math.floor((a+5)/6)*Math.floor((e+5)/6)*16;case tx:return Math.floor((a+7)/8)*Math.floor((e+4)/5)*16;case nx:return Math.floor((a+7)/8)*Math.floor((e+5)/6)*16;case ix:return Math.floor((a+7)/8)*Math.floor((e+7)/8)*16;case ax:return Math.floor((a+9)/10)*Math.floor((e+4)/5)*16;case sx:return Math.floor((a+9)/10)*Math.floor((e+5)/6)*16;case rx:return Math.floor((a+9)/10)*Math.floor((e+7)/8)*16;case ox:return Math.floor((a+9)/10)*Math.floor((e+9)/10)*16;case lx:return Math.floor((a+11)/12)*Math.floor((e+9)/10)*16;case cx:return Math.floor((a+11)/12)*Math.floor((e+11)/12)*16;case ux:case fx:case dx:return Math.ceil(a/4)*Math.ceil(e/4)*16;case hx:case px:return Math.ceil(a/4)*Math.ceil(e/4)*8;case mx:case gx:return Math.ceil(a/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function l5(a){switch(a){case xr:case Vb:return{byteLength:1,components:1};case lh:case Gb:case _f:return{byteLength:2,components:1};case Ux:case Lx:return{byteLength:2,components:4};case Vl:case Ox:case Rs:return{byteLength:4,components:1};case Xb:case qb:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${a}.`)}class c5{static contain(e,t){return s5(e,t)}static cover(e,t){return r5(e,t)}static fill(e){return o5(e)}static getByteLength(e,t,n,s){return Tb(e,t,n,s)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_h}}));typeof window<"u"&&(window.__THREE__?mt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_h);function uE(){let a=null,e=!1,t=null,n=null;function s(o,f){t(o,f),n=a.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(n=a.requestAnimationFrame(s),e=!0)},stop:function(){a.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){a=o}}}function u5(a){const e=new WeakMap;function t(d,p){const m=d.array,y=d.usage,x=m.byteLength,v=a.createBuffer();a.bindBuffer(p,v),a.bufferData(p,m,y),d.onUploadCallback();let S;if(m instanceof Float32Array)S=a.FLOAT;else if(typeof Float16Array<"u"&&m instanceof Float16Array)S=a.HALF_FLOAT;else if(m instanceof Uint16Array)d.isFloat16BufferAttribute?S=a.HALF_FLOAT:S=a.UNSIGNED_SHORT;else if(m instanceof Int16Array)S=a.SHORT;else if(m instanceof Uint32Array)S=a.UNSIGNED_INT;else if(m instanceof Int32Array)S=a.INT;else if(m instanceof Int8Array)S=a.BYTE;else if(m instanceof Uint8Array)S=a.UNSIGNED_BYTE;else if(m instanceof Uint8ClampedArray)S=a.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+m);return{buffer:v,type:S,bytesPerElement:m.BYTES_PER_ELEMENT,version:d.version,size:x}}function n(d,p,m){const y=p.array,x=p.updateRanges;if(a.bindBuffer(m,d),x.length===0)a.bufferSubData(m,0,y);else{x.sort((S,M)=>S.start-M.start);let v=0;for(let S=1;S 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,T5=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,C5=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,R5=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,D5=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,N5=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,O5=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,U5=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,L5=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,z5=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,P5=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,B5=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,I5=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,F5=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,j5=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,H5="gl_FragColor = linearToOutputTexel( gl_FragColor );",k5=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,V5=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,G5=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,X5=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,q5=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Y5=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,W5=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Z5=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,K5=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,Q5=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,J5=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,$5=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,eD=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,tD=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,nD=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,iD=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,aD=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,sD=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,rD=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,oD=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lD=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,cD=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 uv = vec2( roughness, dotNV ); + return texture2D( dfgLUT, uv ).rg; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness ); + vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness ); + vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,uD=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,fD=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,dD=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,hD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,pD=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,mD=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,gD=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,yD=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,xD=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,vD=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,bD=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,_D=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,SD=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,AD=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,MD=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,ED=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,wD=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,TD=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,CD=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,RD=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,DD=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,ND=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,OD=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,UD=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,LD=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,zD=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,PD=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,BD=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,ID=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,FD=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,jD=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,HD=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,kD=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,VD=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,GD=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,XD=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,qD=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + float depth = unpackRGBAToDepth( texture2D( depths, uv ) ); + #ifdef USE_REVERSED_DEPTH_BUFFER + return step( depth, compare ); + #else + return step( compare, depth ); + #endif + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow( sampler2D shadow, vec2 uv, float compare ) { + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( distribution.x, compare ); + #else + float hard_shadow = step( compare, distribution.x ); + #endif + if ( hard_shadow != 1.0 ) { + float distance = compare - distribution.x; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,YD=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,WD=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,ZD=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,KD=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,QD=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,JD=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,$D=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,eN=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,tN=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,nN=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,iN=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,aN=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,sN=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,rN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,oN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,lN=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,cN=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const uN=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,fN=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,dN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,hN=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,pN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,mN=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,gN=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,yN=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,xN=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,vN=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,bN=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,_N=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,SN=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,AN=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include