chunk-4R2RUFTZ.js 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. import {
  2. computed,
  3. createRenderer,
  4. customRef,
  5. defineComponent,
  6. getCurrentInstance,
  7. getCurrentScope,
  8. h,
  9. inject,
  10. nextTick,
  11. onMounted,
  12. onScopeDispose,
  13. onUnmounted,
  14. provide,
  15. readonly,
  16. ref,
  17. shallowReactive,
  18. shallowRef,
  19. toRef,
  20. toRefs,
  21. unref,
  22. watch,
  23. watchEffect
  24. } from "./chunk-LZPJ5JBW.js";
  25. import {
  26. ACESFilmicToneMapping,
  27. BufferAttribute,
  28. Clock,
  29. Color,
  30. LinearSRGBColorSpace,
  31. LoadingManager,
  32. MathUtils,
  33. NoToneMapping,
  34. OrthographicCamera,
  35. PCFShadowMap,
  36. PCFSoftShadowMap,
  37. PerspectiveCamera,
  38. Raycaster,
  39. SRGBColorSpace,
  40. Scene,
  41. TextureLoader,
  42. Vector2,
  43. WebGLRenderer,
  44. three_module_exports
  45. } from "./chunk-PDZK3SQX.js";
  46. // node_modules/.pnpm/@vueuse+shared@10.1.2_vue@3.2.47/node_modules/@vueuse/shared/index.mjs
  47. function tryOnScopeDispose(fn) {
  48. if (getCurrentScope()) {
  49. onScopeDispose(fn);
  50. return true;
  51. }
  52. return false;
  53. }
  54. function createEventHook() {
  55. const fns = /* @__PURE__ */ new Set();
  56. const off = (fn) => {
  57. fns.delete(fn);
  58. };
  59. const on = (fn) => {
  60. fns.add(fn);
  61. const offFn = () => off(fn);
  62. tryOnScopeDispose(offFn);
  63. return {
  64. off: offFn
  65. };
  66. };
  67. const trigger = (param) => {
  68. return Promise.all(Array.from(fns).map((fn) => fn(param)));
  69. };
  70. return {
  71. on,
  72. off,
  73. trigger
  74. };
  75. }
  76. function toValue(r) {
  77. return typeof r === "function" ? r() : unref(r);
  78. }
  79. var isClient = typeof window !== "undefined";
  80. var noop = () => {
  81. };
  82. var isIOS = getIsIOS();
  83. function getIsIOS() {
  84. var _a;
  85. return isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
  86. }
  87. function identity(arg) {
  88. return arg;
  89. }
  90. function toRef2(...args) {
  91. if (args.length !== 1)
  92. return toRef(...args);
  93. const r = args[0];
  94. return typeof r === "function" ? readonly(customRef(() => ({ get: r, set: noop }))) : ref(r);
  95. }
  96. function tryOnMounted(fn, sync = true) {
  97. if (getCurrentInstance())
  98. onMounted(fn);
  99. else if (sync)
  100. fn();
  101. else
  102. nextTick(fn);
  103. }
  104. // node_modules/.pnpm/@vueuse+core@10.1.2_vue@3.2.47/node_modules/@vueuse/core/index.mjs
  105. function unrefElement(elRef) {
  106. var _a;
  107. const plain = toValue(elRef);
  108. return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
  109. }
  110. var defaultWindow = isClient ? window : void 0;
  111. var defaultDocument = isClient ? window.document : void 0;
  112. var defaultNavigator = isClient ? window.navigator : void 0;
  113. var defaultLocation = isClient ? window.location : void 0;
  114. function useEventListener(...args) {
  115. let target;
  116. let events;
  117. let listeners;
  118. let options;
  119. if (typeof args[0] === "string" || Array.isArray(args[0])) {
  120. [events, listeners, options] = args;
  121. target = defaultWindow;
  122. } else {
  123. [target, events, listeners, options] = args;
  124. }
  125. if (!target)
  126. return noop;
  127. if (!Array.isArray(events))
  128. events = [events];
  129. if (!Array.isArray(listeners))
  130. listeners = [listeners];
  131. const cleanups = [];
  132. const cleanup = () => {
  133. cleanups.forEach((fn) => fn());
  134. cleanups.length = 0;
  135. };
  136. const register = (el, event, listener, options2) => {
  137. el.addEventListener(event, listener, options2);
  138. return () => el.removeEventListener(event, listener, options2);
  139. };
  140. const stopWatch = watch(
  141. () => [unrefElement(target), toValue(options)],
  142. ([el, options2]) => {
  143. cleanup();
  144. if (!el)
  145. return;
  146. cleanups.push(
  147. ...events.flatMap((event) => {
  148. return listeners.map((listener) => register(el, event, listener, options2));
  149. })
  150. );
  151. },
  152. { immediate: true, flush: "post" }
  153. );
  154. const stop = () => {
  155. stopWatch();
  156. cleanup();
  157. };
  158. tryOnScopeDispose(stop);
  159. return stop;
  160. }
  161. function useMounted() {
  162. const isMounted = ref(false);
  163. if (getCurrentInstance()) {
  164. onMounted(() => {
  165. isMounted.value = true;
  166. });
  167. }
  168. return isMounted;
  169. }
  170. function useSupported(callback) {
  171. const isMounted = useMounted();
  172. return computed(() => {
  173. isMounted.value;
  174. return Boolean(callback());
  175. });
  176. }
  177. function useRafFn(fn, options = {}) {
  178. const {
  179. immediate = true,
  180. window: window2 = defaultWindow
  181. } = options;
  182. const isActive = ref(false);
  183. let previousFrameTimestamp = 0;
  184. let rafId = null;
  185. function loop(timestamp2) {
  186. if (!isActive.value || !window2)
  187. return;
  188. const delta = timestamp2 - previousFrameTimestamp;
  189. fn({ delta, timestamp: timestamp2 });
  190. previousFrameTimestamp = timestamp2;
  191. rafId = window2.requestAnimationFrame(loop);
  192. }
  193. function resume() {
  194. if (!isActive.value && window2) {
  195. isActive.value = true;
  196. rafId = window2.requestAnimationFrame(loop);
  197. }
  198. }
  199. function pause() {
  200. isActive.value = false;
  201. if (rafId != null && window2) {
  202. window2.cancelAnimationFrame(rafId);
  203. rafId = null;
  204. }
  205. }
  206. if (immediate)
  207. resume();
  208. tryOnScopeDispose(pause);
  209. return {
  210. isActive: readonly(isActive),
  211. pause,
  212. resume
  213. };
  214. }
  215. function useMediaQuery(query, options = {}) {
  216. const { window: window2 = defaultWindow } = options;
  217. const isSupported = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
  218. let mediaQuery;
  219. const matches = ref(false);
  220. const cleanup = () => {
  221. if (!mediaQuery)
  222. return;
  223. if ("removeEventListener" in mediaQuery)
  224. mediaQuery.removeEventListener("change", update);
  225. else
  226. mediaQuery.removeListener(update);
  227. };
  228. const update = () => {
  229. if (!isSupported.value)
  230. return;
  231. cleanup();
  232. mediaQuery = window2.matchMedia(toRef2(query).value);
  233. matches.value = !!(mediaQuery == null ? void 0 : mediaQuery.matches);
  234. if (!mediaQuery)
  235. return;
  236. if ("addEventListener" in mediaQuery)
  237. mediaQuery.addEventListener("change", update);
  238. else
  239. mediaQuery.addListener(update);
  240. };
  241. watchEffect(update);
  242. tryOnScopeDispose(() => cleanup());
  243. return matches;
  244. }
  245. var _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  246. var globalKey = "__vueuse_ssr_handlers__";
  247. var handlers = getHandlers();
  248. function getHandlers() {
  249. if (!(globalKey in _global))
  250. _global[globalKey] = _global[globalKey] || {};
  251. return _global[globalKey];
  252. }
  253. function useDevicePixelRatio({
  254. window: window2 = defaultWindow
  255. } = {}) {
  256. const pixelRatio = ref(1);
  257. if (window2) {
  258. let observe = function() {
  259. pixelRatio.value = window2.devicePixelRatio;
  260. cleanup();
  261. media = window2.matchMedia(`(resolution: ${pixelRatio.value}dppx)`);
  262. media.addEventListener("change", observe, { once: true });
  263. }, cleanup = function() {
  264. media == null ? void 0 : media.removeEventListener("change", observe);
  265. };
  266. let media;
  267. observe();
  268. tryOnScopeDispose(cleanup);
  269. }
  270. return { pixelRatio };
  271. }
  272. var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
  273. var __hasOwnProp$g = Object.prototype.hasOwnProperty;
  274. var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
  275. var __objRest$2 = (source, exclude) => {
  276. var target = {};
  277. for (var prop in source)
  278. if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
  279. target[prop] = source[prop];
  280. if (source != null && __getOwnPropSymbols$g)
  281. for (var prop of __getOwnPropSymbols$g(source)) {
  282. if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
  283. target[prop] = source[prop];
  284. }
  285. return target;
  286. };
  287. function useResizeObserver(target, callback, options = {}) {
  288. const _a = options, { window: window2 = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
  289. let observer;
  290. const isSupported = useSupported(() => window2 && "ResizeObserver" in window2);
  291. const cleanup = () => {
  292. if (observer) {
  293. observer.disconnect();
  294. observer = void 0;
  295. }
  296. };
  297. const targets = computed(
  298. () => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]
  299. );
  300. const stopWatch = watch(
  301. targets,
  302. (els) => {
  303. cleanup();
  304. if (isSupported.value && window2) {
  305. observer = new ResizeObserver(callback);
  306. for (const _el of els)
  307. _el && observer.observe(_el, observerOptions);
  308. }
  309. },
  310. { immediate: true, flush: "post", deep: true }
  311. );
  312. const stop = () => {
  313. cleanup();
  314. stopWatch();
  315. };
  316. tryOnScopeDispose(stop);
  317. return {
  318. isSupported,
  319. stop
  320. };
  321. }
  322. function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
  323. const { window: window2 = defaultWindow, box = "content-box" } = options;
  324. const isSVG = computed(() => {
  325. var _a, _b;
  326. return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
  327. });
  328. const width = ref(initialSize.width);
  329. const height = ref(initialSize.height);
  330. useResizeObserver(
  331. target,
  332. ([entry]) => {
  333. const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
  334. if (window2 && isSVG.value) {
  335. const $elem = unrefElement(target);
  336. if ($elem) {
  337. const styles = window2.getComputedStyle($elem);
  338. width.value = parseFloat(styles.width);
  339. height.value = parseFloat(styles.height);
  340. }
  341. } else {
  342. if (boxSize) {
  343. const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
  344. width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
  345. height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
  346. } else {
  347. width.value = entry.contentRect.width;
  348. height.value = entry.contentRect.height;
  349. }
  350. }
  351. },
  352. options
  353. );
  354. watch(
  355. () => unrefElement(target),
  356. (ele) => {
  357. width.value = ele ? initialSize.width : 0;
  358. height.value = ele ? initialSize.height : 0;
  359. }
  360. );
  361. return {
  362. width,
  363. height
  364. };
  365. }
  366. var defaultState = {
  367. x: 0,
  368. y: 0,
  369. pointerId: 0,
  370. pressure: 0,
  371. tiltX: 0,
  372. tiltY: 0,
  373. width: 0,
  374. height: 0,
  375. twist: 0,
  376. pointerType: null
  377. };
  378. var keys = Object.keys(defaultState);
  379. var _TransitionPresets = {
  380. easeInSine: [0.12, 0, 0.39, 0],
  381. easeOutSine: [0.61, 1, 0.88, 1],
  382. easeInOutSine: [0.37, 0, 0.63, 1],
  383. easeInQuad: [0.11, 0, 0.5, 0],
  384. easeOutQuad: [0.5, 1, 0.89, 1],
  385. easeInOutQuad: [0.45, 0, 0.55, 1],
  386. easeInCubic: [0.32, 0, 0.67, 0],
  387. easeOutCubic: [0.33, 1, 0.68, 1],
  388. easeInOutCubic: [0.65, 0, 0.35, 1],
  389. easeInQuart: [0.5, 0, 0.75, 0],
  390. easeOutQuart: [0.25, 1, 0.5, 1],
  391. easeInOutQuart: [0.76, 0, 0.24, 1],
  392. easeInQuint: [0.64, 0, 0.78, 0],
  393. easeOutQuint: [0.22, 1, 0.36, 1],
  394. easeInOutQuint: [0.83, 0, 0.17, 1],
  395. easeInExpo: [0.7, 0, 0.84, 0],
  396. easeOutExpo: [0.16, 1, 0.3, 1],
  397. easeInOutExpo: [0.87, 0, 0.13, 1],
  398. easeInCirc: [0.55, 0, 1, 0.45],
  399. easeOutCirc: [0, 0.55, 0.45, 1],
  400. easeInOutCirc: [0.85, 0, 0.15, 1],
  401. easeInBack: [0.36, 0, 0.66, -0.56],
  402. easeOutBack: [0.34, 1.56, 0.64, 1],
  403. easeInOutBack: [0.68, -0.6, 0.32, 1.6]
  404. };
  405. var TransitionPresets = Object.assign({}, { linear: identity }, _TransitionPresets);
  406. function useWindowSize(options = {}) {
  407. const {
  408. window: window2 = defaultWindow,
  409. initialWidth = Infinity,
  410. initialHeight = Infinity,
  411. listenOrientation = true,
  412. includeScrollbar = true
  413. } = options;
  414. const width = ref(initialWidth);
  415. const height = ref(initialHeight);
  416. const update = () => {
  417. if (window2) {
  418. if (includeScrollbar) {
  419. width.value = window2.innerWidth;
  420. height.value = window2.innerHeight;
  421. } else {
  422. width.value = window2.document.documentElement.clientWidth;
  423. height.value = window2.document.documentElement.clientHeight;
  424. }
  425. }
  426. };
  427. update();
  428. tryOnMounted(update);
  429. useEventListener("resize", update, { passive: true });
  430. if (listenOrientation) {
  431. const matches = useMediaQuery("(orientation: portrait)");
  432. watch(matches, () => update());
  433. }
  434. return { width, height };
  435. }
  436. // node_modules/.pnpm/@tresjs+core@2.0.0-rc.2_three@0.152.2_vue@3.2.47/node_modules/@tresjs/core/dist/tres.js
  437. var ye = ref({ uuid: MathUtils.generateUUID() });
  438. var Me = (e) => void Object.assign(ye.value, e);
  439. var Qe = ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Qe || {});
  440. var Ze = 45;
  441. var A;
  442. function Ce() {
  443. const { state: e, setState: t, aspectRatio: o } = _();
  444. function a(i = "Perspective", s) {
  445. var u, f, m;
  446. if (i === "Perspective") {
  447. const { near: v, far: h2, fov: M } = s || {
  448. near: 0.1,
  449. far: 1e3,
  450. fov: Ze
  451. };
  452. A = new PerspectiveCamera(M, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, v, h2), (f = e.cameras) == null || f.push(A);
  453. } else {
  454. const { left: v, right: h2, top: M, bottom: w, near: P, far: C } = s || {
  455. left: -100,
  456. right: 100,
  457. top: 100,
  458. bottom: -100,
  459. near: 0.1,
  460. far: 1e3
  461. };
  462. A = new OrthographicCamera(v, h2, M, w, P, C), (m = e.cameras) == null || m.push(A);
  463. }
  464. return e.camera = A, t("camera", e.camera), A;
  465. }
  466. function n() {
  467. var i;
  468. e.camera instanceof PerspectiveCamera && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (i = e.camera) == null || i.updateProjectionMatrix();
  469. }
  470. function r(i) {
  471. var s;
  472. (s = e.cameras) == null || s.push(i), i instanceof PerspectiveCamera && e.aspectRatio && (i.aspect = e.aspectRatio.value), i.updateProjectionMatrix(), t("camera", i);
  473. }
  474. function c() {
  475. e.cameras = [];
  476. }
  477. return watchEffect(() => {
  478. o != null && o.value && n();
  479. }), {
  480. activeCamera: toRef(e, "camera"),
  481. createCamera: a,
  482. updateCamera: n,
  483. pushCamera: r,
  484. clearCameras: c
  485. };
  486. }
  487. var xe = createEventHook();
  488. var Re = createEventHook();
  489. var X = createEventHook();
  490. var j = new Clock();
  491. var W = 0;
  492. var H = 0;
  493. var { pause: et, resume: tt, isActive: at } = useRafFn(
  494. () => {
  495. xe.trigger({ delta: W, elapsed: H, clock: j }), Re.trigger({ delta: W, elapsed: H, clock: j }), X.trigger({ delta: W, elapsed: H, clock: j });
  496. },
  497. { immediate: false }
  498. );
  499. X.on(() => {
  500. W = j.getDelta(), H = j.getElapsedTime();
  501. });
  502. function Ee() {
  503. return {
  504. onBeforeLoop: xe.on,
  505. onLoop: Re.on,
  506. onAfterLoop: X.on,
  507. pause: et,
  508. resume: tt,
  509. isActive: at
  510. };
  511. }
  512. function nt(e) {
  513. return e instanceof Color ? e : Array.isArray(e) ? new Color(...e) : new Color(e);
  514. }
  515. var K = {
  516. realistic: {
  517. outputColorSpace: SRGBColorSpace,
  518. toneMapping: ACESFilmicToneMapping,
  519. toneMappingExposure: 3,
  520. shadowMap: {
  521. enabled: true,
  522. type: PCFSoftShadowMap
  523. }
  524. }
  525. };
  526. var Pe = (e, t) => {
  527. for (const o of Object.keys(t))
  528. t[o] instanceof Object && Object.assign(t[o], Pe(e[o], t[o]));
  529. return Object.assign(e || {}, t), e;
  530. };
  531. var rt = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  532. var ot = it(rt);
  533. function V(e) {
  534. return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
  535. }
  536. function it(e, t) {
  537. const o = /* @__PURE__ */ Object.create(null), a = e.split(",");
  538. for (let n = 0; n < a.length; n++)
  539. o[a[n]] = true;
  540. return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
  541. }
  542. function st(e) {
  543. var te, ae;
  544. const t = shallowRef(), o = ref(false), {
  545. alpha: a = true,
  546. antialias: n = true,
  547. depth: r,
  548. logarithmicDepthBuffer: c,
  549. failIfMajorPerformanceCaveat: i,
  550. precision: s,
  551. premultipliedAlpha: u,
  552. stencil: f,
  553. shadows: m = false,
  554. shadowMapType: v = PCFShadowMap,
  555. useLegacyLights: h2 = false,
  556. outputColorSpace: M = LinearSRGBColorSpace,
  557. toneMapping: w = NoToneMapping,
  558. toneMappingExposure: P = 1,
  559. context: C = void 0,
  560. powerPreference: U = "default",
  561. preserveDrawingBuffer: S = false,
  562. clearColor: d,
  563. windowSize: b = false,
  564. preset: y = void 0
  565. } = toRefs(e), { state: g, setState: T } = _(), { width: O, height: x } = toValue(b) == true || toValue(b) === "" || toValue(b) === "true" ? useWindowSize() : useElementSize(g.container), { logError: I, logWarning: B } = D(), { pixelRatio: R } = useDevicePixelRatio(), { pause: z, resume: G } = Ee(), Y = computed(() => O.value / x.value);
  566. !toValue(b) && ((ae = (te = g.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && B(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
  567. You could set windowSize=true to force the canvas to be the size of the window.`);
  568. const Z = () => {
  569. t.value && (t.value.setSize(O.value, x.value), t.value.setPixelRatio(Math.min(R.value, 2)));
  570. }, ee = () => {
  571. if (!t.value)
  572. return;
  573. const L = toValue(y);
  574. if (L) {
  575. L in K || I("Renderer Preset must be one of these: " + Object.keys(K).join(", ")), Pe(t.value, K[L]);
  576. return;
  577. }
  578. t.value.shadowMap.enabled = toValue(m), t.value.shadowMap.type = toValue(v), t.value.toneMapping = toValue(w) || NoToneMapping, t.value.toneMappingExposure = toValue(P), t.value.outputColorSpace = toValue(M) || LinearSRGBColorSpace, d != null && d.value && t.value.setClearColor(nt(toValue(d))), t.value.useLegacyLights = toValue(h2);
  579. }, Te = () => {
  580. const L = unrefElement(g.canvas);
  581. L && (t.value = new WebGLRenderer({
  582. canvas: L,
  583. alpha: toValue(a),
  584. antialias: toValue(n),
  585. context: toValue(C),
  586. depth: toValue(r),
  587. failIfMajorPerformanceCaveat: toValue(i),
  588. logarithmicDepthBuffer: toValue(c),
  589. powerPreference: toValue(U),
  590. precision: toValue(s),
  591. stencil: toValue(f),
  592. preserveDrawingBuffer: toValue(S),
  593. premultipliedAlpha: toValue(u)
  594. }), T("renderer", t.value), T("clock", new Clock()), T("aspectRatio", Y), ee(), Z(), G(), o.value = true);
  595. }, Le = () => {
  596. t.value && (t.value.dispose(), t.value = void 0, o.value = false, z());
  597. };
  598. return watch([Y, R], Z), watch(
  599. [m, v, M, h2, w, P, d],
  600. ee
  601. ), watch(
  602. () => [g.canvas, g.container],
  603. () => {
  604. unrefElement(g.canvas) && unrefElement(g.container) && Te();
  605. },
  606. { immediate: true, deep: true }
  607. ), {
  608. renderer: t,
  609. isReady: o,
  610. dispose: Le,
  611. aspectRatio: Y
  612. };
  613. }
  614. var oe = (e) => typeof e == "function";
  615. var ct = (e) => typeof e == "string";
  616. var Se = (e) => !!e && e.constructor === Array;
  617. function ut(e) {
  618. const t = { nodes: {}, materials: {} };
  619. return e && e.traverse((o) => {
  620. o.name && (t.nodes[o.name] = o), o.material && !t.materials[o.material.name] && (t.materials[o.material.name] = o.material);
  621. }), t;
  622. }
  623. async function xt(e, t, o, a, n) {
  624. const { logError: r } = D(), c = new e();
  625. n && n(c), o && o(c);
  626. const s = (Array.isArray(t) ? t : [t]).map(
  627. (u) => new Promise((f, m) => {
  628. c.load(
  629. u,
  630. (v) => {
  631. v.scene && Object.assign(v, ut(v.scene)), f(v);
  632. },
  633. a,
  634. (v) => m(r("[useLoader] - Failed to load resource", v))
  635. );
  636. })
  637. );
  638. return Se(t) ? await Promise.all(s) : await s[0];
  639. }
  640. async function Rt(e) {
  641. const t = new LoadingManager(), o = new TextureLoader(t), a = (n) => new Promise((r, c) => {
  642. o.load(
  643. n,
  644. (i) => r(i),
  645. () => null,
  646. () => {
  647. c(new Error("[useTextures] - Failed to load texture"));
  648. }
  649. );
  650. });
  651. if (Se(e)) {
  652. const n = await Promise.all(e.map((r) => a(r)));
  653. return e.length > 1 ? n : n[0];
  654. } else {
  655. const {
  656. map: n,
  657. displacementMap: r,
  658. normalMap: c,
  659. roughnessMap: i,
  660. metalnessMap: s,
  661. aoMap: u,
  662. alphaMap: f,
  663. matcap: m
  664. } = e;
  665. return {
  666. map: n ? await a(n) : null,
  667. displacementMap: r ? await a(r) : null,
  668. normalMap: c ? await a(c) : null,
  669. roughnessMap: i ? await a(i) : null,
  670. metalnessMap: s ? await a(s) : null,
  671. aoMap: u ? await a(u) : null,
  672. alphaMap: f ? await a(f) : null,
  673. matcap: m ? await a(m) : null
  674. };
  675. }
  676. }
  677. var p = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
  678. function ft() {
  679. const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
  680. return (p[e & 255] + p[e >> 8 & 255] + p[e >> 16 & 255] + p[e >> 24 & 255] + "-" + p[t & 255] + p[t >> 8 & 255] + "-" + p[t >> 16 & 15 | 64] + p[t >> 24 & 255] + "-" + p[o & 63 | 128] + p[o >> 8 & 255] + "-" + p[o >> 16 & 255] + p[o >> 24 & 255] + p[a & 255] + p[a >> 8 & 255] + p[a >> 16 & 255] + p[a >> 24 & 255]).toLowerCase();
  681. }
  682. var Q = Symbol();
  683. function lt() {
  684. const e = shallowReactive({
  685. uuid: ft(),
  686. camera: void 0,
  687. cameras: [],
  688. scene: void 0,
  689. renderer: void 0,
  690. aspectRatio: computed(() => window.innerWidth / window.innerHeight)
  691. });
  692. function t(n) {
  693. return e[n];
  694. }
  695. function o(n, r) {
  696. e[n] = r;
  697. }
  698. const a = {
  699. state: e,
  700. ...toRefs(e),
  701. getState: t,
  702. setState: o
  703. };
  704. return provide(Q, a), a;
  705. }
  706. var _ = () => inject(Q, {
  707. state: shallowReactive({
  708. camera: void 0,
  709. cameras: [],
  710. scene: void 0,
  711. renderer: void 0
  712. })
  713. });
  714. function dt() {
  715. var c;
  716. const e = shallowRef(new Raycaster()), t = ref(new Vector2()), o = ref(null), { setState: a, state: n } = _();
  717. a("raycaster", e.value), a("pointer", t), a("currentInstance", o);
  718. function r(i) {
  719. t.value.x = i.clientX / window.innerWidth * 2 - 1, t.value.y = -(i.clientY / window.innerHeight) * 2 + 1;
  720. }
  721. return (c = n == null ? void 0 : n.renderer) == null || c.domElement.addEventListener("pointermove", r), onUnmounted(() => {
  722. var i;
  723. (i = n == null ? void 0 : n.renderer) == null || i.domElement.removeEventListener("pointermove", r);
  724. }), {
  725. raycaster: e,
  726. pointer: t
  727. };
  728. }
  729. var Et = true;
  730. var ie = "[TresJS ▲ ■ ●] ";
  731. function D() {
  732. function e(a, n) {
  733. console.error(`${ie} ${a}`, n || "");
  734. }
  735. function t(a) {
  736. console.warn(`${ie} ${a}`);
  737. }
  738. function o(a, n) {
  739. }
  740. return {
  741. logError: e,
  742. logWarning: t,
  743. logMessage: o
  744. };
  745. }
  746. function Pt() {
  747. const { logWarning: e } = D();
  748. function t(a, n, r) {
  749. let c = null;
  750. return a.traverse((i) => {
  751. i[n] === r && (c = i);
  752. }), c || e(`Child with ${n} '${r}' not found.`), c;
  753. }
  754. function o(a, n) {
  755. return t(a, "name", n);
  756. }
  757. return {
  758. seek: t,
  759. seekByName: o
  760. };
  761. }
  762. var mt = /^on[^a-z]/;
  763. var pt = (e) => mt.test(e);
  764. var se = null;
  765. var ce = {
  766. GEOMETRY_VIA_PROP: "tres__geometryViaProp",
  767. MATERIAL_VIA_PROP: "tres__materialViaProp"
  768. };
  769. var { logError: ue } = D();
  770. var vt = {
  771. createElement(e, t, o, a) {
  772. var s, u;
  773. if (a || (a = {}), a.args || (a.args = []), e === "template" || ot(e))
  774. return null;
  775. let n = e.replace("Tres", ""), r;
  776. if (e === "primitive") {
  777. (a == null ? void 0 : a.object) === void 0 && ue("Tres primitives need a prop 'object'");
  778. const f = a.object;
  779. n = f.type, r = Object.assign(f, { type: n, attach: a.attach, primitive: true });
  780. } else {
  781. const f = ye.value[n];
  782. f || ue(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new f(...a.args);
  783. }
  784. if (r.isCamera) {
  785. a != null && a.position || r.position.set(3, 3, 3), a != null && a.lookAt || r.lookAt(0, 0, 0);
  786. const { pushCamera: f } = Ce();
  787. f(r);
  788. }
  789. (a == null ? void 0 : a.attach) === void 0 && (r.isMaterial ? r.attach = "material" : r.isBufferGeometry && (r.attach = "geometry"));
  790. const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
  791. return r.isObject3D && ((s = a == null ? void 0 : a.material) != null && s.isMaterial && (r.userData[i] = true), (u = a == null ? void 0 : a.geometry) != null && u.isBufferGeometry && (r.userData[c] = true)), r.events = {}, r;
  792. },
  793. insert(e, t) {
  794. var o, a, n, r;
  795. if ((((o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.type) === "TresGroup" || ((a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.type) === "TresObject3D") && t === null && !((r = (n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.ctx) != null && r.asyncResolved)) {
  796. se = e;
  797. return;
  798. }
  799. t || (t = se), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
  800. },
  801. remove(e) {
  802. var t, o;
  803. if (e) {
  804. if (e.isObject3D) {
  805. const a = e, n = (r) => {
  806. var s, u;
  807. const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
  808. r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (u = r.geometry) == null || u.dispose();
  809. };
  810. a.traverse((r) => n(r)), n(a);
  811. }
  812. (t = e.removeFromParent) == null || t.call(e), (o = e.dispose) == null || o.call(e);
  813. }
  814. },
  815. patchProp(e, t, o, a) {
  816. if (e) {
  817. let n = e, r = t, c = V(r), i = n == null ? void 0 : n[c];
  818. if (n.type === "BufferGeometry") {
  819. if (r === "args")
  820. return;
  821. n.setAttribute(
  822. V(r),
  823. new BufferAttribute(...a)
  824. );
  825. return;
  826. }
  827. if (r.includes("-") && i === void 0) {
  828. const u = r.split("-");
  829. i = u.reduce((f, m) => f[V(m)], n), r = u.pop(), c = r.toLowerCase(), i != null && i.set || (n = u.reduce((f, m) => f[V(m)], n));
  830. }
  831. pt(r) && (e.events[r] = a);
  832. let s = a;
  833. if (s === "" && (s = true), oe(i)) {
  834. Array.isArray(s) ? e[c](...s) : e[c](s);
  835. return;
  836. }
  837. !(i != null && i.set) && !oe(i) ? n[c] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
  838. }
  839. },
  840. parentNode(e) {
  841. return (e == null ? void 0 : e.parent) || null;
  842. },
  843. createText: () => void 0,
  844. createComment: () => void 0,
  845. setText: () => void 0,
  846. setElementText: () => void 0,
  847. nextSibling: () => void 0,
  848. querySelector: () => void 0,
  849. setScopeId: () => void 0,
  850. cloneNode: () => void 0,
  851. insertStaticContent: () => void 0
  852. };
  853. var { createApp: gt } = createRenderer(vt);
  854. var ht = (e) => {
  855. const t = gt(o);
  856. function o() {
  857. return e && e.default ? e.default() : [];
  858. }
  859. return t;
  860. };
  861. Me(three_module_exports);
  862. var { logWarning: fe } = D();
  863. var wt = defineComponent({
  864. name: "TresScene",
  865. props: [
  866. "shadows",
  867. "shadowMapType",
  868. "physicallyCorrectLights",
  869. "useLegacyLights",
  870. "outputColorSpace",
  871. "toneMapping",
  872. "toneMappingExposure",
  873. "context",
  874. "powerPreference",
  875. "preserveDrawingBuffer",
  876. "clearColor",
  877. "windowSize",
  878. "preset",
  879. "disableRender",
  880. "camera"
  881. ],
  882. setup(e, { slots: t, expose: o }) {
  883. e.physicallyCorrectLights === true && fe("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
  884. const a = ref(), n = ref(), r = new Scene(), { setState: c } = _();
  885. c("scene", r), c("canvas", n), c("container", a);
  886. const i = ref(), s = t && t.default && t.default();
  887. s && (s == null ? void 0 : s.length) > 0 && (i.value = s.some((w) => ct(w.type) && w.type.includes("Camera")) || e.camera, i.value || fe("No camera found in the scene, please add one!")), onMounted(() => {
  888. v();
  889. }), onUnmounted(() => {
  890. c("renderer", null);
  891. });
  892. const { activeCamera: u, pushCamera: f, clearCameras: m } = Ce();
  893. function v() {
  894. const { renderer: w } = st(e);
  895. e.camera && f(e.camera);
  896. const { onLoop: P } = Ee(), { raycaster: C, pointer: U } = dt();
  897. let S = null, d = null;
  898. watchEffect(() => {
  899. u.value && C.value.setFromCamera(U.value, u.value);
  900. }), P(() => {
  901. var b, y, g, T, O, x, I, B, R, z;
  902. if (u.value && e.disableRender !== true && e.disableRender !== "" && ((b = w.value) == null || b.render(r, u.value)), C.value) {
  903. const G = C.value.intersectObjects(r.children);
  904. G.length > 0 ? (d = G[0], S === null && ((T = (g = (y = d.object) == null ? void 0 : y.events) == null ? void 0 : g.onPointerEnter) == null || T.call(g, d)), (I = (x = (O = d.object) == null ? void 0 : O.events) == null ? void 0 : x.onPointerMove) == null || I.call(x, d)) : S !== null && ((z = (R = (B = d == null ? void 0 : d.object) == null ? void 0 : B.events) == null ? void 0 : R.onPointerLeave) == null || z.call(R, S), d = null), S = d;
  905. }
  906. }), useEventListener(n.value, "click", () => {
  907. var b, y, g;
  908. d !== null && ((g = (y = (b = d.object) == null ? void 0 : b.events) == null ? void 0 : y.onClick) == null || g.call(y, d));
  909. });
  910. }
  911. let h2;
  912. function M() {
  913. h2 = ht(t), h2.provide("useTres", _()), h2.provide(Q, _()), h2.provide("extend", Me), h2.mount(r);
  914. }
  915. return M(), o({
  916. scene: r
  917. }), watch(
  918. () => e.camera,
  919. (w) => {
  920. w && (m(), f(w));
  921. }
  922. ), () => h(
  923. h(
  924. "div",
  925. {
  926. ref: a,
  927. "data-scene": r.uuid,
  928. key: r.uuid,
  929. style: {
  930. position: "relative",
  931. width: "100%",
  932. height: "100%",
  933. pointerEvents: "auto",
  934. touchAction: "none"
  935. }
  936. },
  937. [
  938. h(
  939. "div",
  940. {
  941. style: {
  942. width: "100%",
  943. height: "100%"
  944. }
  945. },
  946. [
  947. h("canvas", {
  948. ref: n,
  949. "data-scene": r.uuid,
  950. style: {
  951. display: "block",
  952. width: "100%",
  953. height: "100%",
  954. position: e.windowSize ? "fixed" : "absolute",
  955. top: 0,
  956. left: 0
  957. }
  958. })
  959. ]
  960. )
  961. ]
  962. )
  963. );
  964. }
  965. });
  966. var bt = defineComponent({
  967. name: "TresCanvas",
  968. props: [
  969. "shadows",
  970. "shadowMapType",
  971. "physicallyCorrectLights",
  972. "useLegacyLights",
  973. "outputColorSpace",
  974. "toneMapping",
  975. "toneMappingExposure",
  976. "context",
  977. "powerPreference",
  978. "preserveDrawingBuffer",
  979. "clearColor",
  980. "windowSize",
  981. "preset",
  982. "disableRender",
  983. "camera"
  984. ],
  985. setup(e, { slots: t, expose: o }) {
  986. const a = lt();
  987. return o(a), () => h(wt, e, t);
  988. }
  989. });
  990. var St = {
  991. install(e) {
  992. e.component("TresCanvas", bt);
  993. }
  994. };
  995. export {
  996. ye,
  997. Me,
  998. Qe,
  999. Ce,
  1000. Ee,
  1001. st,
  1002. ut,
  1003. xt,
  1004. Rt,
  1005. Q,
  1006. lt,
  1007. _,
  1008. dt,
  1009. Et,
  1010. D,
  1011. Pt,
  1012. bt,
  1013. St
  1014. };
  1015. //# sourceMappingURL=chunk-4R2RUFTZ.js.map