@dcl/wearable-preview 1.0.0-1785859770.commit-569e873 → 1.0.0-1864186784.commit-91b0d1d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "files": {
3
- "main.css": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/css/main.bcd9c703.chunk.css",
4
- "main.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/main.dcd96f7f.chunk.js",
5
- "main.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/main.dcd96f7f.chunk.js.map",
6
- "runtime-main.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/runtime-main.0e53727d.js",
7
- "runtime-main.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/runtime-main.0e53727d.js.map",
8
- "static/js/2.221fd615.chunk.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/2.221fd615.chunk.js",
9
- "static/js/2.221fd615.chunk.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/2.221fd615.chunk.js.map",
10
- "index.html": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/index.html",
11
- "static/css/main.bcd9c703.chunk.css.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/css/main.bcd9c703.chunk.css.map",
12
- "static/js/2.221fd615.chunk.js.LICENSE.txt": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/2.221fd615.chunk.js.LICENSE.txt"
3
+ "main.css": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/css/main.bcd9c703.chunk.css",
4
+ "main.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/main.8f1b76b4.chunk.js",
5
+ "main.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/main.8f1b76b4.chunk.js.map",
6
+ "runtime-main.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/runtime-main.4dc54380.js",
7
+ "runtime-main.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/runtime-main.4dc54380.js.map",
8
+ "static/js/2.221fd615.chunk.js": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/2.221fd615.chunk.js",
9
+ "static/js/2.221fd615.chunk.js.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/2.221fd615.chunk.js.map",
10
+ "index.html": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/index.html",
11
+ "static/css/main.bcd9c703.chunk.css.map": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/css/main.bcd9c703.chunk.css.map",
12
+ "static/js/2.221fd615.chunk.js.LICENSE.txt": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/2.221fd615.chunk.js.LICENSE.txt"
13
13
  },
14
14
  "entrypoints": [
15
- "static/js/runtime-main.0e53727d.js",
15
+ "static/js/runtime-main.4dc54380.js",
16
16
  "static/js/2.221fd615.chunk.js",
17
17
  "static/css/main.bcd9c703.chunk.css",
18
- "static/js/main.dcd96f7f.chunk.js"
18
+ "static/js/main.8f1b76b4.chunk.js"
19
19
  ]
20
20
  }
