diff --git a/assets/dark/1.jpg b/assets/dark/1.jpg
deleted file mode 100644
index 6a32479f..00000000
Binary files a/assets/dark/1.jpg and /dev/null differ
diff --git a/assets/icons/blank_fallback.svg b/assets/icons/blank_fallback.svg
new file mode 100644
index 00000000..00585d2d
--- /dev/null
+++ b/assets/icons/blank_fallback.svg
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/assets/icons/cardano.svg b/assets/icons/cardano.svg
new file mode 100644
index 00000000..b732eef6
--- /dev/null
+++ b/assets/icons/cardano.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/index.ts b/assets/icons/index.ts
index 90177943..5bbf1e5d 100644
--- a/assets/icons/index.ts
+++ b/assets/icons/index.ts
@@ -7,3 +7,5 @@ export { default as StarIcon } from "./star.svg";
export { default as CopyIcon } from "./copy.svg";
export { default as CopySuccessIcon } from "./copy_success.svg";
export { default as SingleCommitIcon } from "./single_commit.svg";
+export { default as CardanoIcon } from "./cardano.svg";
+export { default as BlankFallback } from "./blank_fallback.svg";
diff --git a/assets/icons/oss.svg b/assets/icons/oss.svg
index 3c7642e6..6e0a8644 100644
--- a/assets/icons/oss.svg
+++ b/assets/icons/oss.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/assets/images/black_sand.jpg b/assets/images/black_sand.jpg
deleted file mode 100644
index 6a32479f..00000000
Binary files a/assets/images/black_sand.jpg and /dev/null differ
diff --git a/assets/light/1.jpg b/assets/light/1.jpg
deleted file mode 100644
index ed6d403a..00000000
Binary files a/assets/light/1.jpg and /dev/null differ
diff --git a/components/Favicon.tsx b/components/Favicon.tsx
deleted file mode 100644
index 1a3d93eb..00000000
--- a/components/Favicon.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import Image from "next/image";
-
-type FaviconProps = {
- url: string | null;
-};
-
-const Favicon = ({ url }: FaviconProps) => {
- return (
-
-
-
- );
-};
-
-export default Favicon;
diff --git a/components/HomeHero.jsx b/components/HomeHero.jsx
index 726acd1d..5855b911 100644
--- a/components/HomeHero.jsx
+++ b/components/HomeHero.jsx
@@ -1,4 +1,3 @@
-// components/HomeHero.jsx
import Link from "next/link";
import Image from "next/image";
import bgImage from "../assets/images/bg.jpg";
@@ -26,7 +25,10 @@ const HomeHero = () => {
-
+
Adastack is your comprehensive guide to the Cardano ecosystem.
Open-source knowledge, curated by the Cardano community.
diff --git a/components/LibraryInfoBar.tsx b/components/LibraryInfoBar.tsx
new file mode 100644
index 00000000..d8cc9105
--- /dev/null
+++ b/components/LibraryInfoBar.tsx
@@ -0,0 +1,21 @@
+import React from "react";
+import RepoShieldIo from "./badges/shield_io_badges/RepoShieldIo";
+import LanguageShieldIo from "./badges/shield_io_badges/LanguageShieldIo";
+import LatestCommitBadgeIo from "./badges/shield_io_badges/LatestCommitBadgeIo";
+
+interface LibraryInfoBarProps {
+ repoURL: string;
+ language: string;
+}
+
+const LibraryInfoBar = ({ repoURL, language }: LibraryInfoBarProps) => {
+ return (
+
+
+
+
+
+ );
+};
+
+export default LibraryInfoBar;
diff --git a/components/StarBadge.tsx b/components/StarBadge.tsx
deleted file mode 100644
index b8ca0c08..00000000
--- a/components/StarBadge.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import React, { useEffect, useState, useCallback } from "react";
-
-const isValidRepoURL = (url) => {
- try {
- const parsedURL = new URL(url);
- const isGitHub = parsedURL.hostname === "github.com";
- const pathParts = parsedURL.pathname.split("/").filter(Boolean);
-
- return isGitHub && pathParts.length >= 1;
- } catch (error) {
- console.error("Error parsing URL:", error);
- return false;
- }
-};
-
-// Memoized StarIcon component
-const StarIcon = React.memo(() => (
-
-));
-
-StarIcon.displayName = "StarIcon";
-
-const StarBadge = ({ repoURL }) => {
- const [stars, setStars] = useState(null);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- // Function to fetch all GitHub repos for a user or organization
- const fetchAllGitHubRepos = useCallback(async (url, name) => {
- let response = await fetch(url, {
- headers: {
- Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN}`,
- Accept: "application/vnd.github.v3+json",
- },
- });
- if (response.status === 404) {
- // If user not found, try organization endpoint
- url = `https://api.github.com/orgs/${name}/repos?per_page=100`;
- response = await fetch(url, {
- headers: {
- Authorization: `token ${process.env.GITHUB_ACCESS_TOKEN}`,
- Accept: "application/vnd.github.v3+json",
- },
- });
- }
- if (!response.ok) {
- const errorMessage = `HTTP error! Status: ${response.status}, Text: ${response.statusText}`;
- console.error(errorMessage);
- throw new Error(errorMessage);
- }
- const repos = await response.json();
- const nextLink = response.headers
- .get("Link")
- ?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
- return { repos, nextLink };
- }, []);
-
- // Function to fetch total star count for a GitHub user or organization
- const fetchGitHubStars = useCallback(
- async (name) => {
- let url = `https://api.github.com/users/${name}/repos?per_page=100`;
- let totalStars = 0;
-
- while (url) {
- const { repos, nextLink } = await fetchAllGitHubRepos(url, name);
- totalStars += repos.reduce(
- (sum, repo) => sum + repo.stargazers_count,
- 0
- );
- url = nextLink;
- }
- return totalStars;
- },
- [fetchAllGitHubRepos]
- );
-
- // Main function to fetch stars
- const fetchStars = useCallback(async () => {
- if (!isValidRepoURL(repoURL)) {
- console.error("Error: Invalid repository URL");
- setError("Error: Invalid URL");
- setLoading(false);
- return;
- }
-
- try {
- const urlParts = new URL(repoURL).pathname.split("/").filter(Boolean);
- const owner = urlParts[0];
- const starCount = await fetchGitHubStars(owner);
-
- setStars(starCount);
- setLoading(false);
- } catch (error) {
- console.error("Error fetching stars:", error);
- setError("Unable to fetch data");
- setLoading(false);
- }
- }, [repoURL, fetchGitHubStars]);
-
- // Effect to trigger star fetching
- useEffect(() => {
- fetchStars();
- }, [fetchStars]);
-
- // Determine badge content based on loading/error state
- const getBadgeContent = () => {
- if (loading) return "Loading...";
- if (error) return error;
- return stars !== null ? stars.toLocaleString() : "N/A";
- };
-
- // Render the star badge
- return (
-
-
-
- {getBadgeContent()}
-
-
- );
-};
-
-export default StarBadge;
diff --git a/components/badges/Favicon.tsx b/components/badges/Favicon.tsx
index 89ba2d54..b0f5d07b 100644
--- a/components/badges/Favicon.tsx
+++ b/components/badges/Favicon.tsx
@@ -1,16 +1,31 @@
import Image from "next/image";
+import { useState } from "react";
+import { BlankFallback } from "../../assets/icons";
type FaviconProps = {
url: string | null;
};
const Favicon = ({ url }: FaviconProps) => {
+ const [imageError, setImageError] = useState(false);
+ const [src] = useState(
+ `https://www.google.com/s2/favicons?sz=128&domain_url=${url}`
+ );
+
return (
-
-
+
+ {imageError ? (
+
+ ) : (
+ setImageError(true)}
+ />
+ )}
);
};
diff --git a/components/badges/OS.tsx b/components/badges/OS.tsx
new file mode 100644
index 00000000..a96e6f73
--- /dev/null
+++ b/components/badges/OS.tsx
@@ -0,0 +1,19 @@
+import { OSIcon } from "../../assets/icons";
+
+const OS = ({ url, className }) => {
+ if (!url) return null;
+
+ const spanClass = className
+ ? `open-source-icon-inline inline-block h-3 w-3 ${className}`
+ : "open-source-icon-inline inline-block h-3 w-3";
+
+ return (
+
+
+
+
+
+ );
+};
+
+export default OS;
diff --git a/components/badges/shield_io_badges/CodeLanguageShieldIoBadge.tsx b/components/badges/shield_io_badges/CodeLanguageShieldIoBadge.tsx
deleted file mode 100644
index f27b337f..00000000
--- a/components/badges/shield_io_badges/CodeLanguageShieldIoBadge.tsx
+++ /dev/null
@@ -1,108 +0,0 @@
-import React from "react";
-import Image from "next/image";
-
-const CodeLanguageShieldIoBadge = ({ language }) => {
- if (!language) return null;
-
- // Convert language name to lowercase and handle special cases
- const formatLanguageName = (name) => {
- const specialCases = {
- "c++": "cpp",
- "c#": "csharp",
- "f#": "fsharp",
- "objective-c": "objectivec",
- "jupyter notebook": "jupyter",
- cuda: "nvidia",
- };
- return specialCases[name.toLowerCase()] || name.toLowerCase();
- };
-
- const languageLower = formatLanguageName(language);
-
- // Logo colors mapped to GitHub's language colors
- const logoColorMap = {
- assembly: "6E4C13",
- c: "555555",
- cpp: "F34B7D",
- csharp: "178600",
- css: "563D7C",
- dart: "00B4AB",
- elixir: "6E4A7E",
- elm: "60B5CC",
- erlang: "B83998",
- fsharp: "B845FC",
- go: "00ADD8",
- groovy: "4298B8",
- haskell: "5D4F85",
- html: "E34C26",
- java: "B07219",
- javascript: "F1E05A",
- julia: "A270BA",
- jupyter: "DA5B0B",
- kotlin: "A97BFF",
- latex: "008080",
- lua: "000080",
- markdown: "083FA1",
- nix: "7E7EFF",
- objectivec: "438EFF",
- ocaml: "3BE133",
- perl: "0298C3",
- php: "4F5D95",
- python: "3572A5",
- r: "198CE7",
- ruby: "701516",
- rust: "DEA584",
- scala: "C22D40",
- shell: "89E051",
- solidity: "AA6746",
- swift: "F05138",
- typescript: "007ACC",
- vim: "199F4B",
- vue: "41B883",
- webassembly: "04133B",
- zig: "EC915C",
- default: "333333",
- };
-
- const logoColor = logoColorMap[languageLower] || logoColorMap.default;
-
- return (
- <>
-
-
-
- >
- );
-};
-
-export default CodeLanguageShieldIoBadge;
diff --git a/components/badges/shield_io_badges/LanguageShieldIo.tsx b/components/badges/shield_io_badges/LanguageShieldIo.tsx
new file mode 100644
index 00000000..90d6b87a
--- /dev/null
+++ b/components/badges/shield_io_badges/LanguageShieldIo.tsx
@@ -0,0 +1,114 @@
+import React from "react";
+
+interface LanguageShieldIoProps {
+ language: string;
+ isColorChanging?: boolean;
+}
+
+const LanguageShieldIo = ({
+ language,
+ isColorChanging = false,
+}: LanguageShieldIoProps) => {
+ if (!language) return null;
+
+ const capitalizedLanguage =
+ language.charAt(0).toUpperCase() + language.slice(1);
+
+ // Convert language name to lowercase and handle special cases
+ const formatLanguageName = (name) => {
+ const specialCases = {
+ "c++": "cplusplus",
+ "c#": "csharp",
+ "f#": "fsharp",
+ "objective-c": "objectivec",
+ "jupyter notebook": "jupyter",
+ html: "html5",
+ java: "openjdk",
+ nix: "nixos",
+ css: "css3",
+ scss: "sass",
+ };
+ return specialCases[name.toLowerCase()] || name.toLowerCase();
+ };
+
+ const languageLower = formatLanguageName(language);
+
+ const encodedLanguage = encodeURIComponent(capitalizedLanguage);
+
+ // Logo colors mapped to GitHub's language colors
+ const logoColorMap = {
+ cplusplus: "007cc7",
+ csharp: "178600",
+ fsharp: "B845FC",
+ objectivec: "438EFF",
+ jupyter: "DA5B0B",
+ html5: "E34C26",
+ openjdk: "ED8B00",
+ nixos: "5277c3",
+ assembly: "6E4C13",
+ css3: "563D7C",
+ sass: "cc6599",
+ agda: "315665",
+ c: "555555",
+ dart: "00B4AB",
+ elixir: "6E4A7E",
+ elm: "60B5CC",
+ erlang: "B83998",
+ go: "00ADD8",
+ groovy: "4298B8",
+ gleam: "FFAFF3",
+ haskell: "5D4F85",
+ javascript: "F1E05A",
+ julia: "A270BA",
+ kotlin: "A97BFF",
+ latex: "008080",
+ lua: "000080",
+ markdown: "083FA1",
+ ocaml: "3BE133",
+ perl: "0298C3",
+ php: "4F5D95",
+ python: "3572A5",
+ r: "198CE7",
+ ruby: "701516",
+ rust: "DEA584",
+ scala: "C22D40",
+ shell: "89E051",
+ solidity: "AA6746",
+ swift: "F05138",
+ typescript: "007ACC",
+ vim: "199F4B",
+ vue: "4FC08D",
+ webassembly: "04133B",
+ zig: "EC915C",
+ default: "333333",
+ };
+
+ const logoColor = logoColorMap[languageLower] || logoColorMap.default;
+
+ if (!isColorChanging) {
+ return (
+
+ );
+ }
+
+ return (
+ <>
+
+
+ >
+ );
+};
+
+export default LanguageShieldIo;
diff --git a/components/badges/shield_io_badges/LatestCommitBadgeIo.tsx b/components/badges/shield_io_badges/LatestCommitBadgeIo.tsx
new file mode 100644
index 00000000..ebe9ac1d
--- /dev/null
+++ b/components/badges/shield_io_badges/LatestCommitBadgeIo.tsx
@@ -0,0 +1,36 @@
+import React from "react";
+
+interface LatestCommitBadgeIoProps {
+ repoURL: string;
+}
+
+const LatestCommitBadgeIo = ({ repoURL }: LatestCommitBadgeIoProps) => {
+ const url = new URL(repoURL);
+ const cleanPath = url.pathname.replace(/\/+$/, "");
+ const pathSegments = cleanPath.split("/").filter(Boolean);
+ const [owner, repo] = pathSegments;
+
+ const isGitLab = url.hostname === "gitlab.com";
+
+
+ const latestURL = isGitLab
+ ? `${url.origin}/${owner}/${repo}/-/commits/`
+ : `${url.origin}/${owner}/${repo}/commits/`;
+
+
+ const shieldUrl = isGitLab
+ ? `https://img.shields.io/gitlab/last-commit/${owner}/${repo}?color=dfe8f0&labelColor=white`
+ : `https://img.shields.io/github/last-commit/${owner}/${repo}?color=dfe8f0&labelColor=white`;
+
+ return (
+
+
+
+ );
+};
+
+export default LatestCommitBadgeIo;
diff --git a/components/badges/shield_io_badges/RepoShieldIo.tsx b/components/badges/shield_io_badges/RepoShieldIo.tsx
new file mode 100644
index 00000000..42f06721
--- /dev/null
+++ b/components/badges/shield_io_badges/RepoShieldIo.tsx
@@ -0,0 +1,30 @@
+import React from "react";
+
+interface RepoShieldIoProps {
+ repoURL: string;
+}
+
+const RepoShieldIo = ({ repoURL }: RepoShieldIoProps) => {
+ const url = new URL(repoURL);
+ const cleanPath = url.pathname.replace(/\/+$/, '');
+ const pathSegments = cleanPath.split('/').filter(Boolean);
+ const [owner, repo] = pathSegments;
+
+ const isGitLab = url.hostname === 'gitlab.com';
+
+ const shieldUrl = isGitLab
+ ? `https://img.shields.io/gitlab/stars/${owner}/${repo}?style=social&label=GitLab`
+ : `https://img.shields.io/github/stars/${owner}/${repo}?style=social&label=GitHub`;
+
+ return (
+
+
+
+ );
+};
+
+export default RepoShieldIo;
\ No newline at end of file
diff --git a/components/badges/shield_io_badges/RepoShieldIoBadge.tsx b/components/badges/shield_io_badges/RepoShieldIoBadge.tsx
deleted file mode 100644
index 98dc4c10..00000000
--- a/components/badges/shield_io_badges/RepoShieldIoBadge.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import React from "react";
-import Image from "next/image";
-
-interface RepoShieldIoBadgeProps {
- githubUrl: string;
- text?: string;
-}
-
-const RepoShieldIoBadge: React.FC = React.memo(
- ({ githubUrl, text = "Repo Github" }) => {
- if (!githubUrl) {
- return null;
- }
-
- // Extract owner and repo from GitHub URL
- const urlParts = githubUrl.split("/");
- const owner = urlParts[urlParts.length - 2];
- const repo = urlParts[urlParts.length - 1];
-
- // Create shields.io URL with flat style and white background
- const shieldsIoUrl = `https://img.shields.io/github/stars/${owner}/${repo}?style=flat&logo=github&logoColor=000000&label=${encodeURIComponent(
- text
- )}&labelColor=ffffff&color=ffffff`;
-
- return (
-
-
-
- );
- }
-);
-
-// Assign display name to the memoized component
-RepoShieldIoBadge.displayName = "RepoShieldIoBadge";
-
-export default RepoShieldIoBadge;
diff --git a/components/demo_components/blackhole.js b/components/demo_components/blackhole.js
deleted file mode 100644
index e64abdef..00000000
--- a/components/demo_components/blackhole.js
+++ /dev/null
@@ -1,33398 +0,0 @@
-import React, { useEffect } from "react";
-import * as THREE from "three";
-import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
-function Blackhole() {
- useEffect(() => {
- var lu = Object.defineProperty;
- var cu = (r, e, t) =>
- e in r
- ? lu(r, e, {
- enumerable: !0,
- configurable: !0,
- writable: !0,
- value: t,
- })
- : (r[e] = t);
- var Xr = (r, e, t) => (cu(r, typeof e != "symbol" ? e + "" : e, t), t);
- const hu = function () {
- const e = document.createElement("link").relList;
- if (e && e.supports && e.supports("modulepreload")) return;
- for (const i of document.querySelectorAll('link[rel="modulepreload"]'))
- n(i);
- new MutationObserver((i) => {
- for (const s of i)
- if (s.type === "childList")
- for (const a of s.addedNodes)
- a.tagName === "LINK" && a.rel === "modulepreload" && n(a);
- }).observe(document, { childList: !0, subtree: !0 });
- function t(i) {
- const s = {};
- return (
- i.integrity && (s.integrity = i.integrity),
- i.referrerpolicy && (s.referrerPolicy = i.referrerpolicy),
- i.crossorigin === "use-credentials"
- ? (s.credentials = "include")
- : i.crossorigin === "anonymous"
- ? (s.credentials = "omit")
- : (s.credentials = "same-origin"),
- s
- );
- }
- function n(i) {
- if (i.ep) return;
- i.ep = !0;
- const s = t(i);
- fetch(i.href, s);
- }
- };
- hu();
- /**
- * @license
- * Copyright 2010-2022 Three.js Authors
- * SPDX-License-Identifier: MIT
- */ const to = "141",
- mi = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 },
- gi = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 },
- uu = 0,
- Io = 1,
- du = 2,
- Cc = 1,
- Lc = 2,
- _s = 3,
- ki = 0,
- qt = 1,
- cn = 2,
- fu = 1,
- Un = 0,
- zi = 1,
- Sr = 2,
- Fo = 3,
- No = 4,
- pu = 5,
- Di = 100,
- mu = 101,
- gu = 102,
- zo = 103,
- Oo = 104,
- vu = 200,
- _u = 201,
- xu = 202,
- yu = 203,
- Rc = 204,
- Pc = 205,
- Mu = 206,
- wu = 207,
- bu = 208,
- Su = 209,
- Tu = 210,
- Eu = 0,
- Au = 1,
- Cu = 2,
- Fa = 3,
- Lu = 4,
- Ru = 5,
- Pu = 6,
- Du = 7,
- zr = 0,
- Iu = 1,
- Fu = 2,
- $t = 0,
- Dc = 1,
- Ic = 2,
- Fc = 3,
- Nc = 4,
- Nu = 5,
- zc = 300,
- Ui = 301,
- Bi = 302,
- Tr = 303,
- Na = 304,
- Or = 306,
- hn = 1e3,
- gt = 1001,
- Er = 1002,
- ft = 1003,
- za = 1004,
- Oa = 1005,
- $e = 1006,
- Oc = 1007,
- li = 1008,
- oi = 1009,
- zu = 1010,
- Ou = 1011,
- kc = 1012,
- ku = 1013,
- ii = 1014,
- Ft = 1015,
- Mn = 1016,
- Uu = 1017,
- Bu = 1018,
- Oi = 1020,
- Vu = 1021,
- Gu = 1022,
- Nt = 1023,
- Hu = 1024,
- Wu = 1025,
- ri = 1026,
- Vi = 1027,
- Uc = 1028,
- ju = 1029,
- Xu = 1030,
- qu = 1031,
- $u = 1033,
- qr = 33776,
- $r = 33777,
- Yr = 33778,
- Kr = 33779,
- ko = 35840,
- Uo = 35841,
- Bo = 35842,
- Vo = 35843,
- Yu = 36196,
- Go = 37492,
- Ho = 37496,
- Wo = 37808,
- jo = 37809,
- Xo = 37810,
- qo = 37811,
- $o = 37812,
- Yo = 37813,
- Ko = 37814,
- Zo = 37815,
- Jo = 37816,
- Qo = 37817,
- el = 37818,
- tl = 37819,
- nl = 37820,
- il = 37821,
- sl = 36492,
- Es = 2300,
- Gi = 2301,
- Zr = 2302,
- rl = 2400,
- al = 2401,
- ol = 2402,
- Ku = 2500,
- Zu = 2501,
- Ju = 1,
- Bc = 2,
- Vn = 3e3,
- Pe = 3001,
- Qu = 3200,
- ed = 3201,
- ci = 0,
- td = 1,
- yn = "srgb",
- si = "srgb-linear",
- Jr = 7680,
- nd = 519,
- ka = 35044,
- Tn = "300 es",
- Ua = 1035;
- class hi {
- 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) {
- if (this._listeners === void 0) return !1;
- const n = this._listeners;
- return n[e] !== void 0 && n[e].indexOf(t) !== -1;
- }
- removeEventListener(e, t) {
- if (this._listeners === void 0) return;
- const i = this._listeners[e];
- if (i !== void 0) {
- const s = i.indexOf(t);
- s !== -1 && i.splice(s, 1);
- }
- }
- dispatchEvent(e) {
- if (this._listeners === void 0) return;
- const n = this._listeners[e.type];
- if (n !== void 0) {
- e.target = this;
- const i = n.slice(0);
- for (let s = 0, a = i.length; s < a; s++) i[s].call(this, e);
- e.target = null;
- }
- }
- }
- const dt = [];
- for (let r = 0; r < 256; r++)
- dt[r] = (r < 16 ? "0" : "") + r.toString(16);
- let ll = 1234567;
- const ys = Math.PI / 180,
- As = 180 / Math.PI;
- function Yt() {
- const r = (Math.random() * 4294967295) | 0,
- e = (Math.random() * 4294967295) | 0,
- t = (Math.random() * 4294967295) | 0,
- n = (Math.random() * 4294967295) | 0;
- return (
- dt[r & 255] +
- dt[(r >> 8) & 255] +
- dt[(r >> 16) & 255] +
- dt[(r >> 24) & 255] +
- "-" +
- dt[e & 255] +
- dt[(e >> 8) & 255] +
- "-" +
- dt[((e >> 16) & 15) | 64] +
- dt[(e >> 24) & 255] +
- "-" +
- dt[(t & 63) | 128] +
- dt[(t >> 8) & 255] +
- "-" +
- dt[(t >> 16) & 255] +
- dt[(t >> 24) & 255] +
- dt[n & 255] +
- dt[(n >> 8) & 255] +
- dt[(n >> 16) & 255] +
- dt[(n >> 24) & 255]
- ).toLowerCase();
- }
- function at(r, e, t) {
- return Math.max(e, Math.min(t, r));
- }
- function no(r, e) {
- return ((r % e) + e) % e;
- }
- function id(r, e, t, n, i) {
- return n + ((r - e) * (i - n)) / (t - e);
- }
- function sd(r, e, t) {
- return r !== e ? (t - r) / (e - r) : 0;
- }
- function Ms(r, e, t) {
- return (1 - t) * r + t * e;
- }
- function rd(r, e, t, n) {
- return Ms(r, e, 1 - Math.exp(-t * n));
- }
- function ad(r, e = 1) {
- return e - Math.abs(no(r, e * 2) - e);
- }
- function od(r, e, t) {
- return r <= e
- ? 0
- : r >= t
- ? 1
- : ((r = (r - e) / (t - e)), r * r * (3 - 2 * r));
- }
- function ld(r, e, t) {
- return r <= e
- ? 0
- : r >= t
- ? 1
- : ((r = (r - e) / (t - e)), r * r * r * (r * (r * 6 - 15) + 10));
- }
- function cd(r, e) {
- return r + Math.floor(Math.random() * (e - r + 1));
- }
- function hd(r, e) {
- return r + Math.random() * (e - r);
- }
- function ud(r) {
- return r * (0.5 - Math.random());
- }
- function dd(r) {
- r !== void 0 && (ll = r);
- let e = (ll += 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 fd(r) {
- return r * ys;
- }
- function pd(r) {
- return r * As;
- }
- function Ba(r) {
- return (r & (r - 1)) === 0 && r !== 0;
- }
- function Vc(r) {
- return Math.pow(2, Math.ceil(Math.log(r) / Math.LN2));
- }
- function Ar(r) {
- return Math.pow(2, Math.floor(Math.log(r) / Math.LN2));
- }
- function md(r, e, t, n, i) {
- const s = Math.cos,
- a = Math.sin,
- o = s(t / 2),
- l = a(t / 2),
- c = s((e + n) / 2),
- u = a((e + n) / 2),
- h = s((e - n) / 2),
- d = a((e - n) / 2),
- f = s((n - e) / 2),
- g = a((n - e) / 2);
- switch (i) {
- case "XYX":
- r.set(o * u, l * h, l * d, o * c);
- break;
- case "YZY":
- r.set(l * d, o * u, l * h, o * c);
- break;
- case "ZXZ":
- r.set(l * h, l * d, o * u, o * c);
- break;
- case "XZX":
- r.set(o * u, l * g, l * f, o * c);
- break;
- case "YXY":
- r.set(l * f, o * u, l * g, o * c);
- break;
- case "ZYZ":
- r.set(l * g, l * f, o * u, o * c);
- break;
- default:
- console.warn(
- "THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " +
- i
- );
- }
- }
- function gd(r, e) {
- switch (e.constructor) {
- case Float32Array:
- return r;
- case Uint16Array:
- return r / 65535;
- case Uint8Array:
- return r / 255;
- case Int16Array:
- return Math.max(r / 32767, -1);
- case Int8Array:
- return Math.max(r / 127, -1);
- default:
- throw new Error("Invalid component type.");
- }
- }
- function vd(r, e) {
- switch (e.constructor) {
- case Float32Array:
- return r;
- case Uint16Array:
- return Math.round(r * 65535);
- case Uint8Array:
- return Math.round(r * 255);
- case Int16Array:
- return Math.round(r * 32767);
- case Int8Array:
- return Math.round(r * 127);
- default:
- throw new Error("Invalid component type.");
- }
- }
- var jt = Object.freeze({
- __proto__: null,
- DEG2RAD: ys,
- RAD2DEG: As,
- generateUUID: Yt,
- clamp: at,
- euclideanModulo: no,
- mapLinear: id,
- inverseLerp: sd,
- lerp: Ms,
- damp: rd,
- pingpong: ad,
- smoothstep: od,
- smootherstep: ld,
- randInt: cd,
- randFloat: hd,
- randFloatSpread: ud,
- seededRandom: dd,
- degToRad: fd,
- radToDeg: pd,
- isPowerOfTwo: Ba,
- ceilPowerOfTwo: Vc,
- floorPowerOfTwo: Ar,
- setQuaternionFromProperEuler: md,
- normalize: vd,
- denormalize: gd,
- });
- class ve {
- constructor(e = 0, t = 0) {
- (this.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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."
- ),
- this.addVectors(e, t))
- : ((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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."
- ),
- this.subVectors(e, t))
- : ((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,
- i = e.elements;
- return (
- (this.x = i[0] * t + i[3] * n + i[6]),
- (this.y = i[1] * t + i[4] * n + i[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 = Math.max(e.x, Math.min(t.x, this.x))),
- (this.y = Math.max(e.y, Math.min(t.y, this.y))),
- this
- );
- }
- clampScalar(e, t) {
- return (
- (this.x = Math.max(e, Math.min(t, this.x))),
- (this.y = Math.max(e, Math.min(t, this.y))),
- this
- );
- }
- clampLength(e, t) {
- const n = this.length();
- return this.divideScalar(n || 1).multiplyScalar(
- Math.max(e, Math.min(t, n))
- );
- }
- 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)),
- (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(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;
- }
- 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, n) {
- return (
- n !== void 0 &&
- console.warn(
- "THREE.Vector2: offset has been removed from .fromBufferAttribute()."
- ),
- (this.x = e.getX(t)),
- (this.y = e.getY(t)),
- this
- );
- }
- rotateAround(e, t) {
- const n = Math.cos(t),
- i = Math.sin(t),
- s = this.x - e.x,
- a = this.y - e.y;
- return (
- (this.x = s * n - a * i + e.x), (this.y = s * i + a * n + e.y), this
- );
- }
- random() {
- return (this.x = Math.random()), (this.y = Math.random()), this;
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y;
- }
- }
- class Xt {
- constructor() {
- (this.isMatrix3 = !0),
- (this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1]),
- arguments.length > 0 &&
- console.error(
- "THREE.Matrix3: the constructor no longer reads arguments. use .set() instead."
- );
- }
- set(e, t, n, i, s, a, o, l, c) {
- const u = this.elements;
- return (
- (u[0] = e),
- (u[1] = i),
- (u[2] = o),
- (u[3] = t),
- (u[4] = s),
- (u[5] = l),
- (u[6] = n),
- (u[7] = a),
- (u[8] = c),
- 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,
- i = t.elements,
- s = this.elements,
- a = n[0],
- o = n[3],
- l = n[6],
- c = n[1],
- u = n[4],
- h = n[7],
- d = n[2],
- f = n[5],
- g = n[8],
- m = i[0],
- p = i[3],
- v = i[6],
- M = i[1],
- x = i[4],
- w = i[7],
- y = i[2],
- A = i[5],
- L = i[8];
- return (
- (s[0] = a * m + o * M + l * y),
- (s[3] = a * p + o * x + l * A),
- (s[6] = a * v + o * w + l * L),
- (s[1] = c * m + u * M + h * y),
- (s[4] = c * p + u * x + h * A),
- (s[7] = c * v + u * w + h * L),
- (s[2] = d * m + f * M + g * y),
- (s[5] = d * p + f * x + g * A),
- (s[8] = d * v + f * w + g * L),
- 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],
- i = e[2],
- s = e[3],
- a = e[4],
- o = e[5],
- l = e[6],
- c = e[7],
- u = e[8];
- return (
- t * a * u -
- t * o * c -
- n * s * u +
- n * o * l +
- i * s * c -
- i * a * l
- );
- }
- invert() {
- const e = this.elements,
- t = e[0],
- n = e[1],
- i = e[2],
- s = e[3],
- a = e[4],
- o = e[5],
- l = e[6],
- c = e[7],
- u = e[8],
- h = u * a - o * c,
- d = o * l - u * s,
- f = c * s - a * l,
- g = t * h + n * d + i * f;
- if (g === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
- const m = 1 / g;
- return (
- (e[0] = h * m),
- (e[1] = (i * c - u * n) * m),
- (e[2] = (o * n - i * a) * m),
- (e[3] = d * m),
- (e[4] = (u * t - i * l) * m),
- (e[5] = (i * s - o * t) * m),
- (e[6] = f * m),
- (e[7] = (n * l - c * t) * m),
- (e[8] = (a * t - n * s) * m),
- 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, i, s, a, o) {
- const l = Math.cos(s),
- c = Math.sin(s);
- return (
- this.set(
- n * l,
- n * c,
- -n * (l * a + c * o) + a + e,
- -i * c,
- i * l,
- -i * (-c * a + l * o) + o + t,
- 0,
- 0,
- 1
- ),
- this
- );
- }
- scale(e, t) {
- const n = this.elements;
- return (
- (n[0] *= e),
- (n[3] *= e),
- (n[6] *= e),
- (n[1] *= t),
- (n[4] *= t),
- (n[7] *= t),
- this
- );
- }
- rotate(e) {
- const t = Math.cos(e),
- n = Math.sin(e),
- i = this.elements,
- s = i[0],
- a = i[3],
- o = i[6],
- l = i[1],
- c = i[4],
- u = i[7];
- return (
- (i[0] = t * s + n * l),
- (i[3] = t * a + n * c),
- (i[6] = t * o + n * u),
- (i[1] = -n * s + t * l),
- (i[4] = -n * a + t * c),
- (i[7] = -n * o + t * u),
- this
- );
- }
- translate(e, t) {
- const n = this.elements;
- return (
- (n[0] += e * n[2]),
- (n[3] += e * n[5]),
- (n[6] += e * n[8]),
- (n[1] += t * n[2]),
- (n[4] += t * n[5]),
- (n[7] += t * n[8]),
- this
- );
- }
- equals(e) {
- const t = this.elements,
- n = e.elements;
- for (let i = 0; i < 9; i++) if (t[i] !== n[i]) 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);
- }
- }
- function Gc(r) {
- for (let e = r.length - 1; e >= 0; --e) if (r[e] > 65535) return !0;
- return !1;
- }
- function Cs(r) {
- return document.createElementNS("http://www.w3.org/1999/xhtml", r);
- }
- function ai(r) {
- return r < 0.04045
- ? r * 0.0773993808
- : Math.pow(r * 0.9478672986 + 0.0521327014, 2.4);
- }
- function vr(r) {
- return r < 0.0031308 ? r * 12.92 : 1.055 * Math.pow(r, 0.41666) - 0.055;
- }
- const Qr = { [yn]: { [si]: ai }, [si]: { [yn]: vr } },
- Ut = {
- legacyMode: !0,
- get workingColorSpace() {
- return si;
- },
- set workingColorSpace(r) {
- console.warn(
- "THREE.ColorManagement: .workingColorSpace is readonly."
- );
- },
- convert: function (r, e, t) {
- if (this.legacyMode || e === t || !e || !t) return r;
- if (Qr[e] && Qr[e][t] !== void 0) {
- const n = Qr[e][t];
- return (r.r = n(r.r)), (r.g = n(r.g)), (r.b = n(r.b)), r;
- }
- throw new Error("Unsupported color space conversion.");
- },
- fromWorkingColorSpace: function (r, e) {
- return this.convert(r, this.workingColorSpace, e);
- },
- toWorkingColorSpace: function (r, e) {
- return this.convert(r, e, this.workingColorSpace);
- },
- },
- Hc = {
- 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,
- },
- rt = { r: 0, g: 0, b: 0 },
- Bt = { h: 0, s: 0, l: 0 },
- js = { h: 0, s: 0, l: 0 };
- function ea(r, e, t) {
- return (
- t < 0 && (t += 1),
- t > 1 && (t -= 1),
- t < 1 / 6
- ? r + (e - r) * 6 * t
- : t < 1 / 2
- ? e
- : t < 2 / 3
- ? r + (e - r) * 6 * (2 / 3 - t)
- : r
- );
- }
- function Xs(r, e) {
- return (e.r = r.r), (e.g = r.g), (e.b = r.b), e;
- }
- class de {
- constructor(e, t, n) {
- return (
- (this.isColor = !0),
- (this.r = 1),
- (this.g = 1),
- (this.b = 1),
- t === void 0 && n === void 0 ? this.set(e) : this.setRGB(e, t, n)
- );
- }
- set(e) {
- return (
- e && e.isColor
- ? this.copy(e)
- : typeof e == "number"
- ? this.setHex(e)
- : typeof e == "string" && this.setStyle(e),
- this
- );
- }
- setScalar(e) {
- return (this.r = e), (this.g = e), (this.b = e), this;
- }
- setHex(e, t = yn) {
- return (
- (e = Math.floor(e)),
- (this.r = ((e >> 16) & 255) / 255),
- (this.g = ((e >> 8) & 255) / 255),
- (this.b = (e & 255) / 255),
- Ut.toWorkingColorSpace(this, t),
- this
- );
- }
- setRGB(e, t, n, i = si) {
- return (
- (this.r = e),
- (this.g = t),
- (this.b = n),
- Ut.toWorkingColorSpace(this, i),
- this
- );
- }
- setHSL(e, t, n, i = si) {
- if (((e = no(e, 1)), (t = at(t, 0, 1)), (n = at(n, 0, 1)), t === 0))
- this.r = this.g = this.b = n;
- else {
- const s = n <= 0.5 ? n * (1 + t) : n + t - n * t,
- a = 2 * n - s;
- (this.r = ea(a, s, e + 1 / 3)),
- (this.g = ea(a, s, e)),
- (this.b = ea(a, s, e - 1 / 3));
- }
- return Ut.toWorkingColorSpace(this, i), this;
- }
- setStyle(e, t = yn) {
- function n(s) {
- s !== void 0 &&
- parseFloat(s) < 1 &&
- console.warn(
- "THREE.Color: Alpha component of " + e + " will be ignored."
- );
- }
- let i;
- if ((i = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e))) {
- let s;
- const a = i[1],
- o = i[2];
- switch (a) {
- case "rgb":
- case "rgba":
- if (
- (s =
- /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(
- o
- ))
- )
- return (
- (this.r = Math.min(255, parseInt(s[1], 10)) / 255),
- (this.g = Math.min(255, parseInt(s[2], 10)) / 255),
- (this.b = Math.min(255, parseInt(s[3], 10)) / 255),
- Ut.toWorkingColorSpace(this, t),
- n(s[4]),
- this
- );
- if (
- (s =
- /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(
- o
- ))
- )
- return (
- (this.r = Math.min(100, parseInt(s[1], 10)) / 100),
- (this.g = Math.min(100, parseInt(s[2], 10)) / 100),
- (this.b = Math.min(100, parseInt(s[3], 10)) / 100),
- Ut.toWorkingColorSpace(this, t),
- n(s[4]),
- this
- );
- break;
- case "hsl":
- case "hsla":
- if (
- (s =
- /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(
- o
- ))
- ) {
- const l = parseFloat(s[1]) / 360,
- c = parseInt(s[2], 10) / 100,
- u = parseInt(s[3], 10) / 100;
- return n(s[4]), this.setHSL(l, c, u, t);
- }
- break;
- }
- } else if ((i = /^\#([A-Fa-f\d]+)$/.exec(e))) {
- const s = i[1],
- a = s.length;
- if (a === 3)
- return (
- (this.r = parseInt(s.charAt(0) + s.charAt(0), 16) / 255),
- (this.g = parseInt(s.charAt(1) + s.charAt(1), 16) / 255),
- (this.b = parseInt(s.charAt(2) + s.charAt(2), 16) / 255),
- Ut.toWorkingColorSpace(this, t),
- this
- );
- if (a === 6)
- return (
- (this.r = parseInt(s.charAt(0) + s.charAt(1), 16) / 255),
- (this.g = parseInt(s.charAt(2) + s.charAt(3), 16) / 255),
- (this.b = parseInt(s.charAt(4) + s.charAt(5), 16) / 255),
- Ut.toWorkingColorSpace(this, t),
- this
- );
- }
- return e && e.length > 0 ? this.setColorName(e, t) : this;
- }
- setColorName(e, t = yn) {
- const n = Hc[e.toLowerCase()];
- return (
- n !== void 0
- ? this.setHex(n, t)
- : console.warn("THREE.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 = ai(e.r)), (this.g = ai(e.g)), (this.b = ai(e.b)), this
- );
- }
- copyLinearToSRGB(e) {
- return (
- (this.r = vr(e.r)), (this.g = vr(e.g)), (this.b = vr(e.b)), this
- );
- }
- convertSRGBToLinear() {
- return this.copySRGBToLinear(this), this;
- }
- convertLinearToSRGB() {
- return this.copyLinearToSRGB(this), this;
- }
- getHex(e = yn) {
- return (
- Ut.fromWorkingColorSpace(Xs(this, rt), e),
- (at(rt.r * 255, 0, 255) << 16) ^
- (at(rt.g * 255, 0, 255) << 8) ^
- (at(rt.b * 255, 0, 255) << 0)
- );
- }
- getHexString(e = yn) {
- return ("000000" + this.getHex(e).toString(16)).slice(-6);
- }
- getHSL(e, t = si) {
- Ut.fromWorkingColorSpace(Xs(this, rt), t);
- const n = rt.r,
- i = rt.g,
- s = rt.b,
- a = Math.max(n, i, s),
- o = Math.min(n, i, s);
- let l, c;
- const u = (o + a) / 2;
- if (o === a) (l = 0), (c = 0);
- else {
- const h = a - o;
- switch (((c = u <= 0.5 ? h / (a + o) : h / (2 - a - o)), a)) {
- case n:
- l = (i - s) / h + (i < s ? 6 : 0);
- break;
- case i:
- l = (s - n) / h + 2;
- break;
- case s:
- l = (n - i) / h + 4;
- break;
- }
- l /= 6;
- }
- return (e.h = l), (e.s = c), (e.l = u), e;
- }
- getRGB(e, t = si) {
- return (
- Ut.fromWorkingColorSpace(Xs(this, rt), t),
- (e.r = rt.r),
- (e.g = rt.g),
- (e.b = rt.b),
- e
- );
- }
- getStyle(e = yn) {
- return (
- Ut.fromWorkingColorSpace(Xs(this, rt), e),
- e !== yn
- ? `color(${e} ${rt.r} ${rt.g} ${rt.b})`
- : `rgb(${(rt.r * 255) | 0},${(rt.g * 255) | 0},${
- (rt.b * 255) | 0
- })`
- );
- }
- offsetHSL(e, t, n) {
- return (
- this.getHSL(Bt),
- (Bt.h += e),
- (Bt.s += t),
- (Bt.l += n),
- this.setHSL(Bt.h, Bt.s, Bt.l),
- this
- );
- }
- add(e) {
- return (this.r += e.r), (this.g += e.g), (this.b += e.b), this;
- }
- addColors(e, t) {
- return (
- (this.r = e.r + t.r),
- (this.g = e.g + t.g),
- (this.b = e.b + t.b),
- this
- );
- }
- addScalar(e) {
- return (this.r += e), (this.g += e), (this.b += e), this;
- }
- sub(e) {
- return (
- (this.r = Math.max(0, this.r - e.r)),
- (this.g = Math.max(0, this.g - e.g)),
- (this.b = Math.max(0, this.b - e.b)),
- this
- );
- }
- multiply(e) {
- return (this.r *= e.r), (this.g *= e.g), (this.b *= e.b), this;
- }
- multiplyScalar(e) {
- return (this.r *= e), (this.g *= e), (this.b *= e), this;
- }
- lerp(e, t) {
- return (
- (this.r += (e.r - this.r) * t),
- (this.g += (e.g - this.g) * t),
- (this.b += (e.b - this.b) * t),
- this
- );
- }
- lerpColors(e, t, n) {
- return (
- (this.r = e.r + (t.r - e.r) * n),
- (this.g = e.g + (t.g - e.g) * n),
- (this.b = e.b + (t.b - e.b) * n),
- this
- );
- }
- lerpHSL(e, t) {
- this.getHSL(Bt), e.getHSL(js);
- const n = Ms(Bt.h, js.h, t),
- i = Ms(Bt.s, js.s, t),
- s = Ms(Bt.l, js.l, t);
- return this.setHSL(n, i, s), this;
- }
- equals(e) {
- return e.r === this.r && e.g === this.g && e.b === this.b;
- }
- fromArray(e, t = 0) {
- return (
- (this.r = e[t]), (this.g = e[t + 1]), (this.b = e[t + 2]), this
- );
- }
- toArray(e = [], t = 0) {
- return (e[t] = this.r), (e[t + 1] = this.g), (e[t + 2] = this.b), e;
- }
- fromBufferAttribute(e, t) {
- return (
- (this.r = e.getX(t)),
- (this.g = e.getY(t)),
- (this.b = e.getZ(t)),
- e.normalized === !0 &&
- ((this.r /= 255), (this.g /= 255), (this.b /= 255)),
- this
- );
- }
- toJSON() {
- return this.getHex();
- }
- *[Symbol.iterator]() {
- yield this.r, yield this.g, yield this.b;
- }
- }
- de.NAMES = Hc;
- let vi;
- class Wc {
- static getDataURL(e) {
- if (/^data:/i.test(e.src) || typeof HTMLCanvasElement == "undefined")
- return e.src;
- let t;
- if (e instanceof HTMLCanvasElement) t = e;
- else {
- vi === void 0 && (vi = Cs("canvas")),
- (vi.width = e.width),
- (vi.height = e.height);
- const n = vi.getContext("2d");
- e instanceof ImageData
- ? n.putImageData(e, 0, 0)
- : n.drawImage(e, 0, 0, e.width, e.height),
- (t = vi);
- }
- return t.width > 2048 || t.height > 2048
- ? (console.warn(
- "THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",
- e
- ),
- t.toDataURL("image/jpeg", 0.6))
- : t.toDataURL("image/png");
- }
- static sRGBToLinear(e) {
- if (
- (typeof HTMLImageElement != "undefined" &&
- e instanceof HTMLImageElement) ||
- (typeof HTMLCanvasElement != "undefined" &&
- e instanceof HTMLCanvasElement) ||
- (typeof ImageBitmap != "undefined" && e instanceof ImageBitmap)
- ) {
- const t = Cs("canvas");
- (t.width = e.width), (t.height = e.height);
- const n = t.getContext("2d");
- n.drawImage(e, 0, 0, e.width, e.height);
- const i = n.getImageData(0, 0, e.width, e.height),
- s = i.data;
- for (let a = 0; a < s.length; a++) s[a] = ai(s[a] / 255) * 255;
- return n.putImageData(i, 0, 0), t;
- } else if (e.data) {
- const t = e.data.slice(0);
- for (let n = 0; n < t.length; n++)
- t instanceof Uint8Array || t instanceof Uint8ClampedArray
- ? (t[n] = Math.floor(ai(t[n] / 255) * 255))
- : (t[n] = ai(t[n]));
- return { data: t, width: e.width, height: e.height };
- } else
- return (
- console.warn(
- "THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."
- ),
- e
- );
- }
- }
- class jc {
- constructor(e = null) {
- (this.isSource = !0),
- (this.uuid = Yt()),
- (this.data = e),
- (this.version = 0);
- }
- set needsUpdate(e) {
- e === !0 && this.version++;
- }
- toJSON(e) {
- const t = e === void 0 || typeof e == "string";
- if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid];
- const n = { uuid: this.uuid, url: "" },
- i = this.data;
- if (i !== null) {
- let s;
- if (Array.isArray(i)) {
- s = [];
- for (let a = 0, o = i.length; a < o; a++)
- i[a].isDataTexture ? s.push(ta(i[a].image)) : s.push(ta(i[a]));
- } else s = ta(i);
- n.url = s;
- }
- return t || (e.images[this.uuid] = n), n;
- }
- }
- function ta(r) {
- return (typeof HTMLImageElement != "undefined" &&
- r instanceof HTMLImageElement) ||
- (typeof HTMLCanvasElement != "undefined" &&
- r instanceof HTMLCanvasElement) ||
- (typeof ImageBitmap != "undefined" && r instanceof ImageBitmap)
- ? Wc.getDataURL(r)
- : r.data
- ? {
- data: Array.prototype.slice.call(r.data),
- width: r.width,
- height: r.height,
- type: r.data.constructor.name,
- }
- : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
- }
- let _d = 0;
- class nt extends hi {
- constructor(
- e = nt.DEFAULT_IMAGE,
- t = nt.DEFAULT_MAPPING,
- n = gt,
- i = gt,
- s = $e,
- a = li,
- o = Nt,
- l = oi,
- c = 1,
- u = Vn
- ) {
- super(),
- (this.isTexture = !0),
- Object.defineProperty(this, "id", { value: _d++ }),
- (this.uuid = Yt()),
- (this.name = ""),
- (this.source = new jc(e)),
- (this.mipmaps = []),
- (this.mapping = t),
- (this.wrapS = n),
- (this.wrapT = i),
- (this.magFilter = s),
- (this.minFilter = a),
- (this.anisotropy = c),
- (this.format = o),
- (this.internalFormat = null),
- (this.type = l),
- (this.offset = new ve(0, 0)),
- (this.repeat = new ve(1, 1)),
- (this.center = new ve(0, 0)),
- (this.rotation = 0),
- (this.matrixAutoUpdate = !0),
- (this.matrix = new Xt()),
- (this.generateMipmaps = !0),
- (this.premultiplyAlpha = !1),
- (this.flipY = !0),
- (this.unpackAlignment = 4),
- (this.encoding = u),
- (this.userData = {}),
- (this.version = 0),
- (this.onUpdate = null),
- (this.isRenderTargetTexture = !1),
- (this.needsPMREMUpdate = !1);
- }
- get image() {
- return this.source.data;
- }
- set image(e) {
- 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
- );
- }
- 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.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.encoding = e.encoding),
- (this.userData = JSON.parse(JSON.stringify(e.userData))),
- (this.needsUpdate = !0),
- this
- );
- }
- 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.5,
- type: "Texture",
- generator: "Texture.toJSON",
- },
- uuid: this.uuid,
- name: this.name,
- image: this.source.toJSON(e).uuid,
- mapping: this.mapping,
- 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,
- type: this.type,
- encoding: this.encoding,
- minFilter: this.minFilter,
- magFilter: this.magFilter,
- anisotropy: this.anisotropy,
- flipY: this.flipY,
- premultiplyAlpha: this.premultiplyAlpha,
- unpackAlignment: this.unpackAlignment,
- };
- return (
- JSON.stringify(this.userData) !== "{}" &&
- (n.userData = this.userData),
- t || (e.textures[this.uuid] = n),
- n
- );
- }
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
- transformUv(e) {
- if (this.mapping !== zc) return e;
- if ((e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1))
- switch (this.wrapS) {
- case hn:
- e.x = e.x - Math.floor(e.x);
- break;
- case gt:
- e.x = e.x < 0 ? 0 : 1;
- break;
- case Er:
- 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 hn:
- e.y = e.y - Math.floor(e.y);
- break;
- case gt:
- e.y = e.y < 0 ? 0 : 1;
- break;
- case Er:
- 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));
- }
- }
- nt.DEFAULT_IMAGE = null;
- nt.DEFAULT_MAPPING = zc;
- class Ue {
- constructor(e = 0, t = 0, n = 0, i = 1) {
- (this.isVector4 = !0),
- (this.x = e),
- (this.y = t),
- (this.z = n),
- (this.w = i);
- }
- 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, i) {
- return (this.x = e), (this.y = t), (this.z = n), (this.w = i), 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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."
- ),
- this.addVectors(e, t))
- : ((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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."
- ),
- this.subVectors(e, t))
- : ((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,
- i = this.z,
- s = this.w,
- a = e.elements;
- return (
- (this.x = a[0] * t + a[4] * n + a[8] * i + a[12] * s),
- (this.y = a[1] * t + a[5] * n + a[9] * i + a[13] * s),
- (this.z = a[2] * t + a[6] * n + a[10] * i + a[14] * s),
- (this.w = a[3] * t + a[7] * n + a[11] * i + a[15] * s),
- 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, i, s;
- const l = e.elements,
- c = l[0],
- u = l[4],
- h = l[8],
- d = l[1],
- f = l[5],
- g = l[9],
- m = l[2],
- p = l[6],
- v = l[10];
- if (
- Math.abs(u - d) < 0.01 &&
- Math.abs(h - m) < 0.01 &&
- Math.abs(g - p) < 0.01
- ) {
- if (
- Math.abs(u + d) < 0.1 &&
- Math.abs(h + m) < 0.1 &&
- Math.abs(g + p) < 0.1 &&
- Math.abs(c + f + v - 3) < 0.1
- )
- return this.set(1, 0, 0, 0), this;
- t = Math.PI;
- const x = (c + 1) / 2,
- w = (f + 1) / 2,
- y = (v + 1) / 2,
- A = (u + d) / 4,
- L = (h + m) / 4,
- _ = (g + p) / 4;
- return (
- x > w && x > y
- ? x < 0.01
- ? ((n = 0), (i = 0.707106781), (s = 0.707106781))
- : ((n = Math.sqrt(x)), (i = A / n), (s = L / n))
- : w > y
- ? w < 0.01
- ? ((n = 0.707106781), (i = 0), (s = 0.707106781))
- : ((i = Math.sqrt(w)), (n = A / i), (s = _ / i))
- : y < 0.01
- ? ((n = 0.707106781), (i = 0.707106781), (s = 0))
- : ((s = Math.sqrt(y)), (n = L / s), (i = _ / s)),
- this.set(n, i, s, t),
- this
- );
- }
- let M = Math.sqrt(
- (p - g) * (p - g) + (h - m) * (h - m) + (d - u) * (d - u)
- );
- return (
- Math.abs(M) < 0.001 && (M = 1),
- (this.x = (p - g) / M),
- (this.y = (h - m) / M),
- (this.z = (d - u) / M),
- (this.w = Math.acos((c + f + v - 1) / 2)),
- 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 = Math.max(e.x, Math.min(t.x, this.x))),
- (this.y = Math.max(e.y, Math.min(t.y, this.y))),
- (this.z = Math.max(e.z, Math.min(t.z, this.z))),
- (this.w = Math.max(e.w, Math.min(t.w, this.w))),
- this
- );
- }
- clampScalar(e, t) {
- return (
- (this.x = Math.max(e, Math.min(t, this.x))),
- (this.y = Math.max(e, Math.min(t, this.y))),
- (this.z = Math.max(e, Math.min(t, this.z))),
- (this.w = Math.max(e, Math.min(t, this.w))),
- this
- );
- }
- clampLength(e, t) {
- const n = this.length();
- return this.divideScalar(n || 1).multiplyScalar(
- Math.max(e, Math.min(t, n))
- );
- }
- 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)),
- (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)),
- (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z)),
- (this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(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, n) {
- return (
- n !== void 0 &&
- console.warn(
- "THREE.Vector4: offset has been removed from .fromBufferAttribute()."
- ),
- (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 Kt extends hi {
- constructor(e, t, n = {}) {
- super(),
- (this.isWebGLRenderTarget = !0),
- (this.width = e),
- (this.height = t),
- (this.depth = 1),
- (this.scissor = new Ue(0, 0, e, t)),
- (this.scissorTest = !1),
- (this.viewport = new Ue(0, 0, e, t));
- const i = { width: e, height: t, depth: 1 };
- (this.texture = new nt(
- i,
- n.mapping,
- n.wrapS,
- n.wrapT,
- n.magFilter,
- n.minFilter,
- n.format,
- n.type,
- n.anisotropy,
- n.encoding
- )),
- (this.texture.isRenderTargetTexture = !0),
- (this.texture.flipY = !1),
- (this.texture.generateMipmaps =
- n.generateMipmaps !== void 0 ? n.generateMipmaps : !1),
- (this.texture.internalFormat =
- n.internalFormat !== void 0 ? n.internalFormat : null),
- (this.texture.minFilter =
- n.minFilter !== void 0 ? n.minFilter : $e),
- (this.depthBuffer = n.depthBuffer !== void 0 ? n.depthBuffer : !0),
- (this.stencilBuffer =
- n.stencilBuffer !== void 0 ? n.stencilBuffer : !1),
- (this.depthTexture =
- n.depthTexture !== void 0 ? n.depthTexture : null),
- (this.samples = n.samples !== void 0 ? n.samples : 0);
- }
- setSize(e, t, n = 1) {
- (this.width !== e || this.height !== t || this.depth !== n) &&
- ((this.width = e),
- (this.height = t),
- (this.depth = n),
- (this.texture.image.width = e),
- (this.texture.image.height = t),
- (this.texture.image.depth = n),
- 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.viewport.copy(e.viewport),
- (this.texture = e.texture.clone()),
- (this.texture.isRenderTargetTexture = !0);
- const t = Object.assign({}, e.texture.image);
- return (
- (this.texture.source = new jc(t)),
- (this.depthBuffer = e.depthBuffer),
- (this.stencilBuffer = e.stencilBuffer),
- e.depthTexture !== null &&
- (this.depthTexture = e.depthTexture.clone()),
- (this.samples = e.samples),
- this
- );
- }
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
- }
- class Xc extends nt {
- constructor(e = null, t = 1, n = 1, i = 1) {
- super(null),
- (this.isDataArrayTexture = !0),
- (this.image = { data: e, width: t, height: n, depth: i }),
- (this.magFilter = ft),
- (this.minFilter = ft),
- (this.wrapR = gt),
- (this.generateMipmaps = !1),
- (this.flipY = !1),
- (this.unpackAlignment = 1);
- }
- }
- class xd extends nt {
- constructor(e = null, t = 1, n = 1, i = 1) {
- super(null),
- (this.isData3DTexture = !0),
- (this.image = { data: e, width: t, height: n, depth: i }),
- (this.magFilter = ft),
- (this.minFilter = ft),
- (this.wrapR = gt),
- (this.generateMipmaps = !1),
- (this.flipY = !1),
- (this.unpackAlignment = 1);
- }
- }
- class Mt {
- constructor(e = 0, t = 0, n = 0, i = 1) {
- (this.isQuaternion = !0),
- (this._x = e),
- (this._y = t),
- (this._z = n),
- (this._w = i);
- }
- static slerp(e, t, n, i) {
- return (
- console.warn(
- "THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."
- ),
- n.slerpQuaternions(e, t, i)
- );
- }
- static slerpFlat(e, t, n, i, s, a, o) {
- let l = n[i + 0],
- c = n[i + 1],
- u = n[i + 2],
- h = n[i + 3];
- const d = s[a + 0],
- f = s[a + 1],
- g = s[a + 2],
- m = s[a + 3];
- if (o === 0) {
- (e[t + 0] = l), (e[t + 1] = c), (e[t + 2] = u), (e[t + 3] = h);
- return;
- }
- if (o === 1) {
- (e[t + 0] = d), (e[t + 1] = f), (e[t + 2] = g), (e[t + 3] = m);
- return;
- }
- if (h !== m || l !== d || c !== f || u !== g) {
- let p = 1 - o;
- const v = l * d + c * f + u * g + h * m,
- M = v >= 0 ? 1 : -1,
- x = 1 - v * v;
- if (x > Number.EPSILON) {
- const y = Math.sqrt(x),
- A = Math.atan2(y, v * M);
- (p = Math.sin(p * A) / y), (o = Math.sin(o * A) / y);
- }
- const w = o * M;
- if (
- ((l = l * p + d * w),
- (c = c * p + f * w),
- (u = u * p + g * w),
- (h = h * p + m * w),
- p === 1 - o)
- ) {
- const y = 1 / Math.sqrt(l * l + c * c + u * u + h * h);
- (l *= y), (c *= y), (u *= y), (h *= y);
- }
- }
- (e[t] = l), (e[t + 1] = c), (e[t + 2] = u), (e[t + 3] = h);
- }
- static multiplyQuaternionsFlat(e, t, n, i, s, a) {
- const o = n[i],
- l = n[i + 1],
- c = n[i + 2],
- u = n[i + 3],
- h = s[a],
- d = s[a + 1],
- f = s[a + 2],
- g = s[a + 3];
- return (
- (e[t] = o * g + u * h + l * f - c * d),
- (e[t + 1] = l * g + u * d + c * h - o * f),
- (e[t + 2] = c * g + u * f + o * d - l * h),
- (e[t + 3] = u * g - o * h - l * d - c * f),
- 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, i) {
- return (
- (this._x = e),
- (this._y = t),
- (this._z = n),
- (this._w = i),
- 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) {
- if (!(e && e.isEuler))
- throw new Error(
- "THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order."
- );
- const n = e._x,
- i = e._y,
- s = e._z,
- a = e._order,
- o = Math.cos,
- l = Math.sin,
- c = o(n / 2),
- u = o(i / 2),
- h = o(s / 2),
- d = l(n / 2),
- f = l(i / 2),
- g = l(s / 2);
- switch (a) {
- case "XYZ":
- (this._x = d * u * h + c * f * g),
- (this._y = c * f * h - d * u * g),
- (this._z = c * u * g + d * f * h),
- (this._w = c * u * h - d * f * g);
- break;
- case "YXZ":
- (this._x = d * u * h + c * f * g),
- (this._y = c * f * h - d * u * g),
- (this._z = c * u * g - d * f * h),
- (this._w = c * u * h + d * f * g);
- break;
- case "ZXY":
- (this._x = d * u * h - c * f * g),
- (this._y = c * f * h + d * u * g),
- (this._z = c * u * g + d * f * h),
- (this._w = c * u * h - d * f * g);
- break;
- case "ZYX":
- (this._x = d * u * h - c * f * g),
- (this._y = c * f * h + d * u * g),
- (this._z = c * u * g - d * f * h),
- (this._w = c * u * h + d * f * g);
- break;
- case "YZX":
- (this._x = d * u * h + c * f * g),
- (this._y = c * f * h + d * u * g),
- (this._z = c * u * g - d * f * h),
- (this._w = c * u * h - d * f * g);
- break;
- case "XZY":
- (this._x = d * u * h - c * f * g),
- (this._y = c * f * h - d * u * g),
- (this._z = c * u * g + d * f * h),
- (this._w = c * u * h + d * f * g);
- break;
- default:
- console.warn(
- "THREE.Quaternion: .setFromEuler() encountered an unknown order: " +
- a
- );
- }
- return t !== !1 && this._onChangeCallback(), this;
- }
- setFromAxisAngle(e, t) {
- const n = t / 2,
- i = Math.sin(n);
- return (
- (this._x = e.x * i),
- (this._y = e.y * i),
- (this._z = e.z * i),
- (this._w = Math.cos(n)),
- this._onChangeCallback(),
- this
- );
- }
- setFromRotationMatrix(e) {
- const t = e.elements,
- n = t[0],
- i = t[4],
- s = t[8],
- a = t[1],
- o = t[5],
- l = t[9],
- c = t[2],
- u = t[6],
- h = t[10],
- d = n + o + h;
- if (d > 0) {
- const f = 0.5 / Math.sqrt(d + 1);
- (this._w = 0.25 / f),
- (this._x = (u - l) * f),
- (this._y = (s - c) * f),
- (this._z = (a - i) * f);
- } else if (n > o && n > h) {
- const f = 2 * Math.sqrt(1 + n - o - h);
- (this._w = (u - l) / f),
- (this._x = 0.25 * f),
- (this._y = (i + a) / f),
- (this._z = (s + c) / f);
- } else if (o > h) {
- const f = 2 * Math.sqrt(1 + o - n - h);
- (this._w = (s - c) / f),
- (this._x = (i + a) / f),
- (this._y = 0.25 * f),
- (this._z = (l + u) / f);
- } else {
- const f = 2 * Math.sqrt(1 + h - n - o);
- (this._w = (a - i) / f),
- (this._x = (s + c) / f),
- (this._y = (l + u) / f),
- (this._z = 0.25 * f);
- }
- return this._onChangeCallback(), this;
- }
- setFromUnitVectors(e, t) {
- let n = e.dot(t) + 1;
- return (
- n < Number.EPSILON
- ? ((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(at(this.dot(e), -1, 1)));
- }
- rotateTowards(e, t) {
- const n = this.angleTo(e);
- if (n === 0) return this;
- const i = Math.min(1, t / n);
- return this.slerp(e, i), 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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."
- ),
- this.multiplyQuaternions(e, t))
- : this.multiplyQuaternions(this, e);
- }
- premultiply(e) {
- return this.multiplyQuaternions(e, this);
- }
- multiplyQuaternions(e, t) {
- const n = e._x,
- i = e._y,
- s = e._z,
- a = e._w,
- o = t._x,
- l = t._y,
- c = t._z,
- u = t._w;
- return (
- (this._x = n * u + a * o + i * c - s * l),
- (this._y = i * u + a * l + s * o - n * c),
- (this._z = s * u + a * c + n * l - i * o),
- (this._w = a * u - n * o - i * l - s * c),
- this._onChangeCallback(),
- this
- );
- }
- slerp(e, t) {
- if (t === 0) return this;
- if (t === 1) return this.copy(e);
- const n = this._x,
- i = this._y,
- s = this._z,
- a = this._w;
- let o = a * e._w + n * e._x + i * e._y + s * e._z;
- if (
- (o < 0
- ? ((this._w = -e._w),
- (this._x = -e._x),
- (this._y = -e._y),
- (this._z = -e._z),
- (o = -o))
- : this.copy(e),
- o >= 1)
- )
- return (
- (this._w = a), (this._x = n), (this._y = i), (this._z = s), this
- );
- const l = 1 - o * o;
- if (l <= Number.EPSILON) {
- const f = 1 - t;
- return (
- (this._w = f * a + t * this._w),
- (this._x = f * n + t * this._x),
- (this._y = f * i + t * this._y),
- (this._z = f * s + t * this._z),
- this.normalize(),
- this._onChangeCallback(),
- this
- );
- }
- const c = Math.sqrt(l),
- u = Math.atan2(c, o),
- h = Math.sin((1 - t) * u) / c,
- d = Math.sin(t * u) / c;
- return (
- (this._w = a * h + this._w * d),
- (this._x = n * h + this._x * d),
- (this._y = i * h + this._y * d),
- (this._z = s * h + this._z * d),
- this._onChangeCallback(),
- this
- );
- }
- slerpQuaternions(e, t, n) {
- return this.copy(e).slerp(t, n);
- }
- random() {
- const e = Math.random(),
- t = Math.sqrt(1 - e),
- n = Math.sqrt(e),
- i = 2 * Math.PI * Math.random(),
- s = 2 * Math.PI * Math.random();
- return this.set(
- t * Math.cos(i),
- n * Math.sin(s),
- n * Math.cos(s),
- t * Math.sin(i)
- );
- }
- 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
- );
- }
- _onChange(e) {
- return (this._onChangeCallback = e), this;
- }
- _onChangeCallback() {}
- *[Symbol.iterator]() {
- yield this._x, yield this._y, yield this._z, yield this._w;
- }
- }
- class P {
- constructor(e = 0, t = 0, n = 0) {
- (this.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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."
- ),
- this.addVectors(e, t))
- : ((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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."
- ),
- this.subVectors(e, t))
- : ((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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."
- ),
- this.multiplyVectors(e, t))
- : ((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 (
- (e && e.isEuler) ||
- console.error(
- "THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."
- ),
- this.applyQuaternion(cl.setFromEuler(e))
- );
- }
- applyAxisAngle(e, t) {
- return this.applyQuaternion(cl.setFromAxisAngle(e, t));
- }
- applyMatrix3(e) {
- const t = this.x,
- n = this.y,
- i = this.z,
- s = e.elements;
- return (
- (this.x = s[0] * t + s[3] * n + s[6] * i),
- (this.y = s[1] * t + s[4] * n + s[7] * i),
- (this.z = s[2] * t + s[5] * n + s[8] * i),
- this
- );
- }
- applyNormalMatrix(e) {
- return this.applyMatrix3(e).normalize();
- }
- applyMatrix4(e) {
- const t = this.x,
- n = this.y,
- i = this.z,
- s = e.elements,
- a = 1 / (s[3] * t + s[7] * n + s[11] * i + s[15]);
- return (
- (this.x = (s[0] * t + s[4] * n + s[8] * i + s[12]) * a),
- (this.y = (s[1] * t + s[5] * n + s[9] * i + s[13]) * a),
- (this.z = (s[2] * t + s[6] * n + s[10] * i + s[14]) * a),
- this
- );
- }
- applyQuaternion(e) {
- const t = this.x,
- n = this.y,
- i = this.z,
- s = e.x,
- a = e.y,
- o = e.z,
- l = e.w,
- c = l * t + a * i - o * n,
- u = l * n + o * t - s * i,
- h = l * i + s * n - a * t,
- d = -s * t - a * n - o * i;
- return (
- (this.x = c * l + d * -s + u * -o - h * -a),
- (this.y = u * l + d * -a + h * -s - c * -o),
- (this.z = h * l + d * -o + c * -a - u * -s),
- 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,
- i = this.z,
- s = e.elements;
- return (
- (this.x = s[0] * t + s[4] * n + s[8] * i),
- (this.y = s[1] * t + s[5] * n + s[9] * i),
- (this.z = s[2] * t + s[6] * n + s[10] * i),
- 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 = Math.max(e.x, Math.min(t.x, this.x))),
- (this.y = Math.max(e.y, Math.min(t.y, this.y))),
- (this.z = Math.max(e.z, Math.min(t.z, this.z))),
- this
- );
- }
- clampScalar(e, t) {
- return (
- (this.x = Math.max(e, Math.min(t, this.x))),
- (this.y = Math.max(e, Math.min(t, this.y))),
- (this.z = Math.max(e, Math.min(t, this.z))),
- this
- );
- }
- clampLength(e, t) {
- const n = this.length();
- return this.divideScalar(n || 1).multiplyScalar(
- Math.max(e, Math.min(t, n))
- );
- }
- 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 = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x)),
- (this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y)),
- (this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(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, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."
- ),
- this.crossVectors(e, t))
- : this.crossVectors(this, e);
- }
- crossVectors(e, t) {
- const n = e.x,
- i = e.y,
- s = e.z,
- a = t.x,
- o = t.y,
- l = t.z;
- return (
- (this.x = i * l - s * o),
- (this.y = s * a - n * l),
- (this.z = n * o - i * a),
- 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 na.copy(this).projectOnVector(e), this.sub(na);
- }
- reflect(e) {
- return this.sub(na.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(at(n, -1, 1));
- }
- distanceTo(e) {
- return Math.sqrt(this.distanceToSquared(e));
- }
- distanceToSquared(e) {
- const t = this.x - e.x,
- n = this.y - e.y,
- i = this.z - e.z;
- return t * t + n * n + i * i;
- }
- 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 i = Math.sin(t) * e;
- return (
- (this.x = i * Math.sin(n)),
- (this.y = Math.cos(t) * e),
- (this.z = i * 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(),
- i = this.setFromMatrixColumn(e, 2).length();
- return (this.x = t), (this.y = n), (this.z = i), 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;
- }
- 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, n) {
- return (
- n !== void 0 &&
- console.warn(
- "THREE.Vector3: offset has been removed from .fromBufferAttribute()."
- ),
- (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() - 0.5) * 2,
- t = Math.random() * Math.PI * 2,
- n = Math.sqrt(1 - e ** 2);
- return (
- (this.x = n * Math.cos(t)),
- (this.y = n * Math.sin(t)),
- (this.z = e),
- this
- );
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y, yield this.z;
- }
- }
- const na = new P(),
- cl = new Mt();
- class Ki {
- constructor(
- e = new P(1 / 0, 1 / 0, 1 / 0),
- t = new P(-1 / 0, -1 / 0, -1 / 0)
- ) {
- (this.isBox3 = !0), (this.min = e), (this.max = t);
- }
- set(e, t) {
- return this.min.copy(e), this.max.copy(t), this;
- }
- setFromArray(e) {
- let t = 1 / 0,
- n = 1 / 0,
- i = 1 / 0,
- s = -1 / 0,
- a = -1 / 0,
- o = -1 / 0;
- for (let l = 0, c = e.length; l < c; l += 3) {
- const u = e[l],
- h = e[l + 1],
- d = e[l + 2];
- u < t && (t = u),
- h < n && (n = h),
- d < i && (i = d),
- u > s && (s = u),
- h > a && (a = h),
- d > o && (o = d);
- }
- return this.min.set(t, n, i), this.max.set(s, a, o), this;
- }
- setFromBufferAttribute(e) {
- let t = 1 / 0,
- n = 1 / 0,
- i = 1 / 0,
- s = -1 / 0,
- a = -1 / 0,
- o = -1 / 0;
- for (let l = 0, c = e.count; l < c; l++) {
- const u = e.getX(l),
- h = e.getY(l),
- d = e.getZ(l);
- u < t && (t = u),
- h < n && (n = h),
- d < i && (i = d),
- u > s && (s = u),
- h > a && (a = h),
- d > o && (o = d);
- }
- return this.min.set(t, n, i), this.max.set(s, a, o), this;
- }
- setFromPoints(e) {
- this.makeEmpty();
- for (let t = 0, n = e.length; t < n; t++) this.expandByPoint(e[t]);
- return this;
- }
- setFromCenterAndSize(e, t) {
- const n = Kn.copy(t).multiplyScalar(0.5);
- return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;
- }
- setFromObject(e, t = !1) {
- return this.makeEmpty(), this.expandByObject(e, t);
- }
- clone() {
- return new this.constructor().copy(this);
- }
- copy(e) {
- return this.min.copy(e.min), this.max.copy(e.max), this;
- }
- makeEmpty() {
- return (
- (this.min.x = this.min.y = this.min.z = 1 / 0),
- (this.max.x = this.max.y = this.max.z = -1 / 0),
- this
- );
- }
- isEmpty() {
- return (
- this.max.x < this.min.x ||
- this.max.y < this.min.y ||
- this.max.z < this.min.z
- );
- }
- getCenter(e) {
- return this.isEmpty()
- ? e.set(0, 0, 0)
- : e.addVectors(this.min, this.max).multiplyScalar(0.5);
- }
- getSize(e) {
- return this.isEmpty()
- ? e.set(0, 0, 0)
- : e.subVectors(this.max, this.min);
- }
- expandByPoint(e) {
- return this.min.min(e), this.max.max(e), this;
- }
- expandByVector(e) {
- return this.min.sub(e), this.max.add(e), this;
- }
- expandByScalar(e) {
- return this.min.addScalar(-e), this.max.addScalar(e), this;
- }
- expandByObject(e, t = !1) {
- e.updateWorldMatrix(!1, !1);
- const n = e.geometry;
- if (n !== void 0)
- if (t && n.attributes != null && n.attributes.position !== void 0) {
- const s = n.attributes.position;
- for (let a = 0, o = s.count; a < o; a++)
- Kn.fromBufferAttribute(s, a).applyMatrix4(e.matrixWorld),
- this.expandByPoint(Kn);
- } else
- n.boundingBox === null && n.computeBoundingBox(),
- ia.copy(n.boundingBox),
- ia.applyMatrix4(e.matrixWorld),
- this.union(ia);
- const i = e.children;
- for (let s = 0, a = i.length; s < a; s++)
- this.expandByObject(i[s], t);
- return this;
- }
- containsPoint(e) {
- return !(
- e.x < 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, Kn),
- Kn.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(ds),
- qs.subVectors(this.max, ds),
- _i.subVectors(e.a, ds),
- xi.subVectors(e.b, ds),
- yi.subVectors(e.c, ds),
- Rn.subVectors(xi, _i),
- Pn.subVectors(yi, xi),
- Zn.subVectors(_i, yi);
- let t = [
- 0,
- -Rn.z,
- Rn.y,
- 0,
- -Pn.z,
- Pn.y,
- 0,
- -Zn.z,
- Zn.y,
- Rn.z,
- 0,
- -Rn.x,
- Pn.z,
- 0,
- -Pn.x,
- Zn.z,
- 0,
- -Zn.x,
- -Rn.y,
- Rn.x,
- 0,
- -Pn.y,
- Pn.x,
- 0,
- -Zn.y,
- Zn.x,
- 0,
- ];
- return !sa(t, _i, xi, yi, qs) ||
- ((t = [1, 0, 0, 0, 1, 0, 0, 0, 1]), !sa(t, _i, xi, yi, qs))
- ? !1
- : ($s.crossVectors(Rn, Pn),
- (t = [$s.x, $s.y, $s.z]),
- sa(t, _i, xi, yi, qs));
- }
- clampPoint(e, t) {
- return t.copy(e).clamp(this.min, this.max);
- }
- distanceToPoint(e) {
- return Kn.copy(e).clamp(this.min, this.max).sub(e).length();
- }
- getBoundingSphere(e) {
- return (
- this.getCenter(e.center),
- (e.radius = this.getSize(Kn).length() * 0.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
- : (fn[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e),
- fn[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e),
- fn[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e),
- fn[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e),
- fn[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e),
- fn[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e),
- fn[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e),
- fn[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e),
- this.setFromPoints(fn),
- 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 fn = [
- new P(),
- new P(),
- new P(),
- new P(),
- new P(),
- new P(),
- new P(),
- new P(),
- ],
- Kn = new P(),
- ia = new Ki(),
- _i = new P(),
- xi = new P(),
- yi = new P(),
- Rn = new P(),
- Pn = new P(),
- Zn = new P(),
- ds = new P(),
- qs = new P(),
- $s = new P(),
- Jn = new P();
- function sa(r, e, t, n, i) {
- for (let s = 0, a = r.length - 3; s <= a; s += 3) {
- Jn.fromArray(r, s);
- const o =
- i.x * Math.abs(Jn.x) +
- i.y * Math.abs(Jn.y) +
- i.z * Math.abs(Jn.z),
- l = e.dot(Jn),
- c = t.dot(Jn),
- u = n.dot(Jn);
- if (Math.max(-Math.max(l, c, u), Math.min(l, c, u)) > o) return !1;
- }
- return !0;
- }
- const yd = new Ki(),
- hl = new P(),
- Ys = new P(),
- ra = new P();
- class Zi {
- constructor(e = new P(), t = -1) {
- (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) : yd.setFromPoints(e).getCenter(n);
- let i = 0;
- for (let s = 0, a = e.length; s < a; s++)
- i = Math.max(i, n.distanceToSquared(e[s]));
- return (this.radius = Math.sqrt(i)), this;
- }
- copy(e) {
- return this.center.copy(e.center), (this.radius = e.radius), this;
- }
- isEmpty() {
- return this.radius < 0;
- }
- makeEmpty() {
- return this.center.set(0, 0, 0), (this.radius = -1), this;
- }
- containsPoint(e) {
- return e.distanceToSquared(this.center) <= this.radius * this.radius;
- }
- distanceToPoint(e) {
- return e.distanceTo(this.center) - this.radius;
- }
- intersectsSphere(e) {
- const t = this.radius + e.radius;
- return e.center.distanceToSquared(this.center) <= t * t;
- }
- intersectsBox(e) {
- return e.intersectsSphere(this);
- }
- intersectsPlane(e) {
- return Math.abs(e.distanceToPoint(this.center)) <= this.radius;
- }
- clampPoint(e, t) {
- const n = this.center.distanceToSquared(e);
- return (
- t.copy(e),
- n > 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) {
- ra.subVectors(e, this.center);
- const t = ra.lengthSq();
- if (t > this.radius * this.radius) {
- const n = Math.sqrt(t),
- i = (n - this.radius) * 0.5;
- this.center.add(ra.multiplyScalar(i / n)), (this.radius += i);
- }
- return this;
- }
- union(e) {
- return (
- this.center.equals(e.center) === !0
- ? Ys.set(0, 0, 1).multiplyScalar(e.radius)
- : Ys.subVectors(e.center, this.center)
- .normalize()
- .multiplyScalar(e.radius),
- this.expandByPoint(hl.copy(e.center).add(Ys)),
- this.expandByPoint(hl.copy(e.center).sub(Ys)),
- this
- );
- }
- equals(e) {
- return e.center.equals(this.center) && e.radius === this.radius;
- }
- clone() {
- return new this.constructor().copy(this);
- }
- }
- const pn = new P(),
- aa = new P(),
- Ks = new P(),
- Dn = new P(),
- oa = new P(),
- Zs = new P(),
- la = new P();
- class io {
- constructor(e = new P(), t = new P(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.direction).multiplyScalar(e).add(this.origin);
- }
- lookAt(e) {
- return this.direction.copy(e).sub(this.origin).normalize(), this;
- }
- recast(e) {
- return this.origin.copy(this.at(e, pn)), 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.direction).multiplyScalar(n).add(this.origin);
- }
- distanceToPoint(e) {
- return Math.sqrt(this.distanceSqToPoint(e));
- }
- distanceSqToPoint(e) {
- const t = pn.subVectors(e, this.origin).dot(this.direction);
- return t < 0
- ? this.origin.distanceToSquared(e)
- : (pn.copy(this.direction).multiplyScalar(t).add(this.origin),
- pn.distanceToSquared(e));
- }
- distanceSqToSegment(e, t, n, i) {
- aa.copy(e).add(t).multiplyScalar(0.5),
- Ks.copy(t).sub(e).normalize(),
- Dn.copy(this.origin).sub(aa);
- const s = e.distanceTo(t) * 0.5,
- a = -this.direction.dot(Ks),
- o = Dn.dot(this.direction),
- l = -Dn.dot(Ks),
- c = Dn.lengthSq(),
- u = Math.abs(1 - a * a);
- let h, d, f, g;
- if (u > 0)
- if (((h = a * l - o), (d = a * o - l), (g = s * u), h >= 0))
- if (d >= -g)
- if (d <= g) {
- const m = 1 / u;
- (h *= m),
- (d *= m),
- (f = h * (h + a * d + 2 * o) + d * (a * h + d + 2 * l) + c);
- } else
- (d = s),
- (h = Math.max(0, -(a * d + o))),
- (f = -h * h + d * (d + 2 * l) + c);
- else
- (d = -s),
- (h = Math.max(0, -(a * d + o))),
- (f = -h * h + d * (d + 2 * l) + c);
- else
- d <= -g
- ? ((h = Math.max(0, -(-a * s + o))),
- (d = h > 0 ? -s : Math.min(Math.max(-s, -l), s)),
- (f = -h * h + d * (d + 2 * l) + c))
- : d <= g
- ? ((h = 0),
- (d = Math.min(Math.max(-s, -l), s)),
- (f = d * (d + 2 * l) + c))
- : ((h = Math.max(0, -(a * s + o))),
- (d = h > 0 ? s : Math.min(Math.max(-s, -l), s)),
- (f = -h * h + d * (d + 2 * l) + c));
- else
- (d = a > 0 ? -s : s),
- (h = Math.max(0, -(a * d + o))),
- (f = -h * h + d * (d + 2 * l) + c);
- return (
- n && n.copy(this.direction).multiplyScalar(h).add(this.origin),
- i && i.copy(Ks).multiplyScalar(d).add(aa),
- f
- );
- }
- intersectSphere(e, t) {
- pn.subVectors(e.center, this.origin);
- const n = pn.dot(this.direction),
- i = pn.dot(pn) - n * n,
- s = e.radius * e.radius;
- if (i > s) return null;
- const a = Math.sqrt(s - i),
- o = n - a,
- l = n + a;
- return o < 0 && l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t);
- }
- intersectsSphere(e) {
- return 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, i, s, a, o, l;
- const c = 1 / this.direction.x,
- u = 1 / this.direction.y,
- h = 1 / this.direction.z,
- d = this.origin;
- return (
- c >= 0
- ? ((n = (e.min.x - d.x) * c), (i = (e.max.x - d.x) * c))
- : ((n = (e.max.x - d.x) * c), (i = (e.min.x - d.x) * c)),
- u >= 0
- ? ((s = (e.min.y - d.y) * u), (a = (e.max.y - d.y) * u))
- : ((s = (e.max.y - d.y) * u), (a = (e.min.y - d.y) * u)),
- n > a ||
- s > i ||
- ((s > n || n !== n) && (n = s),
- (a < i || i !== i) && (i = a),
- h >= 0
- ? ((o = (e.min.z - d.z) * h), (l = (e.max.z - d.z) * h))
- : ((o = (e.max.z - d.z) * h), (l = (e.min.z - d.z) * h)),
- n > l || o > i) ||
- ((o > n || n !== n) && (n = o),
- (l < i || i !== i) && (i = l),
- i < 0)
- ? null
- : this.at(n >= 0 ? n : i, t)
- );
- }
- intersectsBox(e) {
- return this.intersectBox(e, pn) !== null;
- }
- intersectTriangle(e, t, n, i, s) {
- oa.subVectors(t, e), Zs.subVectors(n, e), la.crossVectors(oa, Zs);
- let a = this.direction.dot(la),
- o;
- if (a > 0) {
- if (i) return null;
- o = 1;
- } else if (a < 0) (o = -1), (a = -a);
- else return null;
- Dn.subVectors(this.origin, e);
- const l = o * this.direction.dot(Zs.crossVectors(Dn, Zs));
- if (l < 0) return null;
- const c = o * this.direction.dot(oa.cross(Dn));
- if (c < 0 || l + c > a) return null;
- const u = -o * Dn.dot(la);
- return u < 0 ? null : this.at(u / a, s);
- }
- 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 pe {
- constructor() {
- (this.isMatrix4 = !0),
- (this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
- arguments.length > 0 &&
- console.error(
- "THREE.Matrix4: the constructor no longer reads arguments. use .set() instead."
- );
- }
- set(e, t, n, i, s, a, o, l, c, u, h, d, f, g, m, p) {
- const v = this.elements;
- return (
- (v[0] = e),
- (v[4] = t),
- (v[8] = n),
- (v[12] = i),
- (v[1] = s),
- (v[5] = a),
- (v[9] = o),
- (v[13] = l),
- (v[2] = c),
- (v[6] = u),
- (v[10] = h),
- (v[14] = d),
- (v[3] = f),
- (v[7] = g),
- (v[11] = m),
- (v[15] = p),
- 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 pe().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,
- i = 1 / Mi.setFromMatrixColumn(e, 0).length(),
- s = 1 / Mi.setFromMatrixColumn(e, 1).length(),
- a = 1 / Mi.setFromMatrixColumn(e, 2).length();
- return (
- (t[0] = n[0] * i),
- (t[1] = n[1] * i),
- (t[2] = n[2] * i),
- (t[3] = 0),
- (t[4] = n[4] * s),
- (t[5] = n[5] * s),
- (t[6] = n[6] * s),
- (t[7] = 0),
- (t[8] = n[8] * a),
- (t[9] = n[9] * a),
- (t[10] = n[10] * a),
- (t[11] = 0),
- (t[12] = 0),
- (t[13] = 0),
- (t[14] = 0),
- (t[15] = 1),
- this
- );
- }
- makeRotationFromEuler(e) {
- (e && e.isEuler) ||
- console.error(
- "THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."
- );
- const t = this.elements,
- n = e.x,
- i = e.y,
- s = e.z,
- a = Math.cos(n),
- o = Math.sin(n),
- l = Math.cos(i),
- c = Math.sin(i),
- u = Math.cos(s),
- h = Math.sin(s);
- if (e.order === "XYZ") {
- const d = a * u,
- f = a * h,
- g = o * u,
- m = o * h;
- (t[0] = l * u),
- (t[4] = -l * h),
- (t[8] = c),
- (t[1] = f + g * c),
- (t[5] = d - m * c),
- (t[9] = -o * l),
- (t[2] = m - d * c),
- (t[6] = g + f * c),
- (t[10] = a * l);
- } else if (e.order === "YXZ") {
- const d = l * u,
- f = l * h,
- g = c * u,
- m = c * h;
- (t[0] = d + m * o),
- (t[4] = g * o - f),
- (t[8] = a * c),
- (t[1] = a * h),
- (t[5] = a * u),
- (t[9] = -o),
- (t[2] = f * o - g),
- (t[6] = m + d * o),
- (t[10] = a * l);
- } else if (e.order === "ZXY") {
- const d = l * u,
- f = l * h,
- g = c * u,
- m = c * h;
- (t[0] = d - m * o),
- (t[4] = -a * h),
- (t[8] = g + f * o),
- (t[1] = f + g * o),
- (t[5] = a * u),
- (t[9] = m - d * o),
- (t[2] = -a * c),
- (t[6] = o),
- (t[10] = a * l);
- } else if (e.order === "ZYX") {
- const d = a * u,
- f = a * h,
- g = o * u,
- m = o * h;
- (t[0] = l * u),
- (t[4] = g * c - f),
- (t[8] = d * c + m),
- (t[1] = l * h),
- (t[5] = m * c + d),
- (t[9] = f * c - g),
- (t[2] = -c),
- (t[6] = o * l),
- (t[10] = a * l);
- } else if (e.order === "YZX") {
- const d = a * l,
- f = a * c,
- g = o * l,
- m = o * c;
- (t[0] = l * u),
- (t[4] = m - d * h),
- (t[8] = g * h + f),
- (t[1] = h),
- (t[5] = a * u),
- (t[9] = -o * u),
- (t[2] = -c * u),
- (t[6] = f * h + g),
- (t[10] = d - m * h);
- } else if (e.order === "XZY") {
- const d = a * l,
- f = a * c,
- g = o * l,
- m = o * c;
- (t[0] = l * u),
- (t[4] = -h),
- (t[8] = c * u),
- (t[1] = d * h + m),
- (t[5] = a * u),
- (t[9] = f * h - g),
- (t[2] = g * h - f),
- (t[6] = o * u),
- (t[10] = m * h + d);
- }
- 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(Md, e, wd);
- }
- lookAt(e, t, n) {
- const i = this.elements;
- return (
- Ct.subVectors(e, t),
- Ct.lengthSq() === 0 && (Ct.z = 1),
- Ct.normalize(),
- In.crossVectors(n, Ct),
- In.lengthSq() === 0 &&
- (Math.abs(n.z) === 1 ? (Ct.x += 1e-4) : (Ct.z += 1e-4),
- Ct.normalize(),
- In.crossVectors(n, Ct)),
- In.normalize(),
- Js.crossVectors(Ct, In),
- (i[0] = In.x),
- (i[4] = Js.x),
- (i[8] = Ct.x),
- (i[1] = In.y),
- (i[5] = Js.y),
- (i[9] = Ct.y),
- (i[2] = In.z),
- (i[6] = Js.z),
- (i[10] = Ct.z),
- this
- );
- }
- multiply(e, t) {
- return t !== void 0
- ? (console.warn(
- "THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."
- ),
- this.multiplyMatrices(e, t))
- : this.multiplyMatrices(this, e);
- }
- premultiply(e) {
- return this.multiplyMatrices(e, this);
- }
- multiplyMatrices(e, t) {
- const n = e.elements,
- i = t.elements,
- s = this.elements,
- a = n[0],
- o = n[4],
- l = n[8],
- c = n[12],
- u = n[1],
- h = n[5],
- d = n[9],
- f = n[13],
- g = n[2],
- m = n[6],
- p = n[10],
- v = n[14],
- M = n[3],
- x = n[7],
- w = n[11],
- y = n[15],
- A = i[0],
- L = i[4],
- _ = i[8],
- T = i[12],
- I = i[1],
- F = i[5],
- H = i[9],
- B = i[13],
- D = i[2],
- z = i[6],
- N = i[10],
- k = i[14],
- G = i[3],
- U = i[7],
- X = i[11],
- Z = i[15];
- return (
- (s[0] = a * A + o * I + l * D + c * G),
- (s[4] = a * L + o * F + l * z + c * U),
- (s[8] = a * _ + o * H + l * N + c * X),
- (s[12] = a * T + o * B + l * k + c * Z),
- (s[1] = u * A + h * I + d * D + f * G),
- (s[5] = u * L + h * F + d * z + f * U),
- (s[9] = u * _ + h * H + d * N + f * X),
- (s[13] = u * T + h * B + d * k + f * Z),
- (s[2] = g * A + m * I + p * D + v * G),
- (s[6] = g * L + m * F + p * z + v * U),
- (s[10] = g * _ + m * H + p * N + v * X),
- (s[14] = g * T + m * B + p * k + v * Z),
- (s[3] = M * A + x * I + w * D + y * G),
- (s[7] = M * L + x * F + w * z + y * U),
- (s[11] = M * _ + x * H + w * N + y * X),
- (s[15] = M * T + x * B + w * k + y * Z),
- 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],
- i = e[8],
- s = e[12],
- a = e[1],
- o = e[5],
- l = e[9],
- c = e[13],
- u = e[2],
- h = e[6],
- d = e[10],
- f = e[14],
- g = e[3],
- m = e[7],
- p = e[11],
- v = e[15];
- return (
- g *
- (+s * l * h -
- i * c * h -
- s * o * d +
- n * c * d +
- i * o * f -
- n * l * f) +
- m *
- (+t * l * f -
- t * c * d +
- s * a * d -
- i * a * f +
- i * c * u -
- s * l * u) +
- p *
- (+t * c * h -
- t * o * f -
- s * a * h +
- n * a * f +
- s * o * u -
- n * c * u) +
- v *
- (-i * o * u -
- t * l * h +
- t * o * d +
- i * a * h -
- n * a * d +
- n * l * u)
- );
- }
- 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 i = this.elements;
- return (
- e.isVector3
- ? ((i[12] = e.x), (i[13] = e.y), (i[14] = e.z))
- : ((i[12] = e), (i[13] = t), (i[14] = n)),
- this
- );
- }
- invert() {
- const e = this.elements,
- t = e[0],
- n = e[1],
- i = e[2],
- s = e[3],
- a = e[4],
- o = e[5],
- l = e[6],
- c = e[7],
- u = e[8],
- h = e[9],
- d = e[10],
- f = e[11],
- g = e[12],
- m = e[13],
- p = e[14],
- v = e[15],
- M =
- h * p * c -
- m * d * c +
- m * l * f -
- o * p * f -
- h * l * v +
- o * d * v,
- x =
- g * d * c -
- u * p * c -
- g * l * f +
- a * p * f +
- u * l * v -
- a * d * v,
- w =
- u * m * c -
- g * h * c +
- g * o * f -
- a * m * f -
- u * o * v +
- a * h * v,
- y =
- g * h * l -
- u * m * l -
- g * o * d +
- a * m * d +
- u * o * p -
- a * h * p,
- A = t * M + n * x + i * w + s * y;
- if (A === 0)
- return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- const L = 1 / A;
- return (
- (e[0] = M * L),
- (e[1] =
- (m * d * s -
- h * p * s -
- m * i * f +
- n * p * f +
- h * i * v -
- n * d * v) *
- L),
- (e[2] =
- (o * p * s -
- m * l * s +
- m * i * c -
- n * p * c -
- o * i * v +
- n * l * v) *
- L),
- (e[3] =
- (h * l * s -
- o * d * s -
- h * i * c +
- n * d * c +
- o * i * f -
- n * l * f) *
- L),
- (e[4] = x * L),
- (e[5] =
- (u * p * s -
- g * d * s +
- g * i * f -
- t * p * f -
- u * i * v +
- t * d * v) *
- L),
- (e[6] =
- (g * l * s -
- a * p * s -
- g * i * c +
- t * p * c +
- a * i * v -
- t * l * v) *
- L),
- (e[7] =
- (a * d * s -
- u * l * s +
- u * i * c -
- t * d * c -
- a * i * f +
- t * l * f) *
- L),
- (e[8] = w * L),
- (e[9] =
- (g * h * s -
- u * m * s -
- g * n * f +
- t * m * f +
- u * n * v -
- t * h * v) *
- L),
- (e[10] =
- (a * m * s -
- g * o * s +
- g * n * c -
- t * m * c -
- a * n * v +
- t * o * v) *
- L),
- (e[11] =
- (u * o * s -
- a * h * s -
- u * n * c +
- t * h * c +
- a * n * f -
- t * o * f) *
- L),
- (e[12] = y * L),
- (e[13] =
- (u * m * i -
- g * h * i +
- g * n * d -
- t * m * d -
- u * n * p +
- t * h * p) *
- L),
- (e[14] =
- (g * o * i -
- a * m * i -
- g * n * l +
- t * m * l +
- a * n * p -
- t * o * p) *
- L),
- (e[15] =
- (a * h * i -
- u * o * i +
- u * n * l -
- t * h * l -
- a * n * d +
- t * o * d) *
- L),
- this
- );
- }
- scale(e) {
- const t = this.elements,
- n = e.x,
- i = e.y,
- s = e.z;
- return (
- (t[0] *= n),
- (t[4] *= i),
- (t[8] *= s),
- (t[1] *= n),
- (t[5] *= i),
- (t[9] *= s),
- (t[2] *= n),
- (t[6] *= i),
- (t[10] *= s),
- (t[3] *= n),
- (t[7] *= i),
- (t[11] *= s),
- 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],
- i = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
- return Math.sqrt(Math.max(t, n, i));
- }
- makeTranslation(e, t, n) {
- return 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),
- i = Math.sin(t),
- s = 1 - n,
- a = e.x,
- o = e.y,
- l = e.z,
- c = s * a,
- u = s * o;
- return (
- this.set(
- c * a + n,
- c * o - i * l,
- c * l + i * o,
- 0,
- c * o + i * l,
- u * o + n,
- u * l - i * a,
- 0,
- c * l - i * o,
- u * l + i * a,
- s * l * l + 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, i, s, a) {
- return this.set(1, n, s, 0, e, 1, a, 0, t, i, 1, 0, 0, 0, 0, 1), this;
- }
- compose(e, t, n) {
- const i = this.elements,
- s = t._x,
- a = t._y,
- o = t._z,
- l = t._w,
- c = s + s,
- u = a + a,
- h = o + o,
- d = s * c,
- f = s * u,
- g = s * h,
- m = a * u,
- p = a * h,
- v = o * h,
- M = l * c,
- x = l * u,
- w = l * h,
- y = n.x,
- A = n.y,
- L = n.z;
- return (
- (i[0] = (1 - (m + v)) * y),
- (i[1] = (f + w) * y),
- (i[2] = (g - x) * y),
- (i[3] = 0),
- (i[4] = (f - w) * A),
- (i[5] = (1 - (d + v)) * A),
- (i[6] = (p + M) * A),
- (i[7] = 0),
- (i[8] = (g + x) * L),
- (i[9] = (p - M) * L),
- (i[10] = (1 - (d + m)) * L),
- (i[11] = 0),
- (i[12] = e.x),
- (i[13] = e.y),
- (i[14] = e.z),
- (i[15] = 1),
- this
- );
- }
- decompose(e, t, n) {
- const i = this.elements;
- let s = Mi.set(i[0], i[1], i[2]).length();
- const a = Mi.set(i[4], i[5], i[6]).length(),
- o = Mi.set(i[8], i[9], i[10]).length();
- this.determinant() < 0 && (s = -s),
- (e.x = i[12]),
- (e.y = i[13]),
- (e.z = i[14]),
- Vt.copy(this);
- const c = 1 / s,
- u = 1 / a,
- h = 1 / o;
- return (
- (Vt.elements[0] *= c),
- (Vt.elements[1] *= c),
- (Vt.elements[2] *= c),
- (Vt.elements[4] *= u),
- (Vt.elements[5] *= u),
- (Vt.elements[6] *= u),
- (Vt.elements[8] *= h),
- (Vt.elements[9] *= h),
- (Vt.elements[10] *= h),
- t.setFromRotationMatrix(Vt),
- (n.x = s),
- (n.y = a),
- (n.z = o),
- this
- );
- }
- makePerspective(e, t, n, i, s, a) {
- a === void 0 &&
- console.warn(
- "THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."
- );
- const o = this.elements,
- l = (2 * s) / (t - e),
- c = (2 * s) / (n - i),
- u = (t + e) / (t - e),
- h = (n + i) / (n - i),
- d = -(a + s) / (a - s),
- f = (-2 * a * s) / (a - s);
- return (
- (o[0] = l),
- (o[4] = 0),
- (o[8] = u),
- (o[12] = 0),
- (o[1] = 0),
- (o[5] = c),
- (o[9] = h),
- (o[13] = 0),
- (o[2] = 0),
- (o[6] = 0),
- (o[10] = d),
- (o[14] = f),
- (o[3] = 0),
- (o[7] = 0),
- (o[11] = -1),
- (o[15] = 0),
- this
- );
- }
- makeOrthographic(e, t, n, i, s, a) {
- const o = this.elements,
- l = 1 / (t - e),
- c = 1 / (n - i),
- u = 1 / (a - s),
- h = (t + e) * l,
- d = (n + i) * c,
- f = (a + s) * u;
- return (
- (o[0] = 2 * l),
- (o[4] = 0),
- (o[8] = 0),
- (o[12] = -h),
- (o[1] = 0),
- (o[5] = 2 * c),
- (o[9] = 0),
- (o[13] = -d),
- (o[2] = 0),
- (o[6] = 0),
- (o[10] = -2 * u),
- (o[14] = -f),
- (o[3] = 0),
- (o[7] = 0),
- (o[11] = 0),
- (o[15] = 1),
- this
- );
- }
- equals(e) {
- const t = this.elements,
- n = e.elements;
- for (let i = 0; i < 16; i++) if (t[i] !== n[i]) 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 Mi = new P(),
- Vt = new pe(),
- Md = new P(0, 0, 0),
- wd = new P(1, 1, 1),
- In = new P(),
- Js = new P(),
- Ct = new P(),
- ul = new pe(),
- dl = new Mt();
- class an {
- constructor(e = 0, t = 0, n = 0, i = an.DefaultOrder) {
- (this.isEuler = !0),
- (this._x = e),
- (this._y = t),
- (this._z = n),
- (this._order = i);
- }
- 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, i = this._order) {
- return (
- (this._x = e),
- (this._y = t),
- (this._z = n),
- (this._order = i),
- 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 i = e.elements,
- s = i[0],
- a = i[4],
- o = i[8],
- l = i[1],
- c = i[5],
- u = i[9],
- h = i[2],
- d = i[6],
- f = i[10];
- switch (t) {
- case "XYZ":
- (this._y = Math.asin(at(o, -1, 1))),
- Math.abs(o) < 0.9999999
- ? ((this._x = Math.atan2(-u, f)),
- (this._z = Math.atan2(-a, s)))
- : ((this._x = Math.atan2(d, c)), (this._z = 0));
- break;
- case "YXZ":
- (this._x = Math.asin(-at(u, -1, 1))),
- Math.abs(u) < 0.9999999
- ? ((this._y = Math.atan2(o, f)), (this._z = Math.atan2(l, c)))
- : ((this._y = Math.atan2(-h, s)), (this._z = 0));
- break;
- case "ZXY":
- (this._x = Math.asin(at(d, -1, 1))),
- Math.abs(d) < 0.9999999
- ? ((this._y = Math.atan2(-h, f)),
- (this._z = Math.atan2(-a, c)))
- : ((this._y = 0), (this._z = Math.atan2(l, s)));
- break;
- case "ZYX":
- (this._y = Math.asin(-at(h, -1, 1))),
- Math.abs(h) < 0.9999999
- ? ((this._x = Math.atan2(d, f)), (this._z = Math.atan2(l, s)))
- : ((this._x = 0), (this._z = Math.atan2(-a, c)));
- break;
- case "YZX":
- (this._z = Math.asin(at(l, -1, 1))),
- Math.abs(l) < 0.9999999
- ? ((this._x = Math.atan2(-u, c)),
- (this._y = Math.atan2(-h, s)))
- : ((this._x = 0), (this._y = Math.atan2(o, f)));
- break;
- case "XZY":
- (this._z = Math.asin(-at(a, -1, 1))),
- Math.abs(a) < 0.9999999
- ? ((this._x = Math.atan2(d, c)), (this._y = Math.atan2(o, s)))
- : ((this._x = Math.atan2(-u, f)), (this._y = 0));
- break;
- default:
- console.warn(
- "THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " +
- t
- );
- }
- return (this._order = t), n === !0 && this._onChangeCallback(), this;
- }
- setFromQuaternion(e, t, n) {
- return (
- ul.makeRotationFromQuaternion(e),
- this.setFromRotationMatrix(ul, t, n)
- );
- }
- setFromVector3(e, t = this._order) {
- return this.set(e.x, e.y, e.z, t);
- }
- reorder(e) {
- return dl.setFromEuler(this), this.setFromQuaternion(dl, 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;
- }
- toVector3() {
- console.error(
- "THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead"
- );
- }
- }
- an.DefaultOrder = "XYZ";
- an.RotationOrders = ["XYZ", "YZX", "ZXY", "XZY", "YXZ", "ZYX"];
- class qc {
- constructor() {
- this.mask = 1;
- }
- set(e) {
- this.mask = ((1 << e) | 0) >>> 0;
- }
- enable(e) {
- this.mask |= (1 << e) | 0;
- }
- enableAll() {
- this.mask = -1;
- }
- toggle(e) {
- this.mask ^= (1 << e) | 0;
- }
- disable(e) {
- this.mask &= ~((1 << e) | 0);
- }
- disableAll() {
- this.mask = 0;
- }
- test(e) {
- return (this.mask & e.mask) !== 0;
- }
- isEnabled(e) {
- return (this.mask & ((1 << e) | 0)) !== 0;
- }
- }
- let bd = 0;
- const fl = new P(),
- wi = new Mt(),
- mn = new pe(),
- Qs = new P(),
- fs = new P(),
- Sd = new P(),
- Td = new Mt(),
- pl = new P(1, 0, 0),
- ml = new P(0, 1, 0),
- gl = new P(0, 0, 1),
- Ed = { type: "added" },
- vl = { type: "removed" };
- class Ye extends hi {
- constructor() {
- super(),
- (this.isObject3D = !0),
- Object.defineProperty(this, "id", { value: bd++ }),
- (this.uuid = Yt()),
- (this.name = ""),
- (this.type = "Object3D"),
- (this.parent = null),
- (this.children = []),
- (this.up = Ye.DefaultUp.clone());
- const e = new P(),
- t = new an(),
- n = new Mt(),
- i = new P(1, 1, 1);
- function s() {
- n.setFromEuler(t, !1);
- }
- function a() {
- t.setFromQuaternion(n, void 0, !1);
- }
- t._onChange(s),
- n._onChange(a),
- Object.defineProperties(this, {
- position: { configurable: !0, enumerable: !0, value: e },
- rotation: { configurable: !0, enumerable: !0, value: t },
- quaternion: { configurable: !0, enumerable: !0, value: n },
- scale: { configurable: !0, enumerable: !0, value: i },
- modelViewMatrix: { value: new pe() },
- normalMatrix: { value: new Xt() },
- }),
- (this.matrix = new pe()),
- (this.matrixWorld = new pe()),
- (this.matrixAutoUpdate = Ye.DefaultMatrixAutoUpdate),
- (this.matrixWorldNeedsUpdate = !1),
- (this.layers = new qc()),
- (this.visible = !0),
- (this.castShadow = !1),
- (this.receiveShadow = !1),
- (this.frustumCulled = !0),
- (this.renderOrder = 0),
- (this.animations = []),
- (this.userData = {});
- }
- onBeforeRender() {}
- onAfterRender() {}
- applyMatrix4(e) {
- this.matrixAutoUpdate && this.updateMatrix(),
- this.matrix.premultiply(e),
- this.matrix.decompose(this.position, this.quaternion, this.scale);
- }
- applyQuaternion(e) {
- return this.quaternion.premultiply(e), this;
- }
- setRotationFromAxisAngle(e, t) {
- this.quaternion.setFromAxisAngle(e, t);
- }
- setRotationFromEuler(e) {
- this.quaternion.setFromEuler(e, !0);
- }
- setRotationFromMatrix(e) {
- this.quaternion.setFromRotationMatrix(e);
- }
- setRotationFromQuaternion(e) {
- this.quaternion.copy(e);
- }
- rotateOnAxis(e, t) {
- return wi.setFromAxisAngle(e, t), this.quaternion.multiply(wi), this;
- }
- rotateOnWorldAxis(e, t) {
- return (
- wi.setFromAxisAngle(e, t), this.quaternion.premultiply(wi), this
- );
- }
- rotateX(e) {
- return this.rotateOnAxis(pl, e);
- }
- rotateY(e) {
- return this.rotateOnAxis(ml, e);
- }
- rotateZ(e) {
- return this.rotateOnAxis(gl, e);
- }
- translateOnAxis(e, t) {
- return (
- fl.copy(e).applyQuaternion(this.quaternion),
- this.position.add(fl.multiplyScalar(t)),
- this
- );
- }
- translateX(e) {
- return this.translateOnAxis(pl, e);
- }
- translateY(e) {
- return this.translateOnAxis(ml, e);
- }
- translateZ(e) {
- return this.translateOnAxis(gl, e);
- }
- localToWorld(e) {
- return e.applyMatrix4(this.matrixWorld);
- }
- worldToLocal(e) {
- return e.applyMatrix4(mn.copy(this.matrixWorld).invert());
- }
- lookAt(e, t, n) {
- e.isVector3 ? Qs.copy(e) : Qs.set(e, t, n);
- const i = this.parent;
- this.updateWorldMatrix(!0, !1),
- fs.setFromMatrixPosition(this.matrixWorld),
- this.isCamera || this.isLight
- ? mn.lookAt(fs, Qs, this.up)
- : mn.lookAt(Qs, fs, this.up),
- this.quaternion.setFromRotationMatrix(mn),
- i &&
- (mn.extractRotation(i.matrixWorld),
- wi.setFromRotationMatrix(mn),
- this.quaternion.premultiply(wi.invert()));
- }
- add(e) {
- if (arguments.length > 1) {
- for (let t = 0; t < arguments.length; t++) this.add(arguments[t]);
- return this;
- }
- return e === this
- ? (console.error(
- "THREE.Object3D.add: object can't be added as a child of itself.",
- e
- ),
- this)
- : (e && e.isObject3D
- ? (e.parent !== null && e.parent.remove(e),
- (e.parent = this),
- this.children.push(e),
- e.dispatchEvent(Ed))
- : console.error(
- "THREE.Object3D.add: object not an instance of THREE.Object3D.",
- e
- ),
- this);
- }
- remove(e) {
- if (arguments.length > 1) {
- for (let n = 0; n < arguments.length; n++)
- this.remove(arguments[n]);
- return this;
- }
- const t = this.children.indexOf(e);
- return (
- t !== -1 &&
- ((e.parent = null),
- this.children.splice(t, 1),
- e.dispatchEvent(vl)),
- this
- );
- }
- removeFromParent() {
- const e = this.parent;
- return e !== null && e.remove(this), this;
- }
- clear() {
- for (let e = 0; e < this.children.length; e++) {
- const t = this.children[e];
- (t.parent = null), t.dispatchEvent(vl);
- }
- return (this.children.length = 0), this;
- }
- attach(e) {
- return (
- this.updateWorldMatrix(!0, !1),
- mn.copy(this.matrixWorld).invert(),
- e.parent !== null &&
- (e.parent.updateWorldMatrix(!0, !1),
- mn.multiply(e.parent.matrixWorld)),
- e.applyMatrix4(mn),
- this.add(e),
- e.updateWorldMatrix(!1, !0),
- this
- );
- }
- getObjectById(e) {
- return this.getObjectByProperty("id", e);
- }
- getObjectByName(e) {
- return this.getObjectByProperty("name", e);
- }
- getObjectByProperty(e, t) {
- if (this[e] === t) return this;
- for (let n = 0, i = this.children.length; n < i; n++) {
- const a = this.children[n].getObjectByProperty(e, t);
- if (a !== void 0) return a;
- }
- }
- getWorldPosition(e) {
- return (
- this.updateWorldMatrix(!0, !1),
- e.setFromMatrixPosition(this.matrixWorld)
- );
- }
- getWorldQuaternion(e) {
- return (
- this.updateWorldMatrix(!0, !1),
- this.matrixWorld.decompose(fs, e, Sd),
- e
- );
- }
- getWorldScale(e) {
- return (
- this.updateWorldMatrix(!0, !1),
- this.matrixWorld.decompose(fs, Td, e),
- e
- );
- }
- getWorldDirection(e) {
- this.updateWorldMatrix(!0, !1);
- const t = this.matrixWorld.elements;
- return e.set(t[8], t[9], t[10]).normalize();
- }
- raycast() {}
- traverse(e) {
- e(this);
- const t = this.children;
- for (let n = 0, i = t.length; n < i; n++) t[n].traverse(e);
- }
- traverseVisible(e) {
- if (this.visible === !1) return;
- e(this);
- const t = this.children;
- for (let n = 0, i = t.length; n < i; n++) t[n].traverseVisible(e);
- }
- traverseAncestors(e) {
- const t = this.parent;
- t !== null && (e(t), t.traverseAncestors(e));
- }
- updateMatrix() {
- this.matrix.compose(this.position, this.quaternion, this.scale),
- (this.matrixWorldNeedsUpdate = !0);
- }
- updateMatrixWorld(e) {
- this.matrixAutoUpdate && this.updateMatrix(),
- (this.matrixWorldNeedsUpdate || e) &&
- (this.parent === null
- ? this.matrixWorld.copy(this.matrix)
- : this.matrixWorld.multiplyMatrices(
- this.parent.matrixWorld,
- this.matrix
- ),
- (this.matrixWorldNeedsUpdate = !1),
- (e = !0));
- const t = this.children;
- for (let n = 0, i = t.length; n < i; n++) t[n].updateMatrixWorld(e);
- }
- updateWorldMatrix(e, t) {
- const n = this.parent;
- if (
- (e === !0 && n !== null && n.updateWorldMatrix(!0, !1),
- this.matrixAutoUpdate && this.updateMatrix(),
- this.parent === null
- ? this.matrixWorld.copy(this.matrix)
- : this.matrixWorld.multiplyMatrices(
- this.parent.matrixWorld,
- this.matrix
- ),
- t === !0)
- ) {
- const i = this.children;
- for (let s = 0, a = i.length; s < a; s++)
- i[s].updateWorldMatrix(!1, !0);
- }
- }
- toJSON(e) {
- const t = e === void 0 || typeof e == "string",
- n = {};
- t &&
- ((e = {
- geometries: {},
- materials: {},
- textures: {},
- images: {},
- shapes: {},
- skeletons: {},
- animations: {},
- nodes: {},
- }),
- (n.metadata = {
- version: 4.5,
- type: "Object",
- generator: "Object3D.toJSON",
- }));
- const i = {};
- (i.uuid = this.uuid),
- (i.type = this.type),
- this.name !== "" && (i.name = this.name),
- this.castShadow === !0 && (i.castShadow = !0),
- this.receiveShadow === !0 && (i.receiveShadow = !0),
- this.visible === !1 && (i.visible = !1),
- this.frustumCulled === !1 && (i.frustumCulled = !1),
- this.renderOrder !== 0 && (i.renderOrder = this.renderOrder),
- JSON.stringify(this.userData) !== "{}" &&
- (i.userData = this.userData),
- (i.layers = this.layers.mask),
- (i.matrix = this.matrix.toArray()),
- this.matrixAutoUpdate === !1 && (i.matrixAutoUpdate = !1),
- this.isInstancedMesh &&
- ((i.type = "InstancedMesh"),
- (i.count = this.count),
- (i.instanceMatrix = this.instanceMatrix.toJSON()),
- this.instanceColor !== null &&
- (i.instanceColor = this.instanceColor.toJSON()));
- function s(o, l) {
- return o[l.uuid] === void 0 && (o[l.uuid] = l.toJSON(e)), l.uuid;
- }
- if (this.isScene)
- this.background &&
- (this.background.isColor
- ? (i.background = this.background.toJSON())
- : this.background.isTexture &&
- (i.background = this.background.toJSON(e).uuid)),
- this.environment &&
- this.environment.isTexture &&
- (i.environment = this.environment.toJSON(e).uuid);
- else if (this.isMesh || this.isLine || this.isPoints) {
- i.geometry = s(e.geometries, this.geometry);
- const o = this.geometry.parameters;
- if (o !== void 0 && o.shapes !== void 0) {
- const l = o.shapes;
- if (Array.isArray(l))
- for (let c = 0, u = l.length; c < u; c++) {
- const h = l[c];
- s(e.shapes, h);
- }
- else s(e.shapes, l);
- }
- }
- if (
- (this.isSkinnedMesh &&
- ((i.bindMode = this.bindMode),
- (i.bindMatrix = this.bindMatrix.toArray()),
- this.skeleton !== void 0 &&
- (s(e.skeletons, this.skeleton),
- (i.skeleton = this.skeleton.uuid))),
- this.material !== void 0)
- )
- if (Array.isArray(this.material)) {
- const o = [];
- for (let l = 0, c = this.material.length; l < c; l++)
- o.push(s(e.materials, this.material[l]));
- i.material = o;
- } else i.material = s(e.materials, this.material);
- if (this.children.length > 0) {
- i.children = [];
- for (let o = 0; o < this.children.length; o++)
- i.children.push(this.children[o].toJSON(e).object);
- }
- if (this.animations.length > 0) {
- i.animations = [];
- for (let o = 0; o < this.animations.length; o++) {
- const l = this.animations[o];
- i.animations.push(s(e.animations, l));
- }
- }
- if (t) {
- const o = a(e.geometries),
- l = a(e.materials),
- c = a(e.textures),
- u = a(e.images),
- h = a(e.shapes),
- d = a(e.skeletons),
- f = a(e.animations),
- g = a(e.nodes);
- o.length > 0 && (n.geometries = o),
- l.length > 0 && (n.materials = l),
- c.length > 0 && (n.textures = c),
- u.length > 0 && (n.images = u),
- h.length > 0 && (n.shapes = h),
- d.length > 0 && (n.skeletons = d),
- f.length > 0 && (n.animations = f),
- g.length > 0 && (n.nodes = g);
- }
- return (n.object = i), n;
- function a(o) {
- const l = [];
- for (const c in o) {
- const u = o[c];
- delete u.metadata, l.push(u);
- }
- return l;
- }
- }
- 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.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.userData = JSON.parse(JSON.stringify(e.userData))),
- t === !0)
- )
- for (let n = 0; n < e.children.length; n++) {
- const i = e.children[n];
- this.add(i.clone());
- }
- return this;
- }
- }
- Ye.DefaultUp = new P(0, 1, 0);
- Ye.DefaultMatrixAutoUpdate = !0;
- const Gt = new P(),
- gn = new P(),
- ca = new P(),
- vn = new P(),
- bi = new P(),
- Si = new P(),
- _l = new P(),
- ha = new P(),
- ua = new P(),
- da = new P();
- class rn {
- constructor(e = new P(), t = new P(), n = new P()) {
- (this.a = e), (this.b = t), (this.c = n);
- }
- static getNormal(e, t, n, i) {
- i.subVectors(n, t), Gt.subVectors(e, t), i.cross(Gt);
- const s = i.lengthSq();
- return s > 0 ? i.multiplyScalar(1 / Math.sqrt(s)) : i.set(0, 0, 0);
- }
- static getBarycoord(e, t, n, i, s) {
- Gt.subVectors(i, t), gn.subVectors(n, t), ca.subVectors(e, t);
- const a = Gt.dot(Gt),
- o = Gt.dot(gn),
- l = Gt.dot(ca),
- c = gn.dot(gn),
- u = gn.dot(ca),
- h = a * c - o * o;
- if (h === 0) return s.set(-2, -1, -1);
- const d = 1 / h,
- f = (c * l - o * u) * d,
- g = (a * u - o * l) * d;
- return s.set(1 - f - g, g, f);
- }
- static containsPoint(e, t, n, i) {
- return (
- this.getBarycoord(e, t, n, i, vn),
- vn.x >= 0 && vn.y >= 0 && vn.x + vn.y <= 1
- );
- }
- static getUV(e, t, n, i, s, a, o, l) {
- return (
- this.getBarycoord(e, t, n, i, vn),
- l.set(0, 0),
- l.addScaledVector(s, vn.x),
- l.addScaledVector(a, vn.y),
- l.addScaledVector(o, vn.z),
- l
- );
- }
- static isFrontFacing(e, t, n, i) {
- return (
- Gt.subVectors(n, t), gn.subVectors(e, t), Gt.cross(gn).dot(i) < 0
- );
- }
- set(e, t, n) {
- return this.a.copy(e), this.b.copy(t), this.c.copy(n), this;
- }
- setFromPointsAndIndices(e, t, n, i) {
- return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[i]), this;
- }
- setFromAttributeAndIndices(e, t, n, i) {
- return (
- this.a.fromBufferAttribute(e, t),
- this.b.fromBufferAttribute(e, n),
- this.c.fromBufferAttribute(e, i),
- 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 (
- Gt.subVectors(this.c, this.b),
- gn.subVectors(this.a, this.b),
- Gt.cross(gn).length() * 0.5
- );
- }
- getMidpoint(e) {
- return e
- .addVectors(this.a, this.b)
- .add(this.c)
- .multiplyScalar(1 / 3);
- }
- getNormal(e) {
- return rn.getNormal(this.a, this.b, this.c, e);
- }
- getPlane(e) {
- return e.setFromCoplanarPoints(this.a, this.b, this.c);
- }
- getBarycoord(e, t) {
- return rn.getBarycoord(e, this.a, this.b, this.c, t);
- }
- getUV(e, t, n, i, s) {
- return rn.getUV(e, this.a, this.b, this.c, t, n, i, s);
- }
- containsPoint(e) {
- return rn.containsPoint(e, this.a, this.b, this.c);
- }
- isFrontFacing(e) {
- return rn.isFrontFacing(this.a, this.b, this.c, e);
- }
- intersectsBox(e) {
- return e.intersectsTriangle(this);
- }
- closestPointToPoint(e, t) {
- const n = this.a,
- i = this.b,
- s = this.c;
- let a, o;
- bi.subVectors(i, n), Si.subVectors(s, n), ha.subVectors(e, n);
- const l = bi.dot(ha),
- c = Si.dot(ha);
- if (l <= 0 && c <= 0) return t.copy(n);
- ua.subVectors(e, i);
- const u = bi.dot(ua),
- h = Si.dot(ua);
- if (u >= 0 && h <= u) return t.copy(i);
- const d = l * h - u * c;
- if (d <= 0 && l >= 0 && u <= 0)
- return (a = l / (l - u)), t.copy(n).addScaledVector(bi, a);
- da.subVectors(e, s);
- const f = bi.dot(da),
- g = Si.dot(da);
- if (g >= 0 && f <= g) return t.copy(s);
- const m = f * c - l * g;
- if (m <= 0 && c >= 0 && g <= 0)
- return (o = c / (c - g)), t.copy(n).addScaledVector(Si, o);
- const p = u * g - f * h;
- if (p <= 0 && h - u >= 0 && f - g >= 0)
- return (
- _l.subVectors(s, i),
- (o = (h - u) / (h - u + (f - g))),
- t.copy(i).addScaledVector(_l, o)
- );
- const v = 1 / (p + m + d);
- return (
- (a = m * v),
- (o = d * v),
- t.copy(n).addScaledVector(bi, a).addScaledVector(Si, o)
- );
- }
- equals(e) {
- return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
- }
- }
- let Ad = 0;
- class it extends hi {
- constructor() {
- super(),
- (this.isMaterial = !0),
- Object.defineProperty(this, "id", { value: Ad++ }),
- (this.uuid = Yt()),
- (this.name = ""),
- (this.type = "Material"),
- (this.blending = zi),
- (this.side = ki),
- (this.vertexColors = !1),
- (this.opacity = 1),
- (this.transparent = !1),
- (this.blendSrc = Rc),
- (this.blendDst = Pc),
- (this.blendEquation = Di),
- (this.blendSrcAlpha = null),
- (this.blendDstAlpha = null),
- (this.blendEquationAlpha = null),
- (this.depthFunc = Fa),
- (this.depthTest = !0),
- (this.depthWrite = !0),
- (this.stencilWriteMask = 255),
- (this.stencilFunc = nd),
- (this.stencilRef = 0),
- (this.stencilFuncMask = 255),
- (this.stencilFail = Jr),
- (this.stencilZFail = Jr),
- (this.stencilZPass = Jr),
- (this.stencilWrite = !1),
- (this.clippingPlanes = null),
- (this.clipIntersection = !1),
- (this.clipShadows = !1),
- (this.shadowSide = null),
- (this.colorWrite = !0),
- (this.precision = null),
- (this.polygonOffset = !1),
- (this.polygonOffsetFactor = 0),
- (this.polygonOffsetUnits = 0),
- (this.dithering = !1),
- (this.alphaToCoverage = !1),
- (this.premultipliedAlpha = !1),
- (this.visible = !0),
- (this.toneMapped = !0),
- (this.userData = {}),
- (this.version = 0),
- (this._alphaTest = 0);
- }
- get alphaTest() {
- return this._alphaTest;
- }
- set alphaTest(e) {
- this._alphaTest > 0 != e > 0 && this.version++, (this._alphaTest = e);
- }
- onBuild() {}
- 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) {
- console.warn(
- "THREE.Material: '" + t + "' parameter is undefined."
- );
- continue;
- }
- if (t === "shading") {
- console.warn(
- "THREE." +
- this.type +
- ": .shading has been removed. Use the boolean .flatShading instead."
- ),
- (this.flatShading = n === fu);
- continue;
- }
- const i = this[t];
- if (i === void 0) {
- console.warn(
- "THREE." +
- this.type +
- ": '" +
- t +
- "' is not a property of this material."
- );
- continue;
- }
- i && i.isColor
- ? i.set(n)
- : i && i.isVector3 && n && n.isVector3
- ? i.copy(n)
- : (this[t] = n);
- }
- }
- toJSON(e) {
- const t = e === void 0 || typeof e == "string";
- t && (e = { textures: {}, images: {} });
- const n = {
- metadata: {
- version: 4.5,
- 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 &&
- 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.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.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.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 &&
- (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 !== zi && (n.blending = this.blending),
- this.side !== ki && (n.side = this.side),
- this.vertexColors && (n.vertexColors = !0),
- this.opacity < 1 && (n.opacity = this.opacity),
- this.transparent === !0 && (n.transparent = this.transparent),
- (n.depthFunc = this.depthFunc),
- (n.depthTest = this.depthTest),
- (n.depthWrite = this.depthWrite),
- (n.colorWrite = this.colorWrite),
- (n.stencilWrite = this.stencilWrite),
- (n.stencilWriteMask = this.stencilWriteMask),
- (n.stencilFunc = this.stencilFunc),
- (n.stencilRef = this.stencilRef),
- (n.stencilFuncMask = this.stencilFuncMask),
- (n.stencilFail = this.stencilFail),
- (n.stencilZFail = this.stencilZFail),
- (n.stencilZPass = this.stencilZPass),
- 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.alphaToCoverage === !0 &&
- (n.alphaToCoverage = this.alphaToCoverage),
- this.premultipliedAlpha === !0 &&
- (n.premultipliedAlpha = this.premultipliedAlpha),
- this.wireframe === !0 && (n.wireframe = this.wireframe),
- 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 = this.flatShading),
- this.visible === !1 && (n.visible = !1),
- this.toneMapped === !1 && (n.toneMapped = !1),
- this.fog === !1 && (n.fog = !1),
- JSON.stringify(this.userData) !== "{}" &&
- (n.userData = this.userData);
- function i(s) {
- const a = [];
- for (const o in s) {
- const l = s[o];
- delete l.metadata, a.push(l);
- }
- return a;
- }
- if (t) {
- const s = i(e.textures),
- a = i(e.images);
- s.length > 0 && (n.textures = s), a.length > 0 && (n.images = a);
- }
- 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.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 i = t.length;
- n = new Array(i);
- for (let s = 0; s !== i; ++s) n[s] = t[s].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.alphaToCoverage = e.alphaToCoverage),
- (this.premultipliedAlpha = e.premultipliedAlpha),
- (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++;
- }
- get vertexTangents() {
- return (
- console.warn(
- "THREE." + this.type + ": .vertexTangents has been removed."
- ),
- !1
- );
- }
- set vertexTangents(e) {
- console.warn(
- "THREE." + this.type + ": .vertexTangents has been removed."
- );
- }
- }
- it.fromType = function () {
- return null;
- };
- class wn extends it {
- constructor(e) {
- super(),
- (this.isMeshBasicMaterial = !0),
- (this.type = "MeshBasicMaterial"),
- (this.color = new de(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.combine = zr),
- (this.reflectivity = 1),
- (this.refractionRatio = 0.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.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 tt = new P(),
- er = new ve();
- class wt {
- constructor(e, t, n) {
- if (Array.isArray(e))
- throw new TypeError(
- "THREE.BufferAttribute: array should be a Typed Array."
- );
- (this.isBufferAttribute = !0),
- (this.name = ""),
- (this.array = e),
- (this.itemSize = t),
- (this.count = e !== void 0 ? e.length / t : 0),
- (this.normalized = n === !0),
- (this.usage = ka),
- (this.updateRange = { offset: 0, count: -1 }),
- (this.version = 0);
- }
- onUploadCallback() {}
- set needsUpdate(e) {
- e === !0 && this.version++;
- }
- setUsage(e) {
- return (this.usage = e), this;
- }
- 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
- );
- }
- copyAt(e, t, n) {
- (e *= this.itemSize), (n *= t.itemSize);
- for (let i = 0, s = this.itemSize; i < s; i++)
- this.array[e + i] = t.array[n + i];
- return this;
- }
- copyArray(e) {
- return this.array.set(e), this;
- }
- copyColorsArray(e) {
- const t = this.array;
- let n = 0;
- for (let i = 0, s = e.length; i < s; i++) {
- let a = e[i];
- a === void 0 &&
- (console.warn(
- "THREE.BufferAttribute.copyColorsArray(): color is undefined",
- i
- ),
- (a = new de())),
- (t[n++] = a.r),
- (t[n++] = a.g),
- (t[n++] = a.b);
- }
- return this;
- }
- copyVector2sArray(e) {
- const t = this.array;
- let n = 0;
- for (let i = 0, s = e.length; i < s; i++) {
- let a = e[i];
- a === void 0 &&
- (console.warn(
- "THREE.BufferAttribute.copyVector2sArray(): vector is undefined",
- i
- ),
- (a = new ve())),
- (t[n++] = a.x),
- (t[n++] = a.y);
- }
- return this;
- }
- copyVector3sArray(e) {
- const t = this.array;
- let n = 0;
- for (let i = 0, s = e.length; i < s; i++) {
- let a = e[i];
- a === void 0 &&
- (console.warn(
- "THREE.BufferAttribute.copyVector3sArray(): vector is undefined",
- i
- ),
- (a = new P())),
- (t[n++] = a.x),
- (t[n++] = a.y),
- (t[n++] = a.z);
- }
- return this;
- }
- copyVector4sArray(e) {
- const t = this.array;
- let n = 0;
- for (let i = 0, s = e.length; i < s; i++) {
- let a = e[i];
- a === void 0 &&
- (console.warn(
- "THREE.BufferAttribute.copyVector4sArray(): vector is undefined",
- i
- ),
- (a = new Ue())),
- (t[n++] = a.x),
- (t[n++] = a.y),
- (t[n++] = a.z),
- (t[n++] = a.w);
- }
- return this;
- }
- applyMatrix3(e) {
- if (this.itemSize === 2)
- for (let t = 0, n = this.count; t < n; t++)
- er.fromBufferAttribute(this, t),
- er.applyMatrix3(e),
- this.setXY(t, er.x, er.y);
- else if (this.itemSize === 3)
- for (let t = 0, n = this.count; t < n; t++)
- tt.fromBufferAttribute(this, t),
- tt.applyMatrix3(e),
- this.setXYZ(t, tt.x, tt.y, tt.z);
- return this;
- }
- applyMatrix4(e) {
- for (let t = 0, n = this.count; t < n; t++)
- tt.fromBufferAttribute(this, t),
- tt.applyMatrix4(e),
- this.setXYZ(t, tt.x, tt.y, tt.z);
- return this;
- }
- applyNormalMatrix(e) {
- for (let t = 0, n = this.count; t < n; t++)
- tt.fromBufferAttribute(this, t),
- tt.applyNormalMatrix(e),
- this.setXYZ(t, tt.x, tt.y, tt.z);
- return this;
- }
- transformDirection(e) {
- for (let t = 0, n = this.count; t < n; t++)
- tt.fromBufferAttribute(this, t),
- tt.transformDirection(e),
- this.setXYZ(t, tt.x, tt.y, tt.z);
- return this;
- }
- set(e, t = 0) {
- return this.array.set(e, t), this;
- }
- getX(e) {
- return this.array[e * this.itemSize];
- }
- setX(e, t) {
- return (this.array[e * this.itemSize] = t), this;
- }
- getY(e) {
- return this.array[e * this.itemSize + 1];
- }
- setY(e, t) {
- return (this.array[e * this.itemSize + 1] = t), this;
- }
- getZ(e) {
- return this.array[e * this.itemSize + 2];
- }
- setZ(e, t) {
- return (this.array[e * this.itemSize + 2] = t), this;
- }
- getW(e) {
- return this.array[e * this.itemSize + 3];
- }
- setW(e, t) {
- return (this.array[e * this.itemSize + 3] = t), this;
- }
- setXY(e, t, n) {
- return (
- (e *= this.itemSize),
- (this.array[e + 0] = t),
- (this.array[e + 1] = n),
- this
- );
- }
- setXYZ(e, t, n, i) {
- return (
- (e *= this.itemSize),
- (this.array[e + 0] = t),
- (this.array[e + 1] = n),
- (this.array[e + 2] = i),
- this
- );
- }
- setXYZW(e, t, n, i, s) {
- return (
- (e *= this.itemSize),
- (this.array[e + 0] = t),
- (this.array[e + 1] = n),
- (this.array[e + 2] = i),
- (this.array[e + 3] = s),
- this
- );
- }
- onUpload(e) {
- return (this.onUploadCallback = e), this;
- }
- clone() {
- return new this.constructor(this.array, this.itemSize).copy(this);
- }
- toJSON() {
- const e = {
- itemSize: this.itemSize,
- type: this.array.constructor.name,
- array: Array.prototype.slice.call(this.array),
- normalized: this.normalized,
- };
- return (
- this.name !== "" && (e.name = this.name),
- this.usage !== ka && (e.usage = this.usage),
- (this.updateRange.offset !== 0 || this.updateRange.count !== -1) &&
- (e.updateRange = this.updateRange),
- e
- );
- }
- }
- class so extends wt {
- constructor(e, t, n) {
- super(new Uint16Array(e), t, n);
- }
- }
- class $c extends wt {
- constructor(e, t, n) {
- super(new Uint32Array(e), t, n);
- }
- }
- class Xe extends wt {
- constructor(e, t, n) {
- super(new Float32Array(e), t, n);
- }
- }
- let Cd = 0;
- const Dt = new pe(),
- fa = new Ye(),
- Ti = new P(),
- Lt = new Ki(),
- ps = new Ki(),
- lt = new P();
- class ct extends hi {
- constructor() {
- super(),
- (this.isBufferGeometry = !0),
- Object.defineProperty(this, "id", { value: Cd++ }),
- (this.uuid = Yt()),
- (this.name = ""),
- (this.type = "BufferGeometry"),
- (this.index = null),
- (this.attributes = {}),
- (this.morphAttributes = {}),
- (this.morphTargetsRelative = !1),
- (this.groups = []),
- (this.boundingBox = null),
- (this.boundingSphere = null),
- (this.drawRange = { start: 0, count: 1 / 0 }),
- (this.userData = {});
- }
- getIndex() {
- return this.index;
- }
- setIndex(e) {
- return (
- Array.isArray(e)
- ? (this.index = new (Gc(e) ? $c : so)(e, 1))
- : (this.index = e),
- this
- );
- }
- getAttribute(e) {
- return this.attributes[e];
- }
- setAttribute(e, t) {
- return (this.attributes[e] = t), this;
- }
- deleteAttribute(e) {
- return delete this.attributes[e], this;
- }
- hasAttribute(e) {
- return this.attributes[e] !== void 0;
- }
- addGroup(e, t, n = 0) {
- this.groups.push({ start: e, count: t, materialIndex: n });
- }
- clearGroups() {
- this.groups = [];
- }
- setDrawRange(e, t) {
- (this.drawRange.start = e), (this.drawRange.count = t);
- }
- applyMatrix4(e) {
- const t = this.attributes.position;
- t !== void 0 && (t.applyMatrix4(e), (t.needsUpdate = !0));
- const n = this.attributes.normal;
- if (n !== void 0) {
- const s = new Xt().getNormalMatrix(e);
- n.applyNormalMatrix(s), (n.needsUpdate = !0);
- }
- const i = this.attributes.tangent;
- return (
- i !== void 0 && (i.transformDirection(e), (i.needsUpdate = !0)),
- this.boundingBox !== null && this.computeBoundingBox(),
- this.boundingSphere !== null && this.computeBoundingSphere(),
- this
- );
- }
- applyQuaternion(e) {
- return Dt.makeRotationFromQuaternion(e), this.applyMatrix4(Dt), this;
- }
- rotateX(e) {
- return Dt.makeRotationX(e), this.applyMatrix4(Dt), this;
- }
- rotateY(e) {
- return Dt.makeRotationY(e), this.applyMatrix4(Dt), this;
- }
- rotateZ(e) {
- return Dt.makeRotationZ(e), this.applyMatrix4(Dt), this;
- }
- translate(e, t, n) {
- return Dt.makeTranslation(e, t, n), this.applyMatrix4(Dt), this;
- }
- scale(e, t, n) {
- return Dt.makeScale(e, t, n), this.applyMatrix4(Dt), this;
- }
- lookAt(e) {
- return (
- fa.lookAt(e), fa.updateMatrix(), this.applyMatrix4(fa.matrix), this
- );
- }
- center() {
- return (
- this.computeBoundingBox(),
- this.boundingBox.getCenter(Ti).negate(),
- this.translate(Ti.x, Ti.y, Ti.z),
- this
- );
- }
- setFromPoints(e) {
- const t = [];
- for (let n = 0, i = e.length; n < i; n++) {
- const s = e[n];
- t.push(s.x, s.y, s.z || 0);
- }
- return this.setAttribute("position", new Xe(t, 3)), this;
- }
- computeBoundingBox() {
- this.boundingBox === null && (this.boundingBox = new Ki());
- const e = this.attributes.position,
- t = this.morphAttributes.position;
- if (e && e.isGLBufferAttribute) {
- console.error(
- 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',
- this
- ),
- this.boundingBox.set(
- new P(-1 / 0, -1 / 0, -1 / 0),
- new P(1 / 0, 1 / 0, 1 / 0)
- );
- return;
- }
- if (e !== void 0) {
- if ((this.boundingBox.setFromBufferAttribute(e), t))
- for (let n = 0, i = t.length; n < i; n++) {
- const s = t[n];
- Lt.setFromBufferAttribute(s),
- this.morphTargetsRelative
- ? (lt.addVectors(this.boundingBox.min, Lt.min),
- this.boundingBox.expandByPoint(lt),
- lt.addVectors(this.boundingBox.max, Lt.max),
- this.boundingBox.expandByPoint(lt))
- : (this.boundingBox.expandByPoint(Lt.min),
- this.boundingBox.expandByPoint(Lt.max));
- }
- } else this.boundingBox.makeEmpty();
- (isNaN(this.boundingBox.min.x) ||
- isNaN(this.boundingBox.min.y) ||
- isNaN(this.boundingBox.min.z)) &&
- console.error(
- 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',
- this
- );
- }
- computeBoundingSphere() {
- this.boundingSphere === null && (this.boundingSphere = new Zi());
- const e = this.attributes.position,
- t = this.morphAttributes.position;
- if (e && e.isGLBufferAttribute) {
- console.error(
- 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',
- this
- ),
- this.boundingSphere.set(new P(), 1 / 0);
- return;
- }
- if (e) {
- const n = this.boundingSphere.center;
- if ((Lt.setFromBufferAttribute(e), t))
- for (let s = 0, a = t.length; s < a; s++) {
- const o = t[s];
- ps.setFromBufferAttribute(o),
- this.morphTargetsRelative
- ? (lt.addVectors(Lt.min, ps.min),
- Lt.expandByPoint(lt),
- lt.addVectors(Lt.max, ps.max),
- Lt.expandByPoint(lt))
- : (Lt.expandByPoint(ps.min), Lt.expandByPoint(ps.max));
- }
- Lt.getCenter(n);
- let i = 0;
- for (let s = 0, a = e.count; s < a; s++)
- lt.fromBufferAttribute(e, s),
- (i = Math.max(i, n.distanceToSquared(lt)));
- if (t)
- for (let s = 0, a = t.length; s < a; s++) {
- const o = t[s],
- l = this.morphTargetsRelative;
- for (let c = 0, u = o.count; c < u; c++)
- lt.fromBufferAttribute(o, c),
- l && (Ti.fromBufferAttribute(e, c), lt.add(Ti)),
- (i = Math.max(i, n.distanceToSquared(lt)));
- }
- (this.boundingSphere.radius = Math.sqrt(i)),
- isNaN(this.boundingSphere.radius) &&
- console.error(
- 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',
- this
- );
- }
- }
- computeTangents() {
- const e = this.index,
- t = this.attributes;
- if (
- e === null ||
- t.position === void 0 ||
- t.normal === void 0 ||
- t.uv === void 0
- ) {
- console.error(
- "THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"
- );
- return;
- }
- const n = e.array,
- i = t.position.array,
- s = t.normal.array,
- a = t.uv.array,
- o = i.length / 3;
- this.hasAttribute("tangent") === !1 &&
- this.setAttribute("tangent", new wt(new Float32Array(4 * o), 4));
- const l = this.getAttribute("tangent").array,
- c = [],
- u = [];
- for (let I = 0; I < o; I++) (c[I] = new P()), (u[I] = new P());
- const h = new P(),
- d = new P(),
- f = new P(),
- g = new ve(),
- m = new ve(),
- p = new ve(),
- v = new P(),
- M = new P();
- function x(I, F, H) {
- h.fromArray(i, I * 3),
- d.fromArray(i, F * 3),
- f.fromArray(i, H * 3),
- g.fromArray(a, I * 2),
- m.fromArray(a, F * 2),
- p.fromArray(a, H * 2),
- d.sub(h),
- f.sub(h),
- m.sub(g),
- p.sub(g);
- const B = 1 / (m.x * p.y - p.x * m.y);
- !isFinite(B) ||
- (v
- .copy(d)
- .multiplyScalar(p.y)
- .addScaledVector(f, -m.y)
- .multiplyScalar(B),
- M.copy(f)
- .multiplyScalar(m.x)
- .addScaledVector(d, -p.x)
- .multiplyScalar(B),
- c[I].add(v),
- c[F].add(v),
- c[H].add(v),
- u[I].add(M),
- u[F].add(M),
- u[H].add(M));
- }
- let w = this.groups;
- w.length === 0 && (w = [{ start: 0, count: n.length }]);
- for (let I = 0, F = w.length; I < F; ++I) {
- const H = w[I],
- B = H.start,
- D = H.count;
- for (let z = B, N = B + D; z < N; z += 3)
- x(n[z + 0], n[z + 1], n[z + 2]);
- }
- const y = new P(),
- A = new P(),
- L = new P(),
- _ = new P();
- function T(I) {
- L.fromArray(s, I * 3), _.copy(L);
- const F = c[I];
- y.copy(F),
- y.sub(L.multiplyScalar(L.dot(F))).normalize(),
- A.crossVectors(_, F);
- const B = A.dot(u[I]) < 0 ? -1 : 1;
- (l[I * 4] = y.x),
- (l[I * 4 + 1] = y.y),
- (l[I * 4 + 2] = y.z),
- (l[I * 4 + 3] = B);
- }
- for (let I = 0, F = w.length; I < F; ++I) {
- const H = w[I],
- B = H.start,
- D = H.count;
- for (let z = B, N = B + D; z < N; z += 3)
- T(n[z + 0]), T(n[z + 1]), T(n[z + 2]);
- }
- }
- computeVertexNormals() {
- const e = this.index,
- t = this.getAttribute("position");
- if (t !== void 0) {
- let n = this.getAttribute("normal");
- if (n === void 0)
- (n = new wt(new Float32Array(t.count * 3), 3)),
- this.setAttribute("normal", n);
- else for (let d = 0, f = n.count; d < f; d++) n.setXYZ(d, 0, 0, 0);
- const i = new P(),
- s = new P(),
- a = new P(),
- o = new P(),
- l = new P(),
- c = new P(),
- u = new P(),
- h = new P();
- if (e)
- for (let d = 0, f = e.count; d < f; d += 3) {
- const g = e.getX(d + 0),
- m = e.getX(d + 1),
- p = e.getX(d + 2);
- i.fromBufferAttribute(t, g),
- s.fromBufferAttribute(t, m),
- a.fromBufferAttribute(t, p),
- u.subVectors(a, s),
- h.subVectors(i, s),
- u.cross(h),
- o.fromBufferAttribute(n, g),
- l.fromBufferAttribute(n, m),
- c.fromBufferAttribute(n, p),
- o.add(u),
- l.add(u),
- c.add(u),
- n.setXYZ(g, o.x, o.y, o.z),
- n.setXYZ(m, l.x, l.y, l.z),
- n.setXYZ(p, c.x, c.y, c.z);
- }
- else
- for (let d = 0, f = t.count; d < f; d += 3)
- i.fromBufferAttribute(t, d + 0),
- s.fromBufferAttribute(t, d + 1),
- a.fromBufferAttribute(t, d + 2),
- u.subVectors(a, s),
- h.subVectors(i, s),
- u.cross(h),
- n.setXYZ(d + 0, u.x, u.y, u.z),
- n.setXYZ(d + 1, u.x, u.y, u.z),
- n.setXYZ(d + 2, u.x, u.y, u.z);
- this.normalizeNormals(), (n.needsUpdate = !0);
- }
- }
- merge(e, t) {
- if (!(e && e.isBufferGeometry)) {
- console.error(
- "THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",
- e
- );
- return;
- }
- t === void 0 &&
- ((t = 0),
- console.warn(
- "THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."
- ));
- const n = this.attributes;
- for (const i in n) {
- if (e.attributes[i] === void 0) continue;
- const a = n[i].array,
- o = e.attributes[i],
- l = o.array,
- c = o.itemSize * t,
- u = Math.min(l.length, a.length - c);
- for (let h = 0, d = c; h < u; h++, d++) a[d] = l[h];
- }
- return this;
- }
- normalizeNormals() {
- const e = this.attributes.normal;
- for (let t = 0, n = e.count; t < n; t++)
- lt.fromBufferAttribute(e, t),
- lt.normalize(),
- e.setXYZ(t, lt.x, lt.y, lt.z);
- }
- toNonIndexed() {
- function e(o, l) {
- const c = o.array,
- u = o.itemSize,
- h = o.normalized,
- d = new c.constructor(l.length * u);
- let f = 0,
- g = 0;
- for (let m = 0, p = l.length; m < p; m++) {
- o.isInterleavedBufferAttribute
- ? (f = l[m] * o.data.stride + o.offset)
- : (f = l[m] * u);
- for (let v = 0; v < u; v++) d[g++] = c[f++];
- }
- return new wt(d, u, h);
- }
- if (this.index === null)
- return (
- console.warn(
- "THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."
- ),
- this
- );
- const t = new ct(),
- n = this.index.array,
- i = this.attributes;
- for (const o in i) {
- const l = i[o],
- c = e(l, n);
- t.setAttribute(o, c);
- }
- const s = this.morphAttributes;
- for (const o in s) {
- const l = [],
- c = s[o];
- for (let u = 0, h = c.length; u < h; u++) {
- const d = c[u],
- f = e(d, n);
- l.push(f);
- }
- t.morphAttributes[o] = l;
- }
- t.morphTargetsRelative = this.morphTargetsRelative;
- const a = this.groups;
- for (let o = 0, l = a.length; o < l; o++) {
- const c = a[o];
- t.addGroup(c.start, c.count, c.materialIndex);
- }
- return t;
- }
- toJSON() {
- const e = {
- metadata: {
- version: 4.5,
- type: "BufferGeometry",
- generator: "BufferGeometry.toJSON",
- },
- };
- if (
- ((e.uuid = this.uuid),
- (e.type = this.type),
- this.name !== "" && (e.name = this.name),
- Object.keys(this.userData).length > 0 &&
- (e.userData = this.userData),
- this.parameters !== void 0)
- ) {
- const l = this.parameters;
- for (const c in l) l[c] !== void 0 && (e[c] = l[c]);
- 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 l in n) {
- const c = n[l];
- e.data.attributes[l] = c.toJSON(e.data);
- }
- const i = {};
- let s = !1;
- for (const l in this.morphAttributes) {
- const c = this.morphAttributes[l],
- u = [];
- for (let h = 0, d = c.length; h < d; h++) {
- const f = c[h];
- u.push(f.toJSON(e.data));
- }
- u.length > 0 && ((i[l] = u), (s = !0));
- }
- s &&
- ((e.data.morphAttributes = i),
- (e.data.morphTargetsRelative = this.morphTargetsRelative));
- const a = this.groups;
- a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a)));
- const o = this.boundingSphere;
- return (
- o !== null &&
- (e.data.boundingSphere = {
- center: o.center.toArray(),
- radius: o.radius,
- }),
- 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(t));
- const i = e.attributes;
- for (const c in i) {
- const u = i[c];
- this.setAttribute(c, u.clone(t));
- }
- const s = e.morphAttributes;
- for (const c in s) {
- const u = [],
- h = s[c];
- for (let d = 0, f = h.length; d < f; d++) u.push(h[d].clone(t));
- this.morphAttributes[c] = u;
- }
- this.morphTargetsRelative = e.morphTargetsRelative;
- const a = e.groups;
- for (let c = 0, u = a.length; c < u; c++) {
- const h = a[c];
- this.addGroup(h.start, h.count, h.materialIndex);
- }
- const o = e.boundingBox;
- o !== null && (this.boundingBox = o.clone());
- const l = e.boundingSphere;
- return (
- l !== null && (this.boundingSphere = l.clone()),
- (this.drawRange.start = e.drawRange.start),
- (this.drawRange.count = e.drawRange.count),
- (this.userData = e.userData),
- e.parameters !== void 0 &&
- (this.parameters = Object.assign({}, e.parameters)),
- this
- );
- }
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
- }
- const xl = new pe(),
- Ei = new io(),
- pa = new Zi(),
- Fn = new P(),
- Nn = new P(),
- zn = new P(),
- ma = new P(),
- ga = new P(),
- va = new P(),
- tr = new P(),
- nr = new P(),
- ir = new P(),
- sr = new ve(),
- rr = new ve(),
- ar = new ve(),
- _a = new P(),
- or = new P();
- class Qe extends Ye {
- constructor(e = new ct(), t = new wn()) {
- super(),
- (this.isMesh = !0),
- (this.type = "Mesh"),
- (this.geometry = e),
- (this.material = t),
- this.updateMorphTargets();
- }
- copy(e, t) {
- return (
- super.copy(e, t),
- e.morphTargetInfluences !== void 0 &&
- (this.morphTargetInfluences = e.morphTargetInfluences.slice()),
- e.morphTargetDictionary !== void 0 &&
- (this.morphTargetDictionary = Object.assign(
- {},
- e.morphTargetDictionary
- )),
- (this.material = e.material),
- (this.geometry = e.geometry),
- this
- );
- }
- updateMorphTargets() {
- const t = this.geometry.morphAttributes,
- n = Object.keys(t);
- if (n.length > 0) {
- const i = t[n[0]];
- if (i !== void 0) {
- (this.morphTargetInfluences = []),
- (this.morphTargetDictionary = {});
- for (let s = 0, a = i.length; s < a; s++) {
- const o = i[s].name || String(s);
- this.morphTargetInfluences.push(0),
- (this.morphTargetDictionary[o] = s);
- }
- }
- }
- }
- raycast(e, t) {
- const n = this.geometry,
- i = this.material,
- s = this.matrixWorld;
- if (
- i === void 0 ||
- (n.boundingSphere === null && n.computeBoundingSphere(),
- pa.copy(n.boundingSphere),
- pa.applyMatrix4(s),
- e.ray.intersectsSphere(pa) === !1) ||
- (xl.copy(s).invert(),
- Ei.copy(e.ray).applyMatrix4(xl),
- n.boundingBox !== null && Ei.intersectsBox(n.boundingBox) === !1)
- )
- return;
- let a;
- const o = n.index,
- l = n.attributes.position,
- c = n.morphAttributes.position,
- u = n.morphTargetsRelative,
- h = n.attributes.uv,
- d = n.attributes.uv2,
- f = n.groups,
- g = n.drawRange;
- if (o !== null)
- if (Array.isArray(i))
- for (let m = 0, p = f.length; m < p; m++) {
- const v = f[m],
- M = i[v.materialIndex],
- x = Math.max(v.start, g.start),
- w = Math.min(
- o.count,
- Math.min(v.start + v.count, g.start + g.count)
- );
- for (let y = x, A = w; y < A; y += 3) {
- const L = o.getX(y),
- _ = o.getX(y + 1),
- T = o.getX(y + 2);
- (a = lr(this, M, e, Ei, l, c, u, h, d, L, _, T)),
- a &&
- ((a.faceIndex = Math.floor(y / 3)),
- (a.face.materialIndex = v.materialIndex),
- t.push(a));
- }
- }
- else {
- const m = Math.max(0, g.start),
- p = Math.min(o.count, g.start + g.count);
- for (let v = m, M = p; v < M; v += 3) {
- const x = o.getX(v),
- w = o.getX(v + 1),
- y = o.getX(v + 2);
- (a = lr(this, i, e, Ei, l, c, u, h, d, x, w, y)),
- a && ((a.faceIndex = Math.floor(v / 3)), t.push(a));
- }
- }
- else if (l !== void 0)
- if (Array.isArray(i))
- for (let m = 0, p = f.length; m < p; m++) {
- const v = f[m],
- M = i[v.materialIndex],
- x = Math.max(v.start, g.start),
- w = Math.min(
- l.count,
- Math.min(v.start + v.count, g.start + g.count)
- );
- for (let y = x, A = w; y < A; y += 3) {
- const L = y,
- _ = y + 1,
- T = y + 2;
- (a = lr(this, M, e, Ei, l, c, u, h, d, L, _, T)),
- a &&
- ((a.faceIndex = Math.floor(y / 3)),
- (a.face.materialIndex = v.materialIndex),
- t.push(a));
- }
- }
- else {
- const m = Math.max(0, g.start),
- p = Math.min(l.count, g.start + g.count);
- for (let v = m, M = p; v < M; v += 3) {
- const x = v,
- w = v + 1,
- y = v + 2;
- (a = lr(this, i, e, Ei, l, c, u, h, d, x, w, y)),
- a && ((a.faceIndex = Math.floor(v / 3)), t.push(a));
- }
- }
- }
- }
- function Ld(r, e, t, n, i, s, a, o) {
- let l;
- if (
- (e.side === qt
- ? (l = n.intersectTriangle(a, s, i, !0, o))
- : (l = n.intersectTriangle(i, s, a, e.side !== cn, o)),
- l === null)
- )
- return null;
- or.copy(o), or.applyMatrix4(r.matrixWorld);
- const c = t.ray.origin.distanceTo(or);
- return c < t.near || c > t.far
- ? null
- : { distance: c, point: or.clone(), object: r };
- }
- function lr(r, e, t, n, i, s, a, o, l, c, u, h) {
- Fn.fromBufferAttribute(i, c),
- Nn.fromBufferAttribute(i, u),
- zn.fromBufferAttribute(i, h);
- const d = r.morphTargetInfluences;
- if (s && d) {
- tr.set(0, 0, 0), nr.set(0, 0, 0), ir.set(0, 0, 0);
- for (let g = 0, m = s.length; g < m; g++) {
- const p = d[g],
- v = s[g];
- p !== 0 &&
- (ma.fromBufferAttribute(v, c),
- ga.fromBufferAttribute(v, u),
- va.fromBufferAttribute(v, h),
- a
- ? (tr.addScaledVector(ma, p),
- nr.addScaledVector(ga, p),
- ir.addScaledVector(va, p))
- : (tr.addScaledVector(ma.sub(Fn), p),
- nr.addScaledVector(ga.sub(Nn), p),
- ir.addScaledVector(va.sub(zn), p)));
- }
- Fn.add(tr), Nn.add(nr), zn.add(ir);
- }
- r.isSkinnedMesh &&
- (r.boneTransform(c, Fn),
- r.boneTransform(u, Nn),
- r.boneTransform(h, zn));
- const f = Ld(r, e, t, n, Fn, Nn, zn, _a);
- if (f) {
- o &&
- (sr.fromBufferAttribute(o, c),
- rr.fromBufferAttribute(o, u),
- ar.fromBufferAttribute(o, h),
- (f.uv = rn.getUV(_a, Fn, Nn, zn, sr, rr, ar, new ve()))),
- l &&
- (sr.fromBufferAttribute(l, c),
- rr.fromBufferAttribute(l, u),
- ar.fromBufferAttribute(l, h),
- (f.uv2 = rn.getUV(_a, Fn, Nn, zn, sr, rr, ar, new ve())));
- const g = { a: c, b: u, c: h, normal: new P(), materialIndex: 0 };
- rn.getNormal(Fn, Nn, zn, g.normal), (f.face = g);
- }
- return f;
- }
- class Ns extends ct {
- constructor(e = 1, t = 1, n = 1, i = 1, s = 1, a = 1) {
- super(),
- (this.type = "BoxGeometry"),
- (this.parameters = {
- width: e,
- height: t,
- depth: n,
- widthSegments: i,
- heightSegments: s,
- depthSegments: a,
- });
- const o = this;
- (i = Math.floor(i)), (s = Math.floor(s)), (a = Math.floor(a));
- const l = [],
- c = [],
- u = [],
- h = [];
- let d = 0,
- f = 0;
- g("z", "y", "x", -1, -1, n, t, e, a, s, 0),
- g("z", "y", "x", 1, -1, n, t, -e, a, s, 1),
- g("x", "z", "y", 1, 1, e, n, t, i, a, 2),
- g("x", "z", "y", 1, -1, e, n, -t, i, a, 3),
- g("x", "y", "z", 1, -1, e, t, n, i, s, 4),
- g("x", "y", "z", -1, -1, e, t, -n, i, s, 5),
- this.setIndex(l),
- this.setAttribute("position", new Xe(c, 3)),
- this.setAttribute("normal", new Xe(u, 3)),
- this.setAttribute("uv", new Xe(h, 2));
- function g(m, p, v, M, x, w, y, A, L, _, T) {
- const I = w / L,
- F = y / _,
- H = w / 2,
- B = y / 2,
- D = A / 2,
- z = L + 1,
- N = _ + 1;
- let k = 0,
- G = 0;
- const U = new P();
- for (let X = 0; X < N; X++) {
- const Z = X * F - B;
- for (let Y = 0; Y < z; Y++) {
- const J = Y * I - H;
- (U[m] = J * M),
- (U[p] = Z * x),
- (U[v] = D),
- c.push(U.x, U.y, U.z),
- (U[m] = 0),
- (U[p] = 0),
- (U[v] = A > 0 ? 1 : -1),
- u.push(U.x, U.y, U.z),
- h.push(Y / L),
- h.push(1 - X / _),
- (k += 1);
- }
- }
- for (let X = 0; X < _; X++)
- for (let Z = 0; Z < L; Z++) {
- const Y = d + Z + z * X,
- J = d + Z + z * (X + 1),
- ae = d + (Z + 1) + z * (X + 1),
- ue = d + (Z + 1) + z * X;
- l.push(Y, J, ue), l.push(J, ae, ue), (G += 6);
- }
- o.addGroup(f, G, T), (f += G), (d += k);
- }
- }
- static fromJSON(e) {
- return new Ns(
- e.width,
- e.height,
- e.depth,
- e.widthSegments,
- e.heightSegments,
- e.depthSegments
- );
- }
- }
- function Hi(r) {
- const e = {};
- for (const t in r) {
- e[t] = {};
- for (const n in r[t]) {
- const i = r[t][n];
- i &&
- (i.isColor ||
- i.isMatrix3 ||
- i.isMatrix4 ||
- i.isVector2 ||
- i.isVector3 ||
- i.isVector4 ||
- i.isTexture ||
- i.isQuaternion)
- ? (e[t][n] = i.clone())
- : Array.isArray(i)
- ? (e[t][n] = i.slice())
- : (e[t][n] = i);
- }
- }
- return e;
- }
- function pt(r) {
- const e = {};
- for (let t = 0; t < r.length; t++) {
- const n = Hi(r[t]);
- for (const i in n) e[i] = n[i];
- }
- return e;
- }
- const Rd = { clone: Hi, merge: pt };
- var Pd = `void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
-}`,
- Dd = `void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
-}`;
- class En extends it {
- constructor(e) {
- super(),
- (this.isShaderMaterial = !0),
- (this.type = "ShaderMaterial"),
- (this.defines = {}),
- (this.uniforms = {}),
- (this.vertexShader = Pd),
- (this.fragmentShader = Dd),
- (this.linewidth = 1),
- (this.wireframe = !1),
- (this.wireframeLinewidth = 1),
- (this.fog = !1),
- (this.lights = !1),
- (this.clipping = !1),
- (this.extensions = {
- derivatives: !1,
- fragDepth: !1,
- drawBuffers: !1,
- shaderTextureLOD: !1,
- }),
- (this.defaultAttributeValues = {
- color: [1, 1, 1],
- uv: [0, 0],
- uv2: [0, 0],
- }),
- (this.index0AttributeName = void 0),
- (this.uniformsNeedUpdate = !1),
- (this.glslVersion = null),
- e !== void 0 &&
- (e.attributes !== void 0 &&
- console.error(
- "THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."
- ),
- this.setValues(e));
- }
- copy(e) {
- return (
- super.copy(e),
- (this.fragmentShader = e.fragmentShader),
- (this.vertexShader = e.vertexShader),
- (this.uniforms = Hi(e.uniforms)),
- (this.defines = Object.assign({}, e.defines)),
- (this.wireframe = e.wireframe),
- (this.wireframeLinewidth = e.wireframeLinewidth),
- (this.fog = e.fog),
- (this.lights = e.lights),
- (this.clipping = e.clipping),
- (this.extensions = Object.assign({}, e.extensions)),
- (this.glslVersion = e.glslVersion),
- this
- );
- }
- toJSON(e) {
- const t = super.toJSON(e);
- (t.glslVersion = this.glslVersion), (t.uniforms = {});
- for (const i in this.uniforms) {
- const a = this.uniforms[i].value;
- a && a.isTexture
- ? (t.uniforms[i] = { type: "t", value: a.toJSON(e).uuid })
- : a && a.isColor
- ? (t.uniforms[i] = { type: "c", value: a.getHex() })
- : a && a.isVector2
- ? (t.uniforms[i] = { type: "v2", value: a.toArray() })
- : a && a.isVector3
- ? (t.uniforms[i] = { type: "v3", value: a.toArray() })
- : a && a.isVector4
- ? (t.uniforms[i] = { type: "v4", value: a.toArray() })
- : a && a.isMatrix3
- ? (t.uniforms[i] = { type: "m3", value: a.toArray() })
- : a && a.isMatrix4
- ? (t.uniforms[i] = { type: "m4", value: a.toArray() })
- : (t.uniforms[i] = { value: a });
- }
- Object.keys(this.defines).length > 0 && (t.defines = this.defines),
- (t.vertexShader = this.vertexShader),
- (t.fragmentShader = this.fragmentShader);
- const n = {};
- for (const i in this.extensions)
- this.extensions[i] === !0 && (n[i] = !0);
- return Object.keys(n).length > 0 && (t.extensions = n), t;
- }
- }
- class Yc extends Ye {
- constructor() {
- super(),
- (this.isCamera = !0),
- (this.type = "Camera"),
- (this.matrixWorldInverse = new pe()),
- (this.projectionMatrix = new pe()),
- (this.projectionMatrixInverse = new pe());
- }
- copy(e, t) {
- return (
- super.copy(e, t),
- this.matrixWorldInverse.copy(e.matrixWorldInverse),
- this.projectionMatrix.copy(e.projectionMatrix),
- this.projectionMatrixInverse.copy(e.projectionMatrixInverse),
- this
- );
- }
- getWorldDirection(e) {
- this.updateWorldMatrix(!0, !1);
- const t = this.matrixWorld.elements;
- return e.set(-t[8], -t[9], -t[10]).normalize();
- }
- 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);
- }
- }
- class mt extends Yc {
- constructor(e = 50, t = 1, n = 0.1, i = 2e3) {
- super(),
- (this.isPerspectiveCamera = !0),
- (this.type = "PerspectiveCamera"),
- (this.fov = e),
- (this.zoom = 1),
- (this.near = n),
- (this.far = i),
- (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 = (0.5 * this.getFilmHeight()) / e;
- (this.fov = As * 2 * Math.atan(t)), this.updateProjectionMatrix();
- }
- getFocalLength() {
- const e = Math.tan(ys * 0.5 * this.fov);
- return (0.5 * this.getFilmHeight()) / e;
- }
- getEffectiveFOV() {
- return As * 2 * Math.atan(Math.tan(ys * 0.5 * this.fov) / this.zoom);
- }
- getFilmWidth() {
- return this.filmGauge * Math.min(this.aspect, 1);
- }
- getFilmHeight() {
- return this.filmGauge / Math.max(this.aspect, 1);
- }
- setViewOffset(e, t, n, i, s, a) {
- (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 = i),
- (this.view.width = s),
- (this.view.height = a),
- this.updateProjectionMatrix();
- }
- clearViewOffset() {
- this.view !== null && (this.view.enabled = !1),
- this.updateProjectionMatrix();
- }
- updateProjectionMatrix() {
- const e = this.near;
- let t = (e * Math.tan(ys * 0.5 * this.fov)) / this.zoom,
- n = 2 * t,
- i = this.aspect * n,
- s = -0.5 * i;
- const a = this.view;
- if (this.view !== null && this.view.enabled) {
- const l = a.fullWidth,
- c = a.fullHeight;
- (s += (a.offsetX * i) / l),
- (t -= (a.offsetY * n) / c),
- (i *= a.width / l),
- (n *= a.height / c);
- }
- const o = this.filmOffset;
- o !== 0 && (s += (e * o) / this.getFilmWidth()),
- this.projectionMatrix.makePerspective(
- s,
- s + i,
- t,
- t - n,
- e,
- this.far
- ),
- 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 Ai = 90,
- Ci = 1;
- class Id extends Ye {
- constructor(e, t, n) {
- if (
- (super(),
- (this.type = "CubeCamera"),
- n.isWebGLCubeRenderTarget !== !0)
- ) {
- console.error(
- "THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."
- );
- return;
- }
- this.renderTarget = n;
- const i = new mt(Ai, Ci, e, t);
- (i.layers = this.layers),
- i.up.set(0, -1, 0),
- i.lookAt(new P(1, 0, 0)),
- this.add(i);
- const s = new mt(Ai, Ci, e, t);
- (s.layers = this.layers),
- s.up.set(0, -1, 0),
- s.lookAt(new P(-1, 0, 0)),
- this.add(s);
- const a = new mt(Ai, Ci, e, t);
- (a.layers = this.layers),
- a.up.set(0, 0, 1),
- a.lookAt(new P(0, 1, 0)),
- this.add(a);
- const o = new mt(Ai, Ci, e, t);
- (o.layers = this.layers),
- o.up.set(0, 0, -1),
- o.lookAt(new P(0, -1, 0)),
- this.add(o);
- const l = new mt(Ai, Ci, e, t);
- (l.layers = this.layers),
- l.up.set(0, -1, 0),
- l.lookAt(new P(0, 0, 1)),
- this.add(l);
- const c = new mt(Ai, Ci, e, t);
- (c.layers = this.layers),
- c.up.set(0, -1, 0),
- c.lookAt(new P(0, 0, -1)),
- this.add(c);
- }
- update(e, t) {
- this.parent === null && this.updateMatrixWorld();
- const n = this.renderTarget,
- [i, s, a, o, l, c] = this.children,
- u = e.getRenderTarget(),
- h = e.toneMapping,
- d = e.xr.enabled;
- (e.toneMapping = $t), (e.xr.enabled = !1);
- const f = n.texture.generateMipmaps;
- (n.texture.generateMipmaps = !1),
- e.setRenderTarget(n, 0),
- e.render(t, i),
- e.setRenderTarget(n, 1),
- e.render(t, s),
- e.setRenderTarget(n, 2),
- e.render(t, a),
- e.setRenderTarget(n, 3),
- e.render(t, o),
- e.setRenderTarget(n, 4),
- e.render(t, l),
- (n.texture.generateMipmaps = f),
- e.setRenderTarget(n, 5),
- e.render(t, c),
- e.setRenderTarget(u),
- (e.toneMapping = h),
- (e.xr.enabled = d),
- (n.texture.needsPMREMUpdate = !0);
- }
- }
- class Kc extends nt {
- constructor(e, t, n, i, s, a, o, l, c, u) {
- (e = e !== void 0 ? e : []),
- (t = t !== void 0 ? t : Ui),
- super(e, t, n, i, s, a, o, l, c, u),
- (this.isCubeTexture = !0),
- (this.flipY = !1);
- }
- get images() {
- return this.image;
- }
- set images(e) {
- this.image = e;
- }
- }
- class Fd extends Kt {
- constructor(e, t = {}) {
- super(e, e, t), (this.isWebGLCubeRenderTarget = !0);
- const n = { width: e, height: e, depth: 1 },
- i = [n, n, n, n, n, n];
- (this.texture = new Kc(
- i,
- t.mapping,
- t.wrapS,
- t.wrapT,
- t.magFilter,
- t.minFilter,
- t.format,
- t.type,
- t.anisotropy,
- t.encoding
- )),
- (this.texture.isRenderTargetTexture = !0),
- (this.texture.generateMipmaps =
- t.generateMipmaps !== void 0 ? t.generateMipmaps : !1),
- (this.texture.minFilter =
- t.minFilter !== void 0 ? t.minFilter : $e);
- }
- fromEquirectangularTexture(e, t) {
- (this.texture.type = t.type),
- (this.texture.encoding = t.encoding),
- (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 );
-
- }
- `,
- },
- i = new Ns(5, 5, 5),
- s = new En({
- name: "CubemapFromEquirect",
- uniforms: Hi(n.uniforms),
- vertexShader: n.vertexShader,
- fragmentShader: n.fragmentShader,
- side: qt,
- blending: Un,
- });
- s.uniforms.tEquirect.value = t;
- const a = new Qe(i, s),
- o = t.minFilter;
- return (
- t.minFilter === li && (t.minFilter = $e),
- new Id(1, 10, this).update(e, a),
- (t.minFilter = o),
- a.geometry.dispose(),
- a.material.dispose(),
- this
- );
- }
- clear(e, t, n, i) {
- const s = e.getRenderTarget();
- for (let a = 0; a < 6; a++)
- e.setRenderTarget(this, a), e.clear(t, n, i);
- e.setRenderTarget(s);
- }
- }
- const xa = new P(),
- Nd = new P(),
- zd = new Xt();
- class Qn {
- constructor(e = new P(1, 0, 0), t = 0) {
- (this.isPlane = !0), (this.normal = e), (this.constant = t);
- }
- set(e, t) {
- return this.normal.copy(e), (this.constant = t), this;
- }
- setComponents(e, t, n, i) {
- return this.normal.set(e, t, n), (this.constant = i), this;
- }
- setFromNormalAndCoplanarPoint(e, t) {
- return (
- this.normal.copy(e), (this.constant = -t.dot(this.normal)), this
- );
- }
- setFromCoplanarPoints(e, t, n) {
- const i = xa.subVectors(n, t).cross(Nd.subVectors(e, t)).normalize();
- return this.setFromNormalAndCoplanarPoint(i, e), this;
- }
- copy(e) {
- return this.normal.copy(e.normal), (this.constant = e.constant), this;
- }
- normalize() {
- const e = 1 / this.normal.length();
- return this.normal.multiplyScalar(e), (this.constant *= e), this;
- }
- negate() {
- return (this.constant *= -1), this.normal.negate(), this;
- }
- distanceToPoint(e) {
- return this.normal.dot(e) + this.constant;
- }
- distanceToSphere(e) {
- return this.distanceToPoint(e.center) - e.radius;
- }
- projectPoint(e, t) {
- return t
- .copy(this.normal)
- .multiplyScalar(-this.distanceToPoint(e))
- .add(e);
- }
- intersectLine(e, t) {
- const n = e.delta(xa),
- i = this.normal.dot(n);
- if (i === 0)
- return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
- const s = -(e.start.dot(this.normal) + this.constant) / i;
- return s < 0 || s > 1
- ? null
- : t.copy(n).multiplyScalar(s).add(e.start);
- }
- 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 || zd.getNormalMatrix(e),
- i = this.coplanarPoint(xa).applyMatrix4(e),
- s = this.normal.applyMatrix3(n).normalize();
- return (this.constant = -i.dot(s)), 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 Li = new Zi(),
- cr = new P();
- class ro {
- constructor(
- e = new Qn(),
- t = new Qn(),
- n = new Qn(),
- i = new Qn(),
- s = new Qn(),
- a = new Qn()
- ) {
- this.planes = [e, t, n, i, s, a];
- }
- set(e, t, n, i, s, a) {
- const o = this.planes;
- return (
- o[0].copy(e),
- o[1].copy(t),
- o[2].copy(n),
- o[3].copy(i),
- o[4].copy(s),
- o[5].copy(a),
- this
- );
- }
- copy(e) {
- const t = this.planes;
- for (let n = 0; n < 6; n++) t[n].copy(e.planes[n]);
- return this;
- }
- setFromProjectionMatrix(e) {
- const t = this.planes,
- n = e.elements,
- i = n[0],
- s = n[1],
- a = n[2],
- o = n[3],
- l = n[4],
- c = n[5],
- u = n[6],
- h = n[7],
- d = n[8],
- f = n[9],
- g = n[10],
- m = n[11],
- p = n[12],
- v = n[13],
- M = n[14],
- x = n[15];
- return (
- t[0].setComponents(o - i, h - l, m - d, x - p).normalize(),
- t[1].setComponents(o + i, h + l, m + d, x + p).normalize(),
- t[2].setComponents(o + s, h + c, m + f, x + v).normalize(),
- t[3].setComponents(o - s, h - c, m - f, x - v).normalize(),
- t[4].setComponents(o - a, h - u, m - g, x - M).normalize(),
- t[5].setComponents(o + a, h + u, m + g, x + M).normalize(),
- this
- );
- }
- intersectsObject(e) {
- const t = e.geometry;
- return (
- t.boundingSphere === null && t.computeBoundingSphere(),
- Li.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),
- this.intersectsSphere(Li)
- );
- }
- intersectsSprite(e) {
- return (
- Li.center.set(0, 0, 0),
- (Li.radius = 0.7071067811865476),
- Li.applyMatrix4(e.matrixWorld),
- this.intersectsSphere(Li)
- );
- }
- intersectsSphere(e) {
- const t = this.planes,
- n = e.center,
- i = -e.radius;
- for (let s = 0; s < 6; s++)
- if (t[s].distanceToPoint(n) < i) return !1;
- return !0;
- }
- intersectsBox(e) {
- const t = this.planes;
- for (let n = 0; n < 6; n++) {
- const i = t[n];
- if (
- ((cr.x = i.normal.x > 0 ? e.max.x : e.min.x),
- (cr.y = i.normal.y > 0 ? e.max.y : e.min.y),
- (cr.z = i.normal.z > 0 ? e.max.z : e.min.z),
- i.distanceToPoint(cr) < 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);
- }
- }
- function Zc() {
- let r = null,
- e = !1,
- t = null,
- n = null;
- function i(s, a) {
- t(s, a), (n = r.requestAnimationFrame(i));
- }
- return {
- start: function () {
- e !== !0 &&
- t !== null &&
- ((n = r.requestAnimationFrame(i)), (e = !0));
- },
- stop: function () {
- r.cancelAnimationFrame(n), (e = !1);
- },
- setAnimationLoop: function (s) {
- t = s;
- },
- setContext: function (s) {
- r = s;
- },
- };
- }
- function Od(r, e) {
- const t = e.isWebGL2,
- n = new WeakMap();
- function i(c, u) {
- const h = c.array,
- d = c.usage,
- f = r.createBuffer();
- r.bindBuffer(u, f), r.bufferData(u, h, d), c.onUploadCallback();
- let g;
- if (h instanceof Float32Array) g = 5126;
- else if (h instanceof Uint16Array)
- if (c.isFloat16BufferAttribute)
- if (t) g = 5131;
- else
- throw new Error(
- "THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."
- );
- else g = 5123;
- else if (h instanceof Int16Array) g = 5122;
- else if (h instanceof Uint32Array) g = 5125;
- else if (h instanceof Int32Array) g = 5124;
- else if (h instanceof Int8Array) g = 5120;
- else if (h instanceof Uint8Array) g = 5121;
- else if (h instanceof Uint8ClampedArray) g = 5121;
- else
- throw new Error(
- "THREE.WebGLAttributes: Unsupported buffer data format: " + h
- );
- return {
- buffer: f,
- type: g,
- bytesPerElement: h.BYTES_PER_ELEMENT,
- version: c.version,
- };
- }
- function s(c, u, h) {
- const d = u.array,
- f = u.updateRange;
- r.bindBuffer(h, c),
- f.count === -1
- ? r.bufferSubData(h, 0, d)
- : (t
- ? r.bufferSubData(
- h,
- f.offset * d.BYTES_PER_ELEMENT,
- d,
- f.offset,
- f.count
- )
- : r.bufferSubData(
- h,
- f.offset * d.BYTES_PER_ELEMENT,
- d.subarray(f.offset, f.offset + f.count)
- ),
- (f.count = -1));
- }
- function a(c) {
- return c.isInterleavedBufferAttribute && (c = c.data), n.get(c);
- }
- function o(c) {
- c.isInterleavedBufferAttribute && (c = c.data);
- const u = n.get(c);
- u && (r.deleteBuffer(u.buffer), n.delete(c));
- }
- function l(c, u) {
- if (c.isGLBufferAttribute) {
- const d = n.get(c);
- (!d || d.version < c.version) &&
- n.set(c, {
- buffer: c.buffer,
- type: c.type,
- bytesPerElement: c.elementSize,
- version: c.version,
- });
- return;
- }
- c.isInterleavedBufferAttribute && (c = c.data);
- const h = n.get(c);
- h === void 0
- ? n.set(c, i(c, u))
- : h.version < c.version &&
- (s(h.buffer, c, u), (h.version = c.version));
- }
- return { get: a, remove: o, update: l };
- }
- class Gn extends ct {
- constructor(e = 1, t = 1, n = 1, i = 1) {
- super(),
- (this.type = "PlaneGeometry"),
- (this.parameters = {
- width: e,
- height: t,
- widthSegments: n,
- heightSegments: i,
- });
- const s = e / 2,
- a = t / 2,
- o = Math.floor(n),
- l = Math.floor(i),
- c = o + 1,
- u = l + 1,
- h = e / o,
- d = t / l,
- f = [],
- g = [],
- m = [],
- p = [];
- for (let v = 0; v < u; v++) {
- const M = v * d - a;
- for (let x = 0; x < c; x++) {
- const w = x * h - s;
- g.push(w, -M, 0),
- m.push(0, 0, 1),
- p.push(x / o),
- p.push(1 - v / l);
- }
- }
- for (let v = 0; v < l; v++)
- for (let M = 0; M < o; M++) {
- const x = M + c * v,
- w = M + c * (v + 1),
- y = M + 1 + c * (v + 1),
- A = M + 1 + c * v;
- f.push(x, w, A), f.push(w, y, A);
- }
- this.setIndex(f),
- this.setAttribute("position", new Xe(g, 3)),
- this.setAttribute("normal", new Xe(m, 3)),
- this.setAttribute("uv", new Xe(p, 2));
- }
- static fromJSON(e) {
- return new Gn(e.width, e.height, e.widthSegments, e.heightSegments);
- }
- }
- var kd = `#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vUv ).g;
-#endif`,
- Ud = `#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
-#endif`,
- Bd = `#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
-#endif`,
- Vd = `#ifdef USE_ALPHATEST
- uniform float alphaTest;
-#endif`,
- Gd = `#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
-#endif`,
- Hd = `#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
-#endif`,
- Wd = "vec3 transformed = vec3( position );",
- jd = `vec3 objectNormal = vec3( normal );
-#ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
-#endif`,
- Xd = `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 );
-}
-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 );
-}
-vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float 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 );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
-}
-#ifdef USE_IRIDESCENCE
-vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float 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 = mix(F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence);
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
-}
-#endif
-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 * transposeMat3( 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 );
-}
-float G_BlinnPhong_Implicit( ) {
- return 0.25;
-}
-float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
-}
-vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
-}
-#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`,
- qd = `#ifdef USE_IRIDESCENCE
-const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
-);
-vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
-}
-vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
-}
-float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
-}
-vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( -pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[0] ) * exp( -4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 srgb = XYZ_TO_REC709 * xyz;
- return srgb;
-}
-vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float R21 = R12;
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[0] < iridescenceIOR ) phi23[0] = PI;
- if ( baseIOR[1] < iridescenceIOR ) phi23[1] = PI;
- if ( baseIOR[2] < iridescenceIOR ) phi23[2] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
-}
-#endif`,
- $d = `#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vUv );
- vec2 dSTdy = dFdy( vUv );
- float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
- vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
-#endif`,
- Yd = `#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #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`,
- Kd = `#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
-#endif`,
- Zd = `#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
-#endif`,
- Jd = `#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
-#endif`,
- Qd = `#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
-#elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
-#endif`,
- ef = `#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
-#elif defined( USE_COLOR )
- varying vec3 vColor;
-#endif`,
- tf = `#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
-#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
-#endif`,
- nf = `#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
-#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
-#endif
-#ifdef USE_COLOR
- vColor *= color;
-#endif
-#ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
-#endif`,
- sf = `#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 color ) { return dot( color, vec3( 0.3333 ) ); }
-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;
-};
-struct GeometricContext {
- vec3 position;
- vec3 normal;
- vec3 viewDir;
-#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal;
-#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 );
-}
-mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
-}
-float linearToRelativeLuminance( const in vec3 color ) {
- vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
- return dot( weights, color.rgb );
-}
-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 );
-}`,
- rf = `#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 );
- 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 r0 1.0
- #define v0 0.339
- #define m0 - 2.0
- #define r1 0.8
- #define v1 0.276
- #define m1 - 1.0
- #define r4 0.4
- #define v4 0.046
- #define m4 2.0
- #define r5 0.305
- #define v5 0.016
- #define m5 3.0
- #define r6 0.21
- #define v6 0.0038
- #define m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= r1 ) {
- mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
- } else if ( roughness >= r4 ) {
- mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
- } else if ( roughness >= r5 ) {
- mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
- } else if ( roughness >= r6 ) {
- mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), 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`,
- af = `vec3 transformedNormal = objectNormal;
-#ifdef USE_INSTANCING
- mat3 m = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
- transformedNormal = m * transformedNormal;
-#endif
-transformedNormal = normalMatrix * transformedNormal;
-#ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
-#endif
-#ifdef USE_TANGENT
- vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
-#endif`,
- of = `#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
-#endif`,
- lf = `#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
-#endif`,
- cf = `#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
-#endif`,
- hf = `#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
-#endif`,
- uf = "gl_FragColor = linearToOutputTexel( gl_FragColor );",
- df = `vec4 LinearToLinear( in vec4 value ) {
- return value;
-}
-vec4 LinearTosRGB( 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 );
-}`,
- ff = `#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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
- #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`,
- pf = `#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
-#endif`,
- mf = `#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
-#endif`,
- gf = `#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
-#endif`,
- vf = `#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`,
- _f = `#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
-#endif`,
- xf = `#ifdef USE_FOG
- varying float vFogDepth;
-#endif`,
- yf = `#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`,
- Mf = `#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
-#endif`,
- wf = `#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
- return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
- #endif
-}`,
- bf = `#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vUv2 );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
-#endif`,
- Sf = `#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
-#endif`,
- Tf = `vec3 diffuse = vec3( 1.0 );
-GeometricContext geometry;
-geometry.position = mvPosition.xyz;
-geometry.normal = normalize( transformedNormal );
-geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
-GeometricContext backGeometry;
-backGeometry.position = geometry.position;
-backGeometry.normal = -geometry.normal;
-backGeometry.viewDir = geometry.viewDir;
-vLightFront = vec3( 0.0 );
-vIndirectFront = vec3( 0.0 );
-#ifdef DOUBLE_SIDED
- vLightBack = vec3( 0.0 );
- vIndirectBack = vec3( 0.0 );
-#endif
-IncidentLight directLight;
-float dotNL;
-vec3 directLightColor_Diffuse;
-vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
-vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
-#ifdef DOUBLE_SIDED
- vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
- vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
-#endif
-#if NUM_POINT_LIGHTS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- getPointLightInfo( pointLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #pragma unroll_loop_end
-#endif
-#if NUM_SPOT_LIGHTS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- getSpotLightInfo( spotLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #pragma unroll_loop_end
-#endif
-#if NUM_DIR_LIGHTS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
- dotNL = dot( geometry.normal, directLight.direction );
- directLightColor_Diffuse = directLight.color;
- vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
- #ifdef DOUBLE_SIDED
- vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
- #endif
- }
- #pragma unroll_loop_end
-#endif
-#if NUM_HEMI_LIGHTS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
- #ifdef DOUBLE_SIDED
- vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
- #endif
- }
- #pragma unroll_loop_end
-#endif`,
- Ef = `uniform bool receiveShadow;
-uniform vec3 ambientLightColor;
-uniform vec3 lightProbe[ 9 ];
-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 ) {
- #if defined ( PHYSICALLY_CORRECT_LIGHTS )
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #else
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #endif
-}
-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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometry.position;
- 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 GeometricContext geometry, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometry.position;
- 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`,
- Af = `#if defined( USE_ENVMAP )
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #if defined( ENVMAP_TYPE_CUBE_UV )
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, 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 ) {
- #if defined( ENVMAP_TYPE_CUBE_UV )
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
-#endif`,
- Cf = `ToonMaterial material;
-material.diffuseColor = diffuseColor.rgb;`,
- Lf = `varying vec3 vViewPosition;
-struct ToonMaterial {
- vec3 diffuseColor;
-};
-void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
-}
-void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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
-#define Material_LightProbeLOD( material ) (0)`,
- Rf = `BlinnPhongMaterial material;
-material.diffuseColor = diffuseColor.rgb;
-material.specularColor = specular;
-material.specularShininess = shininess;
-material.specularStrength = specularStrength;`,
- Pf = `varying vec3 vViewPosition;
-struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
-};
-void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
-}
-void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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
-#define Material_LightProbeLOD( material ) (0)`,
- Df = `PhysicalMaterial material;
-material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
-vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
-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
- #ifdef SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULARINTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
- #endif
- #ifdef USE_SPECULARCOLORMAP
- specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
- #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( ( ior - 1.0 ) / ( 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, vUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).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_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
-#endif
-#ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEENCOLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEENROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
- #endif
-#endif`,
- If = `struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #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
-};
-vec3 clearcoatSpecular = vec3( 0.0 );
-vec3 sheenSpecular = vec3( 0.0 );
-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 ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
-}
-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;
-}
-#if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometry.normal;
- vec3 viewDir = geometry.viewDir;
- vec3 position = geometry.position;
- 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
- #endif
- #ifdef USE_IRIDESCENCE
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
- #else
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
- #endif
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
-}
-void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometry.normal, geometry.viewDir, 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 );
-}`,
- Ff = `
-GeometricContext geometry;
-geometry.position = - vViewPosition;
-geometry.normal = normal;
-geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
-#ifdef USE_CLEARCOAT
- geometry.clearcoatNormal = clearcoatNormal;
-#endif
-#ifdef USE_IRIDESCENCE
-float dotNVi = saturate( dot( normal, geometry.viewDir ) );
-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, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, material, reflectedLight );
- }
- #pragma unroll_loop_end
-#endif
-#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- #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, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, 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, geometry, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometry, 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, geometry, material, reflectedLight );
- }
- #pragma unroll_loop_end
-#endif
-#if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
- }
- #pragma unroll_loop_end
- #endif
-#endif
-#if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
-#endif`,
- Nf = `#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vUv2 );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometry.normal );
- #endif
-#endif
-#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
- #endif
-#endif`,
- zf = `#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
-#endif
-#if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
-#endif`,
- Of = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
-#endif`,
- kf = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
-#endif`,
- Uf = `#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
-#endif`,
- Bf = `#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
-#endif`,
- Vf = `#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
- #endif
- diffuseColor *= sampledDiffuseColor;
-#endif`,
- Gf = `#ifdef USE_MAP
- uniform sampler2D map;
-#endif`,
- Hf = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
-#endif
-#ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
-#endif
-#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
-#endif`,
- Wf = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
-#endif
-#ifdef USE_MAP
- uniform sampler2D map;
-#endif
-#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
-#endif`,
- jf = `float metalnessFactor = metalness;
-#ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vUv );
- metalnessFactor *= texelMetalness.b;
-#endif`,
- Xf = `#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
-#endif`,
- qf = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- 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`,
- $f = `#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
-#endif`,
- Yf = `#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- 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 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
-#endif`,
- Kf = `#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
-#endif`,
- Zf = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
-#ifdef FLAT_SHADED
- vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
- vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
- vec3 normal = normalize( cross( fdx, fdy ) );
-#else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- #ifdef USE_TANGENT
- vec3 tangent = normalize( vTangent );
- vec3 bitangent = normalize( vBitangent );
- #ifdef DOUBLE_SIDED
- tangent = tangent * faceDirection;
- bitangent = bitangent * faceDirection;
- #endif
- #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
- mat3 vTBN = mat3( tangent, bitangent, normal );
- #endif
- #endif
-#endif
-vec3 geometryNormal = normal;`,
- Jf = `#ifdef OBJECTSPACE_NORMALMAP
- normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
-#elif defined( TANGENTSPACE_NORMALMAP )
- vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- #ifdef USE_TANGENT
- normal = normalize( vTBN * mapN );
- #else
- normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
- #endif
-#elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
-#endif`,
- Qf = `#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
-#endif`,
- ep = `#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
-#endif`,
- tp = `#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
-#endif`,
- np = `#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
-#endif
-#ifdef OBJECTSPACE_NORMALMAP
- uniform mat3 normalMatrix;
-#endif
-#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
- vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
- vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
- vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
- vec2 st0 = dFdx( vUv.st );
- vec2 st1 = dFdy( vUv.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 : faceDirection * inversesqrt( det );
- return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
- }
-#endif`,
- ip = `#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = geometryNormal;
-#endif`,
- sp = `#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- #ifdef USE_TANGENT
- clearcoatNormal = normalize( vTBN * clearcoatMapN );
- #else
- clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
- #endif
-#endif`,
- rp = `#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
-#endif
-#ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
-#endif
-#ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
-#endif`,
- ap = `#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
-#endif
-#ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
-#endif`,
- op = `#ifdef OPAQUE
-diffuseColor.a = 1.0;
-#endif
-#ifdef USE_TRANSMISSION
-diffuseColor.a *= transmissionAlpha + 0.1;
-#endif
-gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
- lp = `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 vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
-const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
-const float ShiftRight8 = 1. / 256.;
-vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
-}
-float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
-}
-vec4 pack2HalfToRGBA( 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( 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 linearClipZ, const in float near, const in float far ) {
- return linearClipZ * ( 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 invClipZ, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * invClipZ - far );
-}`,
- cp = `#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
-#endif`,
- hp = `vec4 mvPosition = vec4( transformed, 1.0 );
-#ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
-#endif
-mvPosition = modelViewMatrix * mvPosition;
-gl_Position = projectionMatrix * mvPosition;`,
- up = `#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
-#endif`,
- dp = `#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`,
- fp = `float roughnessFactor = roughness;
-#ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vUv );
- roughnessFactor *= texelRoughness.g;
-#endif`,
- pp = `#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
-#endif`,
- mp = `#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 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 ];
- varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- 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 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 ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- 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 );
- float hard_shadow = step( compare , distribution.x );
- 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 shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
- bool inFrustum = all( inFrustumVec );
- bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
- bool frustumTest = all( frustumTestVec );
- 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 shadow;
- }
- 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 shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- 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
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
-#endif`,
- gp = `#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 shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
- varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- 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 shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
-#endif`,
- vp = `#ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #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_SPOT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
- vSpotShadowCoord[ i ] = spotShadowMatrix[ 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`,
- _p = `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.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.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ 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.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
-}`,
- xp = `#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
-#endif`,
- yp = `#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- uniform int boneTextureSize;
- mat4 getBoneMatrix( const in float i ) {
- float j = i * 4.0;
- float x = mod( j, float( boneTextureSize ) );
- float y = floor( j / float( boneTextureSize ) );
- float dx = 1.0 / float( boneTextureSize );
- float dy = 1.0 / float( boneTextureSize );
- y = dy * ( y + 0.5 );
- vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
- vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
- vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
- vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
- mat4 bone = mat4( v1, v2, v3, v4 );
- return bone;
- }
-#endif`,
- Mp = `#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`,
- wp = `#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`,
- bp = `float specularStrength;
-#ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vUv );
- specularStrength = texelSpecular.r;
-#else
- specularStrength = 1.0;
-#endif`,
- Sp = `#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
-#endif`,
- Tp = `#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
-#endif`,
- Ep = `#ifndef saturate
-#define saturate( a ) clamp( a, 0.0, 1.0 )
-#endif
-uniform float toneMappingExposure;
-vec3 LinearToneMapping( vec3 color ) {
- return toneMappingExposure * color;
-}
-vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
-}
-vec3 OptimizedCineonToneMapping( 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 );
-}
-vec3 CustomToneMapping( vec3 color ) { return color; }`,
- Ap = `#ifdef USE_TRANSMISSION
- float transmissionAlpha = 1.0;
- float transmissionFactor = transmission;
- float thicknessFactor = thickness;
- #ifdef USE_TRANSMISSIONMAP
- transmissionFactor *= texture2D( transmissionMap, vUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- thicknessFactor *= texture2D( thicknessMap, vUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmission = getIBLVolumeRefraction(
- n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,
- attenuationColor, attenuationDistance );
- totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );
- transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );
-#endif`,
- Cp = `#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;
- 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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- #ifdef texture2DLodEXT
- return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
- #else
- return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
- #endif
- }
- vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( attenuationDistance == 0.0 ) {
- return radiance;
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
- }
- }
- 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 ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- 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;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
- }
-#endif`,
- Lp = `#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
- varying vec2 vUv;
-#endif`,
- Rp = `#ifdef USE_UV
- #ifdef UVS_VERTEX_ONLY
- vec2 vUv;
- #else
- varying vec2 vUv;
- #endif
- uniform mat3 uvTransform;
-#endif`,
- Pp = `#ifdef USE_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
-#endif`,
- Dp = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- varying vec2 vUv2;
-#endif`,
- Ip = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- attribute vec2 uv2;
- varying vec2 vUv2;
- uniform mat3 uv2Transform;
-#endif`,
- Fp = `#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
- vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
-#endif`,
- Np = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
-#endif`;
- const zp = `varying vec2 vUv;
-uniform mat3 uvTransform;
-void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
-}`,
- Op = `uniform sampler2D t2D;
-varying vec2 vUv;
-void main() {
- gl_FragColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- gl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );
- #endif
- #include
- #include
-}`,
- kp = `varying vec3 vWorldDirection;
-#include
-void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include
- #include
- gl_Position.z = gl_Position.w;
-}`,
- Up = `#include
-uniform float opacity;
-varying vec3 vWorldDirection;
-#include
-void main() {
- vec3 vReflect = vWorldDirection;
- #include
- gl_FragColor = envColor;
- gl_FragColor.a *= opacity;
- #include
- #include
-}`,
- Bp = `#include
-#include
-#include
-#include
-#include
-#include
-#include
-varying vec2 vHighPrecisionZW;
-void main() {
- #include
- #include
- #ifdef USE_DISPLACEMENTMAP
- #include
- #include
- #include
- #endif
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- vHighPrecisionZW = gl_Position.zw;
-}`,
- Vp = `#if DEPTH_PACKING == 3200
- uniform float opacity;
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-varying vec2 vHighPrecisionZW;
-void main() {
- #include
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include
- #include
- #include
- #include
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
-}`,
- Gp = `#define DISTANCE
-varying vec3 vWorldPosition;
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- #include
- #ifdef USE_DISPLACEMENTMAP
- #include
- #include
- #include
- #endif
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- vWorldPosition = worldPosition.xyz;
-}`,
- Hp = `#define DISTANCE
-uniform vec3 referencePosition;
-uniform float nearDistance;
-uniform float farDistance;
-varying vec3 vWorldPosition;
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-void main () {
- #include
- vec4 diffuseColor = vec4( 1.0 );
- #include
- #include
- #include
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
-}`,
- Wp = `varying vec3 vWorldDirection;
-#include
-void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include
- #include
-}`,
- jp = `uniform sampler2D tEquirect;
-varying vec3 vWorldDirection;
-#include
-void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include
- #include
-}`,
- Xp = `uniform float scale;
-attribute float lineDistance;
-varying float vLineDistance;
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- vLineDistance = scale * lineDistance;
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-}`,
- qp = `uniform vec3 diffuse;
-uniform float opacity;
-uniform float dashSize;
-uniform float totalSize;
-varying float vLineDistance;
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include
- #include
- outgoingLight = diffuseColor.rgb;
- #include
- #include
- #include
- #include
- #include
-}`,
- $p = `#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- #include
- #include
- #include
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include
- #include
- #include
- #include
- #include
- #endif
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-}`,
- Yp = `uniform vec3 diffuse;
-uniform float opacity;
-#ifndef FLAT_SHADED
- varying vec3 vNormal;
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include
- #include
- #include
- #include
- #include
- #include
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vUv2 );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-}`,
- Kp = `#define LAMBERT
-varying vec3 vLightFront;
-varying vec3 vIndirectFront;
-#ifdef DOUBLE_SIDED
- varying vec3 vLightBack;
- varying vec3 vIndirectBack;
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-}`,
- Zp = `uniform vec3 diffuse;
-uniform vec3 emissive;
-uniform float opacity;
-varying vec3 vLightFront;
-varying vec3 vIndirectFront;
-#ifdef DOUBLE_SIDED
- varying vec3 vLightBack;
- varying vec3 vIndirectBack;
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-void main() {
- #include
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #ifdef DOUBLE_SIDED
- reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
- #else
- reflectedLight.indirectDiffuse += vIndirectFront;
- #endif
- #include
- reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
- #ifdef DOUBLE_SIDED
- reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
- #else
- reflectedLight.directDiffuse = vLightFront;
- #endif
- reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();
- #include
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include
- #include
- #include
- #include
- #include
- #include
- #include
-}`,
- Jp = `#define MATCAP
-varying vec3 vViewPosition;
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include