shop-components 0.4.21 → 0.4.23
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.
|
@@ -15,8 +15,8 @@ export default class JFA {
|
|
|
15
15
|
target?: Object3D;
|
|
16
16
|
private readonly selectionLayer;
|
|
17
17
|
maskMaterial: MeshBasicMaterial;
|
|
18
|
-
targets: WebGLRenderTarget<import("three").Texture
|
|
19
|
-
masks: WebGLRenderTarget<import("three").Texture
|
|
18
|
+
targets: WebGLRenderTarget<import("three").Texture<unknown>>[];
|
|
19
|
+
masks: WebGLRenderTarget<import("three").Texture<unknown>>[];
|
|
20
20
|
seedMaterial: SeedMaterial;
|
|
21
21
|
effectQuad: FullScreenQuad;
|
|
22
22
|
jfaQuad: FullScreenQuad;
|
package/dist/dev/src/scene.d.ts
CHANGED
|
@@ -57,8 +57,8 @@ export interface SceneProps {
|
|
|
57
57
|
export declare class Scene3D {
|
|
58
58
|
props: SceneProps;
|
|
59
59
|
stats: Stats;
|
|
60
|
-
scene: Scene
|
|
61
|
-
overlayScene: Scene
|
|
60
|
+
scene: Scene<import("three").Object3DEventMap>;
|
|
61
|
+
overlayScene: Scene<import("three").Object3DEventMap>;
|
|
62
62
|
renderer: WebGLRenderer;
|
|
63
63
|
private css2dRenderer;
|
|
64
64
|
pathTracer: WebGLPathTracer;
|
package/dist/shop-components.cjs
CHANGED
|
@@ -3678,7 +3678,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3678
3678
|
rayDirection.x *= flipEnvMap;
|
|
3679
3679
|
gl_FragColor = textureCube( envMap, rayDirection );
|
|
3680
3680
|
|
|
3681
|
-
}`}),this.depthWrite=!1,this.depthTest=!1}}class Gs{constructor(e){this._renderer=e,this._quad=new ut.FullScreenQuad(new Jo)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=this._renderer,n=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new d.WebGLRenderTarget(t,i,{type:d.FloatType,colorSpace:s.colorSpace}),h=s.height,f=Math.log2(h)-2,p=1/h,r=1/(3*Math.max(Math.pow(2,f),7*16));n.material.defines.CUBEUV_MAX_MIP=`${f}.0`,n.material.defines.CUBEUV_TEXEL_WIDTH=r,n.material.defines.CUBEUV_TEXEL_HEIGHT=p,n.material.uniforms.envMap.value=e,n.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,n.material.needsUpdate=!0;const l=a.getRenderTarget(),u=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),n.render(a),a.setRenderTarget(l),a.autoClear=u;const g=new Uint16Array(t*i*4),y=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,y),c.dispose();for(let v=0,_=y.length;v<_;v++)g[v]=d.DataUtils.toHalfFloat(y[v]);const m=new d.DataTexture(g,t,i,d.RGBAFormat,d.HalfFloatType);return m.minFilter=d.LinearMipMapLinearFilter,m.magFilter=d.LinearFilter,m.wrapS=d.RepeatWrapping,m.wrapT=d.RepeatWrapping,m.mapping=d.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function $o(o){return o.extensions.get("EXT_float_blend")}const je=new d.Vector2;class ea{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Bn,this._pathTracer=new Us(e),this._queueReset=!1,this._clock=new d.Clock,this._compilePromise=null,this._lowResPathTracer=new Us(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new ut.FullScreenQuad(new Zo({map:null,transparent:!0,blending:d.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new d.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},this.setScene(new d.Scene,new d.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,a=so(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=ro(e),a=io(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new Xo(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new Gs(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new Gs(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:a,bvh:n,bvhChanged:c}=i;this._materials=s;const f=this._pathTracer.material;return c&&(f.bvh.updateFrom(n),f.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),f.materialIndexAttribute.updateFrom(a.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,s.start());const n=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!$o(i),e.alpha=t.alpha,this.renderToCanvas){const h=this._renderer,f=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+n/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<f||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(h),a.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?d.AdditiveBlending:d.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,h,a),a.material.blending=d.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(je);const e=Math.floor(this.renderScale*je.x),t=Math.floor(this.renderScale*je.y);if(this._pathTracer.getSize(je),je.x!==e||je.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const ta="";globalThis.GLTF_PROGRESSIVE_VERSION=ta;console.debug("[gltf-progressive] version -");let br="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",ia="https://cdn.needle.tools/static/three/0.179.1/basis2/";const sa=new URL(br+"draco_decoder.js");sa.searchParams.append("range","true");const ra=()=>({dracoDecoderPath:br,ktx2TranscoderPath:ia});function Ar(o){return{dracoLoader:Sr,meshoptDecoder:Mr}}function Tr(o){o.dracoLoader||o.setDRACOLoader(Sr),o.meshoptDecoder||o.setMeshoptDecoder(Mr)}let Sr,Mr;const Hi=new WeakMap;function Cr(o,e){let t=Hi.get(o);t?t=Object.assign(t,e):t=e,Hi.set(o,t)}const Ai=os.GLTFLoader.prototype.load;function na(...o){const e=Hi.get(this);let t=o[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,n=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${n}`:this.requestHeader.Accept=`*/*;usecase=${n}`,t=i.toString()}return o[0]=t,Ai==null?void 0:Ai.call(this,...o)}os.GLTFLoader.prototype.load=na;He("debugprogressive");function He(o){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(o);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function oa(o,e){if(e===void 0||o===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=o.lastIndexOf("/");if(t>=0){const i=o.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function Rr(){return gt!==void 0||(gt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),He("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",gt)),gt}let gt;function Ns(){if(typeof window>"u")return!1;const o=new URL(window.location.href),e=o.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);return o.hostname==="127.0.0.1"||e}class aa{constructor(e=100,t={}){F(this,"_running",new Map);F(this,"_queue",[]);F(this,"debug",!1);F(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:a=>this.add(i,a)})}}}const la=typeof window>"u"&&typeof document>"u",Gi=Symbol("needle:raycast-mesh");function Bt(o){return(o==null?void 0:o[Gi])instanceof d.BufferGeometry?o[Gi]:null}function ca(o,e){if((o.type==="Mesh"||o.type==="SkinnedMesh")&&!Bt(o)){const i=ua(e);i.userData={isRaycastMesh:!0},o[Gi]=i}}function ha(o=!0){if(o){if(vt)return;const e=vt=d.Mesh.prototype.raycast;d.Mesh.prototype.raycast=function(t,i){const s=this,a=Bt(s);let n;a&&s.isMesh&&(n=s.geometry,s.geometry=a),e.call(this,t,i),n&&(s.geometry=n)}}else{if(!vt)return;d.Mesh.prototype.raycast=vt,vt=null}}let vt=null;function ua(o){const e=new d.BufferGeometry;for(const t in o.attributes)e.setAttribute(t,o.getAttribute(t));return e.setIndex(o.getIndex()),e}const Re=new Array,z=He("debugprogressive");let It,Ve=-1;if(z){let o=function(){Ve+=1,Ve>=e&&(Ve=-1),console.log(`Toggle LOD level [${Ve}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&o(),t.key==="w"&&(It=!It,console.log(`Toggle wireframe [${It}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Ve=i,console.log(`Set LOD level to [${Ve}]`))})}function Lr(o){if(z&&It!==void 0)if(Array.isArray(o))for(const e of o)Lr(e);else o&&"wireframe"in o&&(o.wireframe=It===!0)}const _t=new Array;let fa=0;const da=Rr()?2:10;function pa(o){if(_t.length<da){const i=_t.length;z&&console.warn(`[Worker] Creating new worker #${i}`);const s=hs.createWorker(o||{});return _t.push(s),s}const e=fa++%_t.length;return _t[e]}class hs{constructor(e,t){F(this,"_running",[]);F(this,"_webglRenderer",null);F(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const a of this._running)if(a.url===s.result.url){ma(s.result),a.resolve(s.result);const n=a.url;n.startsWith("blob:")&&URL.revokeObjectURL(n)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-fysOIq2s.js").href:new URL("assets/loader.worker-fysOIq2s.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new hs(t,e)}async load(e,t){const i=ra();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:f}=await import("three");return new f})()),s=await this._webglRenderer);const c=Ar().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const h={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",h),this.worker.postMessage(h),new Promise(f=>{this._running.push({url:e.toString(),resolve:f})})}}function ma(o){var e,t,i,s,a,n,c,h,f,p,r,l,u,g,y,m;for(const v of o.geometries){const _=v.geometry,x=new d.BufferGeometry;if(x.name=_.name||"",_.index){const w=_.index;x.setIndex(Ti(w))}for(const w in _.attributes){const b=_.attributes[w],T=Ti(b);x.setAttribute(w,T)}if(_.morphAttributes)for(const w in _.morphAttributes){const T=_.morphAttributes[w].map(S=>Ti(S));x.morphAttributes[w]=T}if(x.morphTargetsRelative=_.morphTargetsRelative??!1,x.boundingBox=new d.Box3,x.boundingBox.min=new d.Vector3((e=_.boundingBox)==null?void 0:e.min.x,(t=_.boundingBox)==null?void 0:t.min.y,(i=_.boundingBox)==null?void 0:i.min.z),x.boundingBox.max=new d.Vector3((s=_.boundingBox)==null?void 0:s.max.x,(a=_.boundingBox)==null?void 0:a.max.y,(n=_.boundingBox)==null?void 0:n.max.z),x.boundingSphere=new d.Sphere(new d.Vector3((c=_.boundingSphere)==null?void 0:c.center.x,(h=_.boundingSphere)==null?void 0:h.center.y,(f=_.boundingSphere)==null?void 0:f.center.z),(p=_.boundingSphere)==null?void 0:p.radius),_.groups)for(const w of _.groups)x.addGroup(w.start,w.count,w.materialIndex);_.userData&&(x.userData=_.userData),v.geometry=x}for(const v of o.textures){const _=v.texture;let x=null;if(_.isCompressedTexture){const w=_.mipmaps,b=((r=_.image)==null?void 0:r.width)||((u=(l=_.source)==null?void 0:l.data)==null?void 0:u.width)||-1,T=((g=_.image)==null?void 0:g.height)||((m=(y=_.source)==null?void 0:y.data)==null?void 0:m.height)||-1;x=new d.CompressedTexture(w,b,T,_.format,_.type,_.mapping,_.wrapS,_.wrapT,_.magFilter,_.minFilter,_.anisotropy,_.colorSpace)}else x=new d.Texture(_.image,_.mapping,_.wrapS,_.wrapT,_.magFilter,_.minFilter,_.format,_.type,_.anisotropy,_.colorSpace),x.mipmaps=_.mipmaps,x.channel=_.channel,x.source.data=_.source.data,x.flipY=_.flipY,x.premultiplyAlpha=_.premultiplyAlpha,x.unpackAlignment=_.unpackAlignment,x.matrix=new d.Matrix3(..._.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return o}function Ti(o){let e=o;if("isInterleavedBufferAttribute"in o&&o.isInterleavedBufferAttribute){const t=o.data,i=t.array,s=new d.InterleavedBuffer(i,t.stride);e=new d.InterleavedBufferAttribute(s,o.itemSize,i.byteOffset,o.normalized),e.offset=o.offset}else"isBufferAttribute"in o&&o.isBufferAttribute&&(e=new d.BufferAttribute(o.array,o.itemSize,o.normalized),e.usage=o.usage,e.gpuType=o.gpuType,e.updateRanges=o.updateRanges);return e}const ga=He("gltf-progressive-worker"),va=He("gltf-progressive-reduce-mipmaps"),Si=Symbol("needle-progressive-texture"),ye="NEEDLE_progressive",O=class O{constructor(e){F(this,"parser");F(this,"url");F(this,"_isLoadingMesh");F(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[ye];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var n;return this._isLoadingMesh=!1,a&&O.registerMesh(this.url,t.guid,a,(n=t.lods)==null?void 0:n.length,0,t),a})):null});const t=e.options.path;z&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return ye}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",a=e[s];if(a!=null)return a;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(z==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const h of Object.keys(c.uniforms)){const f=c.uniforms[h].value;(f==null?void 0:f.isTexture)===!0&&n(f,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const h=e[c];(h==null?void 0:h.isTexture)===!0&&n(h,t)}else z&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function n(c,h){const f=i.getAssignedLODInformation(c);if(f){const p=i.lodInfos.get(f.key);if(p&&p.lods){h.min_count=Math.min(h.min_count,p.lods.length),h.max_count=Math.max(h.max_count,p.lods.length);for(let r=0;r<p.lods.length;r++){const l=p.lods[r];l.width&&(h.lods[r]=h.lods[r]||{min_height:1/0,max_height:0},h.lods[r].min_height=Math.min(h.lods[r].min_height,l.height),h.lods[r].max_height=Math.max(h.lods[r].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;if(Array.isArray(e)){for(const n of e)if(this.hasLODLevelAvailable(n,t))return!0;return!1}if(e.isMaterial===!0){for(const n of Object.keys(e)){const c=e[n];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const n of e.children)if(n.isMesh===!0&&this.hasLODLevelAvailable(n,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(a=i==null?void 0:i.userData)!=null&&a.LODS){const n=i.userData.LODS;if(s=this.lodInfos.get(n.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof d.Mesh||e.isMesh===!0){const s=e.geometry,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const n of Re)(i=n.onBeforeGetLODMesh)==null||i.call(n,e,t);return e["LOD:requested level"]=t,O.getOrLoadLOD(s,t).then(n=>{if(Array.isArray(n)){const c=a.index||0;n=n[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],n&&s!=n&&((n==null?void 0:n.isBufferGeometry)?e.geometry=n:z&&console.error("Invalid LOD geometry",n))),n}).catch(n=>(console.error("Error loading mesh LOD",e,n),null))}else z&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const a of i.material){const n=this.assignTextureLOD(a,t);s.push(n)}return Promise.all(s).then(a=>{const n=new Array;for(const c of a)Array.isArray(c)&&n.push(...c);return n})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const n=i;for(const c of Object.keys(n.uniforms)){const h=n.uniforms[c].value;if((h==null?void 0:h.isTexture)===!0){const f=this.assignTextureLODForSlot(h,t,i,c).then(p=>(p&&n.uniforms[c].value!=p&&(n.uniforms[c].value=p,n.uniformsNeedUpdate=!0),p));s.push(f),a.push(c)}}}else for(const n of Object.keys(i)){const c=i[n];if((c==null?void 0:c.isTexture)===!0){const h=this.assignTextureLODForSlot(c,t,i,n);s.push(h),a.push(n)}}return Promise.all(s).then(n=>{const c=new Array;for(let h=0;h<n.length;h++){const f=n[h],p=a[h];f&&f.isTexture===!0?c.push({material:i,slot:p,texture:f,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof d.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):O.getOrLoadLOD(e,t).then(a=>{var n,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const h=i[s];if(h&&!z){const f=this.getAssignedLODInformation(h);if(f&&(f==null?void 0:f.level)<t)return z==="verbose"&&console.warn("Assigned texture level is already higher: ",f.level,t,i,h,a),null}if(va&&a.mipmaps){const f=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),f!==a.mipmaps.length&&z&&console.debug(`Reduced mipmap count from ${f} to ${a.mipmaps.length} for ${a.uuid}: ${(n=a.image)==null?void 0:n.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else z=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return z&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var n;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[ye];if(c){if(!c.lods){z&&console.warn("Texture has no LODs",c);return}let h=!1;for(const f of this.parser.associations.keys())if(f.isTexture===!0){const p=this.parser.associations.get(f);(p==null?void 0:p.textures)===a&&(h=!0,O.registerTexture(this.url,f,(n=c.lods)==null?void 0:n.length,a,c))}h||this.parser.getDependency("texture",a).then(f=>{var p;f&&O.registerTexture(this.url,f,(p=c.lods)==null?void 0:p.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const n=s==null?void 0:s.extensions[ye];if(n&&n.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const h=this.parser.associations.get(c);(h==null?void 0:h.meshes)===a&&O.registerMesh(this.url,n.guid,c,n.lods.length,h.primitives,n)}}}}),null}static async getOrLoadLOD(e,t){var h,f,p,r;const i=z=="verbose",s=this.getAssignedLODInformation(e);if(!s)return z&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let n;if(e.isTexture===!0){const l=e;l.source&&l.source[Si]&&(n=l.source[Si])}if(n||(n=O.lodInfos.get(a)),!n)z&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,O.lodInfos);else{if(t>0){let g=!1;const y=Array.isArray(n.lods);if(y&&t>=n.lods.length?g=!0:y||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(n.lods)?(h=n.lods[t])==null?void 0:h.path:n.lods;if(!l)return z&&!n["missing:uri"]&&(n["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,n)),null;const u=oa(s.url,l);if(u.endsWith(".glb")||u.endsWith(".gltf")){if(!n.guid)return console.warn("missing pointer for glb/gltf texture",n),null;const g=u+"_"+n.guid,y=await this.queue.slot(u),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await m.catch(T=>(console.error(`Error loading LOD ${t} from ${u}
|
|
3681
|
+
}`}),this.depthWrite=!1,this.depthTest=!1}}class Gs{constructor(e){this._renderer=e,this._quad=new ut.FullScreenQuad(new Jo)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=this._renderer,n=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new d.WebGLRenderTarget(t,i,{type:d.FloatType,colorSpace:s.colorSpace}),h=s.height,f=Math.log2(h)-2,p=1/h,r=1/(3*Math.max(Math.pow(2,f),7*16));n.material.defines.CUBEUV_MAX_MIP=`${f}.0`,n.material.defines.CUBEUV_TEXEL_WIDTH=r,n.material.defines.CUBEUV_TEXEL_HEIGHT=p,n.material.uniforms.envMap.value=e,n.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,n.material.needsUpdate=!0;const l=a.getRenderTarget(),u=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),n.render(a),a.setRenderTarget(l),a.autoClear=u;const g=new Uint16Array(t*i*4),y=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,y),c.dispose();for(let v=0,_=y.length;v<_;v++)g[v]=d.DataUtils.toHalfFloat(y[v]);const m=new d.DataTexture(g,t,i,d.RGBAFormat,d.HalfFloatType);return m.minFilter=d.LinearMipMapLinearFilter,m.magFilter=d.LinearFilter,m.wrapS=d.RepeatWrapping,m.wrapT=d.RepeatWrapping,m.mapping=d.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function $o(o){return o.extensions.get("EXT_float_blend")}const je=new d.Vector2;class ea{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Bn,this._pathTracer=new Us(e),this._queueReset=!1,this._clock=new d.Clock,this._compilePromise=null,this._lowResPathTracer=new Us(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new ut.FullScreenQuad(new Zo({map:null,transparent:!0,blending:d.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new d.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},this.setScene(new d.Scene,new d.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,a=so(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=ro(e),a=io(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new Xo(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new Gs(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new Gs(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:a,bvh:n,bvhChanged:c}=i;this._materials=s;const f=this._pathTracer.material;return c&&(f.bvh.updateFrom(n),f.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),f.materialIndexAttribute.updateFrom(a.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,s.start());const n=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!$o(i),e.alpha=t.alpha,this.renderToCanvas){const h=this._renderer,f=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+n/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<f||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(h),a.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?d.AdditiveBlending:d.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,h,a),a.material.blending=d.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(je);const e=Math.floor(this.renderScale*je.x),t=Math.floor(this.renderScale*je.y);if(this._pathTracer.getSize(je),je.x!==e||je.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const ta="";globalThis.GLTF_PROGRESSIVE_VERSION=ta;console.debug("[gltf-progressive] version -");let br="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",ia="https://cdn.needle.tools/static/three/0.179.1/basis2/";const sa=new URL(br+"draco_decoder.js");sa.searchParams.append("range","true");const ra=()=>({dracoDecoderPath:br,ktx2TranscoderPath:ia});function Ar(o){return{dracoLoader:Sr,meshoptDecoder:Mr}}function Tr(o){o.dracoLoader||o.setDRACOLoader(Sr),o.meshoptDecoder||o.setMeshoptDecoder(Mr)}let Sr,Mr;const Hi=new WeakMap;function Cr(o,e){let t=Hi.get(o);t?t=Object.assign(t,e):t=e,Hi.set(o,t)}const Ai=os.GLTFLoader.prototype.load;function na(...o){const e=Hi.get(this);let t=o[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,n=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${n}`:this.requestHeader.Accept=`*/*;usecase=${n}`,t=i.toString()}return o[0]=t,Ai==null?void 0:Ai.call(this,...o)}os.GLTFLoader.prototype.load=na;He("debugprogressive");function He(o){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(o);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function oa(o,e){if(e===void 0||o===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=o.lastIndexOf("/");if(t>=0){const i=o.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function Rr(){return gt!==void 0||(gt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),He("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",gt)),gt}let gt;function Ns(){if(typeof window>"u")return!1;const o=new URL(window.location.href),e=o.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o.hostname);return o.hostname==="127.0.0.1"||e}class aa{constructor(e=100,t={}){F(this,"_running",new Map);F(this,"_queue",[]);F(this,"debug",!1);F(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:a=>this.add(i,a)})}}}const la=typeof window>"u"&&typeof document>"u",Gi=Symbol("needle:raycast-mesh");function Bt(o){return(o==null?void 0:o[Gi])instanceof d.BufferGeometry?o[Gi]:null}function ca(o,e){if((o.type==="Mesh"||o.type==="SkinnedMesh")&&!Bt(o)){const i=ua(e);i.userData={isRaycastMesh:!0},o[Gi]=i}}function ha(o=!0){if(o){if(vt)return;const e=vt=d.Mesh.prototype.raycast;d.Mesh.prototype.raycast=function(t,i){const s=this,a=Bt(s);let n;a&&s.isMesh&&(n=s.geometry,s.geometry=a),e.call(this,t,i),n&&(s.geometry=n)}}else{if(!vt)return;d.Mesh.prototype.raycast=vt,vt=null}}let vt=null;function ua(o){const e=new d.BufferGeometry;for(const t in o.attributes)e.setAttribute(t,o.getAttribute(t));return e.setIndex(o.getIndex()),e}const Re=new Array,z=He("debugprogressive");let It,Ve=-1;if(z){let o=function(){Ve+=1,Ve>=e&&(Ve=-1),console.log(`Toggle LOD level [${Ve}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&o(),t.key==="w"&&(It=!It,console.log(`Toggle wireframe [${It}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Ve=i,console.log(`Set LOD level to [${Ve}]`))})}function Lr(o){if(z&&It!==void 0)if(Array.isArray(o))for(const e of o)Lr(e);else o&&"wireframe"in o&&(o.wireframe=It===!0)}const _t=new Array;let fa=0;const da=Rr()?2:10;function pa(o){if(_t.length<da){const i=_t.length;z&&console.warn(`[Worker] Creating new worker #${i}`);const s=hs.createWorker(o||{});return _t.push(s),s}const e=fa++%_t.length;return _t[e]}class hs{constructor(e,t){F(this,"_running",[]);F(this,"_webglRenderer",null);F(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const a of this._running)if(a.url===s.result.url){ma(s.result),a.resolve(s.result);const n=a.url;n.startsWith("blob:")&&URL.revokeObjectURL(n)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-46d0lFWx.js").href:new URL("assets/loader.worker-46d0lFWx.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new hs(t,e)}async load(e,t){const i=ra();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:f}=await import("three");return new f})()),s=await this._webglRenderer);const c=Ar().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const h={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",h),this.worker.postMessage(h),new Promise(f=>{this._running.push({url:e.toString(),resolve:f})})}}function ma(o){var e,t,i,s,a,n,c,h,f,p,r,l,u,g,y,m;for(const v of o.geometries){const _=v.geometry,x=new d.BufferGeometry;if(x.name=_.name||"",_.index){const w=_.index;x.setIndex(Ti(w))}for(const w in _.attributes){const b=_.attributes[w],T=Ti(b);x.setAttribute(w,T)}if(_.morphAttributes)for(const w in _.morphAttributes){const T=_.morphAttributes[w].map(S=>Ti(S));x.morphAttributes[w]=T}if(x.morphTargetsRelative=_.morphTargetsRelative??!1,x.boundingBox=new d.Box3,x.boundingBox.min=new d.Vector3((e=_.boundingBox)==null?void 0:e.min.x,(t=_.boundingBox)==null?void 0:t.min.y,(i=_.boundingBox)==null?void 0:i.min.z),x.boundingBox.max=new d.Vector3((s=_.boundingBox)==null?void 0:s.max.x,(a=_.boundingBox)==null?void 0:a.max.y,(n=_.boundingBox)==null?void 0:n.max.z),x.boundingSphere=new d.Sphere(new d.Vector3((c=_.boundingSphere)==null?void 0:c.center.x,(h=_.boundingSphere)==null?void 0:h.center.y,(f=_.boundingSphere)==null?void 0:f.center.z),(p=_.boundingSphere)==null?void 0:p.radius),_.groups)for(const w of _.groups)x.addGroup(w.start,w.count,w.materialIndex);_.userData&&(x.userData=_.userData),v.geometry=x}for(const v of o.textures){const _=v.texture;let x=null;if(_.isCompressedTexture){const w=_.mipmaps,b=((r=_.image)==null?void 0:r.width)||((u=(l=_.source)==null?void 0:l.data)==null?void 0:u.width)||-1,T=((g=_.image)==null?void 0:g.height)||((m=(y=_.source)==null?void 0:y.data)==null?void 0:m.height)||-1;x=new d.CompressedTexture(w,b,T,_.format,_.type,_.mapping,_.wrapS,_.wrapT,_.magFilter,_.minFilter,_.anisotropy,_.colorSpace)}else x=new d.Texture(_.image,_.mapping,_.wrapS,_.wrapT,_.magFilter,_.minFilter,_.format,_.type,_.anisotropy,_.colorSpace),x.mipmaps=_.mipmaps,x.channel=_.channel,x.source.data=_.source.data,x.flipY=_.flipY,x.premultiplyAlpha=_.premultiplyAlpha,x.unpackAlignment=_.unpackAlignment,x.matrix=new d.Matrix3(..._.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return o}function Ti(o){let e=o;if("isInterleavedBufferAttribute"in o&&o.isInterleavedBufferAttribute){const t=o.data,i=t.array,s=new d.InterleavedBuffer(i,t.stride);e=new d.InterleavedBufferAttribute(s,o.itemSize,i.byteOffset,o.normalized),e.offset=o.offset}else"isBufferAttribute"in o&&o.isBufferAttribute&&(e=new d.BufferAttribute(o.array,o.itemSize,o.normalized),e.usage=o.usage,e.gpuType=o.gpuType,e.updateRanges=o.updateRanges);return e}const ga=He("gltf-progressive-worker"),va=He("gltf-progressive-reduce-mipmaps"),Si=Symbol("needle-progressive-texture"),ye="NEEDLE_progressive",O=class O{constructor(e){F(this,"parser");F(this,"url");F(this,"_isLoadingMesh");F(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[ye];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var n;return this._isLoadingMesh=!1,a&&O.registerMesh(this.url,t.guid,a,(n=t.lods)==null?void 0:n.length,0,t),a})):null});const t=e.options.path;z&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return ye}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",a=e[s];if(a!=null)return a;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(z==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const h of Object.keys(c.uniforms)){const f=c.uniforms[h].value;(f==null?void 0:f.isTexture)===!0&&n(f,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const h=e[c];(h==null?void 0:h.isTexture)===!0&&n(h,t)}else z&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function n(c,h){const f=i.getAssignedLODInformation(c);if(f){const p=i.lodInfos.get(f.key);if(p&&p.lods){h.min_count=Math.min(h.min_count,p.lods.length),h.max_count=Math.max(h.max_count,p.lods.length);for(let r=0;r<p.lods.length;r++){const l=p.lods[r];l.width&&(h.lods[r]=h.lods[r]||{min_height:1/0,max_height:0},h.lods[r].min_height=Math.min(h.lods[r].min_height,l.height),h.lods[r].max_height=Math.max(h.lods[r].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;if(Array.isArray(e)){for(const n of e)if(this.hasLODLevelAvailable(n,t))return!0;return!1}if(e.isMaterial===!0){for(const n of Object.keys(e)){const c=e[n];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const n of e.children)if(n.isMesh===!0&&this.hasLODLevelAvailable(n,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(a=i==null?void 0:i.userData)!=null&&a.LODS){const n=i.userData.LODS;if(s=this.lodInfos.get(n.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof d.Mesh||e.isMesh===!0){const s=e.geometry,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const n of Re)(i=n.onBeforeGetLODMesh)==null||i.call(n,e,t);return e["LOD:requested level"]=t,O.getOrLoadLOD(s,t).then(n=>{if(Array.isArray(n)){const c=a.index||0;n=n[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],n&&s!=n&&((n==null?void 0:n.isBufferGeometry)?e.geometry=n:z&&console.error("Invalid LOD geometry",n))),n}).catch(n=>(console.error("Error loading mesh LOD",e,n),null))}else z&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const a of i.material){const n=this.assignTextureLOD(a,t);s.push(n)}return Promise.all(s).then(a=>{const n=new Array;for(const c of a)Array.isArray(c)&&n.push(...c);return n})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const n=i;for(const c of Object.keys(n.uniforms)){const h=n.uniforms[c].value;if((h==null?void 0:h.isTexture)===!0){const f=this.assignTextureLODForSlot(h,t,i,c).then(p=>(p&&n.uniforms[c].value!=p&&(n.uniforms[c].value=p,n.uniformsNeedUpdate=!0),p));s.push(f),a.push(c)}}}else for(const n of Object.keys(i)){const c=i[n];if((c==null?void 0:c.isTexture)===!0){const h=this.assignTextureLODForSlot(c,t,i,n);s.push(h),a.push(n)}}return Promise.all(s).then(n=>{const c=new Array;for(let h=0;h<n.length;h++){const f=n[h],p=a[h];f&&f.isTexture===!0?c.push({material:i,slot:p,texture:f,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof d.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):O.getOrLoadLOD(e,t).then(a=>{var n,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const h=i[s];if(h&&!z){const f=this.getAssignedLODInformation(h);if(f&&(f==null?void 0:f.level)<t)return z==="verbose"&&console.warn("Assigned texture level is already higher: ",f.level,t,i,h,a),null}if(va&&a.mipmaps){const f=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),f!==a.mipmaps.length&&z&&console.debug(`Reduced mipmap count from ${f} to ${a.mipmaps.length} for ${a.uuid}: ${(n=a.image)==null?void 0:n.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else z=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return z&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var n;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[ye];if(c){if(!c.lods){z&&console.warn("Texture has no LODs",c);return}let h=!1;for(const f of this.parser.associations.keys())if(f.isTexture===!0){const p=this.parser.associations.get(f);(p==null?void 0:p.textures)===a&&(h=!0,O.registerTexture(this.url,f,(n=c.lods)==null?void 0:n.length,a,c))}h||this.parser.getDependency("texture",a).then(f=>{var p;f&&O.registerTexture(this.url,f,(p=c.lods)==null?void 0:p.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const n=s==null?void 0:s.extensions[ye];if(n&&n.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const h=this.parser.associations.get(c);(h==null?void 0:h.meshes)===a&&O.registerMesh(this.url,n.guid,c,n.lods.length,h.primitives,n)}}}}),null}static async getOrLoadLOD(e,t){var h,f,p,r;const i=z=="verbose",s=this.getAssignedLODInformation(e);if(!s)return z&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let n;if(e.isTexture===!0){const l=e;l.source&&l.source[Si]&&(n=l.source[Si])}if(n||(n=O.lodInfos.get(a)),!n)z&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,O.lodInfos);else{if(t>0){let g=!1;const y=Array.isArray(n.lods);if(y&&t>=n.lods.length?g=!0:y||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(n.lods)?(h=n.lods[t])==null?void 0:h.path:n.lods;if(!l)return z&&!n["missing:uri"]&&(n["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,n)),null;const u=oa(s.url,l);if(u.endsWith(".glb")||u.endsWith(".gltf")){if(!n.guid)return console.warn("missing pointer for glb/gltf texture",n),null;const g=u+"_"+n.guid,y=await this.queue.slot(u),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await m.catch(T=>(console.error(`Error loading LOD ${t} from ${u}
|
|
3682
3682
|
`,T),null)),b=!1;if(w==null||(w instanceof d.Texture&&e instanceof d.Texture?(f=w.image)!=null&&f.data||(p=w.source)!=null&&p.data?w=this.copySettings(e,w):(b=!0,this.previouslyLoaded.delete(g)):w instanceof d.BufferGeometry&&e instanceof d.BufferGeometry&&((r=w.attributes.position)!=null&&r.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return w}if(!y.use)return z&&console.log(`LOD ${t} was aborted: ${u}`),null;const v=n,_=new Promise(async(w,b)=>{if(ga){const A=await(await pa({})).load(u);if(A.textures.length>0)for(const M of A.textures){let I=M.texture;return O.assignLODInformation(s.url,I,a,t,void 0),e instanceof d.Texture&&(I=this.copySettings(e,I)),I&&(I.guid=v.guid),w(I)}if(A.geometries.length>0){const M=new Array;for(const I of A.geometries){const P=I.geometry;O.assignLODInformation(s.url,P,a,t,I.primitiveIndex),M.push(P)}return w(M)}return w(null)}const T=new os.GLTFLoader;Tr(T),z&&(await new Promise(R=>setTimeout(R,1e3)),i&&console.warn("Start loading (delayed) "+u,v.guid));let S=u;if(v&&Array.isArray(v.lods)){const R=v.lods[t];R.hash&&(S+="?v="+R.hash)}const L=await T.loadAsync(S).catch(R=>(console.error(`Error loading LOD ${t} from ${u}
|
|
3683
3683
|
`,R),w(null)));if(!L)return w(null);const C=L.parser;i&&console.log("Loading finished "+u,v.guid);let D=0;if(L.parser.json.textures){let R=!1;for(const A of L.parser.json.textures){if(A!=null&&A.extensions){const M=A==null?void 0:A.extensions[ye];if(M!=null&&M.guid&&M.guid===v.guid){R=!0;break}}D++}if(R){let A=await C.getDependency("texture",D);return A&&O.assignLODInformation(s.url,A,a,t,void 0),i&&console.log('change "'+e.name+'" → "'+A.name+'"',u,D,A,g),e instanceof d.Texture&&(A=this.copySettings(e,A)),A&&(A.guid=v.guid),w(A)}else z&&console.warn("Could not find texture with guid",v.guid,L.parser.json)}if(D=0,L.parser.json.meshes){let R=!1;for(const A of L.parser.json.meshes){if(A!=null&&A.extensions){const M=A==null?void 0:A.extensions[ye];if(M!=null&&M.guid&&M.guid===v.guid){R=!0;break}}D++}if(R){const A=await C.getDependency("mesh",D);if(i&&console.log(`Loaded Mesh "${A.name}"`,u,D,A,g),A.isMesh===!0){const M=A.geometry;return O.assignLODInformation(s.url,M,a,t,0),w(M)}else{const M=new Array;for(let I=0;I<A.children.length;I++){const P=A.children[I];if(P.isMesh===!0){const E=P.geometry;O.assignLODInformation(s.url,E,a,t,I),M.push(E)}}return w(M)}}else z&&console.warn("Could not find mesh with guid",v.guid,L.parser.json)}return w(null)});return this.previouslyLoaded.set(g,_),y.use(_),await _}else if(e instanceof d.Texture){i&&console.log("Load texture from uri: "+u);const y=await new d.TextureLoader().loadAsync(u);return y?(y.guid=n.guid,y.flipY=!1,y.needsUpdate=!0,y.colorSpace=e.colorSpace,i&&console.log(n,y)):z&&console.warn("failed loading",u),y}}return null}static assignLODInformation(e,t,i,s,a){if(!t)return;t.userData||(t.userData={});const n=new _a(e,i,s,a);t.userData.LODS=n,"source"in t&&typeof t.source=="object"&&(t.source.LODS=n)}static getAssignedLODInformation(e){var t,i;return e?(t=e.userData)!=null&&t.LODS?e.userData.LODS:"source"in e&&((i=e.source)!=null&&i.LODS)?e.source.LODS:null:null}static copySettings(e,t){return t?(z==="verbose"&&console.debug(`Copy texture settings
|
|
3684
3684
|
`,e.uuid,`
|
|
@@ -3751,7 +3751,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,xe=new WeakMap,ui=new
|
|
|
3751
3751
|
border-radius: 100%;
|
|
3752
3752
|
transition: background-color .15s linear;
|
|
3753
3753
|
cursor: pointer;
|
|
3754
|
-
`,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class hc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=
|
|
3754
|
+
`,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class hc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=1024,shadowBias:a=5e-4,lightCount:n=8,size:c=4,frames:h=40,lightRadius:f=1,ambientWeight:p=.8,alphaTest:r=.98,displayDelayFrames:l=1,paused:u=!1}={}){this.params={enabled:!0,frames:h,lightRadius:f,ambientWeight:p,alphaTest:r,debugHelpers:!1,size:c,displayDelayFrames:Math.max(0,Math.floor(l)),paused:u},this.scene=t,this.renderer=e,this.buffer1Active=!1,this.dirLights=[],this.dirLightsHelpers=[],this.clearColor=new d.Color,this.clearAlpha=0,this.progress=0,this.discardMaterial=new fc,this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this._displaySuppressed=!1,this._displayDelayRemaining=0,this._displayRestoreOpacity=1,this.shadowMapHistory=[],this.isZUp=d.Object3D.DEFAULT_UP.z===1,this.progShadowGrp=new d.Group,this.progShadowGrp.name="progressive_shadow_assets",this.scene.add(this.progShadowGrp),this.lightOrigin=new d.Group,this.lightOrigin.name="light_origin",this.isZUp?this.lightOrigin.position.set(c,c,c*1.5):this.lightOrigin.position.set(c,c,c),this.progShadowGrp.add(this.lightOrigin),this.lightGroup=new d.Group,this.lightGroup.name="all_dir_lights",this.progShadowGrp.add(this.lightGroup);const g=Math.PI;for(let v=0;v<n;v++){const _=new d.DirectionalLight(16777215,g/n);_.name="dir_light_"+v,_.castShadow=!0,_.shadow.bias=a,_.shadow.camera.near=.1,_.shadow.camera.far=50,_.shadow.camera.right=c/2,_.shadow.camera.left=-c/2,_.shadow.camera.top=c/2,_.shadow.camera.bottom=-c/2,_.shadow.mapSize.width=s,_.shadow.mapSize.height=s,this.dirLights.push(_),this.lightGroup.add(_)}const y=/(Android|iPad|iPhone|iPod)/g.test(navigator==null?void 0:navigator.userAgent)?d.HalfFloatType:d.FloatType;this.progressiveLightMap1=new d.WebGLRenderTarget(i,i,{type:y}),this.progressiveLightMap2=new d.WebGLRenderTarget(i,i,{type:y}),this.progressiveLightMap1.texture.colorSpace=d.NoColorSpace,this.progressiveLightMap2.texture.colorSpace=d.NoColorSpace,this.shadowCatcherMaterial=new uc({map:this.progressiveLightMap2.texture,transparent:!0,opacity:1});const m=new d.PlaneGeometry(c,c);this.isZUp||m.rotateX(-Math.PI/2),this.shadowCatcherMesh=new d.Mesh(m,this.shadowCatcherMaterial),this.isZUp?this.shadowCatcherMesh.position.z=.001:this.shadowCatcherMesh.position.y=.001,this.shadowCatcherMesh.name="shadowCatcherMesh",this.shadowCatcherMesh.receiveShadow=!0,this.progShadowGrp.add(this.shadowCatcherMesh),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.rebuildObjectsToShowAncestors(),this.debugHelpersGroup=new d.Group,this.targetMat=new d.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:h},this.targetMat.onBeforeCompile=v=>{v.vertexShader=`varying vec2 vUv;
|
|
3755
3755
|
`+v.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const _=v.fragmentShader.indexOf("void main() {");v.fragmentShader=`varying vec2 vUv;
|
|
3756
3756
|
`+v.fragmentShader.slice(0,_)+`uniform sampler2D previousShadowMap;
|
|
3757
3757
|
uniform float averagingWindow;
|
|
@@ -3935,7 +3935,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3935
3935
|
// Combine
|
|
3936
3936
|
gl_FragColor = vec4(uColor, alpha * fade * uOpacity);
|
|
3937
3937
|
}
|
|
3938
|
-
`});super(s,a),this.position.z=-.02}}const yc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",xc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",wc="https://cdn2.seer-group.com/libs/fonts.type.json",bc=new ln.Font(wc);class rs{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof d.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof d.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof d.MeshStandardMaterial);if(this._props.target.material instanceof d.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var Kr=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))(Kr||{});const fr=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let nt,li=0,ns=0;const Ac=()=>{nt=void 0,li=0,ns=0},Tc=new d.MeshBasicMaterial({colorWrite:!1});class Sc{constructor(e){this.props=e,this.stats=new Dt,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new ge.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new Wr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new d.Group,this._raycaster=new d.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new pt,this.sound=new ka,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new _c(18,40),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:f}=this.renderer.domElement.getBoundingClientRect();this.offset.set(f,h),this.mousePos.set(c.clientX-f,c.clientY-h),this.mouseCoord.set((c.clientX-f)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{nt||typeof nt<"u"||(li===0&&(ns=performance.now()),li++,performance.now()-ns>66&&(li>5?nt=!0:nt=!1,nt?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Ac,2e3)))},this.debounceForkHeightChange=Ha(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var j;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(j=this._fitAnimation)==null||j.stop();const f=new d.Box3,p=new d.Box3,r=new d.Vector3,l=new d.Vector3,u=new d.Vector3,g=new d.Vector3,y=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||f.union(p))},m=U=>{var _s,ys;const Q=U.geometry,re=(_s=Q==null?void 0:Q.attributes)==null?void 0:_s.position;if(!re){y(U);return}const te=((ys=Q.morphAttributes)==null?void 0:ys.position)||[],vs=U.morphTargetInfluences||[],Zr=te.length>0&&vs.length>0;for(let Te=0;Te<re.count;Te++){if(r.set(re.getX(Te),re.getY(Te),re.getZ(Te)),Zr){l.set(0,0,0);let gi=0;for(let Ge=0;Ge<te.length;Ge++){const kt=vs[Ge]||0;kt&&(gi+=kt,u.set(te[Ge].getX(Te),te[Ge].getY(Te),te[Ge].getZ(Te)),Q.morphTargetsRelative,l.addScaledVector(u,kt))}Q.morphTargetsRelative?r.add(l):gi>0&&(r.multiplyScalar(1-gi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),f.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(Q=>{if(Q.visible){if(Q instanceof d.Mesh){m(Q);return}(Q.isPoint||Q.isLine)&&y(Q)}})}),f.isEmpty())return;const v=new d.Vector3;f.getCenter(v);const _=new d.Vector3;f.getSize(_);const x=v.clone();this._lastTarget.copy(x);let w;h?w=h.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=_.clone().multiplyScalar(.5),T=[new d.Vector3(b.x,b.y,b.z),new d.Vector3(b.x,b.y,-b.z),new d.Vector3(b.x,-b.y,b.z),new d.Vector3(b.x,-b.y,-b.z),new d.Vector3(-b.x,b.y,b.z),new d.Vector3(-b.x,b.y,-b.z),new d.Vector3(-b.x,-b.y,b.z),new d.Vector3(-b.x,-b.y,-b.z)],S=new d.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const L=new d.Vector3().crossVectors(w,S).normalize(),C=new d.Vector3().crossVectors(L,w).normalize();let D=0;T.forEach(U=>{const Q=U.dot(L),re=U.dot(C),te=Math.sqrt(Q*Q+re*re);D=Math.max(D,te)}),D=D/2+.4;const R=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(R/2)*this.camera.aspect),M=D/Math.tan(A/2),I=D/Math.tan(R/2),P=Math.max(M,I),E=v.clone().add(w.multiplyScalar(P)),B=this.camera.position.clone(),V=this.controls.target.clone();let G=500;const H=B.distanceTo(E)+V.distanceTo(x);H>.001&&(G=Math.min(1e3,Math.max(450,H*45))),this._animateCamera(B,E,V,x,G)},this.focusSlots=c=>{var C,D;if(this.amr.slots.forEach(R=>{R.focused=!1,R.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(R=>{R.show()}),this.shadowMode=!1,this._focusRestoreView){const R=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),M=this.controls.target.clone(),I=R.position.clone(),P=R.target.clone();let E=500;const B=A.distanceTo(I)+M.distanceTo(P);B>.001&&(E=Math.min(1e3,Math.max(450,B*45))),this._animateCamera(A,I,M,P,E,()=>{this.camera.up.copy(R.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(D=this._fitAnimation)==null||D.stop(),this.shadowMode=!0;const h=c.flatMap(R=>{if(R.show(),R.focused=!0,!R.parent)return[];const A=new d.Vector3;return R.parent.getWorldPosition(A),[A]});if(!h.length)return;const f=h.reduce((R,A)=>R.add(A),new d.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const R of h){const A=R.clone().sub(f),M=A.dot(r),I=Math.sqrt(Math.max(0,A.lengthSq()-M*M));I>l&&(l=I)}l=l+.4;const u=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(u/2)*this.camera.aspect),y=l/Math.tan(g/2),m=l/Math.tan(u/2),v=Math.max(y,m),_=f.clone(),x=f.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),T={t:0};let S=500;const L=w.distanceTo(x)+b.distanceTo(_);L>.001&&(S=Math.min(1e3,Math.max(450,L*45))),this._lastTarget=_.clone(),this._fitAnimation=new ci(T).to({t:1},S).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const R=T.t;this.camera.position.lerpVectors(w,x,R),this.controls.target.lerpVectors(b,_,R)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new d.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new d.Vector3),f=h.clone().multiplyScalar(.5),p=new d.Vector3(0,0,f.z);this._lastTarget.copy(p);let r=f.clone().sub(p);r.lengthSq()<1e-6&&(r=new d.Vector3(1,0,0));const l=r.clone().normalize(),u=h.clone().multiplyScalar(.5),g=[new d.Vector3(u.x,u.y,u.z),new d.Vector3(u.x,u.y,-u.z),new d.Vector3(u.x,-u.y,u.z),new d.Vector3(u.x,-u.y,-u.z),new d.Vector3(-u.x,u.y,u.z),new d.Vector3(-u.x,u.y,-u.z),new d.Vector3(-u.x,-u.y,u.z),new d.Vector3(-u.x,-u.y,-u.z)];let y=0;for(const A of g){const M=A.dot(l),I=Math.sqrt(Math.max(0,A.lengthSq()-M*M));I>y&&(y=I)}y=y*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),_=y/Math.tan(v/2),x=y/Math.tan(m/2),w=Math.max(_,x),b=f.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(h.x*2,5);const L=this.camera.position.clone(),C=this.controls.target.clone();let D=600;const R=L.distanceTo(S)+C.distanceTo(p);R>.001&&(D=Math.min(800,Math.max(650,R*45))),this._animateCamera(L,S,C,p,D,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,f=c.clientHeight;this.size.set(h,f),this.camera.aspect=h/f,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,f),this._updateCamera(),this.css2dRenderer.setSize(h,f),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,f),(r=this._jumpFlood)==null||r.setSize(h,f)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Tc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Pe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Pr(We,this.renderer),this._ground.visible=!1,this.controls=new an.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=fr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:kr()?.2:1,this._cameraPositionUI=new dc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=Ua();this.pathTracer=new ea(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new lc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new hc(this.renderer,this.scene,{size:8,lightCount:12,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.8}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new vc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new cc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new d.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new ws.HDRLoader().load(xc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:fr,this.sampleCount=0}get fpsAverage(){return Br(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof d.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new ws.HDRLoader().load(yc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new d.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let f=0;f<t;f++){const p=((i-h-1)*t+f)*4,r=(h*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new Xr({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){be(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await zr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,a,n){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new ci(c).to({t:1},a).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const f=c.t;this.controls.target.lerpVectors(i,s,f);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),u=r.length(),g=l.length(),y=u+(g-u)*f;let m;if(u>.001&&g>.001){const v=r.clone().normalize(),_=l.clone().normalize(),x=v.angleTo(_);if(x>.001){const w=new d.Vector3().crossVectors(v,_);if(w.lengthSq()>.001){w.normalize();const b=new d.Quaternion().setFromAxisAngle(w,x*f),T=v.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(y))}else m=p.clone().add(v.multiplyScalar(y))}else m=p.clone().add(v.multiplyScalar(y))}else m=e.clone().lerp(t,f);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3938
|
+
`});super(s,a),this.position.z=-.02}}const yc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",xc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",wc="https://cdn2.seer-group.com/libs/fonts.type.json",bc=new ln.Font(wc);class rs{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof d.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof d.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof d.MeshStandardMaterial);if(this._props.target.material instanceof d.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var Kr=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))(Kr||{});const fr=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let nt,li=0,ns=0;const Ac=()=>{nt=void 0,li=0,ns=0},Tc=new d.MeshBasicMaterial({colorWrite:!1});class Sc{constructor(e){this.props=e,this.stats=new Dt,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new ge.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new Wr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new d.Group,this._raycaster=new d.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new pt,this.sound=new ka,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new _c(18,40),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:f}=this.renderer.domElement.getBoundingClientRect();this.offset.set(f,h),this.mousePos.set(c.clientX-f,c.clientY-h),this.mouseCoord.set((c.clientX-f)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{nt||typeof nt<"u"||(li===0&&(ns=performance.now()),li++,performance.now()-ns>66&&(li>5?nt=!0:nt=!1,nt?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Ac,2e3)))},this.debounceForkHeightChange=Ha(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var j;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(j=this._fitAnimation)==null||j.stop();const f=new d.Box3,p=new d.Box3,r=new d.Vector3,l=new d.Vector3,u=new d.Vector3,g=new d.Vector3,y=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||f.union(p))},m=U=>{var _s,ys;const Q=U.geometry,re=(_s=Q==null?void 0:Q.attributes)==null?void 0:_s.position;if(!re){y(U);return}const te=((ys=Q.morphAttributes)==null?void 0:ys.position)||[],vs=U.morphTargetInfluences||[],Zr=te.length>0&&vs.length>0;for(let Te=0;Te<re.count;Te++){if(r.set(re.getX(Te),re.getY(Te),re.getZ(Te)),Zr){l.set(0,0,0);let gi=0;for(let Ge=0;Ge<te.length;Ge++){const kt=vs[Ge]||0;kt&&(gi+=kt,u.set(te[Ge].getX(Te),te[Ge].getY(Te),te[Ge].getZ(Te)),Q.morphTargetsRelative,l.addScaledVector(u,kt))}Q.morphTargetsRelative?r.add(l):gi>0&&(r.multiplyScalar(1-gi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),f.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(Q=>{if(Q.visible){if(Q instanceof d.Mesh){m(Q);return}(Q.isPoint||Q.isLine)&&y(Q)}})}),f.isEmpty())return;const v=new d.Vector3;f.getCenter(v);const _=new d.Vector3;f.getSize(_);const x=v.clone();this._lastTarget.copy(x);let w;h?w=h.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=_.clone().multiplyScalar(.5),T=[new d.Vector3(b.x,b.y,b.z),new d.Vector3(b.x,b.y,-b.z),new d.Vector3(b.x,-b.y,b.z),new d.Vector3(b.x,-b.y,-b.z),new d.Vector3(-b.x,b.y,b.z),new d.Vector3(-b.x,b.y,-b.z),new d.Vector3(-b.x,-b.y,b.z),new d.Vector3(-b.x,-b.y,-b.z)],S=new d.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const L=new d.Vector3().crossVectors(w,S).normalize(),C=new d.Vector3().crossVectors(L,w).normalize();let D=0;T.forEach(U=>{const Q=U.dot(L),re=U.dot(C),te=Math.sqrt(Q*Q+re*re);D=Math.max(D,te)}),D=D/2+.4;const R=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(R/2)*this.camera.aspect),M=D/Math.tan(A/2),I=D/Math.tan(R/2),P=Math.max(M,I),E=v.clone().add(w.multiplyScalar(P)),B=this.camera.position.clone(),V=this.controls.target.clone();let G=500;const H=B.distanceTo(E)+V.distanceTo(x);H>.001&&(G=Math.min(1e3,Math.max(450,H*45))),this._animateCamera(B,E,V,x,G)},this.focusSlots=c=>{var C,D;if(this.amr.slots.forEach(R=>{R.focused=!1,R.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(R=>{R.show()}),this.shadowMode=!1,this._focusRestoreView){const R=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),M=this.controls.target.clone(),I=R.position.clone(),P=R.target.clone();let E=500;const B=A.distanceTo(I)+M.distanceTo(P);B>.001&&(E=Math.min(1e3,Math.max(450,B*45))),this._animateCamera(A,I,M,P,E,()=>{this.camera.up.copy(R.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(D=this._fitAnimation)==null||D.stop(),this.shadowMode=!0;const h=c.flatMap(R=>{if(R.show(),R.focused=!0,!R.parent)return[];const A=new d.Vector3;return R.parent.getWorldPosition(A),[A]});if(!h.length)return;const f=h.reduce((R,A)=>R.add(A),new d.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const R of h){const A=R.clone().sub(f),M=A.dot(r),I=Math.sqrt(Math.max(0,A.lengthSq()-M*M));I>l&&(l=I)}l=l+.4;const u=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(u/2)*this.camera.aspect),y=l/Math.tan(g/2),m=l/Math.tan(u/2),v=Math.max(y,m),_=f.clone(),x=f.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),T={t:0};let S=500;const L=w.distanceTo(x)+b.distanceTo(_);L>.001&&(S=Math.min(1e3,Math.max(450,L*45))),this._lastTarget=_.clone(),this._fitAnimation=new ci(T).to({t:1},S).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const R=T.t;this.camera.position.lerpVectors(w,x,R),this.controls.target.lerpVectors(b,_,R)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new d.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new d.Vector3),f=h.clone().multiplyScalar(.5),p=new d.Vector3(0,0,f.z);this._lastTarget.copy(p);let r=f.clone().sub(p);r.lengthSq()<1e-6&&(r=new d.Vector3(1,0,0));const l=r.clone().normalize(),u=h.clone().multiplyScalar(.5),g=[new d.Vector3(u.x,u.y,u.z),new d.Vector3(u.x,u.y,-u.z),new d.Vector3(u.x,-u.y,u.z),new d.Vector3(u.x,-u.y,-u.z),new d.Vector3(-u.x,u.y,u.z),new d.Vector3(-u.x,u.y,-u.z),new d.Vector3(-u.x,-u.y,u.z),new d.Vector3(-u.x,-u.y,-u.z)];let y=0;for(const A of g){const M=A.dot(l),I=Math.sqrt(Math.max(0,A.lengthSq()-M*M));I>y&&(y=I)}y=y*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),_=y/Math.tan(v/2),x=y/Math.tan(m/2),w=Math.max(_,x),b=f.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(h.x*2,5);const L=this.camera.position.clone(),C=this.controls.target.clone();let D=600;const R=L.distanceTo(S)+C.distanceTo(p);R>.001&&(D=Math.min(800,Math.max(650,R*45))),this._animateCamera(L,S,C,p,D,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,f=c.clientHeight;this.size.set(h,f),this.camera.aspect=h/f,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,f),this._updateCamera(),this.css2dRenderer.setSize(h,f),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,f),(r=this._jumpFlood)==null||r.setSize(h,f)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Tc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Pe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Pr(We,this.renderer),this._ground.visible=!1,this.controls=new an.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=fr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:kr()?.2:1,this._cameraPositionUI=new dc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=Ua();this.pathTracer=new ea(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new lc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new hc(this.renderer,this.scene,{size:8,lightCount:6,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.75}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new vc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new cc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new d.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new ws.HDRLoader().load(xc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:fr,this.sampleCount=0}get fpsAverage(){return Br(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof d.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new ws.HDRLoader().load(yc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new d.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let f=0;f<t;f++){const p=((i-h-1)*t+f)*4,r=(h*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new Xr({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){be(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await zr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,a,n){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new ci(c).to({t:1},a).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const f=c.t;this.controls.target.lerpVectors(i,s,f);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),u=r.length(),g=l.length(),y=u+(g-u)*f;let m;if(u>.001&&g>.001){const v=r.clone().normalize(),_=l.clone().normalize(),x=v.angleTo(_);if(x>.001){const w=new d.Vector3().crossVectors(v,_);if(w.lengthSq()>.001){w.normalize();const b=new d.Quaternion().setFromAxisAngle(w,x*f),T=v.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(y))}else m=p.clone().add(v.multiplyScalar(y))}else m=p.clone().add(v.multiplyScalar(y))}else m=e.clone().lerp(t,f);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3939
3939
|
-webkit-user-select: none;
|
|
3940
3940
|
user-select: none;
|
|
3941
3941
|
touch-action: none;
|
|
@@ -3944,4 +3944,4 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3944
3944
|
[data-css2d-root="1"] [data-ui-type="mechanism"] {
|
|
3945
3945
|
z-index: 2147483647 !important;
|
|
3946
3946
|
}
|
|
3947
|
-
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,a,n,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(a=this._sciFiGrid.material)==null||a.dispose(),Pe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),be(this.scene),this.scene.clear()}}class Xr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,y,m,v,_,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((y=e==null?void 0:e.size)==null?void 0:y.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,f=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,n,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),u={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,f,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const S=this.readPixels(t,r,a,n);u[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(_=this.deps).onAfterCapture)==null||x.call(_)}return u}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,n=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,T=d.MathUtils.degToRad(b),S=Math.max(Math.tan(T/2),1e-4),L=Math.max(S*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),D=new d.Vector3().crossVectors(C,h).normalize();D.lengthSq()<1e-6&&D.set(1,0,0);const R=new d.Vector3().crossVectors(D,C).normalize(),A=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),I=Math.max(e.size.z*.5,1e-4),P=[new d.Vector3(-A,-M,-I),new d.Vector3(-A,-M,I),new d.Vector3(-A,M,-I),new d.Vector3(-A,M,I),new d.Vector3(A,-M,-I),new d.Vector3(A,-M,I),new d.Vector3(A,M,-I),new d.Vector3(A,M,I)];let E=0,B=-1/0;for(const H of P){const j=D.dot(H),U=R.dot(H),Q=C.dot(H);B=Math.max(B,Q);const re=Q+Math.abs(j)/L,te=Q+Math.abs(U)/S;E=Math.max(E,re,te)}E=Math.max(E,B+.1);const V=E*(1+s);let G=1/0;for(const H of P){const j=C.dot(H),U=V-j;U>.001&&(G=Math.min(G,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(G)?G*.5:V*.1),w.far=Math.max(w.near+1,V+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(V)),w.up.copy(R),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,u=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),y=Math.max(r[t.plane.depth]*.5,.01);let m=u*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const _=y*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(_));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=_*4,p.zoom=1,p.position.copy(x),p.up.copy(h),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new d.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(n,s.z),r=f*.5+h*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),f=h.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const u=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(u,u+i*4),g)}return c.putImageData(h,0,0),n.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Mc="shop-components",Cc="0.4.21",Rc="Shop components",Lc="dist/shop-components.umd.js",Ic="dist/shop-components.mjs",Dc="dist/main.d.ts",Pc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build","build:web":"BUILD_WEB=1 vite build --outDir dist/web --emptyOutDir",v:"auto-changelog -p && git add CHANGELOG.md"},Fc=["dist","package.json"],Ec=[],Bc="machengda<machengda@seer-group.com>",kc="ISC",Oc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},zc={"string-width":"4.2.3"},Vc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.182.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"0.182.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},Uc={name:Mc,version:Cc,description:Rc,main:Lc,module:Ic,types:Dc,scripts:Pc,files:Fc,keywords:Ec,author:Bc,license:kc,devDependencies:Oc,resolutions:zc,dependencies:Vc};function dr(){const o="Nebula Engin",e=Uc.version,t=`%c ${o} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const pr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[pr]||(o[pr]=!0,dr())}catch{dr()}exports.Amr=Wr;exports.Logo=Yi;exports.SGLBLoader=Et;exports.SLOT_EVENTS=X;exports.Scene3D=Sc;exports.Skin=rs;exports.Slot=Qi;exports.SlotState=Kr;exports.TriViewCapture=Xr;exports.arrayBufferToUrl=qi;exports.calculateArrayAverage=Br;exports.calculateFocalLength=Ea;exports.createSGLBFile=ja;exports.downloadBlob=Fa;exports.dracoExporter=qa;exports.font=bc;exports.gltfExporter=zr;exports.gltfLoader=We;exports.imageBitmapToUrl=ji;exports.isAppleDevice=kr;exports.textureLoader=ds;
|
|
3947
|
+
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,a,n,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(a=this._sciFiGrid.material)==null||a.dispose(),Pe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),be(this.scene),this.scene.clear()}}class Xr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,y,m,v,_,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((y=e==null?void 0:e.size)==null?void 0:y.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,f=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,n,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),u={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,f,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const S=this.readPixels(t,r,a,n);u[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(_=this.deps).onAfterCapture)==null||x.call(_)}return u}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,n=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,T=d.MathUtils.degToRad(b),S=Math.max(Math.tan(T/2),1e-4),L=Math.max(S*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),D=new d.Vector3().crossVectors(C,h).normalize();D.lengthSq()<1e-6&&D.set(1,0,0);const R=new d.Vector3().crossVectors(D,C).normalize(),A=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),I=Math.max(e.size.z*.5,1e-4),P=[new d.Vector3(-A,-M,-I),new d.Vector3(-A,-M,I),new d.Vector3(-A,M,-I),new d.Vector3(-A,M,I),new d.Vector3(A,-M,-I),new d.Vector3(A,-M,I),new d.Vector3(A,M,-I),new d.Vector3(A,M,I)];let E=0,B=-1/0;for(const H of P){const j=D.dot(H),U=R.dot(H),Q=C.dot(H);B=Math.max(B,Q);const re=Q+Math.abs(j)/L,te=Q+Math.abs(U)/S;E=Math.max(E,re,te)}E=Math.max(E,B+.1);const V=E*(1+s);let G=1/0;for(const H of P){const j=C.dot(H),U=V-j;U>.001&&(G=Math.min(G,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(G)?G*.5:V*.1),w.far=Math.max(w.near+1,V+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(V)),w.up.copy(R),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,u=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),y=Math.max(r[t.plane.depth]*.5,.01);let m=u*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const _=y*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(_));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=_*4,p.zoom=1,p.position.copy(x),p.up.copy(h),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new d.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(n,s.z),r=f*.5+h*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),f=h.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const u=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(u,u+i*4),g)}return c.putImageData(h,0,0),n.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Mc="shop-components",Cc="0.4.23",Rc="Shop components",Lc="dist/shop-components.umd.js",Ic="dist/shop-components.mjs",Dc="dist/main.d.ts",Pc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build","build:web":"BUILD_WEB=1 vite build --outDir dist/web --emptyOutDir",v:"auto-changelog -p && git add CHANGELOG.md"},Fc=["dist","package.json"],Ec=[],Bc="machengda<machengda@seer-group.com>",kc="ISC",Oc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3",tweakpane:"^4.0.3","@tweakpane/core":"^2.0.3",stylus:"^0.63.0"},zc={"string-width":"4.2.3"},Vc={three:"0.182.0"},Uc={"@tweenjs/tween.js":"^23.1.2","@types/howler":"^2.2.11","@types/three":"0.182.0",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1"},Wc={name:Mc,version:Cc,description:Rc,main:Lc,module:Ic,types:Dc,scripts:Pc,files:Fc,keywords:Ec,author:Bc,license:kc,devDependencies:Oc,resolutions:zc,peerDependencies:Vc,dependencies:Uc};function dr(){const o="Nebula Engin",e=Wc.version,t=`%c ${o} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const pr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[pr]||(o[pr]=!0,dr())}catch{dr()}exports.Amr=Wr;exports.Logo=Yi;exports.SGLBLoader=Et;exports.SLOT_EVENTS=X;exports.Scene3D=Sc;exports.Skin=rs;exports.Slot=Qi;exports.SlotState=Kr;exports.TriViewCapture=Xr;exports.arrayBufferToUrl=qi;exports.calculateArrayAverage=Br;exports.calculateFocalLength=Ea;exports.createSGLBFile=ja;exports.downloadBlob=Fa;exports.dracoExporter=qa;exports.font=bc;exports.gltfExporter=zr;exports.gltfLoader=We;exports.imageBitmapToUrl=ji;exports.isAppleDevice=kr;exports.textureLoader=ds;
|
package/dist/shop-components.mjs
CHANGED
|
@@ -5656,7 +5656,7 @@ class js {
|
|
|
5656
5656
|
});
|
|
5657
5657
|
}
|
|
5658
5658
|
static async createWorker(e) {
|
|
5659
|
-
const t = new Worker(new URL("" + new URL("assets/loader.worker-
|
|
5659
|
+
const t = new Worker(new URL("" + new URL("assets/loader.worker-46d0lFWx.js", import.meta.url).href, import.meta.url), {
|
|
5660
5660
|
type: "module"
|
|
5661
5661
|
});
|
|
5662
5662
|
return new js(t, e);
|
|
@@ -7466,7 +7466,7 @@ $t.Panel = function(o, e, t) {
|
|
|
7466
7466
|
}
|
|
7467
7467
|
};
|
|
7468
7468
|
};
|
|
7469
|
-
function
|
|
7469
|
+
function Au(o, e) {
|
|
7470
7470
|
const t = URL.createObjectURL(o), i = document.createElement("a");
|
|
7471
7471
|
i.href = t, i.download = e, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(t);
|
|
7472
7472
|
}
|
|
@@ -7485,7 +7485,7 @@ function Fr(o) {
|
|
|
7485
7485
|
const t = e.getContext("2d");
|
|
7486
7486
|
return e.width = o.width, e.height = o.height, t ? (t.drawImage(o, 0, 0), e.toDataURL("image/png", 0.75)) : void 0;
|
|
7487
7487
|
}
|
|
7488
|
-
function
|
|
7488
|
+
function Tu(o, e = 43) {
|
|
7489
7489
|
const t = o * Math.PI / 180;
|
|
7490
7490
|
return e / (2 * Math.tan(t / 2));
|
|
7491
7491
|
}
|
|
@@ -8869,8 +8869,8 @@ ji.setDecoderConfig({ type: "wasm" });
|
|
|
8869
8869
|
ji.setDecoderPath(Rt.endsWith("/") ? Rt : `${Rt}/`);
|
|
8870
8870
|
ji.preload();
|
|
8871
8871
|
Et.setDRACOLoader(ji);
|
|
8872
|
-
const
|
|
8873
|
-
function
|
|
8872
|
+
const Mu = new bo(), Br = [115, 103, 108, 98];
|
|
8873
|
+
function Cu(o, e, t) {
|
|
8874
8874
|
const i = JSON.stringify(e), s = new TextEncoder().encode(i), a = new Uint8Array([115, 103, 108, 98]), n = new Uint8Array(2);
|
|
8875
8875
|
n[0] = t >> 8, n[1] = t & 255;
|
|
8876
8876
|
const c = new Uint8Array(4);
|
|
@@ -12793,13 +12793,13 @@ class Th {
|
|
|
12793
12793
|
}
|
|
12794
12794
|
constructor(e, t, {
|
|
12795
12795
|
resolution: i = 1024,
|
|
12796
|
-
shadowMapRes: s =
|
|
12797
|
-
shadowBias: a =
|
|
12796
|
+
shadowMapRes: s = 1024,
|
|
12797
|
+
shadowBias: a = 5e-4,
|
|
12798
12798
|
lightCount: n = 8,
|
|
12799
12799
|
size: c = 4,
|
|
12800
12800
|
frames: h = 40,
|
|
12801
|
-
lightRadius: f =
|
|
12802
|
-
ambientWeight: d = 0.
|
|
12801
|
+
lightRadius: f = 1,
|
|
12802
|
+
ambientWeight: d = 0.8,
|
|
12803
12803
|
alphaTest: r = 0.98,
|
|
12804
12804
|
displayDelayFrames: l = 1,
|
|
12805
12805
|
paused: u = !1
|
|
@@ -13557,7 +13557,7 @@ class Ph extends Z {
|
|
|
13557
13557
|
super(s, a), this.position.z = -0.02;
|
|
13558
13558
|
}
|
|
13559
13559
|
}
|
|
13560
|
-
const Eh = "https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr", Fh = "https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr", kh = "https://cdn2.seer-group.com/libs/fonts.type.json",
|
|
13560
|
+
const Eh = "https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr", Fh = "https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr", kh = "https://cdn2.seer-group.com/libs/fonts.type.json", Iu = new yo(kh);
|
|
13561
13561
|
class tn {
|
|
13562
13562
|
constructor(e) {
|
|
13563
13563
|
var i;
|
|
@@ -13599,7 +13599,7 @@ let St, ki = 0, Us = 0;
|
|
|
13599
13599
|
const Oh = () => {
|
|
13600
13600
|
St = void 0, ki = 0, Us = 0;
|
|
13601
13601
|
}, zh = new ri({ colorWrite: !1 });
|
|
13602
|
-
class
|
|
13602
|
+
class Ru {
|
|
13603
13603
|
constructor(e) {
|
|
13604
13604
|
this.props = e, this.stats = new $t(), this.scene = new ws(), this.overlayScene = new ws(), this.renderer = new uo({
|
|
13605
13605
|
antialias: !0,
|
|
@@ -13869,10 +13869,10 @@ class Iu {
|
|
|
13869
13869
|
this.sampleCount = 0, n(), this._uiHiddenTime = this._clock.getElapsedTime(), this.orthographicCamera.position.copy(this.camera.position), this.orthographicCamera.lookAt(this.controls.target), this.usePathTracing && (this.pathTracer.pausePathTracing = !1, (c = this.pathTracer) == null || c.updateCamera()), this._updateCamera(), !(Math.abs(this.camera.position.x) < 1e-3 || Math.abs(this.camera.position.y) < 1e-3) && (this._axisMoving || (this.mainCamera = this.camera, this.usePathTracing && this.generateBVH().then()));
|
|
13870
13870
|
}), this._mainCamera = this.camera, this._progressShadow = new Th(this.renderer, this.scene, {
|
|
13871
13871
|
size: 8,
|
|
13872
|
-
lightCount:
|
|
13872
|
+
lightCount: 6,
|
|
13873
13873
|
frames: e.isMobile ? 20 : 60,
|
|
13874
13874
|
lightRadius: 2,
|
|
13875
|
-
ambientWeight: 0.
|
|
13875
|
+
ambientWeight: 0.75
|
|
13876
13876
|
}), this._progressShadow.lightOrigin.position.set(3, 2.5, 0.6), this._progressShadow.visible = !1, this._container.add(this.amr), this.scene.add(this._container), this.ticker(0), this._loadEnv(), this._initEvents(), this.scene.add(this._cameraPositionUI), this._ground.rotateX(-Math.PI / 2), this.scene.add(this._ground), this._jumpFlood = new Dh(this.renderer, this.scene, this.camera, {
|
|
13877
13877
|
thickness: 4,
|
|
13878
13878
|
color: "#fff"
|
|
@@ -14324,7 +14324,7 @@ class Uh {
|
|
|
14324
14324
|
return this.canvas || (this.canvas = document.createElement("canvas")), (this.canvas.width !== e || this.canvas.height !== t) && (this.canvas.width = e, this.canvas.height = t), this.canvas;
|
|
14325
14325
|
}
|
|
14326
14326
|
}
|
|
14327
|
-
const Hh = "shop-components", Wh = "0.4.
|
|
14327
|
+
const Hh = "shop-components", Wh = "0.4.23", Vh = "Shop components", Nh = "dist/shop-components.umd.js", Gh = "dist/shop-components.mjs", qh = "dist/main.d.ts", jh = {
|
|
14328
14328
|
dts: "tsc --emitDeclarationOnly & tsc & storybook build -o dist",
|
|
14329
14329
|
dev: "vite dev",
|
|
14330
14330
|
build: "vite build",
|
|
@@ -14337,28 +14337,25 @@ const Hh = "shop-components", Wh = "0.4.21", Vh = "Shop components", Nh = "dist/
|
|
|
14337
14337
|
"@needle-tools/gltf-progressive": "^3.3.5",
|
|
14338
14338
|
"auto-changelog": "^2.4.0",
|
|
14339
14339
|
vite: "5.1.6",
|
|
14340
|
-
"vite-plugin-dts": "^3.7.3"
|
|
14340
|
+
"vite-plugin-dts": "^3.7.3",
|
|
14341
|
+
tweakpane: "^4.0.3",
|
|
14342
|
+
"@tweakpane/core": "^2.0.3",
|
|
14343
|
+
stylus: "^0.63.0"
|
|
14341
14344
|
}, Jh = {
|
|
14342
14345
|
"string-width": "4.2.3"
|
|
14343
14346
|
}, $h = {
|
|
14344
|
-
|
|
14345
|
-
|
|
14347
|
+
three: "0.182.0"
|
|
14348
|
+
}, eu = {
|
|
14346
14349
|
"@tweenjs/tween.js": "^23.1.2",
|
|
14347
|
-
"@types/bezier-js": "^4.1.1",
|
|
14348
14350
|
"@types/howler": "^2.2.11",
|
|
14349
14351
|
"@types/three": "0.182.0",
|
|
14350
|
-
"bezier-js": "^6.1.4",
|
|
14351
14352
|
eventemitter3: "^5.0.1",
|
|
14352
14353
|
howler: "^2.2.4",
|
|
14353
14354
|
"stats-fps.js": "0.0.6",
|
|
14354
|
-
stylus: "^0.63.0",
|
|
14355
|
-
terser: "^5.44.0",
|
|
14356
|
-
three: "0.182.0",
|
|
14357
14355
|
"three-gpu-pathtracer": "^0.0.23",
|
|
14358
14356
|
"three-mesh-bvh": "^0.7.5",
|
|
14359
|
-
"troika-three-text": "^0.49.1"
|
|
14360
|
-
|
|
14361
|
-
}, eu = {
|
|
14357
|
+
"troika-three-text": "^0.49.1"
|
|
14358
|
+
}, tu = {
|
|
14362
14359
|
name: Hh,
|
|
14363
14360
|
version: Wh,
|
|
14364
14361
|
description: Vh,
|
|
@@ -14372,10 +14369,11 @@ const Hh = "shop-components", Wh = "0.4.21", Vh = "Shop components", Nh = "dist/
|
|
|
14372
14369
|
license: Xh,
|
|
14373
14370
|
devDependencies: Zh,
|
|
14374
14371
|
resolutions: Jh,
|
|
14375
|
-
|
|
14372
|
+
peerDependencies: $h,
|
|
14373
|
+
dependencies: eu
|
|
14376
14374
|
};
|
|
14377
14375
|
function rn() {
|
|
14378
|
-
const o = "Nebula Engin", e =
|
|
14376
|
+
const o = "Nebula Engin", e = tu.version, t = `%c ${o} %c v${e} `;
|
|
14379
14377
|
console.log(t, "background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;", "background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;");
|
|
14380
14378
|
}
|
|
14381
14379
|
const nn = "__SHOP_COMPONENTS_BANNER_PRINTED__";
|
|
@@ -14390,18 +14388,18 @@ export {
|
|
|
14390
14388
|
Vr as Logo,
|
|
14391
14389
|
Ui as SGLBLoader,
|
|
14392
14390
|
ie as SLOT_EVENTS,
|
|
14393
|
-
|
|
14391
|
+
Ru as Scene3D,
|
|
14394
14392
|
tn as Skin,
|
|
14395
14393
|
Ur as Slot,
|
|
14396
14394
|
Bh as SlotState,
|
|
14397
14395
|
Uh as TriViewCapture,
|
|
14398
14396
|
Er as arrayBufferToUrl,
|
|
14399
14397
|
Ql as calculateArrayAverage,
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14398
|
+
Tu as calculateFocalLength,
|
|
14399
|
+
Cu as createSGLBFile,
|
|
14400
|
+
Au as downloadBlob,
|
|
14401
|
+
Mu as dracoExporter,
|
|
14402
|
+
Iu as font,
|
|
14405
14403
|
nc as gltfExporter,
|
|
14406
14404
|
Et as gltfLoader,
|
|
14407
14405
|
Fr as imageBitmapToUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shop-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.23",
|
|
4
4
|
"description": "Shop components",
|
|
5
5
|
"main": "dist/shop-components.umd.js",
|
|
6
6
|
"module": "dist/shop-components.mjs",
|
|
@@ -23,28 +23,26 @@
|
|
|
23
23
|
"@needle-tools/gltf-progressive": "^3.3.5",
|
|
24
24
|
"auto-changelog": "^2.4.0",
|
|
25
25
|
"vite": "5.1.6",
|
|
26
|
-
"vite-plugin-dts": "^3.7.3"
|
|
26
|
+
"vite-plugin-dts": "^3.7.3",
|
|
27
|
+
"tweakpane": "^4.0.3",
|
|
28
|
+
"@tweakpane/core": "^2.0.3",
|
|
29
|
+
"stylus": "^0.63.0"
|
|
27
30
|
},
|
|
28
31
|
"resolutions": {
|
|
29
32
|
"string-width": "4.2.3"
|
|
30
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"three": "0.182.0"
|
|
36
|
+
},
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@nodetoy/three-nodetoy": "^0.1.36",
|
|
33
|
-
"@tweakpane/core": "^2.0.3",
|
|
34
38
|
"@tweenjs/tween.js": "^23.1.2",
|
|
35
|
-
"@types/bezier-js": "^4.1.1",
|
|
36
39
|
"@types/howler": "^2.2.11",
|
|
37
40
|
"@types/three": "0.182.0",
|
|
38
|
-
"bezier-js": "^6.1.4",
|
|
39
41
|
"eventemitter3": "^5.0.1",
|
|
40
42
|
"howler": "^2.2.4",
|
|
41
43
|
"stats-fps.js": "0.0.6",
|
|
42
|
-
"stylus": "^0.63.0",
|
|
43
|
-
"terser": "^5.44.0",
|
|
44
|
-
"three": "0.182.0",
|
|
45
44
|
"three-gpu-pathtracer": "^0.0.23",
|
|
46
45
|
"three-mesh-bvh": "^0.7.5",
|
|
47
|
-
"troika-three-text": "^0.49.1"
|
|
48
|
-
"tweakpane": "^4.0.3"
|
|
46
|
+
"troika-three-text": "^0.49.1"
|
|
49
47
|
}
|
|
50
48
|
}
|