package/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Preview wearables from Decentraland"/><link rel="apple-touch-icon" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/logo192.png"/><link rel="manifest" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/manifest.json"/><title>Decentraland | Wearable Preview</title><link href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/css/main.bcd9c703.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,a=r[0],i=r[1],c=r[2],f=0,s=[];f<a.length;f++)u=a[f],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&s.push(o[u][0]),o[u]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return l.push.apply(l,c||[]),t()}function t(){for(var e,r=0;r<l.length;r++){for(var t=l[r],n=!0,a=1;a<t.length;a++){var i=t[a];0!==o[i]&&(n=!1)}n&&(l.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},l=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/";var a=this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[],i=a.push.bind(a);a.push=r,a=a.slice();for(var c=0;c<a.length;c++)r(a[c]);var p=i;t()}([])</script><script src="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/2.221fd615.chunk.js"></script><script src="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/static/js/main.dcd96f7f.chunk.js"></script></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Preview wearables from Decentraland"/><link rel="apple-touch-icon" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/logo192.png"/><link rel="manifest" href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/manifest.json"/><title>Decentraland | Wearable Preview</title><link href="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/css/main.bcd9c703.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,u,a=r[0],i=r[1],c=r[2],f=0,d=[];f<a.length;f++)u=a[f],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&d.push(o[u][0]),o[u]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);d.length;)d.shift()();return l.push.apply(l,c||[]),t()}function t(){for(var e,r=0;r<l.length;r++){for(var t=l[r],n=!0,a=1;a<t.length;a++){var i=t[a];0!==o[i]&&(n=!1)}n&&(l.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},l=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/";var a=this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[],i=a.push.bind(a);a.push=r,a=a.slice();for(var c=0;c<a.length;c++)r(a[c]);var p=i;t()}([])</script><script src="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/2.221fd615.chunk.js"></script><script src="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/static/js/main.8f1b76b4.chunk.js"></script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/wearable-preview",
3
- "version": "1.0.0-1785859770.commit-569e873",
3
+ "version": "1.0.0-1864186784.commit-91b0d1d",
4
4
  "description": "Static website for the wearable preview",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,6 +9,6 @@
9
9
  "keywords": [],
10
10
  "author": "",
11
11
  "license": "Apache-2.0",
12
- "homepage": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873",
13
- "commit": "569e8735d5a20acc70031da56d2b408aa8086988"
12
+ "homepage": "https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d",
13
+ "commit": "91b0d1db8f151e43dd6045ee0e74089dd01c6b75"
14
14
  }
@@ -0,0 +1,2 @@
1
+ (this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[]).push([[0],{279:function(e,t,n){},364:function(e,t,n){},367:function(e,t,n){"use strict";n.r(t);var r=n(57),a=n.n(r),c=n(273),o=n.n(c),i=(n(279),n(68)),u=n(94),s=n(218),d=n.n(s),f=n(234),l=n(58),p=n.n(l),b=n(82),h=n(53),w=(n(366),n(274)),v=n.n(w);function m(e){var t=e.getChildren().filter((function(e){return"__root__"!==e.id}));if(t.length>0){for(var n=t[0],r=n.getBoundingInfo(),a=r.boundingBox.minimumWorld.add(n.position),c=r.boundingBox.maximumWorld.add(n.position),o=1;o<t.length;o++){var i=t[o],u=(r=i.getBoundingInfo()).boundingBox.minimumWorld.add(i.position),s=r.boundingBox.maximumWorld.add(i.position);a=h.n.Minimize(a,u),c=h.n.Maximize(c,s)}e.setBoundingInfo(new h.b(a,c))}}function O(e){switch(e){case u.WearableCategory.UPPER_BODY:return 2;case u.WearableCategory.SKIN:return 1.75;default:return 1.25}}function g(){return g=Object(b.a)(p.a.mark((function e(t,n,r,a){var c,o,i,u,s,d,l,w,g,j,x,y,k,E,I,R,S,B;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=new h.g(t,!0,{preserveDrawingBuffer:!0,stencil:!0}),(o=new h.k(c)).autoClear=!0,o.clearColor=new h.e(0,0,0,0),o.preventDefaultOnPointerDown=!1,h.l.OnPluginActivatedObservable.addOnce((function(e){"gltf"===e.name&&(e.preprocessUrlAsync=function(){var e=Object(b.a)(p.a.mark((function e(t){var n;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"/content/contents/",n=t.split("/content/contents/"),e.abrupt("return",n.length>0&&n[1]?r[n[1]]:t);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),i=v()(),u=function(){var e=Object(b.a)(p.a.mark((function e(t){return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.l.AppendAsync(n,"",o,null,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),s=function(){var e=Object(b.a)(p.a.mark((function e(){return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u(".glb");case 3:case 10:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),e.next=10,u(".gltf");case 11:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(){return e.apply(this,arguments)}}(),e.next=11,s();case 11:return e.sent.onReadyObservable.addOnce((function(e){return i.resolve(e)})),e.next=15,i;case 15:d=e.sent,new h.h("glow",d,{mainTextureFixedSize:1024,blurKernelSize:64}).intensity=1,(l=new h.a("camera",0,0,0,new h.n(0,0,0),d)).mode=h.c.PERSPECTIVE_CAMERA,l.position=new h.n(-2,2,2),l.useAutoRotationBehavior=!0,l.autoRotationBehavior.idleRotationSpeed=.2,l.setTarget(h.n.Zero()),l.lowerRadiusLimit=l.upperRadiusLimit=l.radius/O(a.category),l.attachControl(t,!0),new h.f("directional",new h.n(0,0,1),d).intensity=1,new h.i("top",new h.n(0,-1,0),d).intensity=1,new h.i("bottom",new h.n(0,1,0),d).intensity=1,new h.m("spot",new h.n(-2,2,2),new h.n(2,-2,-2),Math.PI/2,1e3,d).intensity=1,w=new h.j("parent",d),g=Object(f.a)(d.meshes);try{for(g.s();!(j=g.n()).done;)(x=j.value)!==w&&x.setParent(w)}catch(A){g.e(A)}finally{g.f()}y=Object(f.a)(d.materials);try{for(y.s();!(k=y.n()).done;)(E=k.value).name.toLowerCase().includes("hair_mat")&&(a.hair?E.albedoColor=h.d.FromHexString(a.hair):(E.alpha=0,d.removeMaterial(E))),E.name.toLowerCase().includes("avatarskin_mat")&&(a.skin?E.albedoColor=h.d.FromHexString(a.skin):(E.alpha=0,d.removeMaterial(E)))}catch(A){y.e(A)}finally{y.f()}m(w),I=w.getBoundingInfo().boundingBox.extendSize,R=I.length(),S=new h.n(1/R,1/R,1/R),w.scaling=S,B=w.getBoundingInfo().boundingBox.center.multiply(S),w.position.subtractInPlace(B),c.runRenderLoop((function(){return d.render()}));case 47:case"end":return e.stop()}}),e)}))),g.apply(this,arguments)}function j(e,t){return e.bodyShapes.includes(t)}function x(e){return j(e,u.WearableBodyShape.FEMALE)}var y,k,E=n(215),I=n(216),R=n(161);function S(e){return B.apply(this,arguments)}function B(){return(B=Object(b.a)(p.a.mark((function e(t){var n;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:if((n=e.sent).ok){e.next=9;break}return e.t0=Error,e.next=7,n.text();case 7:throw e.t1=e.sent,new e.t0(e.t1);case 9:return e.abrupt("return",n.json());case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e.PROD="prod",e.DEV="dev"}(y||(y={}));var A,P,D=(k={},Object(R.a)(k,y.DEV,"https://nft-api.decentraland.io"),Object(R.a)(k,y.PROD,"https://nft-api.decentraland.org"),k),C=function(){function e(){Object(E.a)(this,e)}return Object(I.a)(e,[{key:"fetchItem",value:function(){var e=Object(b.a)(p.a.mark((function e(t,n,r){var a,c;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(D[r],"/v1/items?contractAddress=").concat(t,"&itemId=").concat(n));case 2:if(a=e.sent,0!==(c=a.data).length){e.next=6;break}throw new Error('Item not found for contractAddress="'.concat(t,'" itemId="').concat(n,'"'));case 6:return e.abrupt("return",c[0]);case 7:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"fetchNFT",value:function(){var e=Object(b.a)(p.a.mark((function e(t,n,r){var a,c;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(D[r],"/v1/nfts?contractAddress=").concat(t,"&tokenId=").concat(n));case 2:if(a=e.sent,0!==(c=a.data).length){e.next=6;break}throw new Error('NFT not found for contractAddress="'.concat(t,'" tokenId="').concat(n,'"'));case 6:return e.abrupt("return",c[0].nft);case 7:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()}]),e}(),M=new C,W=(A={},Object(R.a)(A,y.DEV,"https://peer.decentraland.zone"),Object(R.a)(A,y.PROD,"https://peer.decentraland.org"),A),L=function(){function e(){Object(E.a)(this,e)}return Object(I.a)(e,[{key:"fetchWearable",value:function(){var e=Object(b.a)(p.a.mark((function e(t,n){var r,a;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(W[n],"/lambdas/collections/wearables?wearableId=").concat(t));case 2:if(r=e.sent,0!==(a=r.wearables).length){e.next=6;break}throw new Error('Wearable not found for urn="'.concat(t,'"'));case 6:return e.abrupt("return",a[0]);case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()}]),e}(),N=new L;function F(e){var t=e.contractAddress,n=e.itemId,a=e.tokenId,c=e.env,o=function(e){var t=Object(r.useState)(!1),n=Object(i.a)(t,2),a=n[0],c=n[1],o=Object(r.useState)(null),u=Object(i.a)(o,2),s=u[0],d=u[1],f=Object(r.useState)(""),l=Object(i.a)(f,2),p=l[0],b=l[1];return Object(r.useEffect)((function(){c(!0),e().then((function(e){return d(e)})).catch((function(e){return b(e.message)})).finally((function(){return c(!1)}))}),[]),[s,a,p]}(Object(b.a)(p.a.mark((function e(){var r,o,i;return p.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error("You must provide a valid contract address");case 2:if(r=c===y.PROD?"matic":"mumbai",o="urn:decentraland:".concat(r,":collections-v2:").concat(t,":").concat(n),n||a){e.next=8;break}throw new Error("You must provide either tokenId or itemId");case 8:if(n||!a){e.next=13;break}return e.next=11,M.fetchNFT(t,a,c);case 11:i=e.sent,o=i.network!==u.Network.ETHEREUM?"urn:decentraland:".concat(r,":collections-v2:").concat(t,":").concat(i.itemId):i.image.split("contents/")[1].split("/thumbnail")[0];case 13:return e.abrupt("return",N.fetchWearable(o,c));case 14:case"end":return e.stop()}}),e)})))),s=Object(i.a)(o,3);return[s[0],s[1],s[2]]}function z(e,t){var n=JSON.stringify({type:e,message:t});window.parent&&window.parent.postMessage(n,"*")}!function(e){e.LOAD="load",e.ERROR="error"}(P||(P={}));n(364);var _=n(121),T=function(){var e=Object(r.useState)(""),t=Object(i.a)(e,2),n=t[0],a=t[1],c=function(){var e=Object(r.useState)({width:void 0,height:void 0}),t=Object(i.a)(e,2),n=t[0],a=t[1];return Object(r.useEffect)((function(){function e(){a({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),o=c.width,s=c.height,f=Object(r.useState)({}),l=Object(i.a)(f,2),p=l[0],b=l[1],h=Object(r.useState)(!1),w=Object(i.a)(h,2),v=w[0],m=w[1],O=Object(r.useState)(!0),j=Object(i.a)(O,2),k=j[0],E=j[1],I=Object(r.useState)(!1),R=Object(i.a)(I,2),S=R[0],B=R[1],A=Object(r.useRef)(null),D=new URLSearchParams(window.location.search),C=D.get("contract"),M=D.get("token"),W=D.get("item"),L=D.get("skin"),N=D.get("hair"),T=D.get("shape"),U=F({contractAddress:C,tokenId:M,itemId:W,env:Object.values(y).reduce((function(e,t){return t===D.get("env")?t:e}),y.PROD)}),H=Object(i.a)(U,3),V=H[0],J=H[1],Y=H[2],K=Object(r.useState)(""),G=Object(i.a)(K,2),Z=G[0],q=G[1],Q=Object(r.useState)(!0),X=Object(i.a)(Q,2),$=X[0],ee=X[1],te=Object(r.useState)(!1),ne=Object(i.a)(te,2),re=ne[0],ae=ne[1],ce=n||Y,oe=(k||J)&&!ce,ie=!!Z&&!$&&!oe,ue=$&&!oe;return Object(r.useEffect)((function(){if(A.current&&V){var e=u.Rarity.getGradient(V.rarity),t=Object(i.a)(e,2),n=t[0],r=t[1],c="radial-gradient(".concat(n,", ").concat(r,")");b({backgroundImage:c,opacity:1}),q(V.thumbnail);var o=V.data.representations[0];if("female"===T&&V.data.representations.some(x)&&(o=V.data.representations.find(x)),o.mainFile.endsWith("png"))ee(!1),E(!1),B(!0);else{var s=o.contents.find((function(e){return e.key===o.mainFile})),d=o.contents.reduce((function(e,t){return e[t.key]=t.url,e}),{});s?function(e,t,n,r){return g.apply(this,arguments)}(A.current,s.url,d,{category:V.data.category,skin:L?"#"+L:void 0,hair:N?"#"+N:void 0}).catch((function(e){return a(e.message)})).finally((function(){E(!1),B(!0)})):(console.warn("Content not found for wearable",V),a("Content not found"))}}}),[A.current,V]),Object(r.useEffect)((function(){re||(S?(z(P.LOAD),ae(!0)):ce&&(z(P.ERROR,ce),ae(!0)))}),[S,ce,re]),Object(_.jsxs)("div",{className:d()("Preview",{"is-dragging":v,"is-loading":oe,"is-loaded":S,"is-3d":$,"has-error":!!ce}),style:p,children:[Object(_.jsx)("img",{src:Z,className:d()("thumbnail",{"is-visible":ie}),alt:"preview"}),Object(_.jsx)("canvas",{id:"wearable-preview",className:d()({"is-visible":ue}),width:o,height:s,ref:A,onMouseDown:function(){return m($&&!ce)},onMouseUp:function(){return m(!1)}}),ce&&Object(_.jsx)("div",{className:"error",children:ce})]})},U=a.a.memo(T);o.a.render(Object(_.jsx)(a.a.StrictMode,{children:Object(_.jsx)(U,{})}),document.getElementById("root"))}},[[367,1,2]]]);
2
+ //# sourceMappingURL=main.8f1b76b4.chunk.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["lib/babylon.ts","lib/representation.ts","types/env.ts","lib/json.ts","lib/api/nft.ts","lib/message.ts","lib/api/peer.ts","hooks/useWearable.ts","hooks/useFetch.ts","components/Preview/Preview.tsx","hooks/useWindowSize.ts","index.tsx"],"names":["refreshBoundingInfo","parent","children","getChildren","filter","mesh","id","length","child","boundingInfo","getBoundingInfo","min","boundingBox","minimumWorld","add","position","max","maximumWorld","i","siblingMin","siblingMax","Vector3","Minimize","Maximize","setBoundingInfo","BoundingInfo","getZoom","category","WearableCategory","UPPER_BODY","SKIN","canvas","url","mappings","options","a","engine","Engine","preserveDrawingBuffer","stencil","root","Scene","autoClear","clearColor","Color4","preventDefaultOnPointerDown","SceneLoader","OnPluginActivatedObservable","addOnce","plugin","name","preprocessUrlAsync","parts","split","sceneFuture","future","loadScene","extension","AppendAsync","getLoader","onReadyObservable","scene","resolve","GlowLayer","mainTextureFixedSize","blurKernelSize","intensity","camera","ArcRotateCamera","mode","Camera","PERSPECTIVE_CAMERA","useAutoRotationBehavior","autoRotationBehavior","idleRotationSpeed","setTarget","Zero","lowerRadiusLimit","upperRadiusLimit","radius","attachControl","DirectionalLight","HemisphericLight","SpotLight","Math","PI","Mesh","meshes","setParent","materials","material","toLowerCase","includes","hair","albedoColor","Color3","FromHexString","alpha","removeMaterial","skin","bounds","extendSize","size","scale","scaling","center","multiply","subtractInPlace","runRenderLoop","render","is","representation","bodyShape","bodyShapes","isFemale","WearableBodyShape","FEMALE","Env","json","fetch","resp","ok","Error","text","MessageType","nftApiByEnv","DEV","PROD","NFTApi","contractAddress","itemId","env","data","tokenId","nft","nftApi","peerByEnv","PeerApi","urn","wearables","peerApi","useWearable","fetcher","useState","isLoading","setIsLoading","result","setResult","error","setError","useEffect","then","catch","message","finally","useFetch","network","fetchNFT","Network","ETHEREUM","image","fetchWearable","sendMessage","type","event","JSON","stringify","window","postMessage","Preview","previewError","setPreviewError","width","undefined","height","windowSize","setWindowSize","handleResize","innerWidth","innerHeight","addEventListener","removeEventListener","useWindowSize","style","setStyle","isDragging","setIsDragging","isLoadingModel","setIsLoadingModel","isLoaded","setIsLoaded","canvasRef","useRef","params","URLSearchParams","location","search","get","shape","Object","values","reduce","selected","value","wearable","isLoadingWearable","wearableError","setImage","is3D","setIs3D","isMessageSent","setIsMessageSent","showImage","showCanvas","current","Rarity","getGradient","rarity","light","dark","backgroundImage","opacity","thumbnail","representations","some","find","mainFile","endsWith","content","contents","key","obj","file","loadWearable","console","warn","LOAD","ERROR","className","classNames","src","alt","ref","onMouseDown","onMouseUp","React","memo","ReactDOM","StrictMode","document","getElementById"],"mappings":"gVAsBA,SAASA,EAAoBC,GAC3B,IAAMC,EAAWD,EAAOE,cAAcC,QAAO,SAACC,GAAD,MAAsB,aAAZA,EAAKC,MAC5D,GAAIJ,EAASK,OAAS,EAAG,CAQvB,IAPA,IAAMC,EAAQN,EAAS,GAEnBO,EAAeD,EAAME,kBAErBC,EAAMF,EAAaG,YAAYC,aAAaC,IAAIN,EAAMO,UACtDC,EAAMP,EAAaG,YAAYK,aAAaH,IAAIN,EAAMO,UAEjDG,EAAI,EAAGA,EAAIhB,EAASK,OAAQW,IAAK,CACxC,IAAMV,EAAQN,EAASgB,GAGjBC,GADNV,EAAeD,EAAME,mBACWE,YAAYC,aAAaC,IAAIN,EAAMO,UAC7DK,EAAaX,EAAaG,YAAYK,aAAaH,IAAIN,EAAMO,UAEnEJ,EAAMU,IAAQC,SAASX,EAAKQ,GAC5BH,EAAMK,IAAQE,SAASP,EAAKI,GAG9BnB,EAAOuB,gBAAgB,IAAIC,IAAad,EAAKK,KAIjD,SAASU,EAAQC,GACf,OAAQA,GACN,KAAKC,mBAAiBC,WACpB,OAAO,EACT,KAAKD,mBAAiBE,KACpB,OAAO,KACT,QACE,OAAO,M,4CAIN,WACLC,EACAC,EACAC,EACAC,GAJK,iDAAAC,EAAA,6DAOCC,EAAS,IAAIC,IAAON,GAAQ,EAAM,CACtCO,uBAAuB,EACvBC,SAAS,KAILC,EAAO,IAAIC,IAAML,IAClBM,WAAY,EACjBF,EAAKG,WAAa,IAAIC,IAAO,EAAG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C,GACd,YAAa6C,EACb,QAASmB,EACT,cAAe5D,KAEjBmC,MAAOA,EART,UAUE,qBACEyD,IAAKhF,EACL8E,UAAWC,IAAW,YAAa,CACjC,aAAc3B,KAEhB6B,IAAI,YAEN,wBACE3O,GAAG,mBACHwO,UAAWC,IAAW,CACpB,aAAc1B,KAEhBzC,MAAOA,EACPE,OAAQA,EACRoE,IAAKnD,EACLoD,YAAa,kBAAMzD,EAAcsB,IAAS5D,KAC1CgG,UAAW,kBAAM1D,GAAc,MAEhCtC,IAAS,qBAAK0F,UAAU,QAAf,SAAwB1F,SAKzBiG,MAAMC,KAAK7E,GE5H1B8E,IAAS1I,OACP,cAAC,IAAM2I,WAAP,UACE,cAAC,EAAD,MAEFC,SAASC,eAAe,W","file":"static/js/main.dcd96f7f.chunk.js","sourcesContent":["import {\n ArcRotateCamera,\n BoundingInfo,\n Camera,\n Color3,\n Color4,\n DirectionalLight,\n Engine,\n GlowLayer,\n HemisphericLight,\n Mesh,\n PBRMaterial,\n Scene,\n SceneLoader,\n SpotLight,\n Vector3,\n} from '@babylonjs/core'\nimport '@babylonjs/loaders'\nimport { GLTFFileLoader } from '@babylonjs/loaders'\nimport { WearableCategory } from '@dcl/schemas'\nimport future from 'fp-future'\n\nfunction refreshBoundingInfo(parent: Mesh) {\n const children = parent.getChildren().filter((mesh) => mesh.id !== '__root__')\n if (children.length > 0) {\n const child = children[0] as Mesh\n // child.showBoundingBox = true\n let boundingInfo = child.getBoundingInfo()\n\n let min = boundingInfo.boundingBox.minimumWorld.add(child.position)\n let max = boundingInfo.boundingBox.maximumWorld.add(child.position)\n\n for (let i = 1; i < children.length; i++) {\n const child = children[i] as Mesh\n // child.showBoundingBox = true\n boundingInfo = child.getBoundingInfo()\n const siblingMin = boundingInfo.boundingBox.minimumWorld.add(child.position)\n const siblingMax = boundingInfo.boundingBox.maximumWorld.add(child.position)\n\n min = Vector3.Minimize(min, siblingMin)\n max = Vector3.Maximize(max, siblingMax)\n }\n\n parent.setBoundingInfo(new BoundingInfo(min, max))\n }\n}\n\nfunction getZoom(category: WearableCategory) {\n switch (category) {\n case WearableCategory.UPPER_BODY:\n return 2\n case WearableCategory.SKIN:\n return 1.75\n default:\n return 1.25\n }\n}\n\nexport async function loadWearable(\n canvas: HTMLCanvasElement,\n url: string,\n mappings: Record<string, string>,\n options: { category: WearableCategory; skin?: string; hair?: string }\n) {\n // Create engine\n const engine = new Engine(canvas, true, {\n preserveDrawingBuffer: true,\n stencil: true,\n })\n\n // Load GLB/GLTF\n const root = new Scene(engine)\n root.autoClear = true\n root.clearColor = new Color4(0, 0, 0, 0)\n root.preventDefaultOnPointerDown = false\n SceneLoader.OnPluginActivatedObservable.addOnce((plugin) => {\n if (plugin.name === 'gltf') {\n const gltf = plugin as GLTFFileLoader\n gltf.preprocessUrlAsync = async (url: string) => {\n const baseUrl = `/content/contents/`\n const parts = url.split(baseUrl)\n return parts.length > 0 && !!parts[1] ? mappings[parts[1]] : url\n }\n }\n })\n const sceneFuture = future<Scene>()\n const loadScene = async (extension: string) => SceneLoader.AppendAsync(url, '', root, null, extension)\n const getLoader = async () => {\n // try with GLB, if it fails try with GLTF\n try {\n return await loadScene('.glb')\n } catch (error) {\n return await loadScene('.gltf')\n }\n }\n const loader = await getLoader()\n loader.onReadyObservable.addOnce((scene) => sceneFuture.resolve(scene))\n const scene = await sceneFuture\n\n // effects\n var glow = new GlowLayer('glow', scene, {\n mainTextureFixedSize: 1024,\n blurKernelSize: 64,\n })\n glow.intensity = 1\n\n // Setup Camera\n var camera = new ArcRotateCamera('camera', 0, 0, 0, new Vector3(0, 0, 0), scene)\n camera.mode = Camera.PERSPECTIVE_CAMERA\n camera.position = new Vector3(-2, 2, 2)\n camera.useAutoRotationBehavior = true\n camera.autoRotationBehavior!.idleRotationSpeed = 0.2\n camera.setTarget(Vector3.Zero())\n camera.lowerRadiusLimit = camera.upperRadiusLimit = camera.radius / getZoom(options.category)\n camera.attachControl(canvas, true)\n\n // Setup lights\n var directional = new DirectionalLight('directional', new Vector3(0, 0, 1), scene)\n directional.intensity = 1\n var top = new HemisphericLight('top', new Vector3(0, -1, 0), scene)\n top.intensity = 1\n var bottom = new HemisphericLight('bottom', new Vector3(0, 1, 0), scene)\n bottom.intensity = 1\n var spot = new SpotLight('spot', new Vector3(-2, 2, 2), new Vector3(2, -2, -2), Math.PI / 2, 1000, scene)\n spot.intensity = 1\n\n // Setup parent\n var parent = new Mesh('parent', scene)\n for (const mesh of scene.meshes) {\n if (mesh !== parent) {\n mesh.setParent(parent)\n }\n }\n\n // Clean up\n for (let material of scene.materials) {\n if (material.name.toLowerCase().includes('hair_mat')) {\n if (options.hair) {\n const pbr = material as PBRMaterial\n pbr.albedoColor = Color3.FromHexString(options.hair)\n } else {\n material.alpha = 0\n scene.removeMaterial(material)\n }\n }\n if (material.name.toLowerCase().includes('avatarskin_mat')) {\n if (options.skin) {\n const pbr = material as PBRMaterial\n pbr.albedoColor = Color3.FromHexString(options.skin)\n } else {\n material.alpha = 0\n scene.removeMaterial(material)\n }\n }\n }\n\n // resize and center\n refreshBoundingInfo(parent)\n const bounds = parent.getBoundingInfo().boundingBox.extendSize\n const size = bounds.length()\n const scale = new Vector3(1 / size, 1 / size, 1 / size)\n parent.scaling = scale\n const center = parent.getBoundingInfo().boundingBox.center.multiply(scale)\n parent.position.subtractInPlace(center)\n\n // render loop\n engine.runRenderLoop(() => scene.render())\n}\n","import { WearableBodyShape } from '@dcl/schemas'\nimport { WearableRepresentation } from './api/peer'\n\nexport function is(representation: WearableRepresentation, bodyShape: WearableBodyShape) {\n return representation.bodyShapes.includes(bodyShape)\n}\n\nexport function isMale(representation: WearableRepresentation) {\n return is(representation, WearableBodyShape.MALE)\n}\n\nexport function isFemale(representation: WearableRepresentation) {\n return is(representation, WearableBodyShape.FEMALE)\n}\n","export enum Env {\n PROD = 'prod',\n DEV = 'dev',\n}\n","export async function json<T>(url: string) {\n const resp = await fetch(url)\n if (!resp.ok) {\n throw new Error(await resp.text())\n }\n return resp.json() as Promise<T>\n}\n","import { Item, NFT } from '@dcl/schemas'\nimport { Env } from '../../types/env'\nimport { json } from '../json'\n\nexport const nftApiByEnv: Record<Env, string> = {\n [Env.DEV]: 'https://nft-api.decentraland.io',\n [Env.PROD]: 'https://nft-api.decentraland.org',\n}\n\nclass NFTApi {\n async fetchItem(contractAddress: string, itemId: string, env: Env) {\n const { data } = await json<{ data: Item[] }>(`${nftApiByEnv[env]}/v1/items?contractAddress=${contractAddress}&itemId=${itemId}`)\n if (data.length === 0) {\n throw new Error(`Item not found for contractAddress=\"${contractAddress}\" itemId=\"${itemId}\"`)\n }\n return data[0]\n }\n async fetchNFT(contractAddress: string, tokenId: string, env: Env) {\n const { data } = await json<{ data: { nft: NFT }[] }>(\n `${nftApiByEnv[env]}/v1/nfts?contractAddress=${contractAddress}&tokenId=${tokenId}`\n )\n if (data.length === 0) {\n throw new Error(`NFT not found for contractAddress=\"${contractAddress}\" tokenId=\"${tokenId}\"`)\n }\n return data[0].nft\n }\n}\n\nexport const nftApi = new NFTApi()\n","export enum MessageType {\n LOAD = 'load',\n ERROR = 'error',\n}\n\nexport function sendMessage(type: MessageType, message?: string) {\n const event = JSON.stringify({ type, message })\n window.parent && window.parent.postMessage(event, '*')\n}\n","import { Wearable as WearableBroken, WearableRepresentation as WearableRepresentationBroken } from '@dcl/schemas'\nimport { Env } from '../../types/env'\nimport { json } from '../json'\n\nexport const peerByEnv: Record<Env, string> = {\n [Env.DEV]: 'https://peer.decentraland.zone',\n [Env.PROD]: 'https://peer-lb.decentraland.org',\n}\n\nexport type Wearable = Omit<WearableBroken, 'data'> & {\n data: Omit<WearableBroken['data'], 'representations'> & {\n representations: WearableRepresentation[]\n }\n}\n\nexport type WearableRepresentation = Omit<WearableRepresentationBroken, 'contents'> & { contents: { key: string; url: string }[] }\n\nclass PeerApi {\n async fetchWearable(urn: string, env: Env) {\n const { wearables } = await json<{ wearables: Wearable[] }>(`${peerByEnv[env]}/lambdas/collections/wearables?wearableId=${urn}`)\n if (wearables.length === 0) {\n throw new Error(`Wearable not found for urn=\"${urn}\"`)\n }\n return wearables[0]\n }\n}\n\nexport const peerApi = new PeerApi()\n","import { Network } from '@dcl/schemas'\nimport { nftApi } from '../lib/api/nft'\nimport { peerApi } from '../lib/api/peer'\nimport { Env } from '../types/env'\nimport { useFetch } from './useFetch'\n\nexport function useWearable(options: { contractAddress: string; itemId?: string | null; tokenId?: string | null; env: Env }) {\n let { contractAddress, itemId, tokenId, env } = options\n const [wearable, isWearableLoading, wearableError] = useFetch(async () => {\n if (!contractAddress) {\n throw new Error('You must provide a valid contract address')\n }\n const network = env === Env.PROD ? 'matic' : 'mumbai'\n let urn = `urn:decentraland:${network}:collections-v2:${contractAddress}:${itemId}`\n if (!itemId && !tokenId) {\n throw new Error(`You must provide either tokenId or itemId`)\n } else if (!itemId && tokenId) {\n const nft = await nftApi.fetchNFT(contractAddress, tokenId, env)\n urn =\n nft.network !== Network.ETHEREUM\n ? `urn:decentraland:${network}:collections-v2:${contractAddress}:${nft.itemId}`\n : nft.image.split('contents/')[1].split('/thumbnail')[0] // since the Ethereum collections have a different URN, we extract it from the image path\n }\n return peerApi.fetchWearable(urn, env)\n })\n\n return [wearable, isWearableLoading, wearableError] as const\n}\n","import { useEffect, useState } from 'react'\n\nexport function useFetch<T>(fetcher: () => Promise<T>) {\n const [isLoading, setIsLoading] = useState(false)\n const [result, setResult] = useState<T | null>(null)\n const [error, setError] = useState('')\n useEffect(() => {\n setIsLoading(true)\n fetcher()\n .then((result) => setResult(result))\n .catch((error) => setError(error.message))\n .finally(() => setIsLoading(false))\n }, [])\n return [result, isLoading, error] as const\n}\n","import React, { useEffect, useRef, useState } from 'react'\nimport { Rarity } from '@dcl/schemas'\nimport classNames from 'classnames'\nimport { loadWearable } from '../../lib/babylon'\nimport { isFemale } from '../../lib/representation'\nimport { useWearable } from '../../hooks/useWearable'\nimport { useWindowSize } from '../../hooks/useWindowSize'\nimport { MessageType, sendMessage } from '../../lib/message'\nimport { Env } from '../../types/env'\nimport './Preview.css'\n\nconst Preview: React.FC = () => {\n const [previewError, setPreviewError] = useState('')\n const { width, height } = useWindowSize()\n const [style, setStyle] = useState<React.CSSProperties>({})\n const [isDragging, setIsDragging] = useState(false)\n const [isLoadingModel, setIsLoadingModel] = useState(true)\n const [isLoaded, setIsLoaded] = useState(false)\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const params = new URLSearchParams(window.location.search)\n const contractAddress = params.get('contract')!\n const tokenId = params.get('token')\n const itemId = params.get('item')\n const skin = params.get('skin')\n const hair = params.get('hair')\n const shape = params.get('shape')\n const env = Object.values(Env).reduce((selected, value) => (value === params.get('env') ? value : selected), Env.PROD)\n const [wearable, isLoadingWearable, wearableError] = useWearable({ contractAddress, tokenId, itemId, env })\n const [image, setImage] = useState('')\n const [is3D, setIs3D] = useState(true)\n const [isMessageSent, setIsMessageSent] = useState(false)\n\n const error = previewError || wearableError\n const isLoading = (isLoadingModel || isLoadingWearable) && !error\n const showImage = !!image && !is3D && !isLoading\n const showCanvas = is3D && !isLoading\n\n useEffect(() => {\n if (canvasRef.current && wearable) {\n // rarity background\n const [light, dark] = Rarity.getGradient(wearable.rarity)\n const backgroundImage = `radial-gradient(${light}, ${dark})`\n setStyle({ backgroundImage, opacity: 1 })\n\n // set background image\n setImage(wearable.thumbnail)\n\n // load model or image (for texture only wearables)\n let representation = wearable.data.representations[0]\n if (shape === 'female' && wearable.data.representations.some(isFemale)) {\n representation = wearable.data.representations.find(isFemale)!\n }\n if (representation.mainFile.endsWith('png')) {\n setIs3D(false)\n setIsLoadingModel(false)\n setIsLoaded(true)\n } else {\n // load model\n const content = representation.contents.find((content) => content.key === representation.mainFile)\n const mappings = representation.contents.reduce((obj, file) => {\n obj[file.key] = file.url\n return obj\n }, {} as Record<string, string>)\n if (content) {\n loadWearable(canvasRef.current, content.url, mappings, {\n category: wearable.data.category,\n skin: skin ? '#' + skin : undefined,\n hair: hair ? '#' + hair : undefined,\n })\n .catch((error) => setPreviewError(error.message))\n .finally(() => {\n setIsLoadingModel(false)\n setIsLoaded(true)\n })\n } else {\n console.warn('Content not found for wearable', wearable)\n setPreviewError('Content not found')\n }\n }\n }\n }, [canvasRef.current, wearable])\n\n // send a mesasge to the parent window when loaded or error occurs\n useEffect(() => {\n if (!isMessageSent) {\n if (isLoaded) {\n sendMessage(MessageType.LOAD)\n setIsMessageSent(true)\n } else if (error) {\n sendMessage(MessageType.ERROR, error)\n setIsMessageSent(true)\n }\n }\n }, [isLoaded, error, isMessageSent])\n\n return (\n <div\n className={classNames('Preview', {\n 'is-dragging': isDragging,\n 'is-loading': isLoading,\n 'is-loaded': isLoaded,\n 'is-3d': is3D,\n 'has-error': !!error,\n })}\n style={style}\n >\n <img\n src={image}\n className={classNames('thumbnail', {\n 'is-visible': showImage,\n })}\n alt=\"preview\"\n />\n <canvas\n id=\"wearable-preview\"\n className={classNames({\n 'is-visible': showCanvas,\n })}\n width={width}\n height={height}\n ref={canvasRef}\n onMouseDown={() => setIsDragging(is3D && !error)}\n onMouseUp={() => setIsDragging(false)}\n ></canvas>\n {error && <div className=\"error\">{error}</div>}\n </div>\n )\n}\n\nexport default React.memo(Preview)\n","import { useState, useEffect } from 'react'\n\n// Define general type for useWindowSize hook, which includes width and height\ninterface Size {\n width: number | undefined\n height: number | undefined\n}\n\nexport function useWindowSize(): Size {\n // Initialize state with undefined width/height so server and client renders match\n // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/\n const [windowSize, setWindowSize] = useState<Size>({\n width: undefined,\n height: undefined,\n })\n useEffect(() => {\n // Handler to call on window resize\n function handleResize() {\n // Set window width/height to state\n setWindowSize({\n width: window.innerWidth,\n height: window.innerHeight,\n })\n }\n // Add event listener\n window.addEventListener('resize', handleResize)\n // Call handler right away so state gets updated with initial window size\n handleResize()\n // Remove event listener on cleanup\n return () => window.removeEventListener('resize', handleResize)\n }, []) // Empty array ensures that effect is only run on mount\n return windowSize\n}\n","import React from 'react'\nimport ReactDOM from 'react-dom'\nimport './index.css'\nimport { Preview } from './components/Preview'\n\nReactDOM.render(\n <React.StrictMode>\n <Preview />\n </React.StrictMode>,\n document.getElementById('root')\n)\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["lib/babylon.ts","lib/representation.ts","types/env.ts","lib/json.ts","lib/api/nft.ts","lib/message.ts","lib/api/peer.ts","hooks/useWearable.ts","hooks/useFetch.ts","components/Preview/Preview.tsx","hooks/useWindowSize.ts","index.tsx"],"names":["refreshBoundingInfo","parent","children","getChildren","filter","mesh","id","length","child","boundingInfo","getBoundingInfo","min","boundingBox","minimumWorld","add","position","max","maximumWorld","i","siblingMin","siblingMax","Vector3","Minimize","Maximize","setBoundingInfo","BoundingInfo","getZoom","category","WearableCategory","UPPER_BODY","SKIN","canvas","url","mappings","options","a","engine","Engine","preserveDrawingBuffer","stencil","root","Scene","autoClear","clearColor","Color4","preventDefaultOnPointerDown","SceneLoader","OnPluginActivatedObservable","addOnce","plugin","name","preprocessUrlAsync","parts","split","sceneFuture","future","loadScene","extension","AppendAsync","getLoader","onReadyObservable","scene","resolve","GlowLayer","mainTextureFixedSize","blurKernelSize","intensity","camera","ArcRotateCamera","mode","Camera","PERSPECTIVE_CAMERA","useAutoRotationBehavior","autoRotationBehavior","idleRotationSpeed","setTarget","Zero","lowerRadiusLimit","upperRadiusLimit","radius","attachControl","DirectionalLight","HemisphericLight","SpotLight","Math","PI","Mesh","meshes","setParent","materials","material","toLowerCase","includes","hair","albedoColor","Color3","FromHexString","alpha","removeMaterial","skin","bounds","extendSize","size","scale","scaling","center","multiply","subtractInPlace","runRenderLoop","render","is","representation","bodyShape","bodyShapes","isFemale","WearableBodyShape","FEMALE","Env","json","fetch","resp","ok","Error","text","MessageType","nftApiByEnv","DEV","PROD","NFTApi","contractAddress","itemId","env","data","tokenId","nft","nftApi","peerByEnv","PeerApi","urn","wearables","peerApi","useWearable","fetcher","useState","isLoading","setIsLoading","result","setResult","error","setError","useEffect","then","catch","message","finally","useFetch","network","fetchNFT","Network","ETHEREUM","image","fetchWearable","sendMessage","type","event","JSON","stringify","window","postMessage","Preview","previewError","setPreviewError","width","undefined","height","windowSize","setWindowSize","handleResize","innerWidth","innerHeight","addEventListener","removeEventListener","useWindowSize","style","setStyle","isDragging","setIsDragging","isLoadingModel","setIsLoadingModel","isLoaded","setIsLoaded","canvasRef","useRef","params","URLSearchParams","location","search","get","shape","Object","values","reduce","selected","value","wearable","isLoadingWearable","wearableError","setImage","is3D","setIs3D","isMessageSent","setIsMessageSent","showImage","showCanvas","current","Rarity","getGradient","rarity","light","dark","backgroundImage","opacity","thumbnail","representations","some","find","mainFile","endsWith","content","contents","key","obj","file","loadWearable","console","warn","LOAD","ERROR","className","classNames","src","alt","ref","onMouseDown","onMouseUp","React","memo","ReactDOM","StrictMode","document","getElementById"],"mappings":"gVAsBA,SAASA,EAAoBC,GAC3B,IAAMC,EAAWD,EAAOE,cAAcC,QAAO,SAACC,GAAD,MAAsB,aAAZA,EAAKC,MAC5D,GAAIJ,EAASK,OAAS,EAAG,CAQvB,IAPA,IAAMC,EAAQN,EAAS,GAEnBO,EAAeD,EAAME,kBAErBC,EAAMF,EAAaG,YAAYC,aAAaC,IAAIN,EAAMO,UACtDC,EAAMP,EAAaG,YAAYK,aAAaH,IAAIN,EAAMO,UAEjDG,EAAI,EAAGA,EAAIhB,EAASK,OAAQW,IAAK,CACxC,IAAMV,EAAQN,EAASgB,GAGjBC,GADNV,EAAeD,EAAME,mBACWE,YAAYC,aAAaC,IAAIN,EAAMO,UAC7DK,EAAaX,EAAaG,YAAYK,aAAaH,IAAIN,EAAMO,UAEnEJ,EAAMU,IAAQC,SAASX,EAAKQ,GAC5BH,EAAMK,IAAQE,SAASP,EAAKI,GAG9BnB,EAAOuB,gBAAgB,IAAIC,IAAad,EAAKK,KAIjD,SAASU,EAAQC,GACf,OAAQA,GACN,KAAKC,mBAAiBC,WACpB,OAAO,EACT,KAAKD,mBAAiBE,KACpB,OAAO,KACT,QACE,OAAO,M,4CAIN,WACLC,EAC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F3B,EAAYtC,EAAYgH,MACxBzB,IAAiB,IACR/D,KACTc,EAAYtC,EAAYiH,MAAOzF,IAC/B+D,IAAiB,OAGpB,CAACtB,EAAUzC,GAAO8D,KAGnB,sBACE4B,UAAWC,IAAW,UAAW,CAC/B,cAAetD,EACf,aAAczC,GACd,YAAa6C,EACb,QAASmB,EACT,cAAe5D,KAEjBmC,MAAOA,EART,UAUE,qBACEyD,IAAKhF,EACL8E,UAAWC,IAAW,YAAa,CACjC,aAAc3B,KAEhB6B,IAAI,YAEN,wBACE3O,GAAG,mBACHwO,UAAWC,IAAW,CACpB,aAAc1B,KAEhBzC,MAAOA,EACPE,OAAQA,EACRoE,IAAKnD,EACLoD,YAAa,kBAAMzD,EAAcsB,IAAS5D,KAC1CgG,UAAW,kBAAM1D,GAAc,MAEhCtC,IAAS,qBAAK0F,UAAU,QAAf,SAAwB1F,SAKzBiG,MAAMC,KAAK7E,GE5H1B8E,IAAS1I,OACP,cAAC,IAAM2I,WAAP,UACE,cAAC,EAAD,MAEFC,SAASC,eAAe,W","file":"static/js/main.8f1b76b4.chunk.js","sourcesContent":["import {\n ArcRotateCamera,\n BoundingInfo,\n Camera,\n Color3,\n Color4,\n DirectionalLight,\n Engine,\n GlowLayer,\n HemisphericLight,\n Mesh,\n PBRMaterial,\n Scene,\n SceneLoader,\n SpotLight,\n Vector3,\n} from '@babylonjs/core'\nimport '@babylonjs/loaders'\nimport { GLTFFileLoader } from '@babylonjs/loaders'\nimport { WearableCategory } from '@dcl/schemas'\nimport future from 'fp-future'\n\nfunction refreshBoundingInfo(parent: Mesh) {\n const children = parent.getChildren().filter((mesh) => mesh.id !== '__root__')\n if (children.length > 0) {\n const child = children[0] as Mesh\n // child.showBoundingBox = true\n let boundingInfo = child.getBoundingInfo()\n\n let min = boundingInfo.boundingBox.minimumWorld.add(child.position)\n let max = boundingInfo.boundingBox.maximumWorld.add(child.position)\n\n for (let i = 1; i < children.length; i++) {\n const child = children[i] as Mesh\n // child.showBoundingBox = true\n boundingInfo = child.getBoundingInfo()\n const siblingMin = boundingInfo.boundingBox.minimumWorld.add(child.position)\n const siblingMax = boundingInfo.boundingBox.maximumWorld.add(child.position)\n\n min = Vector3.Minimize(min, siblingMin)\n max = Vector3.Maximize(max, siblingMax)\n }\n\n parent.setBoundingInfo(new BoundingInfo(min, max))\n }\n}\n\nfunction getZoom(category: WearableCategory) {\n switch (category) {\n case WearableCategory.UPPER_BODY:\n return 2\n case WearableCategory.SKIN:\n return 1.75\n default:\n return 1.25\n }\n}\n\nexport async function loadWearable(\n canvas: HTMLCanvasElement,\n url: string,\n mappings: Record<string, string>,\n options: { category: WearableCategory; skin?: string; hair?: string }\n) {\n // Create engine\n const engine = new Engine(canvas, true, {\n preserveDrawingBuffer: true,\n stencil: true,\n })\n\n // Load GLB/GLTF\n const root = new Scene(engine)\n root.autoClear = true\n root.clearColor = new Color4(0, 0, 0, 0)\n root.preventDefaultOnPointerDown = false\n SceneLoader.OnPluginActivatedObservable.addOnce((plugin) => {\n if (plugin.name === 'gltf') {\n const gltf = plugin as GLTFFileLoader\n gltf.preprocessUrlAsync = async (url: string) => {\n const baseUrl = `/content/contents/`\n const parts = url.split(baseUrl)\n return parts.length > 0 && !!parts[1] ? mappings[parts[1]] : url\n }\n }\n })\n const sceneFuture = future<Scene>()\n const loadScene = async (extension: string) => SceneLoader.AppendAsync(url, '', root, null, extension)\n const getLoader = async () => {\n // try with GLB, if it fails try with GLTF\n try {\n return await loadScene('.glb')\n } catch (error) {\n return await loadScene('.gltf')\n }\n }\n const loader = await getLoader()\n loader.onReadyObservable.addOnce((scene) => sceneFuture.resolve(scene))\n const scene = await sceneFuture\n\n // effects\n var glow = new GlowLayer('glow', scene, {\n mainTextureFixedSize: 1024,\n blurKernelSize: 64,\n })\n glow.intensity = 1\n\n // Setup Camera\n var camera = new ArcRotateCamera('camera', 0, 0, 0, new Vector3(0, 0, 0), scene)\n camera.mode = Camera.PERSPECTIVE_CAMERA\n camera.position = new Vector3(-2, 2, 2)\n camera.useAutoRotationBehavior = true\n camera.autoRotationBehavior!.idleRotationSpeed = 0.2\n camera.setTarget(Vector3.Zero())\n camera.lowerRadiusLimit = camera.upperRadiusLimit = camera.radius / getZoom(options.category)\n camera.attachControl(canvas, true)\n\n // Setup lights\n var directional = new DirectionalLight('directional', new Vector3(0, 0, 1), scene)\n directional.intensity = 1\n var top = new HemisphericLight('top', new Vector3(0, -1, 0), scene)\n top.intensity = 1\n var bottom = new HemisphericLight('bottom', new Vector3(0, 1, 0), scene)\n bottom.intensity = 1\n var spot = new SpotLight('spot', new Vector3(-2, 2, 2), new Vector3(2, -2, -2), Math.PI / 2, 1000, scene)\n spot.intensity = 1\n\n // Setup parent\n var parent = new Mesh('parent', scene)\n for (const mesh of scene.meshes) {\n if (mesh !== parent) {\n mesh.setParent(parent)\n }\n }\n\n // Clean up\n for (let material of scene.materials) {\n if (material.name.toLowerCase().includes('hair_mat')) {\n if (options.hair) {\n const pbr = material as PBRMaterial\n pbr.albedoColor = Color3.FromHexString(options.hair)\n } else {\n material.alpha = 0\n scene.removeMaterial(material)\n }\n }\n if (material.name.toLowerCase().includes('avatarskin_mat')) {\n if (options.skin) {\n const pbr = material as PBRMaterial\n pbr.albedoColor = Color3.FromHexString(options.skin)\n } else {\n material.alpha = 0\n scene.removeMaterial(material)\n }\n }\n }\n\n // resize and center\n refreshBoundingInfo(parent)\n const bounds = parent.getBoundingInfo().boundingBox.extendSize\n const size = bounds.length()\n const scale = new Vector3(1 / size, 1 / size, 1 / size)\n parent.scaling = scale\n const center = parent.getBoundingInfo().boundingBox.center.multiply(scale)\n parent.position.subtractInPlace(center)\n\n // render loop\n engine.runRenderLoop(() => scene.render())\n}\n","import { WearableBodyShape } from '@dcl/schemas'\nimport { WearableRepresentation } from './api/peer'\n\nexport function is(representation: WearableRepresentation, bodyShape: WearableBodyShape) {\n return representation.bodyShapes.includes(bodyShape)\n}\n\nexport function isMale(representation: WearableRepresentation) {\n return is(representation, WearableBodyShape.MALE)\n}\n\nexport function isFemale(representation: WearableRepresentation) {\n return is(representation, WearableBodyShape.FEMALE)\n}\n","export enum Env {\n PROD = 'prod',\n DEV = 'dev',\n}\n","export async function json<T>(url: string) {\n const resp = await fetch(url)\n if (!resp.ok) {\n throw new Error(await resp.text())\n }\n return resp.json() as Promise<T>\n}\n","import { Item, NFT } from '@dcl/schemas'\nimport { Env } from '../../types/env'\nimport { json } from '../json'\n\nexport const nftApiByEnv: Record<Env, string> = {\n [Env.DEV]: 'https://nft-api.decentraland.io',\n [Env.PROD]: 'https://nft-api.decentraland.org',\n}\n\nclass NFTApi {\n async fetchItem(contractAddress: string, itemId: string, env: Env) {\n const { data } = await json<{ data: Item[] }>(`${nftApiByEnv[env]}/v1/items?contractAddress=${contractAddress}&itemId=${itemId}`)\n if (data.length === 0) {\n throw new Error(`Item not found for contractAddress=\"${contractAddress}\" itemId=\"${itemId}\"`)\n }\n return data[0]\n }\n async fetchNFT(contractAddress: string, tokenId: string, env: Env) {\n const { data } = await json<{ data: { nft: NFT }[] }>(\n `${nftApiByEnv[env]}/v1/nfts?contractAddress=${contractAddress}&tokenId=${tokenId}`\n )\n if (data.length === 0) {\n throw new Error(`NFT not found for contractAddress=\"${contractAddress}\" tokenId=\"${tokenId}\"`)\n }\n return data[0].nft\n }\n}\n\nexport const nftApi = new NFTApi()\n","export enum MessageType {\n LOAD = 'load',\n ERROR = 'error',\n}\n\nexport function sendMessage(type: MessageType, message?: string) {\n const event = JSON.stringify({ type, message })\n window.parent && window.parent.postMessage(event, '*')\n}\n","import { Wearable as WearableBroken, WearableRepresentation as WearableRepresentationBroken } from '@dcl/schemas'\nimport { Env } from '../../types/env'\nimport { json } from '../json'\n\nexport const peerByEnv: Record<Env, string> = {\n [Env.DEV]: 'https://peer.decentraland.zone',\n [Env.PROD]: 'https://peer.decentraland.org',\n}\n\nexport type Wearable = Omit<WearableBroken, 'data'> & {\n data: Omit<WearableBroken['data'], 'representations'> & {\n representations: WearableRepresentation[]\n }\n}\n\nexport type WearableRepresentation = Omit<WearableRepresentationBroken, 'contents'> & { contents: { key: string; url: string }[] }\n\nclass PeerApi {\n async fetchWearable(urn: string, env: Env) {\n const { wearables } = await json<{ wearables: Wearable[] }>(`${peerByEnv[env]}/lambdas/collections/wearables?wearableId=${urn}`)\n if (wearables.length === 0) {\n throw new Error(`Wearable not found for urn=\"${urn}\"`)\n }\n return wearables[0]\n }\n}\n\nexport const peerApi = new PeerApi()\n","import { Network } from '@dcl/schemas'\nimport { nftApi } from '../lib/api/nft'\nimport { peerApi } from '../lib/api/peer'\nimport { Env } from '../types/env'\nimport { useFetch } from './useFetch'\n\nexport function useWearable(options: { contractAddress: string; itemId?: string | null; tokenId?: string | null; env: Env }) {\n let { contractAddress, itemId, tokenId, env } = options\n const [wearable, isWearableLoading, wearableError] = useFetch(async () => {\n if (!contractAddress) {\n throw new Error('You must provide a valid contract address')\n }\n const network = env === Env.PROD ? 'matic' : 'mumbai'\n let urn = `urn:decentraland:${network}:collections-v2:${contractAddress}:${itemId}`\n if (!itemId && !tokenId) {\n throw new Error(`You must provide either tokenId or itemId`)\n } else if (!itemId && tokenId) {\n const nft = await nftApi.fetchNFT(contractAddress, tokenId, env)\n urn =\n nft.network !== Network.ETHEREUM\n ? `urn:decentraland:${network}:collections-v2:${contractAddress}:${nft.itemId}`\n : nft.image.split('contents/')[1].split('/thumbnail')[0] // since the Ethereum collections have a different URN, we extract it from the image path\n }\n return peerApi.fetchWearable(urn, env)\n })\n\n return [wearable, isWearableLoading, wearableError] as const\n}\n","import { useEffect, useState } from 'react'\n\nexport function useFetch<T>(fetcher: () => Promise<T>) {\n const [isLoading, setIsLoading] = useState(false)\n const [result, setResult] = useState<T | null>(null)\n const [error, setError] = useState('')\n useEffect(() => {\n setIsLoading(true)\n fetcher()\n .then((result) => setResult(result))\n .catch((error) => setError(error.message))\n .finally(() => setIsLoading(false))\n }, [])\n return [result, isLoading, error] as const\n}\n","import React, { useEffect, useRef, useState } from 'react'\nimport { Rarity } from '@dcl/schemas'\nimport classNames from 'classnames'\nimport { loadWearable } from '../../lib/babylon'\nimport { isFemale } from '../../lib/representation'\nimport { useWearable } from '../../hooks/useWearable'\nimport { useWindowSize } from '../../hooks/useWindowSize'\nimport { MessageType, sendMessage } from '../../lib/message'\nimport { Env } from '../../types/env'\nimport './Preview.css'\n\nconst Preview: React.FC = () => {\n const [previewError, setPreviewError] = useState('')\n const { width, height } = useWindowSize()\n const [style, setStyle] = useState<React.CSSProperties>({})\n const [isDragging, setIsDragging] = useState(false)\n const [isLoadingModel, setIsLoadingModel] = useState(true)\n const [isLoaded, setIsLoaded] = useState(false)\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const params = new URLSearchParams(window.location.search)\n const contractAddress = params.get('contract')!\n const tokenId = params.get('token')\n const itemId = params.get('item')\n const skin = params.get('skin')\n const hair = params.get('hair')\n const shape = params.get('shape')\n const env = Object.values(Env).reduce((selected, value) => (value === params.get('env') ? value : selected), Env.PROD)\n const [wearable, isLoadingWearable, wearableError] = useWearable({ contractAddress, tokenId, itemId, env })\n const [image, setImage] = useState('')\n const [is3D, setIs3D] = useState(true)\n const [isMessageSent, setIsMessageSent] = useState(false)\n\n const error = previewError || wearableError\n const isLoading = (isLoadingModel || isLoadingWearable) && !error\n const showImage = !!image && !is3D && !isLoading\n const showCanvas = is3D && !isLoading\n\n useEffect(() => {\n if (canvasRef.current && wearable) {\n // rarity background\n const [light, dark] = Rarity.getGradient(wearable.rarity)\n const backgroundImage = `radial-gradient(${light}, ${dark})`\n setStyle({ backgroundImage, opacity: 1 })\n\n // set background image\n setImage(wearable.thumbnail)\n\n // load model or image (for texture only wearables)\n let representation = wearable.data.representations[0]\n if (shape === 'female' && wearable.data.representations.some(isFemale)) {\n representation = wearable.data.representations.find(isFemale)!\n }\n if (representation.mainFile.endsWith('png')) {\n setIs3D(false)\n setIsLoadingModel(false)\n setIsLoaded(true)\n } else {\n // load model\n const content = representation.contents.find((content) => content.key === representation.mainFile)\n const mappings = representation.contents.reduce((obj, file) => {\n obj[file.key] = file.url\n return obj\n }, {} as Record<string, string>)\n if (content) {\n loadWearable(canvasRef.current, content.url, mappings, {\n category: wearable.data.category,\n skin: skin ? '#' + skin : undefined,\n hair: hair ? '#' + hair : undefined,\n })\n .catch((error) => setPreviewError(error.message))\n .finally(() => {\n setIsLoadingModel(false)\n setIsLoaded(true)\n })\n } else {\n console.warn('Content not found for wearable', wearable)\n setPreviewError('Content not found')\n }\n }\n }\n }, [canvasRef.current, wearable])\n\n // send a mesasge to the parent window when loaded or error occurs\n useEffect(() => {\n if (!isMessageSent) {\n if (isLoaded) {\n sendMessage(MessageType.LOAD)\n setIsMessageSent(true)\n } else if (error) {\n sendMessage(MessageType.ERROR, error)\n setIsMessageSent(true)\n }\n }\n }, [isLoaded, error, isMessageSent])\n\n return (\n <div\n className={classNames('Preview', {\n 'is-dragging': isDragging,\n 'is-loading': isLoading,\n 'is-loaded': isLoaded,\n 'is-3d': is3D,\n 'has-error': !!error,\n })}\n style={style}\n >\n <img\n src={image}\n className={classNames('thumbnail', {\n 'is-visible': showImage,\n })}\n alt=\"preview\"\n />\n <canvas\n id=\"wearable-preview\"\n className={classNames({\n 'is-visible': showCanvas,\n })}\n width={width}\n height={height}\n ref={canvasRef}\n onMouseDown={() => setIsDragging(is3D && !error)}\n onMouseUp={() => setIsDragging(false)}\n ></canvas>\n {error && <div className=\"error\">{error}</div>}\n </div>\n )\n}\n\nexport default React.memo(Preview)\n","import { useState, useEffect } from 'react'\n\n// Define general type for useWindowSize hook, which includes width and height\ninterface Size {\n width: number | undefined\n height: number | undefined\n}\n\nexport function useWindowSize(): Size {\n // Initialize state with undefined width/height so server and client renders match\n // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/\n const [windowSize, setWindowSize] = useState<Size>({\n width: undefined,\n height: undefined,\n })\n useEffect(() => {\n // Handler to call on window resize\n function handleResize() {\n // Set window width/height to state\n setWindowSize({\n width: window.innerWidth,\n height: window.innerHeight,\n })\n }\n // Add event listener\n window.addEventListener('resize', handleResize)\n // Call handler right away so state gets updated with initial window size\n handleResize()\n // Remove event listener on cleanup\n return () => window.removeEventListener('resize', handleResize)\n }, []) // Empty array ensures that effect is only run on mount\n return windowSize\n}\n","import React from 'react'\nimport ReactDOM from 'react-dom'\nimport './index.css'\nimport { Preview } from './components/Preview'\n\nReactDOM.render(\n <React.StrictMode>\n <Preview />\n </React.StrictMode>,\n document.getElementById('root')\n)\n"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !function(e){function r(r){for(var n,u,a=r[0],i=r[1],c=r[2],f=0,s=[];f<a.length;f++)u=a[f],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&s.push(o[u][0]),o[u]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return l.push.apply(l,c||[]),t()}function t(){for(var e,r=0;r<l.length;r++){for(var t=l[r],n=!0,a=1;a<t.length;a++){var i=t[a];0!==o[i]&&(n=!1)}n&&(l.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},l=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/";var a=this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[],i=a.push.bind(a);a.push=r,a=a.slice();for(var c=0;c<a.length;c++)r(a[c]);var p=i;t()}([]);
2
- //# sourceMappingURL=runtime-main.0e53727d.js.map
1
+ !function(e){function r(r){for(var n,u,a=r[0],i=r[1],c=r[2],f=0,d=[];f<a.length;f++)u=a[f],Object.prototype.hasOwnProperty.call(o,u)&&o[u]&&d.push(o[u][0]),o[u]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);d.length;)d.shift()();return l.push.apply(l,c||[]),t()}function t(){for(var e,r=0;r<l.length;r++){for(var t=l[r],n=!0,a=1;a<t.length;a++){var i=t[a];0!==o[i]&&(n=!1)}n&&(l.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={1:0},l=[];function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/";var a=this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[],i=a.push.bind(a);a.push=r,a=a.slice();for(var c=0;c<a.length;c++)r(a[c]);var p=i;t()}([]);
2
+ //# sourceMappingURL=runtime-main.4dc54380.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../webpack/bootstrap"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","this","oldJsonpFunction","slice"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAiBL,EAAK,GAIHM,EAAI,EAAGC,EAAW,GACpCD,EAAIH,EAASK,OAAQF,IACzBJ,EAAUC,EAASG,GAChBG,OAAOC,UAAUC,eAAeC,KAAKC,EAAiBX,IAAYW,EAAgBX,IACpFK,EAASO,KAAKD,EAAgBX,GAAS,IAExCW,EAAgBX,GAAW,EAE5B,IAAID,KAAYG,EACZK,OAAOC,UAAUC,eAAeC,KAAKR,EAAaH,KACpDc,EAAQd,GAAYG,EAAYH,IAKlC,IAFGe,GAAqBA,EAAoBhB,GAEtCO,EAASC,QACdD,EAASU,OAATV,GAOD,OAHAW,EAAgBJ,KAAKK,MAAMD,EAAiBb,GAAkB,IAGvDe,IAER,SAASA,IAER,IADA,IAAIC,EACIf,EAAI,EAAGA,EAAIY,EAAgBV,OAAQF,IAAK,CAG/C,IAFA,IAAIgB,EAAiBJ,EAAgBZ,GACjCiB,GAAY,EACRC,EAAI,EAAGA,EAAIF,EAAed,OAAQgB,IAAK,CAC9C,IAAIC,EA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AO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRtB,EAAoB0B,EAAI,SAAStB,GAChC,IAAIM,EAASN,GAAUA,EAAOiB,WAC7B,WAAwB,OAAOjB,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAJ,EAAoBQ,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRV,EAAoBW,EAAI,SAASgB,EAAQC,GAAY,OAAO9C,OAAOC,UAAUC,eAAeC,KAAK0C,EAAQC,IAGzG5B,EAAoB6B,EAAI,sFAExB,IAAIC,EAAaC,KAAK,qCAAuCA,KAAK,sCAAwC,GACtGC,EAAmBF,EAAW3C,KAAKsC,KAAKK,GAC5CA,EAAW3C,KAAOf,EAClB0D,EAAaA,EAAWG,QACxB,IAAI,IAAItD,EAAI,EAAGA,EAAImD,EAAWjD,OAAQF,IAAKP,EAAqB0D,EAAWnD,IAC3E,IAAIU,EAAsB2C,EAI1BvC,I","file":"static/js/runtime-main.0e53727d.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1785859770.commit-569e873/\";\n\n \tvar jsonpArray = this[\"webpackJsonp@dcl/wearable-preview\"] = this[\"webpackJsonp@dcl/wearable-preview\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// run deferred modules from other chunks\n \tcheckDeferredModules();\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["../webpack/bootstrap"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","this","oldJsonpFunction","slice"],"mappings":"aACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAiBL,EAAK,GAIHM,EAAI,EAAGC,EAAW,GACpCD,EAAIH,EAASK,OAAQF,IACzBJ,EAAUC,EAASG,GAChBG,OAAOC,UAAUC,eAAeC,KAAKC,EAAiBX,IAAYW,EAAgBX,IACpFK,EAASO,KAAKD,EAAgBX,GAAS,IAExCW,EAAgBX,GAAW,EAE5B,IAAID,KAAYG,EACZK,OAAOC,UAAUC,eAAeC,KAAKR,EAAaH,KACpDc,EAAQd,GAAYG,EAAYH,IAKlC,IAFGe,GAAqBA,EAAoBhB,GAEtCO,EAASC,QACdD,EAASU,OAATV,GAOD,OAHAW,EAAgBJ,KAAKK,MAAMD,EAAiBb,GAAkB,IAGvDe,IAER,SAASA,IAER,IADA,IAAIC,EACIf,EAAI,EAAGA,EAAIY,EAAgBV,OAAQF,IAAK,CAG/C,IAFA,IAAIgB,EAAiBJ,EAAgBZ,GACjCiB,GAAY,EACRC,EAAI,EAAGA,EAAIF,EAAed,OAAQgB,IAAK,CAC9C,IAAIC,EAAQH,EAAeE,GACG,IAA3BX,EAAgBY,KAAcF,GAAY,GAE3CA,IACFL,EAAgBQ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,EAAI,SAAStB,GAChC,IAAIM,EAASN,GAAUA,EAAOiB,WAC7B,WAAwB,OAAOjB,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAJ,EAAoBQ,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRV,EAAoBW,EAAI,SAASgB,EAAQC,GAAY,OAAO9C,OAAOC,UAAUC,eAAeC,KAAK0C,EAAQC,IAGzG5B,EAAoB6B,EAAI,sFAExB,IAAIC,EAAaC,KAAK,qCAAuCA,KAAK,sCAAwC,GACtGC,EAAmBF,EAAW3C,KAAKsC,KAAKK,GAC5CA,EAAW3C,KAAOf,EAClB0D,EAAaA,EAAWG,QACxB,IAAI,IAAItD,EAAI,EAAGA,EAAImD,EAAWjD,OAAQF,IAAKP,EAAqB0D,EAAWnD,IAC3E,IAAIU,EAAsB2C,EAI1BvC,I","file":"static/js/runtime-main.4dc54380.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"https://cdn.decentraland.org/@dcl/wearable-preview/1.0.0-1864186784.commit-91b0d1d/\";\n\n \tvar jsonpArray = this[\"webpackJsonp@dcl/wearable-preview\"] = this[\"webpackJsonp@dcl/wearable-preview\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// run deferred modules from other chunks\n \tcheckDeferredModules();\n"],"sourceRoot":""}
@@ -1,2 +0,0 @@
1
- (this["webpackJsonp@dcl/wearable-preview"]=this["webpackJsonp@dcl/wearable-preview"]||[]).push([[0],{279:function(e,t,n){},364:function(e,t,n){},367:function(e,t,n){"use strict";n.r(t);var r=n(57),a=n.n(r),c=n(273),o=n.n(c),i=(n(279),n(68)),u=n(94),s=n(218),d=n.n(s),f=n(234),l=n(58),b=n.n(l),p=n(82),h=n(53),w=(n(366),n(274)),v=n.n(w);function m(e){var t=e.getChildren().filter((function(e){return"__root__"!==e.id}));if(t.length>0){for(var n=t[0],r=n.getBoundingInfo(),a=r.boundingBox.minimumWorld.add(n.position),c=r.boundingBox.maximumWorld.add(n.position),o=1;o<t.length;o++){var i=t[o],u=(r=i.getBoundingInfo()).boundingBox.minimumWorld.add(i.position),s=r.boundingBox.maximumWorld.add(i.position);a=h.n.Minimize(a,u),c=h.n.Maximize(c,s)}e.setBoundingInfo(new h.b(a,c))}}function O(e){switch(e){case u.WearableCategory.UPPER_BODY:return 2;case u.WearableCategory.SKIN:return 1.75;default:return 1.25}}function g(){return g=Object(p.a)(b.a.mark((function e(t,n,r,a){var c,o,i,u,s,d,l,w,g,j,x,y,k,E,I,R,S,B;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=new h.g(t,!0,{preserveDrawingBuffer:!0,stencil:!0}),(o=new h.k(c)).autoClear=!0,o.clearColor=new h.e(0,0,0,0),o.preventDefaultOnPointerDown=!1,h.l.OnPluginActivatedObservable.addOnce((function(e){"gltf"===e.name&&(e.preprocessUrlAsync=function(){var e=Object(p.a)(b.a.mark((function e(t){var n;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"/content/contents/",n=t.split("/content/contents/"),e.abrupt("return",n.length>0&&n[1]?r[n[1]]:t);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),i=v()(),u=function(){var e=Object(p.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",h.l.AppendAsync(n,"",o,null,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),s=function(){var e=Object(p.a)(b.a.mark((function e(){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,u(".glb");case 3:case 10:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),e.next=10,u(".gltf");case 11:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(){return e.apply(this,arguments)}}(),e.next=11,s();case 11:return e.sent.onReadyObservable.addOnce((function(e){return i.resolve(e)})),e.next=15,i;case 15:d=e.sent,new h.h("glow",d,{mainTextureFixedSize:1024,blurKernelSize:64}).intensity=1,(l=new h.a("camera",0,0,0,new h.n(0,0,0),d)).mode=h.c.PERSPECTIVE_CAMERA,l.position=new h.n(-2,2,2),l.useAutoRotationBehavior=!0,l.autoRotationBehavior.idleRotationSpeed=.2,l.setTarget(h.n.Zero()),l.lowerRadiusLimit=l.upperRadiusLimit=l.radius/O(a.category),l.attachControl(t,!0),new h.f("directional",new h.n(0,0,1),d).intensity=1,new h.i("top",new h.n(0,-1,0),d).intensity=1,new h.i("bottom",new h.n(0,1,0),d).intensity=1,new h.m("spot",new h.n(-2,2,2),new h.n(2,-2,-2),Math.PI/2,1e3,d).intensity=1,w=new h.j("parent",d),g=Object(f.a)(d.meshes);try{for(g.s();!(j=g.n()).done;)(x=j.value)!==w&&x.setParent(w)}catch(A){g.e(A)}finally{g.f()}y=Object(f.a)(d.materials);try{for(y.s();!(k=y.n()).done;)(E=k.value).name.toLowerCase().includes("hair_mat")&&(a.hair?E.albedoColor=h.d.FromHexString(a.hair):(E.alpha=0,d.removeMaterial(E))),E.name.toLowerCase().includes("avatarskin_mat")&&(a.skin?E.albedoColor=h.d.FromHexString(a.skin):(E.alpha=0,d.removeMaterial(E)))}catch(A){y.e(A)}finally{y.f()}m(w),I=w.getBoundingInfo().boundingBox.extendSize,R=I.length(),S=new h.n(1/R,1/R,1/R),w.scaling=S,B=w.getBoundingInfo().boundingBox.center.multiply(S),w.position.subtractInPlace(B),c.runRenderLoop((function(){return d.render()}));case 47:case"end":return e.stop()}}),e)}))),g.apply(this,arguments)}function j(e,t){return e.bodyShapes.includes(t)}function x(e){return j(e,u.WearableBodyShape.FEMALE)}var y,k,E=n(215),I=n(216),R=n(161);function S(e){return B.apply(this,arguments)}function B(){return(B=Object(p.a)(b.a.mark((function e(t){var n;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:if((n=e.sent).ok){e.next=9;break}return e.t0=Error,e.next=7,n.text();case 7:throw e.t1=e.sent,new e.t0(e.t1);case 9:return e.abrupt("return",n.json());case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e.PROD="prod",e.DEV="dev"}(y||(y={}));var A,P,D=(k={},Object(R.a)(k,y.DEV,"https://nft-api.decentraland.io"),Object(R.a)(k,y.PROD,"https://nft-api.decentraland.org"),k),C=function(){function e(){Object(E.a)(this,e)}return Object(I.a)(e,[{key:"fetchItem",value:function(){var e=Object(p.a)(b.a.mark((function e(t,n,r){var a,c;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(D[r],"/v1/items?contractAddress=").concat(t,"&itemId=").concat(n));case 2:if(a=e.sent,0!==(c=a.data).length){e.next=6;break}throw new Error('Item not found for contractAddress="'.concat(t,'" itemId="').concat(n,'"'));case 6:return e.abrupt("return",c[0]);case 7:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"fetchNFT",value:function(){var e=Object(p.a)(b.a.mark((function e(t,n,r){var a,c;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(D[r],"/v1/nfts?contractAddress=").concat(t,"&tokenId=").concat(n));case 2:if(a=e.sent,0!==(c=a.data).length){e.next=6;break}throw new Error('NFT not found for contractAddress="'.concat(t,'" tokenId="').concat(n,'"'));case 6:return e.abrupt("return",c[0].nft);case 7:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}()}]),e}(),M=new C,W=(A={},Object(R.a)(A,y.DEV,"https://peer.decentraland.zone"),Object(R.a)(A,y.PROD,"https://peer-lb.decentraland.org"),A),L=function(){function e(){Object(E.a)(this,e)}return Object(I.a)(e,[{key:"fetchWearable",value:function(){var e=Object(p.a)(b.a.mark((function e(t,n){var r,a;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,S("".concat(W[n],"/lambdas/collections/wearables?wearableId=").concat(t));case 2:if(r=e.sent,0!==(a=r.wearables).length){e.next=6;break}throw new Error('Wearable not found for urn="'.concat(t,'"'));case 6:return e.abrupt("return",a[0]);case 7:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()}]),e}(),N=new L;function F(e){var t=e.contractAddress,n=e.itemId,a=e.tokenId,c=e.env,o=function(e){var t=Object(r.useState)(!1),n=Object(i.a)(t,2),a=n[0],c=n[1],o=Object(r.useState)(null),u=Object(i.a)(o,2),s=u[0],d=u[1],f=Object(r.useState)(""),l=Object(i.a)(f,2),b=l[0],p=l[1];return Object(r.useEffect)((function(){c(!0),e().then((function(e){return d(e)})).catch((function(e){return p(e.message)})).finally((function(){return c(!1)}))}),[]),[s,a,b]}(Object(p.a)(b.a.mark((function e(){var r,o,i;return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error("You must provide a valid contract address");case 2:if(r=c===y.PROD?"matic":"mumbai",o="urn:decentraland:".concat(r,":collections-v2:").concat(t,":").concat(n),n||a){e.next=8;break}throw new Error("You must provide either tokenId or itemId");case 8:if(n||!a){e.next=13;break}return e.next=11,M.fetchNFT(t,a,c);case 11:i=e.sent,o=i.network!==u.Network.ETHEREUM?"urn:decentraland:".concat(r,":collections-v2:").concat(t,":").concat(i.itemId):i.image.split("contents/")[1].split("/thumbnail")[0];case 13:return e.abrupt("return",N.fetchWearable(o,c));case 14:case"end":return e.stop()}}),e)})))),s=Object(i.a)(o,3);return[s[0],s[1],s[2]]}function z(e,t){var n=JSON.stringify({type:e,message:t});window.parent&&window.parent.postMessage(n,"*")}!function(e){e.LOAD="load",e.ERROR="error"}(P||(P={}));n(364);var _=n(121),T=function(){var e=Object(r.useState)(""),t=Object(i.a)(e,2),n=t[0],a=t[1],c=function(){var e=Object(r.useState)({width:void 0,height:void 0}),t=Object(i.a)(e,2),n=t[0],a=t[1];return Object(r.useEffect)((function(){function e(){a({width:window.innerWidth,height:window.innerHeight})}return window.addEventListener("resize",e),e(),function(){return window.removeEventListener("resize",e)}}),[]),n}(),o=c.width,s=c.height,f=Object(r.useState)({}),l=Object(i.a)(f,2),b=l[0],p=l[1],h=Object(r.useState)(!1),w=Object(i.a)(h,2),v=w[0],m=w[1],O=Object(r.useState)(!0),j=Object(i.a)(O,2),k=j[0],E=j[1],I=Object(r.useState)(!1),R=Object(i.a)(I,2),S=R[0],B=R[1],A=Object(r.useRef)(null),D=new URLSearchParams(window.location.search),C=D.get("contract"),M=D.get("token"),W=D.get("item"),L=D.get("skin"),N=D.get("hair"),T=D.get("shape"),U=F({contractAddress:C,tokenId:M,itemId:W,env:Object.values(y).reduce((function(e,t){return t===D.get("env")?t:e}),y.PROD)}),H=Object(i.a)(U,3),V=H[0],J=H[1],Y=H[2],K=Object(r.useState)(""),G=Object(i.a)(K,2),Z=G[0],q=G[1],Q=Object(r.useState)(!0),X=Object(i.a)(Q,2),$=X[0],ee=X[1],te=Object(r.useState)(!1),ne=Object(i.a)(te,2),re=ne[0],ae=ne[1],ce=n||Y,oe=(k||J)&&!ce,ie=!!Z&&!$&&!oe,ue=$&&!oe;return Object(r.useEffect)((function(){if(A.current&&V){var e=u.Rarity.getGradient(V.rarity),t=Object(i.a)(e,2),n=t[0],r=t[1],c="radial-gradient(".concat(n,", ").concat(r,")");p({backgroundImage:c,opacity:1}),q(V.thumbnail);var o=V.data.representations[0];if("female"===T&&V.data.representations.some(x)&&(o=V.data.representations.find(x)),o.mainFile.endsWith("png"))ee(!1),E(!1),B(!0);else{var s=o.contents.find((function(e){return e.key===o.mainFile})),d=o.contents.reduce((function(e,t){return e[t.key]=t.url,e}),{});s?function(e,t,n,r){return g.apply(this,arguments)}(A.current,s.url,d,{category:V.data.category,skin:L?"#"+L:void 0,hair:N?"#"+N:void 0}).catch((function(e){return a(e.message)})).finally((function(){E(!1),B(!0)})):(console.warn("Content not found for wearable",V),a("Content not found"))}}}),[A.current,V]),Object(r.useEffect)((function(){re||(S?(z(P.LOAD),ae(!0)):ce&&(z(P.ERROR,ce),ae(!0)))}),[S,ce,re]),Object(_.jsxs)("div",{className:d()("Preview",{"is-dragging":v,"is-loading":oe,"is-loaded":S,"is-3d":$,"has-error":!!ce}),style:b,children:[Object(_.jsx)("img",{src:Z,className:d()("thumbnail",{"is-visible":ie}),alt:"preview"}),Object(_.jsx)("canvas",{id:"wearable-preview",className:d()({"is-visible":ue}),width:o,height:s,ref:A,onMouseDown:function(){return m($&&!ce)},onMouseUp:function(){return m(!1)}}),ce&&Object(_.jsx)("div",{className:"error",children:ce})]})},U=a.a.memo(T);o.a.render(Object(_.jsx)(a.a.StrictMode,{children:Object(_.jsx)(U,{})}),document.getElementById("root"))}},[[367,1,2]]]);
2
- //# sourceMappingURL=main.dcd96f7f.chunk.js.map