softbox 4.21.0 → 4.22.0
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.
- package/README.md +12 -3
- package/dist/{ThreePathTracingService-Dze7maGx.js → ThreePathTracingService-CcWLjj2l.js} +312 -313
- package/dist/{ThreePathTracingService-CMw8SvGp.cjs → ThreePathTracingService-Io1vC_FO.cjs} +4 -4
- package/dist/index.d.cts +49 -12
- package/dist/index.d.ts +49 -12
- package/dist/simple-viewer.cjs +95 -3
- package/dist/simple-viewer.es.js +1791 -1565
- package/dist/{unwrap-DdgS2iXe.js → smoothstep-DR5B0_eF.js} +47 -41
- package/dist/{unwrap-CuSMMFPQ.cjs → smoothstep-DUhHZEuB.cjs} +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./
|
|
1
|
+
const e=require("./smoothstep-DUhHZEuB.cjs"),t=require("./Pass-D0vYi-gB.cjs");let n=require("three");n=e.P(n,1);function r(e){switch(e){case 1:return`R`;case 2:return`RG`;case 3:return`RGBA`;case 4:return`RGBA`}throw Error()}function i(e){switch(e){case 1:return n.RedFormat;case 2:return n.RGFormat;case 3:return n.RGBAFormat;case 4:return n.RGBAFormat}}function a(e){switch(e){case 1:return n.RedIntegerFormat;case 2:return n.RGIntegerFormat;case 3:return n.RGBAIntegerFormat;case 4:return n.RGBAIntegerFormat}}var o=class extends n.DataTexture{constructor(){super(),this.minFilter=n.NearestFilter,this.magFilter=n.NearestFilter,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){let t=this.overrideItemSize,o=e.itemSize,s=e.count;if(t!==null){if(o*s%t!==0)throw Error(`VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.`);e.itemSize=t,e.count=s*o/t}let c=e.itemSize,l=e.count,u=e.normalized,d=e.array.constructor,f=d.BYTES_PER_ELEMENT,p=this._forcedType,m=c;if(p===null)switch(d){case Float32Array:p=n.FloatType;break;case Uint8Array:case Uint16Array:case Uint32Array:p=n.UnsignedIntType;break;case Int8Array:case Int16Array:case Int32Array:p=n.IntType;break}let h,g,_,v,y=r(c);switch(p){case n.FloatType:_=1,g=i(c),u&&f===1?(v=d,y+=`8`,d===Uint8Array?h=n.UnsignedByteType:(h=n.ByteType,y+=`_SNORM`)):(v=Float32Array,y+=`32F`,h=n.FloatType);break;case n.IntType:y+=f*8+`I`,_=u?2**(d.BYTES_PER_ELEMENT*8-1):1,g=a(c),f===1?(v=Int8Array,h=n.ByteType):f===2?(v=Int16Array,h=n.ShortType):(v=Int32Array,h=n.IntType);break;case n.UnsignedIntType:y+=f*8+`UI`,_=u?2**(d.BYTES_PER_ELEMENT*8-1):1,g=a(c),f===1?(v=Uint8Array,h=n.UnsignedByteType):f===2?(v=Uint16Array,h=n.UnsignedShortType):(v=Uint32Array,h=n.UnsignedIntType);break}m===3&&(g===n.RGBAFormat||g===n.RGBAIntegerFormat)&&(m=4);let b=Math.ceil(Math.sqrt(l))||1,x=m*b*b,S=new v(x),C=e.normalized;e.normalized=!1;for(let t=0;t<l;t++){let n=m*t;S[n]=e.getX(t)/_,c>=2&&(S[n+1]=e.getY(t)/_),c>=3&&(S[n+2]=e.getZ(t)/_,m===4&&(S[n+3]=1)),c>=4&&(S[n+3]=e.getW(t)/_)}e.normalized=C,this.internalFormat=y,this.format=g,this.type=h,this.image.width=b,this.image.height=b,this.image.data=S,this.needsUpdate=!0,this.dispose(),e.itemSize=o,e.count=s}},s=class extends o{constructor(){super(),this._forcedType=n.UnsignedIntType}},c=class extends o{constructor(){super(),this._forcedType=n.FloatType}},l=class{constructor(){this.index=new s,this.position=new c,this.bvhBounds=new n.DataTexture,this.bvhContents=new n.DataTexture,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(t){let{geometry:r}=t;if(d(t,this.bvhBounds,this.bvhContents),this.position.updateFrom(r.attributes.position),t.indirect){let i=t._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(r.index)this._cachedIndexAttr=r.index.clone();else{let t=e.b(e.x(r));this._cachedIndexAttr=new n.BufferAttribute(t,1,!1)}u(r,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(r.index)}dispose(){let{index:e,position:t,bvhBounds:n,bvhContents:r}=this;e&&e.dispose(),t&&t.dispose(),n&&n.dispose(),r&&r.dispose()}};function u(e,t,n){let r=n.array,i=e.index?e.index.array:null;for(let e=0,n=t.length;e<n;e++){let n=3*e,a=3*t[e];for(let e=0;e<3;e++)r[n+e]=i?i[a+e]:a+e}}function d(t,r,i){let a=t._roots;if(a.length!==1)throw Error(`MeshBVHUniformStruct: Multi-root BVHs not supported.`);let o=a[0],s=new Uint16Array(o),c=new Uint32Array(o),l=new Float32Array(o),u=o.byteLength/32,d=2*Math.ceil(Math.sqrt(u/2)),f=new Float32Array(4*d*d),p=Math.ceil(Math.sqrt(u)),m=new Uint32Array(2*p*p);for(let t=0;t<u;t++){let n=t*32/4,r=n*2,i=e.S(n);for(let e=0;e<3;e++)f[8*t+0+e]=l[i+0+e],f[8*t+4+e]=l[i+3+e];if(e.w(r,s)){let i=e.C(r,s),a=e.T(n,c),o=e.D|i;m[t*2+0]=o,m[t*2+1]=a}else{let r=c[n+6],i=e.E(n,c);m[t*2+0]=i,m[t*2+1]=r}}r.image.data=f,r.image.width=d,r.image.height=d,r.format=n.RGBAFormat,r.type=n.FloatType,r.internalFormat=`RGBA32F`,r.minFilter=n.NearestFilter,r.magFilter=n.NearestFilter,r.generateMipmaps=!1,r.needsUpdate=!0,r.dispose(),i.image.data=m,i.image.width=p,i.image.height=p,i.format=n.RGIntegerFormat,i.type=n.UnsignedIntType,i.internalFormat=`RG32UI`,i.minFilter=n.NearestFilter,i.magFilter=n.NearestFilter,i.generateMipmaps=!1,i.needsUpdate=!0,i.dispose()}var f=`
|
|
2
2
|
|
|
3
3
|
// A stack of uint32 indices can can store the indices for
|
|
4
4
|
// a perfectly balanced tree with a depth up to 31. Lower stack
|
|
@@ -294,7 +294,7 @@ struct BVH {
|
|
|
294
294
|
usampler2D bvhContents;
|
|
295
295
|
|
|
296
296
|
};
|
|
297
|
-
`;function h(e,t,n=0){if(e.isInterleavedBufferAttribute){let r=e.itemSize;for(let i=0,a=e.count;i<a;i++){let a=i+n;t.setX(a,e.getX(i)),r>=2&&t.setY(a,e.getY(i)),r>=3&&t.setZ(a,e.getZ(i)),r>=4&&t.setW(a,e.getW(i))}}else{let r=t.array,i=r.constructor,a=r.BYTES_PER_ELEMENT*e.itemSize*n;new i(r.buffer,a,e.array.length).set(e.array)}}function g(e,t=null){let r=e.array.constructor,i=e.normalized,a=e.itemSize;return new n.BufferAttribute(new r(a*(t===null?e.count:t)),a,i)}function _(e,t){if(!e&&!t)return!0;if(!!e!=!!t)return!1;let n=e.count===t.count,r=e.normalized===t.normalized,i=e.array.constructor===t.array.constructor,a=e.itemSize===t.itemSize;return!(!n||!r||!i||!a)}function v(e){let t=e[0].index!==null,n=new Set(Object.keys(e[0].attributes));if(!e[0].getAttribute(`position`))throw Error(`StaticGeometryGenerator: position attribute is required.`);for(let r=0;r<e.length;++r){let i=e[r],a=0;if(t!==(i.index!==null))throw Error(`StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`);for(let e in i.attributes){if(!n.has(e))throw Error(`StaticGeometryGenerator: All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`);a++}if(a!==n.size)throw Error(`StaticGeometryGenerator: All geometries must have the same number of attributes.`)}}function y(e){let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].getIndex().count;return t}function b(e){let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].getAttribute(`position`).count;return t}function x(e,t,n){e.index&&e.index.count!==t&&e.setIndex(null);let r=e.attributes;for(let t in r)r[t].count!==n&&e.deleteAttribute(t)}function S(e,t={},r=new n.BufferGeometry){let{useGroups:i=!1,forceUpdate:a=!1,skipAssigningAttributes:o=[],overwriteIndex:s=!0}=t;v(e);let c=e[0].index!==null,l=c?y(e):-1,u=b(e);if(x(r,l,u),i){let t=0;for(let n=0,i=e.length;n<i;n++){let i=e[n],a;a=c?i.getIndex().count:i.getAttribute(`position`).count,r.addGroup(t,a,n),t+=a}}if(c){let t=!1;if(r.index||(r.setIndex(new n.BufferAttribute(new Uint32Array(l),1,!1)),t=!0),t||s){let n=0,i=0,s=r.getIndex();for(let r=0,c=e.length;r<c;r++){let c=e[r],l=c.getIndex();if(!(!a&&!t&&o[r]))for(let e=0;e<l.count;++e)s.setX(n+e,l.getX(e)+i);n+=l.count,i+=c.getAttribute(`position`).count}}}let d=Object.keys(e[0].attributes);for(let t=0,n=d.length;t<n;t++){let n=!1,i=d[t];if(!r.getAttribute(i)){let t=e[0].getAttribute(i);r.setAttribute(i,g(t,u)),n=!0}let s=0,c=r.getAttribute(i);for(let t=0,r=e.length;t<r;t++){let r=e[t],l=!a&&!n&&o[t],u=r.getAttribute(i);l||h(u,c,s),s+=u.count}}}function C(e,t,r){let i=e.index,a=e.attributes.position.count,o=i?i.count:a,s=e.groups;s.length===0&&(s=[{count:o,start:0,materialIndex:0}]);let c=e.getAttribute(`materialIndex`);if(!c||c.count!==a){let t;t=r.length<=255?new Uint8Array(a):new Uint16Array(a),c=new n.BufferAttribute(t,1,!1),e.deleteAttribute(`materialIndex`),e.setAttribute(`materialIndex`,c)}let l=c.array;for(let e=0;e<s.length;e++){let n=s[e],a=n.start,c=n.count,u=Math.min(c,o-a),d=Array.isArray(t)?t[n.materialIndex]:t,f=r.indexOf(d);for(let e=0;e<u;e++){let t=a+e;i&&(t=i.getX(t)),l[t]=f}}}function w(e,t){if(!e.index){let t=e.attributes.position.count,n=Array(t);for(let e=0;e<t;e++)n[e]=e;e.setIndex(n)}if(!e.attributes.normal&&t&&t.includes(`normal`)&&e.computeVertexNormals(),!e.attributes.uv&&t&&t.includes(`uv`)){let t=e.attributes.position.count;e.setAttribute(`uv`,new n.BufferAttribute(new Float32Array(t*2),2,!1))}if(!e.attributes.uv2&&t&&t.includes(`uv2`)){let t=e.attributes.position.count;e.setAttribute(`uv2`,new n.BufferAttribute(new Float32Array(t*2),2,!1))}if(!e.attributes.tangent&&t&&t.includes(`tangent`))if(e.attributes.uv&&e.attributes.normal)e.computeTangents();else{let t=e.attributes.position.count;e.setAttribute(`tangent`,new n.BufferAttribute(new Float32Array(t*4),4,!1))}if(!e.attributes.color&&t&&t.includes(`color`)){let t=e.attributes.position.count,r=new Float32Array(t*4);r.fill(1),e.setAttribute(`color`,new n.BufferAttribute(r,4))}}function T(e){let t=0;if(e.byteLength!==0){let n=new Uint8Array(e);for(let r=0;r<e.byteLength;r++){let e=n[r];t=(t<<5)-t+e,t|=0}}return t}function E(e){let t=e.uuid,n=Object.values(e.attributes);e.index&&(n.push(e.index),t+=`index|${e.index.version}`);let r=Object.keys(n).sort();for(let e of r){let r=n[e];t+=`${e}_${r.version}|`}return t}function D(e){let t=e.skeleton;return t?(t.boneTexture||t.computeBoneTexture(),`${T(t.boneTexture.image.data.buffer)}_${t.boneTexture.uuid}`):null}var O=class{constructor(e=null){this.matrixWorld=new n.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){let t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=E(t),this.primitiveCount=n,this.skeletonHash=D(e)}didChange(e){let t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===E(t)&&this.skeletonHash===D(e)&&this.primitiveCount===n)}},k=new n.Vector3,A=new n.Vector3,j=new n.Vector3,M=new n.Vector4,N=new n.Vector3,P=new n.Vector3,ee=new n.Vector4,te=new n.Vector4,F=new n.Matrix4,I=new n.Matrix4;function ne(e,t,n){let r=e.skeleton,i=e.geometry,a=r.bones,o=r.boneInverses;ee.fromBufferAttribute(i.attributes.skinIndex,t),te.fromBufferAttribute(i.attributes.skinWeight,t),F.elements.fill(0);for(let e=0;e<4;e++){let t=te.getComponent(e);if(t!==0){let n=ee.getComponent(e);I.multiplyMatrices(a[n].matrixWorld,o[n]),re(F,I,t)}}return F.multiply(e.bindMatrix).premultiply(e.bindMatrixInverse),n.transformDirection(F),n}function L(e,t,n,r,i){N.set(0,0,0);for(let a=0,o=e.length;a<o;a++){let o=t[a],s=e[a];o!==0&&(P.fromBufferAttribute(s,r),n?N.addScaledVector(P,o):N.addScaledVector(P.sub(i),o))}i.add(N)}function re(e,t,n){let r=e.elements,i=t.elements;for(let e=0,t=i.length;e<t;e++)r[e]+=i[e]*n}function ie(e){let{index:t,attributes:n}=e;if(t)for(let e=0,n=t.count;e<n;e+=3){let n=t.getX(e),r=t.getX(e+2);t.setX(e,r),t.setX(e+2,n)}else for(let e in n){let t=n[e],r=t.itemSize;for(let e=0,n=t.count;e<n;e+=3)for(let n=0;n<r;n++){let r=t.getComponent(e,n),i=t.getComponent(e+2,n);t.setComponent(e,n,i),t.setComponent(e+2,n,r)}}return e}function ae(e,t={},r=new n.BufferGeometry){t={applyWorldTransforms:!0,attributes:[],...t};let i=e.geometry,a=t.applyWorldTransforms,o=t.attributes.includes(`normal`),s=t.attributes.includes(`tangent`),c=i.attributes,l=r.attributes;for(let e in r.attributes)(!t.attributes.includes(e)||!(e in i.attributes))&&r.deleteAttribute(e);!r.index&&i.index&&(r.index=i.index.clone()),l.position||r.setAttribute(`position`,g(c.position)),o&&!l.normal&&c.normal&&r.setAttribute(`normal`,g(c.normal)),s&&!l.tangent&&c.tangent&&r.setAttribute(`tangent`,g(c.tangent)),_(i.index,r.index),_(c.position,l.position),o&&_(c.normal,l.normal),s&&_(c.tangent,l.tangent);let u=c.position,d=o?c.normal:null,f=s?c.tangent:null,p=i.morphAttributes.position,m=i.morphAttributes.normal,v=i.morphAttributes.tangent,y=i.morphTargetsRelative,b=e.morphTargetInfluences,x=new n.Matrix3;x.getNormalMatrix(e.matrixWorld),i.index&&r.index.array.set(i.index.array);for(let t=0,n=c.position.count;t<n;t++)k.fromBufferAttribute(u,t),d&&A.fromBufferAttribute(d,t),f&&(M.fromBufferAttribute(f,t),j.fromBufferAttribute(f,t)),b&&(p&&L(p,b,y,t,k),m&&L(m,b,y,t,A),v&&L(v,b,y,t,j)),e.isSkinnedMesh&&(e.applyBoneTransform(t,k),d&&ne(e,t,A),f&&ne(e,t,j)),a&&k.applyMatrix4(e.matrixWorld),l.position.setXYZ(t,k.x,k.y,k.z),d&&(a&&A.applyNormalMatrix(x),l.normal.setXYZ(t,A.x,A.y,A.z)),f&&(a&&j.transformDirection(e.matrixWorld),l.tangent.setXYZW(t,j.x,j.y,j.z,M.w));for(let e in t.attributes){let n=t.attributes[e];n===`position`||n===`tangent`||n===`normal`||!(n in c)||(l[n]||r.setAttribute(n,g(c[n])),_(c[n],l[n]),h(c[n],l[n]))}return e.matrixWorld.determinant()<0&&ie(r),r}var oe=class extends n.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new O}isCompatible(e,t){let n=e.geometry;for(let e=0;e<t.length;e++){let r=t[e],i=n.attributes[r],a=this.attributes[r];if(i&&!_(i,a))return!1}return!0}updateFrom(e,t){let n=this._diff;return n.didChange(e)?(ae(e,t,this),n.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}};function se(e,t){for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(e=>{e.isMesh&&t(e)})}function ce(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];Array.isArray(r.material)?t.push(...r.material):t.push(r.material)}return t}function le(e,t,r){if(e.length===0){t.setIndex(null);let e=t.attributes;for(let n in e)t.deleteAttribute(n);for(let e in r.attributes)t.setAttribute(r.attributes[e],new n.BufferAttribute(new Float32Array,4,!1))}else S(e,r,t);for(let e in t.attributes)t.attributes[e].needsUpdate=!0}var ue=class{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=[`position`,`normal`,`color`,`tangent`,`uv`,`uv2`],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){let e=new n.MeshBasicMaterial,t=new n.BufferGeometry;t.setAttribute(`position`,new n.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new n.Mesh(t,e)}return this._dummyMesh}_getMeshes(){let e=[];return se(this.objects,t=>{e.push(t)}),e.sort((e,t)=>e.uuid>t.uuid?1:e.uuid<t.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){let{_intermediateGeometry:e}=this,t=this._getMeshes(),n=new Set(e.keys()),r={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let i=0,a=t.length;i<a;i++){let a=t[i],o=a.uuid;n.delete(o);let s=e.get(o);(!s||!s.isCompatible(a,this.attributes))&&(s&&s.dispose(),s=new oe,e.set(o,s)),s.updateFrom(a,r)&&this.generateMissingAttributes&&w(s,this.attributes)}n.forEach(t=>{e.delete(t)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new n.BufferGeometry){let{useGroups:t,overwriteIndex:r,_intermediateGeometry:i,_geometryMergeSets:a}=this,o=this._getMeshes(),s=[],c=[],l=a.get(e)||[];this._updateIntermediateGeometries();let u=!1;o.length!==l.length&&(u=!0);for(let e=0,t=o.length;e<t;e++){let t=o[e],n=i.get(t.uuid);c.push(n);let r=l[e];!r||r.uuid!==n.uuid?(s.push(!1),u=!0):r.version===n.version?s.push(!0):s.push(!1)}le(c,e,{useGroups:t,forceUpdate:u,skipAssigningAttributes:s,overwriteIndex:r}),u&&e.dispose(),a.set(e,c.map(e=>({version:e.version,uuid:e.uuid})));let d=0;return u?d=2:s.includes(!1)&&(d=1),{changeType:d,materials:ce(o),geometry:e}}};function de(e){let t=new Set;for(let n=0,r=e.length;n<r;n++){let r=e[n];for(let e in r){let n=r[e];n&&n.isTexture&&t.add(n)}}return Array.from(t)}function fe(e){let t=[],n=new Set;for(let r=0,i=e.length;r<i;r++)e[r].traverse(e=>{e.visible&&(e.isRectAreaLight||e.isSpotLight||e.isPointLight||e.isDirectionalLight)&&(t.push(e),e.iesMap&&n.add(e.iesMap))});return{lights:t,iesTextures:Array.from(n).sort((e,t)=>e.uuid<t.uuid?1:e.uuid>t.uuid?-1:0)}}var pe=class{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=[`position`,`normal`,`tangent`,`color`,`uv`,`uv2`],this.generateBVH=!0,this.bvh=null,this.geometry=new n.BufferGeometry,this.staticGeometryGenerator=new ue(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw Error(`PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.`);if(this.bvh instanceof Promise)return this._pendingGenerate||=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e))),this._pendingGenerate;{this._buildAsync=!0;let t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(t=null){let{staticGeometryGenerator:n,geometry:r,attributes:i}=this,a=n.objects;n.attributes=i,a.forEach(e=>{e.traverse(e=>{e.isSkinnedMesh&&e.skeleton&&e.skeleton.update()})});let o=n.generate(r),s=o.materials,c=de(s),{lights:l,iesTextures:u}=fe(a);if(o.changeType!==0&&C(r,s,s),this.generateBVH){if(this.bvh instanceof Promise)throw Error(`PathTracingSceneGenerator: BVH is already building asynchronously.`);if(o.changeType===2){let n={strategy:2,maxLeafTris:1,indirect:!0,onProgress:t,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(r,n):this.bvh=new e.g(r,n)}else o.changeType===1&&this.bvh.refit()}return{bvhChanged:o.changeType!==0,bvh:this.bvh,lights:l,iesTextures:u,geometry:r,materials:s,textures:c,objects:a}}},R=class extends n.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:`recompilation`})}constructor(e){super(e);for(let e in this.uniforms)Object.defineProperty(this,e,{get(){return this.uniforms[e].value},set(t){this.uniforms[e].value=t}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}},me=class extends R{constructor(e){super({blending:n.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
297
|
+
`;function h(e,t,n=0){if(e.isInterleavedBufferAttribute){let r=e.itemSize;for(let i=0,a=e.count;i<a;i++){let a=i+n;t.setX(a,e.getX(i)),r>=2&&t.setY(a,e.getY(i)),r>=3&&t.setZ(a,e.getZ(i)),r>=4&&t.setW(a,e.getW(i))}}else{let r=t.array,i=r.constructor,a=r.BYTES_PER_ELEMENT*e.itemSize*n;new i(r.buffer,a,e.array.length).set(e.array)}}function g(e,t=null){let r=e.array.constructor,i=e.normalized,a=e.itemSize;return new n.BufferAttribute(new r(a*(t===null?e.count:t)),a,i)}function _(e,t){if(!e&&!t)return!0;if(!!e!=!!t)return!1;let n=e.count===t.count,r=e.normalized===t.normalized,i=e.array.constructor===t.array.constructor,a=e.itemSize===t.itemSize;return!(!n||!r||!i||!a)}function v(e){let t=e[0].index!==null,n=new Set(Object.keys(e[0].attributes));if(!e[0].getAttribute(`position`))throw Error(`StaticGeometryGenerator: position attribute is required.`);for(let r=0;r<e.length;++r){let i=e[r],a=0;if(t!==(i.index!==null))throw Error(`StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`);for(let e in i.attributes){if(!n.has(e))throw Error(`StaticGeometryGenerator: All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`);a++}if(a!==n.size)throw Error(`StaticGeometryGenerator: All geometries must have the same number of attributes.`)}}function y(e){let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].getIndex().count;return t}function b(e){let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].getAttribute(`position`).count;return t}function x(e,t,n){e.index&&e.index.count!==t&&e.setIndex(null);let r=e.attributes;for(let t in r)r[t].count!==n&&e.deleteAttribute(t)}function S(e,t={},r=new n.BufferGeometry){let{useGroups:i=!1,forceUpdate:a=!1,skipAssigningAttributes:o=[],overwriteIndex:s=!0}=t;v(e);let c=e[0].index!==null,l=c?y(e):-1,u=b(e);if(x(r,l,u),i){let t=0;for(let n=0,i=e.length;n<i;n++){let i=e[n],a;a=c?i.getIndex().count:i.getAttribute(`position`).count,r.addGroup(t,a,n),t+=a}}if(c){let t=!1;if(r.index||(r.setIndex(new n.BufferAttribute(new Uint32Array(l),1,!1)),t=!0),t||s){let n=0,i=0,s=r.getIndex();for(let r=0,c=e.length;r<c;r++){let c=e[r],l=c.getIndex();if(!(!a&&!t&&o[r]))for(let e=0;e<l.count;++e)s.setX(n+e,l.getX(e)+i);n+=l.count,i+=c.getAttribute(`position`).count}}}let d=Object.keys(e[0].attributes);for(let t=0,n=d.length;t<n;t++){let n=!1,i=d[t];if(!r.getAttribute(i)){let t=e[0].getAttribute(i);r.setAttribute(i,g(t,u)),n=!0}let s=0,c=r.getAttribute(i);for(let t=0,r=e.length;t<r;t++){let r=e[t],l=!a&&!n&&o[t],u=r.getAttribute(i);l||h(u,c,s),s+=u.count}}}function C(e,t,r){let i=e.index,a=e.attributes.position.count,o=i?i.count:a,s=e.groups;s.length===0&&(s=[{count:o,start:0,materialIndex:0}]);let c=e.getAttribute(`materialIndex`);if(!c||c.count!==a){let t;t=r.length<=255?new Uint8Array(a):new Uint16Array(a),c=new n.BufferAttribute(t,1,!1),e.deleteAttribute(`materialIndex`),e.setAttribute(`materialIndex`,c)}let l=c.array;for(let e=0;e<s.length;e++){let n=s[e],a=n.start,c=n.count,u=Math.min(c,o-a),d=Array.isArray(t)?t[n.materialIndex]:t,f=r.indexOf(d);for(let e=0;e<u;e++){let t=a+e;i&&(t=i.getX(t)),l[t]=f}}}function w(e,t){if(!e.index){let t=e.attributes.position.count,n=Array(t);for(let e=0;e<t;e++)n[e]=e;e.setIndex(n)}if(!e.attributes.normal&&t&&t.includes(`normal`)&&e.computeVertexNormals(),!e.attributes.uv&&t&&t.includes(`uv`)){let t=e.attributes.position.count;e.setAttribute(`uv`,new n.BufferAttribute(new Float32Array(t*2),2,!1))}if(!e.attributes.uv2&&t&&t.includes(`uv2`)){let t=e.attributes.position.count;e.setAttribute(`uv2`,new n.BufferAttribute(new Float32Array(t*2),2,!1))}if(!e.attributes.tangent&&t&&t.includes(`tangent`))if(e.attributes.uv&&e.attributes.normal)e.computeTangents();else{let t=e.attributes.position.count;e.setAttribute(`tangent`,new n.BufferAttribute(new Float32Array(t*4),4,!1))}if(!e.attributes.color&&t&&t.includes(`color`)){let t=e.attributes.position.count,r=new Float32Array(t*4);r.fill(1),e.setAttribute(`color`,new n.BufferAttribute(r,4))}}function T(e){let t=0;if(e.byteLength!==0){let n=new Uint8Array(e);for(let r=0;r<e.byteLength;r++){let e=n[r];t=(t<<5)-t+e,t|=0}}return t}function E(e){let t=e.uuid,n=Object.values(e.attributes);e.index&&(n.push(e.index),t+=`index|${e.index.version}`);let r=Object.keys(n).sort();for(let e of r){let r=n[e];t+=`${e}_${r.version}|`}return t}function D(e){let t=e.skeleton;return t?(t.boneTexture||t.computeBoneTexture(),`${T(t.boneTexture.image.data.buffer)}_${t.boneTexture.uuid}`):null}var O=class{constructor(e=null){this.matrixWorld=new n.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){let t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=E(t),this.primitiveCount=n,this.skeletonHash=D(e)}didChange(e){let t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===E(t)&&this.skeletonHash===D(e)&&this.primitiveCount===n)}},k=new n.Vector3,A=new n.Vector3,j=new n.Vector3,M=new n.Vector4,N=new n.Vector3,P=new n.Vector3,ee=new n.Vector4,te=new n.Vector4,F=new n.Matrix4,I=new n.Matrix4;function ne(e,t,n){let r=e.skeleton,i=e.geometry,a=r.bones,o=r.boneInverses;ee.fromBufferAttribute(i.attributes.skinIndex,t),te.fromBufferAttribute(i.attributes.skinWeight,t),F.elements.fill(0);for(let e=0;e<4;e++){let t=te.getComponent(e);if(t!==0){let n=ee.getComponent(e);I.multiplyMatrices(a[n].matrixWorld,o[n]),re(F,I,t)}}return F.multiply(e.bindMatrix).premultiply(e.bindMatrixInverse),n.transformDirection(F),n}function L(e,t,n,r,i){N.set(0,0,0);for(let a=0,o=e.length;a<o;a++){let o=t[a],s=e[a];o!==0&&(P.fromBufferAttribute(s,r),n?N.addScaledVector(P,o):N.addScaledVector(P.sub(i),o))}i.add(N)}function re(e,t,n){let r=e.elements,i=t.elements;for(let e=0,t=i.length;e<t;e++)r[e]+=i[e]*n}function ie(e){let{index:t,attributes:n}=e;if(t)for(let e=0,n=t.count;e<n;e+=3){let n=t.getX(e),r=t.getX(e+2);t.setX(e,r),t.setX(e+2,n)}else for(let e in n){let t=n[e],r=t.itemSize;for(let e=0,n=t.count;e<n;e+=3)for(let n=0;n<r;n++){let r=t.getComponent(e,n),i=t.getComponent(e+2,n);t.setComponent(e,n,i),t.setComponent(e+2,n,r)}}return e}function ae(e,t={},r=new n.BufferGeometry){t={applyWorldTransforms:!0,attributes:[],...t};let i=e.geometry,a=t.applyWorldTransforms,o=t.attributes.includes(`normal`),s=t.attributes.includes(`tangent`),c=i.attributes,l=r.attributes;for(let e in r.attributes)(!t.attributes.includes(e)||!(e in i.attributes))&&r.deleteAttribute(e);!r.index&&i.index&&(r.index=i.index.clone()),l.position||r.setAttribute(`position`,g(c.position)),o&&!l.normal&&c.normal&&r.setAttribute(`normal`,g(c.normal)),s&&!l.tangent&&c.tangent&&r.setAttribute(`tangent`,g(c.tangent)),_(i.index,r.index),_(c.position,l.position),o&&_(c.normal,l.normal),s&&_(c.tangent,l.tangent);let u=c.position,d=o?c.normal:null,f=s?c.tangent:null,p=i.morphAttributes.position,m=i.morphAttributes.normal,v=i.morphAttributes.tangent,y=i.morphTargetsRelative,b=e.morphTargetInfluences,x=new n.Matrix3;x.getNormalMatrix(e.matrixWorld),i.index&&r.index.array.set(i.index.array);for(let t=0,n=c.position.count;t<n;t++)k.fromBufferAttribute(u,t),d&&A.fromBufferAttribute(d,t),f&&(M.fromBufferAttribute(f,t),j.fromBufferAttribute(f,t)),b&&(p&&L(p,b,y,t,k),m&&L(m,b,y,t,A),v&&L(v,b,y,t,j)),e.isSkinnedMesh&&(e.applyBoneTransform(t,k),d&&ne(e,t,A),f&&ne(e,t,j)),a&&k.applyMatrix4(e.matrixWorld),l.position.setXYZ(t,k.x,k.y,k.z),d&&(a&&A.applyNormalMatrix(x),l.normal.setXYZ(t,A.x,A.y,A.z)),f&&(a&&j.transformDirection(e.matrixWorld),l.tangent.setXYZW(t,j.x,j.y,j.z,M.w));for(let e in t.attributes){let n=t.attributes[e];n===`position`||n===`tangent`||n===`normal`||!(n in c)||(l[n]||r.setAttribute(n,g(c[n])),_(c[n],l[n]),h(c[n],l[n]))}return e.matrixWorld.determinant()<0&&ie(r),r}var oe=class extends n.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new O}isCompatible(e,t){let n=e.geometry;for(let e=0;e<t.length;e++){let r=t[e],i=n.attributes[r],a=this.attributes[r];if(i&&!_(i,a))return!1}return!0}updateFrom(e,t){let n=this._diff;return n.didChange(e)?(ae(e,t,this),n.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}};function se(e,t){for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(e=>{e.isMesh&&t(e)})}function ce(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];Array.isArray(r.material)?t.push(...r.material):t.push(r.material)}return t}function le(e,t,r){if(e.length===0){t.setIndex(null);let e=t.attributes;for(let n in e)t.deleteAttribute(n);for(let e in r.attributes)t.setAttribute(r.attributes[e],new n.BufferAttribute(new Float32Array,4,!1))}else S(e,r,t);for(let e in t.attributes)t.attributes[e].needsUpdate=!0}var ue=class{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=[`position`,`normal`,`color`,`tangent`,`uv`,`uv2`],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){let e=new n.MeshBasicMaterial,t=new n.BufferGeometry;t.setAttribute(`position`,new n.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new n.Mesh(t,e)}return this._dummyMesh}_getMeshes(){let e=[];return se(this.objects,t=>{e.push(t)}),e.sort((e,t)=>e.uuid>t.uuid?1:e.uuid<t.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){let{_intermediateGeometry:e}=this,t=this._getMeshes(),n=new Set(e.keys()),r={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let i=0,a=t.length;i<a;i++){let a=t[i],o=a.uuid;n.delete(o);let s=e.get(o);(!s||!s.isCompatible(a,this.attributes))&&(s&&s.dispose(),s=new oe,e.set(o,s)),s.updateFrom(a,r)&&this.generateMissingAttributes&&w(s,this.attributes)}n.forEach(t=>{e.delete(t)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new n.BufferGeometry){let{useGroups:t,overwriteIndex:r,_intermediateGeometry:i,_geometryMergeSets:a}=this,o=this._getMeshes(),s=[],c=[],l=a.get(e)||[];this._updateIntermediateGeometries();let u=!1;o.length!==l.length&&(u=!0);for(let e=0,t=o.length;e<t;e++){let t=o[e],n=i.get(t.uuid);c.push(n);let r=l[e];!r||r.uuid!==n.uuid?(s.push(!1),u=!0):r.version===n.version?s.push(!0):s.push(!1)}le(c,e,{useGroups:t,forceUpdate:u,skipAssigningAttributes:s,overwriteIndex:r}),u&&e.dispose(),a.set(e,c.map(e=>({version:e.version,uuid:e.uuid})));let d=0;return u?d=2:s.includes(!1)&&(d=1),{changeType:d,materials:ce(o),geometry:e}}};function de(e){let t=new Set;for(let n=0,r=e.length;n<r;n++){let r=e[n];for(let e in r){let n=r[e];n&&n.isTexture&&t.add(n)}}return Array.from(t)}function fe(e){let t=[],n=new Set;for(let r=0,i=e.length;r<i;r++)e[r].traverse(e=>{e.visible&&(e.isRectAreaLight||e.isSpotLight||e.isPointLight||e.isDirectionalLight)&&(t.push(e),e.iesMap&&n.add(e.iesMap))});return{lights:t,iesTextures:Array.from(n).sort((e,t)=>e.uuid<t.uuid?1:e.uuid>t.uuid?-1:0)}}var pe=class{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=[`position`,`normal`,`tangent`,`color`,`uv`,`uv2`],this.generateBVH=!0,this.bvh=null,this.geometry=new n.BufferGeometry,this.staticGeometryGenerator=new ue(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw Error(`PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.`);if(this.bvh instanceof Promise)return this._pendingGenerate||=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e))),this._pendingGenerate;{this._buildAsync=!0;let t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(t=null){let{staticGeometryGenerator:n,geometry:r,attributes:i}=this,a=n.objects;n.attributes=i,a.forEach(e=>{e.traverse(e=>{e.isSkinnedMesh&&e.skeleton&&e.skeleton.update()})});let o=n.generate(r),s=o.materials,c=de(s),{lights:l,iesTextures:u}=fe(a);if(o.changeType!==0&&C(r,s,s),this.generateBVH){if(this.bvh instanceof Promise)throw Error(`PathTracingSceneGenerator: BVH is already building asynchronously.`);if(o.changeType===2){let n={strategy:2,maxLeafTris:1,indirect:!0,onProgress:t,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(r,n):this.bvh=new e.y(r,n)}else o.changeType===1&&this.bvh.refit()}return{bvhChanged:o.changeType!==0,bvh:this.bvh,lights:l,iesTextures:u,geometry:r,materials:s,textures:c,objects:a}}},R=class extends n.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:`recompilation`})}constructor(e){super(e);for(let e in this.uniforms)Object.defineProperty(this,e,{get(){return this.uniforms[e].value},set(t){this.uniforms[e].value=t}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}},me=class extends R{constructor(e){super({blending:n.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
298
298
|
|
|
299
299
|
varying vec2 vUv;
|
|
300
300
|
|
|
@@ -3974,7 +3974,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3974
3974
|
rayDirection.x *= flipEnvMap;
|
|
3975
3975
|
gl_FragColor = textureCube( envMap, rayDirection );
|
|
3976
3976
|
|
|
3977
|
-
}`}),this.depthWrite=!1,this.depthTest=!1}},Gt=class{constructor(e){this._renderer=e,this._quad=new t.t(new Wt)}generate(e,t=null,r=null){if(!e.isCubeTexture)throw Error(`CubeToEquirectMaterial: Source can only be cube textures.`);let i=e.images[0],a=this._renderer,o=this._quad;t===null&&(t=4*i.height),r===null&&(r=2*i.height);let s=new n.WebGLRenderTarget(t,r,{type:n.FloatType,colorSpace:i.colorSpace}),c=i.height,l=Math.log2(c)-2,u=1/c,d=1/(3*Math.max(2**l,112));o.material.defines.CUBEUV_MAX_MIP=`${l}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=d,o.material.defines.CUBEUV_TEXEL_HEIGHT=u,o.material.uniforms.envMap.value=e,o.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,o.material.needsUpdate=!0;let f=a.getRenderTarget(),p=a.autoClear;a.autoClear=!0,a.setRenderTarget(s),o.render(a),a.setRenderTarget(f),a.autoClear=p;let m=new Uint16Array(t*r*4),h=new Float32Array(t*r*4);a.readRenderTargetPixels(s,0,0,t,r,h),s.dispose();for(let e=0,t=h.length;e<t;e++)m[e]=n.DataUtils.toHalfFloat(h[e]);let g=new n.DataTexture(m,t,r,n.RGBAFormat,n.HalfFloatType);return g.minFilter=n.LinearMipMapLinearFilter,g.magFilter=n.LinearFilter,g.wrapS=n.RepeatWrapping,g.wrapT=n.RepeatWrapping,g.mapping=n.EquirectangularReflectionMapping,g.needsUpdate=!0,g}dispose(){this._quad.dispose()}};function Kt(e){return e.extensions.get(`EXT_float_blend`)}var $=new n.Vector2,qt=class{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine(`FEATURE_MIS`,+!!e)}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 pe,this._pathTracer=new Rt(e),this._queueReset=!1,this._clock=new n.Clock,this._compilePromise=null,this._lowResPathTracer=new Rt(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new t.t(new Ut({map:null,transparent:!0,blending:n.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 n.Vector2(1024,1024),this.rasterizeSceneCallback=(e,t)=>{this._renderer.render(e,t)},this.renderToCanvasCallback=(e,t,n)=>{let r=t.autoClear;t.autoClear=!1,n.render(t),t.autoClear=r},this.setScene(new n.Scene,new n.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,n={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();let r=this._generator;if(r.setObjects(e),this._buildAsync)return r.generateAsync(n.onProgress).then(n=>this._updateFromResults(e,t,n));{let n=r.generate();return this._updateFromResults(e,t,n)}}setSceneAsync(...e){this._buildAsync=!0;let t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){let e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){let e=this._pathTracer.material,t=this._renderer,n=this._materials,r=this.textureSize,i=ze(n);e.textures.setTextures(t,i,r.x,r.y),e.materials.updateFrom(n,i),this.reset()}updateLights(){let e=this.scene,t=this._renderer,n=this._pathTracer.material,r=Be(e),i=Re(r);n.lights.updateFrom(r,i),n.iesProfiles.setTextures(t,i),this.reset()}updateEnvironment(){let e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&=(this._internalBackground.dispose(),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 Ht(16);let n=this._colorBackground;n.topColor.equals(e.background)||(n.topColor.set(e.background),n.bottomColor.set(e.background),n.update()),t.backgroundMap=n,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){let n=new Gt(this._renderer).generate(e.background);this._internalBackground=n,t.backgroundMap=n,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){let n=new Gt(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(n)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,n){let{materials:r,geometry:i,bvh:a,bvhChanged:o}=n;this._materials=r;let s=this._pathTracer.material;return o&&(s.bvh.updateFrom(a),s.attributesArray.updateFrom(i.attributes.normal,i.attributes.tangent,i.attributes.uv,i.attributes.color),s.materialIndexAttribute.updateFrom(i.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),n}renderSample(){let e=this._lowResPathTracer,t=this._pathTracer,r=this._renderer,i=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,i.start());let o=i.getDelta()*1e3,s=i.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=s&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!Kt(r),e.alpha=t.alpha,this.renderToCanvas){let r=this._renderer,i=this.minSamples;if(s>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration===0?a.material.opacity=1:a.material.opacity=Math.min(a.material.opacity+o/this.fadeDuration,1)),!this.enablePathTracing||this.samples<i||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());let n=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(r),a.material.opacity=n}(!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?n.AdditiveBlending:n.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,r,a),a.material.blending=n.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($);let e=Math.floor(this.renderScale*$.x),t=Math.floor(this.renderScale*$.y);if(this._pathTracer.getSize($),$.x!==e||$.y!==t){let n=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*n),Math.floor(t*n))}}}},Jt=class r{ingestSceneWithoutShadowHelpers(e,t){let n=[],r=[];e.traverse(e=>{e.userData?.softboxContactShadowHelper&&e.visible?n.push(e):e.userData?.softboxPathTracingFloor&&!e.visible&&r.push(e)}),n.forEach(e=>e.visible=!1),r.forEach(e=>e.visible=!0);try{this.pathTracer?.setScene(e,t)}finally{n.forEach(e=>e.visible=!0),r.forEach(e=>e.visible=!1)}}convertToDataTexture(e){if(!e.image||!(e.image instanceof HTMLImageElement))return null;let t=e.image,r=document.createElement(`canvas`);r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);if(!i)return null;i.drawImage(t,0,0);let a=i.getImageData(0,0,r.width,r.height),o=new Float32Array(a.data.length);for(let e=0;e<a.data.length;e++)o[e]=a.data[e]/255;let s=new n.DataTexture(o,r.width,r.height,n.RGBAFormat,n.FloatType);return s.mapping=e.mapping,s.wrapS=e.wrapS,s.wrapT=e.wrapT,s.magFilter=e.magFilter,s.minFilter=e.minFilter,s.anisotropy=e.anisotropy,s.needsUpdate=!0,s}getThreeRenderer(){return e.i(this.renderer)}static{this.CAMERA_SETTLE_MS=200}static{this.FADE_SAMPLES=256}static{this.FADE_HOLD_SAMPLES=4}static{this.FADE_PREVIEW_OPACITY=.3}static{this.FADE_RELEASE_FRACTION=.5}constructor(){this.pathTracer=null,this.enabled=!1,this.renderer=null,this.sampleCount=0,this.createAttempts=0,this.maxCreateAttempts=10,this.sceneInitialized=!1,this.environmentWaitFrames=0,this.maxEnvironmentWaitFrames=300,this.disposed=!1,this.convertedEnvTexture=null,this.convertedEnvSourceUuid=null,this.resumable=!1,this.lastCameraMoveTime=-1/0,this.cameraDirty=!1,this.events=new e.D,this.rasterFadeTarget=null,this.fadeQuad=null,this.fadeToneMapping=null,this.fadeSupported=!0,this.settings={samples:300,bounces:4,transmissiveBounces:2,renderScale:1,lowResScale:.5,dynamicLowRes:!0,enablePathTracing:!0}}async initialize(t){try{return this.renderer=t.renderer,this.enabled=t.enabled,this.isSupported()?e.O.ok(void 0):e.O.err(new e.A(`Path tracing is not supported in this environment`,e.k.PATH_TRACING_INIT_FAILED,{reason:`WebGL2 or required extensions not available`}))}catch(t){return e.O.err(new e.A(`Failed to initialize path tracing`,e.k.PATH_TRACING_INIT_FAILED,{originalError:t}))}}createPathTracer(){if(this.disposed)return e.O.err(new e.A(`Instance is disposed`,e.k.INVALID_STATE));try{let t=this.getThreeRenderer();return t?(this.pathTracer=new qt(t),this.pathTracer.tiles&&`set`in this.pathTracer.tiles&&this.pathTracer.tiles.set(1,1),this.pathTracer.bounces=this.settings.bounces,this.settings.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=this.settings.transmissiveBounces),this.pathTracer.renderScale=this.settings.renderScale,this.pathTracer.dynamicLowRes=this.settings.dynamicLowRes,this.pathTracer.lowResScale=this.settings.lowResScale,t.setRenderTarget(null),e.O.ok(void 0)):e.O.err(new e.A(`Renderer not ready, will retry`,e.k.RENDERER_NOT_INITIALIZED))}catch(t){return e.O.err(new e.A(`Failed to create path tracer`,e.k.PATH_TRACING_INIT_FAILED,{originalError:t}))}}setEnabled(e){if(this.enabled!==e&&(this.enabled=e,!e)){this.resumable=!1,this.reset(),this.sceneInitialized=!1;let e=this.getThreeRenderer();e&&(e.autoClear=!0)}}disableAfterSelfPause(e){this.enabled=!1,this.resumable=e===`completed`,this.events.emit(`pathtracing:paused`,{samples:this.sampleCount,reason:e})}updateSettings(e){this.settings={...this.settings,...e},e.enablePathTracing!==void 0&&this.setEnabled(e.enablePathTracing),this.pathTracer&&(e.bounces!==void 0&&(this.pathTracer.bounces=e.bounces),e.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=e.transmissiveBounces),e.renderScale!==void 0&&(this.pathTracer.renderScale=e.renderScale),e.lowResScale!==void 0&&(this.pathTracer.lowResScale=e.lowResScale),e.dynamicLowRes!==void 0&&(this.pathTracer.dynamicLowRes=e.dynamicLowRes))}async render(t,n){if(this.disposed)return e.O.ok(void 0);let r=this.renderer;if(!r)return e.O.ok(void 0);if(!this.enabled)return this.renderWhileDisabled(t,n);if(!this.pathTracer){let e=this.ensurePathTracerCreated(r,t,n);if(e)return e}try{let i=this.extractThreeObjects(t,n);if(!i)return e.O.err(new e.A(`Could not extract Three.js scene or camera`,e.k.INVALID_PARAMETER));let{threeScene:a,threeCamera:o}=i;if(!this.sceneInitialized){let e=await this.initializeSceneForPathTracing(r,t,n,a,o);if(e)return e}return this.sceneInitialized?this.accumulateSample(r,t,n):r.render(t,n)}catch(t){return e.O.err(new e.A(`Failed to render with path tracing`,e.k.RENDER_FAILED,{originalError:t}))}}ensurePathTracerCreated(e,t,n){this.createAttempts++;let r=this.createPathTracer();return r.ok?(this.createAttempts=0,null):this.createAttempts<this.maxCreateAttempts&&r.error?.message===`Renderer not ready, will retry`?e.render(t,n):(this.disableAfterSelfPause(`gave-up`),this.createAttempts=0,e.render(t,n))}extractThreeObjects(t,n){let r=e.a(t),i=e.t(n);return!r||!i?null:{threeScene:r,threeCamera:i}}async initializeSceneForPathTracing(e,t,r,i,a){try{let o=i.__originalEnvironmentTexture;if(!i.environment&&!o)return this.environmentWaitFrames++,this.environmentWaitFrames>=this.maxEnvironmentWaitFrames&&(this.disableAfterSelfPause(`gave-up`),this.environmentWaitFrames=0),e.render(t,r);if(this.environmentWaitFrames=0,o&&o.isCubeTexture){let e=i.environment;i.environment=o;try{this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0}finally{i.environment=e}}else if(o&&o.mapping===n.EquirectangularReflectionMapping){let e=o;if(o.image instanceof HTMLImageElement)if(this.convertedEnvTexture&&this.convertedEnvSourceUuid===o.uuid)e=this.convertedEnvTexture;else{this.convertedEnvTexture?.dispose(),this.convertedEnvTexture=null,this.convertedEnvSourceUuid=null;let t=this.convertToDataTexture(o);if(!t)throw Error(`Failed to convert environment texture to DataTexture`);this.convertedEnvTexture=t,this.convertedEnvSourceUuid=o.uuid,e=t}let t=i.environment;i.environment=e;try{let e=o.image;e&&!(`data`in e&&e.data)&&e instanceof HTMLImageElement&&!e.complete&&await new Promise(t=>{e.onload=()=>{o.needsUpdate=!0,t()},e.onerror=()=>{t()},e.complete&&t()}),this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0,i.environment=t}catch(e){throw i.environment=t,e}}else if(i.environment?.mapping===n.EquirectangularReflectionMapping)this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0;else return this.disableAfterSelfPause(`gave-up`),e.render(t,r)}catch(n){return console.warn(`Scene initialization error:`,n),e.render(t,r)}return null}accumulateSample(t,n,i){if(this.sampleCount===0)try{this.pathTracer?.updateLights()}catch(e){console.warn(`Failed to update lights for path tracing:`,e)}let a=t.render(n,i);if(!a.ok)return a;if(performance.now()-this.lastCameraMoveTime<r.CAMERA_SETTLE_MS)return e.O.ok(void 0);if(this.cameraDirty&&(this.cameraDirty=!1,this.pathTracer?.updateCamera()),this.fadeSupported&&this.sampleCount===0&&this.runFadeStep(()=>this.captureRasterFade(t,n,i)),this.accumulateOneSample(),this.sampleCount++,this.fadeSupported&&this.sampleCount<this.fadeWindowSamples()){let e=1-this.pathTracedLayerOpacity(this.sampleCount);this.runFadeStep(()=>this.renderRasterFade(e))}return this.sampleCount===this.settings.samples?this.captureCompletedFrame():e.O.ok(void 0)}runFadeStep(e){try{e()}catch(e){console.warn(`Path-tracing startup dissolve unavailable; showing samples directly:`,e),this.fadeSupported=!1}}fadeWindowSamples(){let e=r.FADE_HOLD_SAMPLES+2;return Math.max(e,Math.min(r.FADE_SAMPLES,this.settings.samples))}pathTracedLayerOpacity(e){let t=r.FADE_HOLD_SAMPLES,n=this.fadeWindowSamples(),i=r.FADE_PREVIEW_OPACITY,a=t+(n-t)*r.FADE_RELEASE_FRACTION;return e<a?i*r.smoothstep(t,a,e):i+(1-i)*r.smoothstep(a,n,e)}static smoothstep(e,t,n){let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)}captureRasterFade(e,t,r){let i=this.getThreeRenderer();if(!i)return;let a=i.getDrawingBufferSize(new n.Vector2);this.rasterFadeTarget?(this.rasterFadeTarget.width!==a.x||this.rasterFadeTarget.height!==a.y)&&this.rasterFadeTarget.setSize(a.x,a.y):(this.rasterFadeTarget=new n.WebGLRenderTarget(a.x,a.y,{type:n.HalfFloatType}),this.rasterFadeTarget.texture.colorSpace=n.LinearSRGBColorSpace);let o=i.getRenderTarget();i.setRenderTarget(this.rasterFadeTarget),e.render(t,r),i.setRenderTarget(o)}renderRasterFade(e){let n=this.getThreeRenderer();if(!n||!this.rasterFadeTarget)return;(!this.fadeQuad||this.fadeToneMapping!==n.toneMapping)&&((this.fadeQuad?.material)?.dispose(),this.fadeToneMapping=n.toneMapping,this.fadeQuad=new t.t(this.createFadeMaterial(n.toneMapping)));let r=this.fadeQuad.material;r.uniforms.tRaster.value=this.rasterFadeTarget.texture,r.uniforms.uOpacity.value=e;let i=n.autoClear,a=n.getRenderTarget();n.setRenderTarget(null),n.autoClear=!1;try{this.fadeQuad.render(n)}finally{n.autoClear=i,n.setRenderTarget(a)}}createFadeMaterial(e){let t={[n.LinearToneMapping]:`LINEAR_TONE_MAPPING`,[n.ReinhardToneMapping]:`REINHARD_TONE_MAPPING`,[n.CineonToneMapping]:`CINEON_TONE_MAPPING`,[n.ACESFilmicToneMapping]:`ACES_FILMIC_TONE_MAPPING`,[n.AgXToneMapping]:`AGX_TONE_MAPPING`,[n.NeutralToneMapping]:`NEUTRAL_TONE_MAPPING`},r={},i=t[e];return i&&(r[i]=``),new n.ShaderMaterial({defines:r,uniforms:{tRaster:{value:null},uOpacity:{value:1}},vertexShader:`
|
|
3977
|
+
}`}),this.depthWrite=!1,this.depthTest=!1}},Gt=class{constructor(e){this._renderer=e,this._quad=new t.t(new Wt)}generate(e,t=null,r=null){if(!e.isCubeTexture)throw Error(`CubeToEquirectMaterial: Source can only be cube textures.`);let i=e.images[0],a=this._renderer,o=this._quad;t===null&&(t=4*i.height),r===null&&(r=2*i.height);let s=new n.WebGLRenderTarget(t,r,{type:n.FloatType,colorSpace:i.colorSpace}),c=i.height,l=Math.log2(c)-2,u=1/c,d=1/(3*Math.max(2**l,112));o.material.defines.CUBEUV_MAX_MIP=`${l}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=d,o.material.defines.CUBEUV_TEXEL_HEIGHT=u,o.material.uniforms.envMap.value=e,o.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,o.material.needsUpdate=!0;let f=a.getRenderTarget(),p=a.autoClear;a.autoClear=!0,a.setRenderTarget(s),o.render(a),a.setRenderTarget(f),a.autoClear=p;let m=new Uint16Array(t*r*4),h=new Float32Array(t*r*4);a.readRenderTargetPixels(s,0,0,t,r,h),s.dispose();for(let e=0,t=h.length;e<t;e++)m[e]=n.DataUtils.toHalfFloat(h[e]);let g=new n.DataTexture(m,t,r,n.RGBAFormat,n.HalfFloatType);return g.minFilter=n.LinearMipMapLinearFilter,g.magFilter=n.LinearFilter,g.wrapS=n.RepeatWrapping,g.wrapT=n.RepeatWrapping,g.mapping=n.EquirectangularReflectionMapping,g.needsUpdate=!0,g}dispose(){this._quad.dispose()}};function Kt(e){return e.extensions.get(`EXT_float_blend`)}var $=new n.Vector2,qt=class{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine(`FEATURE_MIS`,+!!e)}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 pe,this._pathTracer=new Rt(e),this._queueReset=!1,this._clock=new n.Clock,this._compilePromise=null,this._lowResPathTracer=new Rt(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new t.t(new Ut({map:null,transparent:!0,blending:n.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 n.Vector2(1024,1024),this.rasterizeSceneCallback=(e,t)=>{this._renderer.render(e,t)},this.renderToCanvasCallback=(e,t,n)=>{let r=t.autoClear;t.autoClear=!1,n.render(t),t.autoClear=r},this.setScene(new n.Scene,new n.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,n={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();let r=this._generator;if(r.setObjects(e),this._buildAsync)return r.generateAsync(n.onProgress).then(n=>this._updateFromResults(e,t,n));{let n=r.generate();return this._updateFromResults(e,t,n)}}setSceneAsync(...e){this._buildAsync=!0;let t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){let e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){let e=this._pathTracer.material,t=this._renderer,n=this._materials,r=this.textureSize,i=ze(n);e.textures.setTextures(t,i,r.x,r.y),e.materials.updateFrom(n,i),this.reset()}updateLights(){let e=this.scene,t=this._renderer,n=this._pathTracer.material,r=Be(e),i=Re(r);n.lights.updateFrom(r,i),n.iesProfiles.setTextures(t,i),this.reset()}updateEnvironment(){let e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&=(this._internalBackground.dispose(),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 Ht(16);let n=this._colorBackground;n.topColor.equals(e.background)||(n.topColor.set(e.background),n.bottomColor.set(e.background),n.update()),t.backgroundMap=n,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){let n=new Gt(this._renderer).generate(e.background);this._internalBackground=n,t.backgroundMap=n,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){let n=new Gt(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(n)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,n){let{materials:r,geometry:i,bvh:a,bvhChanged:o}=n;this._materials=r;let s=this._pathTracer.material;return o&&(s.bvh.updateFrom(a),s.attributesArray.updateFrom(i.attributes.normal,i.attributes.tangent,i.attributes.uv,i.attributes.color),s.materialIndexAttribute.updateFrom(i.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),n}renderSample(){let e=this._lowResPathTracer,t=this._pathTracer,r=this._renderer,i=this._clock,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.material.opacity=0,i.start());let o=i.getDelta()*1e3,s=i.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=s&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!Kt(r),e.alpha=t.alpha,this.renderToCanvas){let r=this._renderer,i=this.minSamples;if(s>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration===0?a.material.opacity=1:a.material.opacity=Math.min(a.material.opacity+o/this.fadeDuration,1)),!this.enablePathTracing||this.samples<i||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());let n=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(r),a.material.opacity=n}(!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?n.AdditiveBlending:n.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,r,a),a.material.blending=n.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($);let e=Math.floor(this.renderScale*$.x),t=Math.floor(this.renderScale*$.y);if(this._pathTracer.getSize($),$.x!==e||$.y!==t){let n=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*n),Math.floor(t*n))}}}},Jt=class r{ingestSceneWithoutShadowHelpers(e,t){let n=[],r=[];e.traverse(e=>{e.userData?.softboxContactShadowHelper&&e.visible?n.push(e):e.userData?.softboxPathTracingFloor&&!e.visible&&r.push(e)}),n.forEach(e=>e.visible=!1),r.forEach(e=>e.visible=!0);try{this.pathTracer?.setScene(e,t)}finally{n.forEach(e=>e.visible=!0),r.forEach(e=>e.visible=!1)}}convertToDataTexture(e){if(!e.image||!(e.image instanceof HTMLImageElement))return null;let t=e.image,r=document.createElement(`canvas`);r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);if(!i)return null;i.drawImage(t,0,0);let a=i.getImageData(0,0,r.width,r.height),o=new Float32Array(a.data.length);for(let e=0;e<a.data.length;e++)o[e]=a.data[e]/255;let s=new n.DataTexture(o,r.width,r.height,n.RGBAFormat,n.FloatType);return s.mapping=e.mapping,s.wrapS=e.wrapS,s.wrapT=e.wrapT,s.magFilter=e.magFilter,s.minFilter=e.minFilter,s.anisotropy=e.anisotropy,s.needsUpdate=!0,s}getThreeRenderer(){return e.a(this.renderer)}static{this.CAMERA_SETTLE_MS=200}static{this.FADE_SAMPLES=256}static{this.FADE_HOLD_SAMPLES=4}static{this.FADE_PREVIEW_OPACITY=.3}static{this.FADE_RELEASE_FRACTION=.5}constructor(){this.pathTracer=null,this.enabled=!1,this.renderer=null,this.sampleCount=0,this.createAttempts=0,this.maxCreateAttempts=10,this.sceneInitialized=!1,this.environmentWaitFrames=0,this.maxEnvironmentWaitFrames=300,this.disposed=!1,this.convertedEnvTexture=null,this.convertedEnvSourceUuid=null,this.resumable=!1,this.lastCameraMoveTime=-1/0,this.cameraDirty=!1,this.events=new e.A,this.rasterFadeTarget=null,this.fadeQuad=null,this.fadeToneMapping=null,this.fadeSupported=!0,this.settings={samples:300,bounces:4,transmissiveBounces:2,renderScale:1,lowResScale:.5,dynamicLowRes:!0,enablePathTracing:!0}}async initialize(t){try{return this.renderer=t.renderer,this.enabled=t.enabled,this.isSupported()?e.j.ok(void 0):e.j.err(new e.N(`Path tracing is not supported in this environment`,e.M.PATH_TRACING_INIT_FAILED,{reason:`WebGL2 or required extensions not available`}))}catch(t){return e.j.err(new e.N(`Failed to initialize path tracing`,e.M.PATH_TRACING_INIT_FAILED,{originalError:t}))}}createPathTracer(){if(this.disposed)return e.j.err(new e.N(`Instance is disposed`,e.M.INVALID_STATE));try{let t=this.getThreeRenderer();return t?(this.pathTracer=new qt(t),this.pathTracer.tiles&&`set`in this.pathTracer.tiles&&this.pathTracer.tiles.set(1,1),this.pathTracer.bounces=this.settings.bounces,this.settings.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=this.settings.transmissiveBounces),this.pathTracer.renderScale=this.settings.renderScale,this.pathTracer.dynamicLowRes=this.settings.dynamicLowRes,this.pathTracer.lowResScale=this.settings.lowResScale,t.setRenderTarget(null),e.j.ok(void 0)):e.j.err(new e.N(`Renderer not ready, will retry`,e.M.RENDERER_NOT_INITIALIZED))}catch(t){return e.j.err(new e.N(`Failed to create path tracer`,e.M.PATH_TRACING_INIT_FAILED,{originalError:t}))}}setEnabled(e){if(this.enabled!==e&&(this.enabled=e,!e)){this.resumable=!1,this.reset(),this.sceneInitialized=!1;let e=this.getThreeRenderer();e&&(e.autoClear=!0)}}disableAfterSelfPause(e){this.enabled=!1,this.resumable=e===`completed`,this.events.emit(`pathtracing:paused`,{samples:this.sampleCount,reason:e})}updateSettings(e){this.settings={...this.settings,...e},e.enablePathTracing!==void 0&&this.setEnabled(e.enablePathTracing),this.pathTracer&&(e.bounces!==void 0&&(this.pathTracer.bounces=e.bounces),e.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=e.transmissiveBounces),e.renderScale!==void 0&&(this.pathTracer.renderScale=e.renderScale),e.lowResScale!==void 0&&(this.pathTracer.lowResScale=e.lowResScale),e.dynamicLowRes!==void 0&&(this.pathTracer.dynamicLowRes=e.dynamicLowRes))}async render(t,n){if(this.disposed)return e.j.ok(void 0);let r=this.renderer;if(!r)return e.j.ok(void 0);if(!this.enabled)return this.renderWhileDisabled(t,n);if(!this.pathTracer){let e=this.ensurePathTracerCreated(r,t,n);if(e)return e}try{let i=this.extractThreeObjects(t,n);if(!i)return e.j.err(new e.N(`Could not extract Three.js scene or camera`,e.M.INVALID_PARAMETER));let{threeScene:a,threeCamera:o}=i;if(!this.sceneInitialized){let e=await this.initializeSceneForPathTracing(r,t,n,a,o);if(e)return e}return this.sceneInitialized?this.accumulateSample(r,t,n):r.render(t,n)}catch(t){return e.j.err(new e.N(`Failed to render with path tracing`,e.M.RENDER_FAILED,{originalError:t}))}}ensurePathTracerCreated(e,t,n){this.createAttempts++;let r=this.createPathTracer();return r.ok?(this.createAttempts=0,null):this.createAttempts<this.maxCreateAttempts&&r.error?.message===`Renderer not ready, will retry`?e.render(t,n):(this.disableAfterSelfPause(`gave-up`),this.createAttempts=0,e.render(t,n))}extractThreeObjects(t,n){let r=e.o(t),i=e.n(n);return!r||!i?null:{threeScene:r,threeCamera:i}}async initializeSceneForPathTracing(e,t,r,i,a){try{let o=i.__originalEnvironmentTexture;if(!i.environment&&!o)return this.environmentWaitFrames++,this.environmentWaitFrames>=this.maxEnvironmentWaitFrames&&(this.disableAfterSelfPause(`gave-up`),this.environmentWaitFrames=0),e.render(t,r);if(this.environmentWaitFrames=0,o&&o.isCubeTexture){let e=i.environment;i.environment=o;try{this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0}finally{i.environment=e}}else if(o&&o.mapping===n.EquirectangularReflectionMapping){let e=o;if(o.image instanceof HTMLImageElement)if(this.convertedEnvTexture&&this.convertedEnvSourceUuid===o.uuid)e=this.convertedEnvTexture;else{this.convertedEnvTexture?.dispose(),this.convertedEnvTexture=null,this.convertedEnvSourceUuid=null;let t=this.convertToDataTexture(o);if(!t)throw Error(`Failed to convert environment texture to DataTexture`);this.convertedEnvTexture=t,this.convertedEnvSourceUuid=o.uuid,e=t}let t=i.environment;i.environment=e;try{let e=o.image;e&&!(`data`in e&&e.data)&&e instanceof HTMLImageElement&&!e.complete&&await new Promise(t=>{e.onload=()=>{o.needsUpdate=!0,t()},e.onerror=()=>{t()},e.complete&&t()}),this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0,i.environment=t}catch(e){throw i.environment=t,e}}else if(i.environment?.mapping===n.EquirectangularReflectionMapping)this.ingestSceneWithoutShadowHelpers(i,a),this.sceneInitialized=!0;else return this.disableAfterSelfPause(`gave-up`),e.render(t,r)}catch(n){return console.warn(`Scene initialization error:`,n),e.render(t,r)}return null}accumulateSample(t,n,i){if(this.sampleCount===0)try{this.pathTracer?.updateLights()}catch(e){console.warn(`Failed to update lights for path tracing:`,e)}let a=t.render(n,i);if(!a.ok)return a;if(performance.now()-this.lastCameraMoveTime<r.CAMERA_SETTLE_MS)return e.j.ok(void 0);if(this.cameraDirty&&(this.cameraDirty=!1,this.pathTracer?.updateCamera()),this.fadeSupported&&this.sampleCount===0&&this.runFadeStep(()=>this.captureRasterFade(t,n,i)),this.accumulateOneSample(),this.sampleCount++,this.fadeSupported&&this.sampleCount<this.fadeWindowSamples()){let e=1-this.pathTracedLayerOpacity(this.sampleCount);this.runFadeStep(()=>this.renderRasterFade(e))}return this.sampleCount===this.settings.samples?this.captureCompletedFrame():e.j.ok(void 0)}runFadeStep(e){try{e()}catch(e){console.warn(`Path-tracing startup dissolve unavailable; showing samples directly:`,e),this.fadeSupported=!1}}fadeWindowSamples(){let e=r.FADE_HOLD_SAMPLES+2;return Math.max(e,Math.min(r.FADE_SAMPLES,this.settings.samples))}pathTracedLayerOpacity(e){let t=r.FADE_HOLD_SAMPLES,n=this.fadeWindowSamples(),i=r.FADE_PREVIEW_OPACITY,a=t+(n-t)*r.FADE_RELEASE_FRACTION;return e<a?i*r.smoothstep(t,a,e):i+(1-i)*r.smoothstep(a,n,e)}static smoothstep(t,n,r){return e.t(Math.min(1,Math.max(0,(r-t)/(n-t))))}captureRasterFade(e,t,r){let i=this.getThreeRenderer();if(!i)return;let a=i.getDrawingBufferSize(new n.Vector2);this.rasterFadeTarget?(this.rasterFadeTarget.width!==a.x||this.rasterFadeTarget.height!==a.y)&&this.rasterFadeTarget.setSize(a.x,a.y):(this.rasterFadeTarget=new n.WebGLRenderTarget(a.x,a.y,{type:n.HalfFloatType}),this.rasterFadeTarget.texture.colorSpace=n.LinearSRGBColorSpace);let o=i.getRenderTarget();i.setRenderTarget(this.rasterFadeTarget),e.render(t,r),i.setRenderTarget(o)}renderRasterFade(e){let n=this.getThreeRenderer();if(!n||!this.rasterFadeTarget)return;(!this.fadeQuad||this.fadeToneMapping!==n.toneMapping)&&((this.fadeQuad?.material)?.dispose(),this.fadeToneMapping=n.toneMapping,this.fadeQuad=new t.t(this.createFadeMaterial(n.toneMapping)));let r=this.fadeQuad.material;r.uniforms.tRaster.value=this.rasterFadeTarget.texture,r.uniforms.uOpacity.value=e;let i=n.autoClear,a=n.getRenderTarget();n.setRenderTarget(null),n.autoClear=!1;try{this.fadeQuad.render(n)}finally{n.autoClear=i,n.setRenderTarget(a)}}createFadeMaterial(e){let t={[n.LinearToneMapping]:`LINEAR_TONE_MAPPING`,[n.ReinhardToneMapping]:`REINHARD_TONE_MAPPING`,[n.CineonToneMapping]:`CINEON_TONE_MAPPING`,[n.ACESFilmicToneMapping]:`ACES_FILMIC_TONE_MAPPING`,[n.AgXToneMapping]:`AGX_TONE_MAPPING`,[n.NeutralToneMapping]:`NEUTRAL_TONE_MAPPING`},r={},i=t[e];return i&&(r[i]=``),new n.ShaderMaterial({defines:r,uniforms:{tRaster:{value:null},uOpacity:{value:1}},vertexShader:`
|
|
3978
3978
|
varying vec2 vUv;
|
|
3979
3979
|
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }
|
|
3980
3980
|
`,fragmentShader:`
|
|
@@ -3998,4 +3998,4 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3998
3998
|
#endif
|
|
3999
3999
|
gl_FragColor = vec4( sRGBTransferOETF( vec4( color, 1.0 ) ).rgb, uOpacity );
|
|
4000
4000
|
}
|
|
4001
|
-
`,transparent:!0,depthTest:!1,depthWrite:!1})}renderWhileDisabled(t,n){if(!this.renderer)return e.
|
|
4001
|
+
`,transparent:!0,depthTest:!1,depthWrite:!1})}renderWhileDisabled(t,n){if(!this.renderer)return e.j.ok(void 0);if(this.sampleCount>=this.settings.samples&&this.sampleCount>0){let t=this.getThreeRenderer();return this.pathTracer&&t&&t.setRenderTarget(null),e.j.ok(void 0)}return this.renderer.render(t,n)}accumulateOneSample(){let e=this.getThreeRenderer();if(!e)throw Error(`Three.js renderer not available`);let t=e.autoClear,n=e.getRenderTarget();e.autoClear=!1,this.pathTracer&&this.pathTracer.renderSample(),e.autoClear=t,e.setRenderTarget(n)}captureCompletedFrame(){let t=this.getThreeRenderer();if(t&&this.pathTracer)try{let e=t.autoClear;t.autoClear=!0,t.setRenderTarget(null),t.clear(!0,!0,!0);let n=this.pathTracer.copyQuad;n&&typeof n.render==`function`?n.render(t):(t.autoClear=!1,this.pathTracer.renderSample()),t.autoClear=e}catch(e){console.warn(`Failed to present path traced result:`,e)}return this.disableAfterSelfPause(`completed`),e.j.ok(void 0)}getSampleCount(){return this.sampleCount}isEnabled(){return this.enabled}isPathTracerDisposed(){return this.disposed}canResume(){return this.resumable&&this.pathTracer!==null&&!this.disposed}reset(e=!1){if(this.sampleCount=0,this.pathTracer){if(e){this.pathTracer.reset(),this.sceneInitialized=!1;return}this.lastCameraMoveTime=performance.now(),this.cameraDirty=!0,this.pathTracer.reset()}}dispose(){if(this.disposed=!0,this.events.removeAllListeners(),this.pathTracer){try{this.pathTracer.dispose()}catch(e){console.warn(`Failed to dispose path tracer during service disposal:`,e)}this.pathTracer=null}this.convertedEnvTexture&&(this.convertedEnvTexture.dispose(),this.convertedEnvTexture=null,this.convertedEnvSourceUuid=null),this.fadeQuad&&=(this.fadeQuad.material.dispose(),null),this.fadeToneMapping=null,this.rasterFadeTarget&&=(this.rasterFadeTarget.dispose(),null),this.sampleCount=0,this.sceneInitialized=!1,this.createAttempts=0,this.renderer=null}isSupported(){return document.createElement(`canvas`).getContext(`webgl2`)!==null}};exports.ThreePathTracingService=Jt;
|
package/dist/index.d.cts
CHANGED
|
@@ -132,6 +132,29 @@ export declare enum ControlType {
|
|
|
132
132
|
OrbitControls = "OrbitControls"
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Photographic PBR maps for the outdoor concrete ground (CC0, Poly Haven;
|
|
137
|
+
* ~600 KB total, same CDN and override/self-host contract as the HDRI).
|
|
138
|
+
* Captured micro-structure is what reads as real concrete; the procedural
|
|
139
|
+
* generator stays as the offline fallback when these fail to fetch.
|
|
140
|
+
*/
|
|
141
|
+
export declare const DEFAULT_OUTDOOR_CONCRETE_TEXTURES: {
|
|
142
|
+
readonly texture: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_diff_1k.jpg";
|
|
143
|
+
readonly normalMap: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_nor_gl_1k.jpg";
|
|
144
|
+
readonly roughnessMap: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_rough_1k.jpg";
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The daylight HDRI `outdoor_concrete` lights with when no explicit
|
|
149
|
+
* `environment.url` is given: a bright partly-cloudy sky (CC0, Poly Haven;
|
|
150
|
+
* the projection shows its soft open terrain at the horizon), fetched on
|
|
151
|
+
* demand from their CDN — the one network request the outdoor scene makes.
|
|
152
|
+
* Pass your own `environment.url` to override or self-host, exactly like
|
|
153
|
+
* the DRACO/KTX2 decoder paths. (Urban candidates — potsdamer_platz,
|
|
154
|
+
* quarry_01 — were rejected visually: dusk-dark and olive-tinted grounds.)
|
|
155
|
+
*/
|
|
156
|
+
export declare const DEFAULT_OUTDOOR_HDRI_URL = "https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/2k/kloofendal_48d_partly_cloudy_puresky_2k.hdr";
|
|
157
|
+
|
|
135
158
|
/** The scene every viewer stands in when none is set. */
|
|
136
159
|
export declare const DEFAULT_SCENE: ViewerScene;
|
|
137
160
|
|
|
@@ -211,6 +234,23 @@ export declare interface EnvironmentOptions {
|
|
|
211
234
|
environmentIntensity?: number;
|
|
212
235
|
/** Grade of the built-in studio environment; ignored when `url` is set. */
|
|
213
236
|
studioLook?: StudioLook;
|
|
237
|
+
/**
|
|
238
|
+
* Project the environment map onto a virtual ground plane so the model
|
|
239
|
+
* appears to STAND in the environment instead of floating in front of it —
|
|
240
|
+
* the outdoor scenes' horizon treatment (three's GroundedSkybox). `true`
|
|
241
|
+
* uses the defaults (height 2m — a typical eye-level HDRI shot — and a
|
|
242
|
+
* 120m world radius); pass numbers to match an HDRI shot from another
|
|
243
|
+
* height or a larger set. Only applies when `url` is set. Structural —
|
|
244
|
+
* changing it rebuilds the viewer.
|
|
245
|
+
*
|
|
246
|
+
* While active the projection mesh IS the visible backdrop, so
|
|
247
|
+
* `backgroundBlurriness` has no effect (`backgroundIntensity` is emulated
|
|
248
|
+
* by dimming the projection).
|
|
249
|
+
*/
|
|
250
|
+
groundProjection?: boolean | {
|
|
251
|
+
height?: number;
|
|
252
|
+
radius?: number;
|
|
253
|
+
};
|
|
214
254
|
}
|
|
215
255
|
|
|
216
256
|
export declare enum ErrorCode {
|
|
@@ -251,7 +291,7 @@ export declare interface GridHelperOptions {
|
|
|
251
291
|
divisions?: number;
|
|
252
292
|
colorCenterLine?: string | number;
|
|
253
293
|
colorGrid?: string | number;
|
|
254
|
-
type?: 'shadow_floor' | 'square_wire' | 'hexagonal_wire' | 'hexagonal_glass' | 'stone_tiles';
|
|
294
|
+
type?: 'shadow_floor' | 'concrete_disc' | 'square_wire' | 'hexagonal_wire' | 'hexagonal_glass' | 'stone_tiles';
|
|
255
295
|
opacity?: number;
|
|
256
296
|
styleOptions?: {
|
|
257
297
|
hexRadius?: number;
|
|
@@ -797,14 +837,6 @@ declare interface Vec3Like {
|
|
|
797
837
|
*/
|
|
798
838
|
export declare const VIEWER_PRESETS: Record<ViewerPreset, Partial<SimpleViewerOptions>>;
|
|
799
839
|
|
|
800
|
-
/**
|
|
801
|
-
* Scenes: named SETS layered over the defaults (deep-merged), the structural
|
|
802
|
-
* counterpart of `VIEWER_PRESETS`. Where a preset grades the picture (runtime
|
|
803
|
-
* look fields, applied live), a scene selects the physical set the model
|
|
804
|
-
* stands in — floor, backdrop and how the studio environment is built — so
|
|
805
|
-
* each scene only sets **structural** fields and switching one rebuilds the
|
|
806
|
-
* viewer. Explicit user options always win.
|
|
807
|
-
*/
|
|
808
840
|
export declare const VIEWER_SCENES: Record<ViewerScene, Partial<SimpleViewerOptions>>;
|
|
809
841
|
|
|
810
842
|
/**
|
|
@@ -905,9 +937,14 @@ export declare type ViewerPreset = 'studio' | 'product' | 'neutral' | 'dark' | '
|
|
|
905
937
|
* soft contact shadow, crisp contrast-pushed studio environment (distinct
|
|
906
938
|
* highlights on glossy materials) and the path-traced infinity dome.
|
|
907
939
|
* - `studio_soft` — the same set lit softly: the studio environment is used
|
|
908
|
-
* as-built, without the contrast push,
|
|
909
|
-
*
|
|
940
|
+
* as-built, without the contrast push, plus a rebalanced rig (the key steps
|
|
941
|
+
* back, the rim edge nearly goes, the fill opens the shadows) for an even,
|
|
942
|
+
* low-drama read that flatters matte materials.
|
|
943
|
+
* - `outdoor_concrete` — open air: a real daylight HDRI lights the model and
|
|
944
|
+
* paints the sky, standing on a large matte concrete ground disc. The HDRI
|
|
945
|
+
* is fetched from a CDN by default (the one network request this scene
|
|
946
|
+
* makes); pass your own `environment.url` to override or self-host it.
|
|
910
947
|
*/
|
|
911
|
-
export declare type ViewerScene = 'studio_dome' | 'studio_soft';
|
|
948
|
+
export declare type ViewerScene = 'studio_dome' | 'studio_soft' | 'outdoor_concrete';
|
|
912
949
|
|
|
913
950
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,29 @@ export declare enum ControlType {
|
|
|
132
132
|
OrbitControls = "OrbitControls"
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Photographic PBR maps for the outdoor concrete ground (CC0, Poly Haven;
|
|
137
|
+
* ~600 KB total, same CDN and override/self-host contract as the HDRI).
|
|
138
|
+
* Captured micro-structure is what reads as real concrete; the procedural
|
|
139
|
+
* generator stays as the offline fallback when these fail to fetch.
|
|
140
|
+
*/
|
|
141
|
+
export declare const DEFAULT_OUTDOOR_CONCRETE_TEXTURES: {
|
|
142
|
+
readonly texture: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_diff_1k.jpg";
|
|
143
|
+
readonly normalMap: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_nor_gl_1k.jpg";
|
|
144
|
+
readonly roughnessMap: "https://dl.polyhaven.org/file/ph-assets/Textures/jpg/1k/concrete_floor_02/concrete_floor_02_rough_1k.jpg";
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The daylight HDRI `outdoor_concrete` lights with when no explicit
|
|
149
|
+
* `environment.url` is given: a bright partly-cloudy sky (CC0, Poly Haven;
|
|
150
|
+
* the projection shows its soft open terrain at the horizon), fetched on
|
|
151
|
+
* demand from their CDN — the one network request the outdoor scene makes.
|
|
152
|
+
* Pass your own `environment.url` to override or self-host, exactly like
|
|
153
|
+
* the DRACO/KTX2 decoder paths. (Urban candidates — potsdamer_platz,
|
|
154
|
+
* quarry_01 — were rejected visually: dusk-dark and olive-tinted grounds.)
|
|
155
|
+
*/
|
|
156
|
+
export declare const DEFAULT_OUTDOOR_HDRI_URL = "https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/2k/kloofendal_48d_partly_cloudy_puresky_2k.hdr";
|
|
157
|
+
|
|
135
158
|
/** The scene every viewer stands in when none is set. */
|
|
136
159
|
export declare const DEFAULT_SCENE: ViewerScene;
|
|
137
160
|
|
|
@@ -211,6 +234,23 @@ export declare interface EnvironmentOptions {
|
|
|
211
234
|
environmentIntensity?: number;
|
|
212
235
|
/** Grade of the built-in studio environment; ignored when `url` is set. */
|
|
213
236
|
studioLook?: StudioLook;
|
|
237
|
+
/**
|
|
238
|
+
* Project the environment map onto a virtual ground plane so the model
|
|
239
|
+
* appears to STAND in the environment instead of floating in front of it —
|
|
240
|
+
* the outdoor scenes' horizon treatment (three's GroundedSkybox). `true`
|
|
241
|
+
* uses the defaults (height 2m — a typical eye-level HDRI shot — and a
|
|
242
|
+
* 120m world radius); pass numbers to match an HDRI shot from another
|
|
243
|
+
* height or a larger set. Only applies when `url` is set. Structural —
|
|
244
|
+
* changing it rebuilds the viewer.
|
|
245
|
+
*
|
|
246
|
+
* While active the projection mesh IS the visible backdrop, so
|
|
247
|
+
* `backgroundBlurriness` has no effect (`backgroundIntensity` is emulated
|
|
248
|
+
* by dimming the projection).
|
|
249
|
+
*/
|
|
250
|
+
groundProjection?: boolean | {
|
|
251
|
+
height?: number;
|
|
252
|
+
radius?: number;
|
|
253
|
+
};
|
|
214
254
|
}
|
|
215
255
|
|
|
216
256
|
export declare enum ErrorCode {
|
|
@@ -251,7 +291,7 @@ export declare interface GridHelperOptions {
|
|
|
251
291
|
divisions?: number;
|
|
252
292
|
colorCenterLine?: string | number;
|
|
253
293
|
colorGrid?: string | number;
|
|
254
|
-
type?: 'shadow_floor' | 'square_wire' | 'hexagonal_wire' | 'hexagonal_glass' | 'stone_tiles';
|
|
294
|
+
type?: 'shadow_floor' | 'concrete_disc' | 'square_wire' | 'hexagonal_wire' | 'hexagonal_glass' | 'stone_tiles';
|
|
255
295
|
opacity?: number;
|
|
256
296
|
styleOptions?: {
|
|
257
297
|
hexRadius?: number;
|
|
@@ -797,14 +837,6 @@ declare interface Vec3Like {
|
|
|
797
837
|
*/
|
|
798
838
|
export declare const VIEWER_PRESETS: Record<ViewerPreset, Partial<SimpleViewerOptions>>;
|
|
799
839
|
|
|
800
|
-
/**
|
|
801
|
-
* Scenes: named SETS layered over the defaults (deep-merged), the structural
|
|
802
|
-
* counterpart of `VIEWER_PRESETS`. Where a preset grades the picture (runtime
|
|
803
|
-
* look fields, applied live), a scene selects the physical set the model
|
|
804
|
-
* stands in — floor, backdrop and how the studio environment is built — so
|
|
805
|
-
* each scene only sets **structural** fields and switching one rebuilds the
|
|
806
|
-
* viewer. Explicit user options always win.
|
|
807
|
-
*/
|
|
808
840
|
export declare const VIEWER_SCENES: Record<ViewerScene, Partial<SimpleViewerOptions>>;
|
|
809
841
|
|
|
810
842
|
/**
|
|
@@ -905,9 +937,14 @@ export declare type ViewerPreset = 'studio' | 'product' | 'neutral' | 'dark' | '
|
|
|
905
937
|
* soft contact shadow, crisp contrast-pushed studio environment (distinct
|
|
906
938
|
* highlights on glossy materials) and the path-traced infinity dome.
|
|
907
939
|
* - `studio_soft` — the same set lit softly: the studio environment is used
|
|
908
|
-
* as-built, without the contrast push,
|
|
909
|
-
*
|
|
940
|
+
* as-built, without the contrast push, plus a rebalanced rig (the key steps
|
|
941
|
+
* back, the rim edge nearly goes, the fill opens the shadows) for an even,
|
|
942
|
+
* low-drama read that flatters matte materials.
|
|
943
|
+
* - `outdoor_concrete` — open air: a real daylight HDRI lights the model and
|
|
944
|
+
* paints the sky, standing on a large matte concrete ground disc. The HDRI
|
|
945
|
+
* is fetched from a CDN by default (the one network request this scene
|
|
946
|
+
* makes); pass your own `environment.url` to override or self-host it.
|
|
910
947
|
*/
|
|
911
|
-
export declare type ViewerScene = 'studio_dome' | 'studio_soft';
|
|
948
|
+
export declare type ViewerScene = 'studio_dome' | 'studio_soft' | 'outdoor_concrete';
|
|
912
949
|
|
|
913
950
|
export { }
|