@shopware-ag/dive 2.2.17 → 2.2.18
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/build/chunks/{AssetCache-CpKF1NzV.cjs → AssetCache-BElKTasn.cjs} +1 -1
- package/build/chunks/{AssetCache-Ba-m-7zA.mjs → AssetCache-DbUJFLZt.mjs} +1 -1
- package/build/chunks/{AssetLoader-B03j7xvX.cjs → AssetLoader-CT_t_ZfO.cjs} +1 -1
- package/build/chunks/{AssetLoader-C2NGPDLw.mjs → AssetLoader-D5zuGw5p.mjs} +2 -2
- package/build/chunks/FileTypes-Bq4uWglF.mjs +2105 -0
- package/build/chunks/FileTypes-Vbu3ti7s.cjs +33 -0
- package/build/chunks/{SelectTool-ClSKQ893.cjs → SelectTool-4zYuuCRL.cjs} +1 -1
- package/build/chunks/{SelectTool-D-StWurg.mjs → SelectTool-PaTy0iER.mjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +50 -48
- package/build/engine/Dive.d.ts +6 -0
- package/build/engine/environment/Environment.d.ts +133 -0
- package/build/engine/index.d.ts +1 -0
- package/build/engine/renderer/Renderer.d.ts +3 -0
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +16 -24
- package/build/plugins/quickview/src/QuickView.d.ts +1 -3
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +0 -5
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +2 -2
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +2 -2
- package/package.json +6 -8
- package/build/chunks/FileTypes-D5A0_pG_.cjs +0 -29
- package/build/chunks/FileTypes-Djlx9wth.mjs +0 -1804
- package/build/chunks/HDREnvorinment-CP2Uvq4_.cjs +0 -5
- package/build/chunks/HDREnvorinment-DKzwfsKr.mjs +0 -257
- package/build/plugins/hdr/index.cjs +0 -1
- package/build/plugins/hdr/index.d.ts +0 -2
- package/build/plugins/hdr/index.mjs +0 -5
- package/build/plugins/hdr/src/HDREnvorinment.d.ts +0 -35
- package/build/plugins/hdr/src/index.d.ts +0 -1
- package/build/plugins/hdr/types/HDREnvironmentSettings.d.ts +0 -44
- package/build/plugins/hdr/types/index.d.ts +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty;var O=(b,t,c)=>t in b?z(b,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[t]=c;var m=(b,t,c)=>O(b,typeof t!="symbol"?t+"":t,c);const r=require("three");class H extends r.DataTextureLoader{constructor(t){super(t),this.type=r.HalfFloatType}parse(t){const o=function(e,i){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(i||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(i||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(i||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(i||""))}},C=`
|
|
2
|
-
`,I=function(e,i,s){i=i||1024;let p=e.pos,h=-1,n=0,g="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(p,p+128)));for(;0>(h=a.indexOf(C))&&n<i&&p<e.byteLength;)g+=a,n+=a.length,p+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(p,p+128)));return-1<h?(e.pos+=n+h+1,g+a.slice(0,h)):!1},N=function(e){const i=/^#\?(\S+)/,s=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,l=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,p=/^\s*FORMAT=(\S+)\s*$/,h=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,n={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let g,a;for((e.pos>=e.byteLength||!(g=I(e)))&&o(1,"no header found"),(a=g.match(i))||o(3,"bad initial token"),n.valid|=1,n.programtype=a[1],n.string+=g+`
|
|
3
|
-
`;g=I(e),g!==!1;){if(n.string+=g+`
|
|
4
|
-
`,g.charAt(0)==="#"){n.comments+=g+`
|
|
5
|
-
`;continue}if((a=g.match(s))&&(n.gamma=parseFloat(a[1])),(a=g.match(l))&&(n.exposure=parseFloat(a[1])),(a=g.match(p))&&(n.valid|=2,n.format=a[1]),(a=g.match(h))&&(n.valid|=4,n.height=parseInt(a[1],10),n.width=parseInt(a[2],10)),n.valid&2&&n.valid&4)break}return n.valid&2||o(3,"missing format specifier"),n.valid&4||o(3,"missing image size specifier"),n},V=function(e,i,s){const l=i;if(l<8||l>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);l!==(e[2]<<8|e[3])&&o(3,"wrong scanline width");const p=new Uint8Array(4*i*s);p.length||o(4,"unable to allocate buffer space");let h=0,n=0;const g=4*l,a=new Uint8Array(4),k=new Uint8Array(g);let U=s;for(;U>0&&n<e.byteLength;){n+4>e.byteLength&&o(1),a[0]=e[n++],a[1]=e[n++],a[2]=e[n++],a[3]=e[n++],(a[0]!=2||a[1]!=2||(a[2]<<8|a[3])!=l)&&o(3,"bad rgbe scanline format");let M=0,R;for(;M<g&&n<e.byteLength;){R=e[n++];const y=R>128;if(y&&(R-=128),(R===0||M+R>g)&&o(3,"bad scanline data"),y){const _=e[n++];for(let x=0;x<R;x++)k[M++]=_}else k.set(e.subarray(n,n+R),M),M+=R,n+=R}const j=l;for(let y=0;y<j;y++){let _=0;p[h]=k[y+_],_+=l,p[h+1]=k[y+_],_+=l,p[h+2]=k[y+_],_+=l,p[h+3]=k[y+_],h+=4}U--}return p},Y=function(e,i,s,l){const p=e[i+3],h=Math.pow(2,p-128)/255;s[l+0]=e[i+0]*h,s[l+1]=e[i+1]*h,s[l+2]=e[i+2]*h,s[l+3]=1},P=function(e,i,s,l){const p=e[i+3],h=Math.pow(2,p-128)/255;s[l+0]=r.DataUtils.toHalfFloat(Math.min(e[i+0]*h,65504)),s[l+1]=r.DataUtils.toHalfFloat(Math.min(e[i+1]*h,65504)),s[l+2]=r.DataUtils.toHalfFloat(Math.min(e[i+2]*h,65504)),s[l+3]=r.DataUtils.toHalfFloat(1)},T=new Uint8Array(t);T.pos=0;const S=N(T),F=S.width,D=S.height,L=V(T.subarray(T.pos),F,D);let G,A,w;switch(this.type){case r.FloatType:w=L.length/4;const e=new Float32Array(w*4);for(let s=0;s<w;s++)Y(L,s*4,e,s*4);G=e,A=r.FloatType;break;case r.HalfFloatType:w=L.length/4;const i=new Uint16Array(w*4);for(let s=0;s<w;s++)P(L,s*4,i,s*4);G=i,A=r.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:F,height:D,data:G,header:S.string,gamma:S.gamma,exposure:S.exposure,type:A}}setDataType(t){return this.type=t,this}load(t,c,u,v){function E(o,f){switch(o.type){case r.FloatType:case r.HalfFloatType:o.colorSpace=r.LinearSRGBColorSpace,o.minFilter=r.LinearFilter,o.magFilter=r.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}c&&c(o,f)}return super.load(t,E,u,v)}}const q={enabled:!0,imageUrl:void 0,useAsBackground:!0,globalEnvIntensity:1,exposure:1,rotateY:0,replaceLights:!0};class ${constructor(t,c,u={}){m(this,"originalBackground",null);m(this,"isBackgroundReplaced",!1);m(this,"renderer");m(this,"scene");m(this,"pmrem");m(this,"currentEnvRT",null);m(this,"currentBackgroundCube",null);m(this,"sourceImage",null);m(this,"originalLights",[]);m(this,"options");this.renderer=t,this.scene=c,this.pmrem=new r.PMREMGenerator(t),this.options=u,this.options.imageUrl&&(this.sourceImage=new H().loadAsync(this.options.imageUrl)),this.options.enabled&&this.enable()}async enable(t){if(this.options={...this.options,enabled:!0,...t},!this.options.imageUrl)return;this.renderer.outputColorSpace=r.SRGBColorSpace,this.renderer.toneMapping=r.ACESFilmicToneMapping,this.options.exposure!=null&&(this.renderer.toneMappingExposure=this.options.exposure),this.sourceImage||(this.sourceImage=new H().loadAsync(this.options.imageUrl));const c=await this.sourceImage;if(c.mapping=r.EquirectangularReflectionMapping,this.options.useAsBackground?(this.isBackgroundReplaced||(this.originalBackground=this.scene.background,this.isBackgroundReplaced=!0),this.scene.background=c):this.isBackgroundReplaced&&(this.scene.background=this.originalBackground,this.isBackgroundReplaced=!1),this.options.rotateY)await this.applyRotationAndSetEnvironment(this.options.rotateY);else{const u=this.pmrem.fromEquirectangular(c);this.cleanupEnv(),this.currentEnvRT=u,this.scene.environment=u.texture}this.applyEnvIntensity(this.scene,this.options.globalEnvIntensity??1),this.options.replaceLights&&this.disableExistingLights()}async setImageUrl(t){this.options.imageUrl=t,this.sourceImage=null,this.options.enabled&&await this.enable()}async setRotationY(t){this.options.rotateY=t,this.sourceImage&&await this.applyRotationAndSetEnvironment(t)}setExposure(t){this.options.exposure=t,this.renderer.toneMappingExposure=t}setGlobalEnvIntensity(t){this.options.globalEnvIntensity=t,this.applyEnvIntensity(this.scene,t)}disable(){this.options.enabled=!1,this.scene.environment=null,this.isBackgroundReplaced&&(this.scene.background=this.originalBackground,this.isBackgroundReplaced=!1),this.restoreLights(),this.cleanupEnv()}async dispose(){this.disable(),this.pmrem.dispose(),this.sourceImage&&((await this.sourceImage).dispose(),this.sourceImage=null)}async applyRotationAndSetEnvironment(t){if(!this.sourceImage)return;const c=await this.sourceImage,u=new r.Scene,v=new r.SphereGeometry(10,60,40);c.mapping=r.EquirectangularReflectionMapping;const E=new r.MeshBasicMaterial({map:c,side:r.BackSide}),o=new r.Mesh(v,E);o.scale.set(1,1,-1),o.rotation.y=t,u.add(o);const f=this.renderer.toneMapping,d=this.renderer.outputColorSpace;this.renderer.toneMapping=r.NoToneMapping,this.renderer.outputColorSpace=r.LinearSRGBColorSpace;const B=new r.WebGLCubeRenderTarget(1024,{type:r.HalfFloatType});new r.CubeCamera(.1,1e3,B).update(this.renderer,u),this.renderer.toneMapping=f,this.renderer.outputColorSpace=d;const I=this.pmrem.fromCubemap(B.texture);this.cleanupEnv(),this.currentEnvRT=I,this.scene.environment=I.texture,this.options.useAsBackground?(this.scene.background=B.texture,this.currentBackgroundCube&&(this.currentBackgroundCube.texture.dispose(),this.currentBackgroundCube.dispose()),this.currentBackgroundCube=B):(B.texture.dispose(),B.dispose(),this.isBackgroundReplaced&&(this.scene.background=this.originalBackground,this.isBackgroundReplaced=!1)),this.applyEnvIntensity(this.scene,this.options.globalEnvIntensity??1)}applyEnvIntensity(t,c){t.traverse(u=>{const E=u.material;if(!E)return;const o=Array.isArray(E)?E:[E];for(const f of o){const d=f;d&&"envMapIntensity"in d&&(d.envMapIntensity=c,d.needsUpdate=!0),d&&d.map&&"colorSpace"in d.map&&(d.map.colorSpace=r.SRGBColorSpace)}})}disableExistingLights(){const t=[];this.scene.traverse(c=>{const u=c;u.isLight&&(u.visible=!1,t.push(u))}),this.originalLights=t}restoreLights(){for(const t of this.originalLights)t.visible=!0;this.originalLights=[]}cleanupEnv(){this.currentEnvRT&&(this.currentEnvRT.texture.dispose(),this.currentEnvRT.dispose(),this.currentEnvRT=null),this.currentBackgroundCube&&(this.currentBackgroundCube.texture.dispose(),this.currentBackgroundCube.dispose(),this.currentBackgroundCube=null)}}exports.HDREnvironment=$;exports.HDREnvironmentDefaultSettings=q;
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
var J = Object.defineProperty;
|
|
2
|
-
var K = (b, t, c) => t in b ? J(b, t, { enumerable: !0, configurable: !0, writable: !0, value: c }) : b[t] = c;
|
|
3
|
-
var d = (b, t, c) => K(b, typeof t != "symbol" ? t + "" : t, c);
|
|
4
|
-
import { DataTextureLoader as Q, HalfFloatType as S, FloatType as x, DataUtils as A, LinearSRGBColorSpace as z, LinearFilter as V, PMREMGenerator as Z, SRGBColorSpace as Y, ACESFilmicToneMapping as ee, EquirectangularReflectionMapping as P, Scene as te, SphereGeometry as ne, MeshBasicMaterial as re, BackSide as ie, Mesh as se, NoToneMapping as ae, WebGLCubeRenderTarget as oe, CubeCamera as ce } from "three";
|
|
5
|
-
class j extends Q {
|
|
6
|
-
constructor(t) {
|
|
7
|
-
super(t), this.type = S;
|
|
8
|
-
}
|
|
9
|
-
// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
|
|
10
|
-
parse(t) {
|
|
11
|
-
const a = function(e, r) {
|
|
12
|
-
switch (e) {
|
|
13
|
-
case 1:
|
|
14
|
-
throw new Error("THREE.RGBELoader: Read Error: " + (r || ""));
|
|
15
|
-
case 2:
|
|
16
|
-
throw new Error("THREE.RGBELoader: Write Error: " + (r || ""));
|
|
17
|
-
case 3:
|
|
18
|
-
throw new Error("THREE.RGBELoader: Bad File Format: " + (r || ""));
|
|
19
|
-
default:
|
|
20
|
-
case 4:
|
|
21
|
-
throw new Error("THREE.RGBELoader: Memory Error: " + (r || ""));
|
|
22
|
-
}
|
|
23
|
-
}, F = `
|
|
24
|
-
`, I = function(e, r, s) {
|
|
25
|
-
r = r || 1024;
|
|
26
|
-
let h = e.pos, l = -1, n = 0, p = "", i = String.fromCharCode.apply(null, new Uint16Array(e.subarray(h, h + 128)));
|
|
27
|
-
for (; 0 > (l = i.indexOf(F)) && n < r && h < e.byteLength; )
|
|
28
|
-
p += i, n += i.length, h += 128, i += String.fromCharCode.apply(null, new Uint16Array(e.subarray(h, h + 128)));
|
|
29
|
-
return -1 < l ? (e.pos += n + l + 1, p + i.slice(0, l)) : !1;
|
|
30
|
-
}, O = function(e) {
|
|
31
|
-
const r = /^#\?(\S+)/, s = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, o = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, h = /^\s*FORMAT=(\S+)\s*$/, l = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, n = {
|
|
32
|
-
valid: 0,
|
|
33
|
-
/* indicate which fields are valid */
|
|
34
|
-
string: "",
|
|
35
|
-
/* the actual header string */
|
|
36
|
-
comments: "",
|
|
37
|
-
/* comments found in header */
|
|
38
|
-
programtype: "RGBE",
|
|
39
|
-
/* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
|
|
40
|
-
format: "",
|
|
41
|
-
/* RGBE format, default 32-bit_rle_rgbe */
|
|
42
|
-
gamma: 1,
|
|
43
|
-
/* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
|
|
44
|
-
exposure: 1,
|
|
45
|
-
/* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
|
|
46
|
-
width: 0,
|
|
47
|
-
height: 0
|
|
48
|
-
/* image dimensions, width/height */
|
|
49
|
-
};
|
|
50
|
-
let p, i;
|
|
51
|
-
for ((e.pos >= e.byteLength || !(p = I(e))) && a(1, "no header found"), (i = p.match(r)) || a(3, "bad initial token"), n.valid |= 1, n.programtype = i[1], n.string += p + `
|
|
52
|
-
`; p = I(e), p !== !1; ) {
|
|
53
|
-
if (n.string += p + `
|
|
54
|
-
`, p.charAt(0) === "#") {
|
|
55
|
-
n.comments += p + `
|
|
56
|
-
`;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if ((i = p.match(s)) && (n.gamma = parseFloat(i[1])), (i = p.match(o)) && (n.exposure = parseFloat(i[1])), (i = p.match(h)) && (n.valid |= 2, n.format = i[1]), (i = p.match(l)) && (n.valid |= 4, n.height = parseInt(i[1], 10), n.width = parseInt(i[2], 10)), n.valid & 2 && n.valid & 4) break;
|
|
60
|
-
}
|
|
61
|
-
return n.valid & 2 || a(3, "missing format specifier"), n.valid & 4 || a(3, "missing image size specifier"), n;
|
|
62
|
-
}, $ = function(e, r, s) {
|
|
63
|
-
const o = r;
|
|
64
|
-
if (
|
|
65
|
-
// run length encoding is not allowed so read flat
|
|
66
|
-
o < 8 || o > 32767 || // this file is not run length encoded
|
|
67
|
-
e[0] !== 2 || e[1] !== 2 || e[2] & 128
|
|
68
|
-
)
|
|
69
|
-
return new Uint8Array(e);
|
|
70
|
-
o !== (e[2] << 8 | e[3]) && a(3, "wrong scanline width");
|
|
71
|
-
const h = new Uint8Array(4 * r * s);
|
|
72
|
-
h.length || a(4, "unable to allocate buffer space");
|
|
73
|
-
let l = 0, n = 0;
|
|
74
|
-
const p = 4 * o, i = new Uint8Array(4), k = new Uint8Array(p);
|
|
75
|
-
let H = s;
|
|
76
|
-
for (; H > 0 && n < e.byteLength; ) {
|
|
77
|
-
n + 4 > e.byteLength && a(1), i[0] = e[n++], i[1] = e[n++], i[2] = e[n++], i[3] = e[n++], (i[0] != 2 || i[1] != 2 || (i[2] << 8 | i[3]) != o) && a(3, "bad rgbe scanline format");
|
|
78
|
-
let M = 0, E;
|
|
79
|
-
for (; M < p && n < e.byteLength; ) {
|
|
80
|
-
E = e[n++];
|
|
81
|
-
const R = E > 128;
|
|
82
|
-
if (R && (E -= 128), (E === 0 || M + E > p) && a(3, "bad scanline data"), R) {
|
|
83
|
-
const _ = e[n++];
|
|
84
|
-
for (let N = 0; N < E; N++)
|
|
85
|
-
k[M++] = _;
|
|
86
|
-
} else
|
|
87
|
-
k.set(e.subarray(n, n + E), M), M += E, n += E;
|
|
88
|
-
}
|
|
89
|
-
const X = o;
|
|
90
|
-
for (let R = 0; R < X; R++) {
|
|
91
|
-
let _ = 0;
|
|
92
|
-
h[l] = k[R + _], _ += o, h[l + 1] = k[R + _], _ += o, h[l + 2] = k[R + _], _ += o, h[l + 3] = k[R + _], l += 4;
|
|
93
|
-
}
|
|
94
|
-
H--;
|
|
95
|
-
}
|
|
96
|
-
return h;
|
|
97
|
-
}, W = function(e, r, s, o) {
|
|
98
|
-
const h = e[r + 3], l = Math.pow(2, h - 128) / 255;
|
|
99
|
-
s[o + 0] = e[r + 0] * l, s[o + 1] = e[r + 1] * l, s[o + 2] = e[r + 2] * l, s[o + 3] = 1;
|
|
100
|
-
}, q = function(e, r, s, o) {
|
|
101
|
-
const h = e[r + 3], l = Math.pow(2, h - 128) / 255;
|
|
102
|
-
s[o + 0] = A.toHalfFloat(Math.min(e[r + 0] * l, 65504)), s[o + 1] = A.toHalfFloat(Math.min(e[r + 1] * l, 65504)), s[o + 2] = A.toHalfFloat(Math.min(e[r + 2] * l, 65504)), s[o + 3] = A.toHalfFloat(1);
|
|
103
|
-
}, L = new Uint8Array(t);
|
|
104
|
-
L.pos = 0;
|
|
105
|
-
const v = O(L), D = v.width, U = v.height, G = $(L.subarray(L.pos), D, U);
|
|
106
|
-
let T, C, w;
|
|
107
|
-
switch (this.type) {
|
|
108
|
-
case x:
|
|
109
|
-
w = G.length / 4;
|
|
110
|
-
const e = new Float32Array(w * 4);
|
|
111
|
-
for (let s = 0; s < w; s++)
|
|
112
|
-
W(G, s * 4, e, s * 4);
|
|
113
|
-
T = e, C = x;
|
|
114
|
-
break;
|
|
115
|
-
case S:
|
|
116
|
-
w = G.length / 4;
|
|
117
|
-
const r = new Uint16Array(w * 4);
|
|
118
|
-
for (let s = 0; s < w; s++)
|
|
119
|
-
q(G, s * 4, r, s * 4);
|
|
120
|
-
T = r, C = S;
|
|
121
|
-
break;
|
|
122
|
-
default:
|
|
123
|
-
throw new Error("THREE.RGBELoader: Unsupported type: " + this.type);
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
width: D,
|
|
127
|
-
height: U,
|
|
128
|
-
data: T,
|
|
129
|
-
header: v.string,
|
|
130
|
-
gamma: v.gamma,
|
|
131
|
-
exposure: v.exposure,
|
|
132
|
-
type: C
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
setDataType(t) {
|
|
136
|
-
return this.type = t, this;
|
|
137
|
-
}
|
|
138
|
-
load(t, c, g, f) {
|
|
139
|
-
function m(a, B) {
|
|
140
|
-
switch (a.type) {
|
|
141
|
-
case x:
|
|
142
|
-
case S:
|
|
143
|
-
a.colorSpace = z, a.minFilter = V, a.magFilter = V, a.generateMipmaps = !1, a.flipY = !0;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
c && c(a, B);
|
|
147
|
-
}
|
|
148
|
-
return super.load(t, m, g, f);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const pe = {
|
|
152
|
-
enabled: !0,
|
|
153
|
-
imageUrl: void 0,
|
|
154
|
-
useAsBackground: !0,
|
|
155
|
-
globalEnvIntensity: 1,
|
|
156
|
-
exposure: 1,
|
|
157
|
-
rotateY: 0,
|
|
158
|
-
replaceLights: !0
|
|
159
|
-
};
|
|
160
|
-
class ge {
|
|
161
|
-
constructor(t, c, g = {}) {
|
|
162
|
-
d(this, "originalBackground", null);
|
|
163
|
-
d(this, "isBackgroundReplaced", !1);
|
|
164
|
-
d(this, "renderer");
|
|
165
|
-
d(this, "scene");
|
|
166
|
-
d(this, "pmrem");
|
|
167
|
-
d(this, "currentEnvRT", null);
|
|
168
|
-
d(this, "currentBackgroundCube", null);
|
|
169
|
-
d(this, "sourceImage", null);
|
|
170
|
-
d(this, "originalLights", []);
|
|
171
|
-
d(this, "options");
|
|
172
|
-
this.renderer = t, this.scene = c, this.pmrem = new Z(t), this.options = g, this.options.imageUrl && (this.sourceImage = new j().loadAsync(
|
|
173
|
-
this.options.imageUrl
|
|
174
|
-
)), this.options.enabled && this.enable();
|
|
175
|
-
}
|
|
176
|
-
async enable(t) {
|
|
177
|
-
if (this.options = { ...this.options, enabled: !0, ...t }, !this.options.imageUrl) return;
|
|
178
|
-
this.renderer.outputColorSpace = Y, this.renderer.toneMapping = ee, this.options.exposure != null && (this.renderer.toneMappingExposure = this.options.exposure), this.sourceImage || (this.sourceImage = new j().loadAsync(
|
|
179
|
-
this.options.imageUrl
|
|
180
|
-
));
|
|
181
|
-
const c = await this.sourceImage;
|
|
182
|
-
if (c.mapping = P, this.options.useAsBackground ? (this.isBackgroundReplaced || (this.originalBackground = this.scene.background, this.isBackgroundReplaced = !0), this.scene.background = c) : this.isBackgroundReplaced && (this.scene.background = this.originalBackground, this.isBackgroundReplaced = !1), this.options.rotateY)
|
|
183
|
-
await this.applyRotationAndSetEnvironment(this.options.rotateY);
|
|
184
|
-
else {
|
|
185
|
-
const g = this.pmrem.fromEquirectangular(c);
|
|
186
|
-
this.cleanupEnv(), this.currentEnvRT = g, this.scene.environment = g.texture;
|
|
187
|
-
}
|
|
188
|
-
this.applyEnvIntensity(
|
|
189
|
-
this.scene,
|
|
190
|
-
this.options.globalEnvIntensity ?? 1
|
|
191
|
-
), this.options.replaceLights && this.disableExistingLights();
|
|
192
|
-
}
|
|
193
|
-
async setImageUrl(t) {
|
|
194
|
-
this.options.imageUrl = t, this.sourceImage = null, this.options.enabled && await this.enable();
|
|
195
|
-
}
|
|
196
|
-
async setRotationY(t) {
|
|
197
|
-
this.options.rotateY = t, this.sourceImage && await this.applyRotationAndSetEnvironment(t);
|
|
198
|
-
}
|
|
199
|
-
setExposure(t) {
|
|
200
|
-
this.options.exposure = t, this.renderer.toneMappingExposure = t;
|
|
201
|
-
}
|
|
202
|
-
setGlobalEnvIntensity(t) {
|
|
203
|
-
this.options.globalEnvIntensity = t, this.applyEnvIntensity(this.scene, t);
|
|
204
|
-
}
|
|
205
|
-
disable() {
|
|
206
|
-
this.options.enabled = !1, this.scene.environment = null, this.isBackgroundReplaced && (this.scene.background = this.originalBackground, this.isBackgroundReplaced = !1), this.restoreLights(), this.cleanupEnv();
|
|
207
|
-
}
|
|
208
|
-
async dispose() {
|
|
209
|
-
this.disable(), this.pmrem.dispose(), this.sourceImage && ((await this.sourceImage).dispose(), this.sourceImage = null);
|
|
210
|
-
}
|
|
211
|
-
async applyRotationAndSetEnvironment(t) {
|
|
212
|
-
if (!this.sourceImage) return;
|
|
213
|
-
const c = await this.sourceImage, g = new te(), f = new ne(10, 60, 40);
|
|
214
|
-
c.mapping = P;
|
|
215
|
-
const m = new re({ map: c, side: ie }), a = new se(f, m);
|
|
216
|
-
a.scale.set(1, 1, -1), a.rotation.y = t, g.add(a);
|
|
217
|
-
const B = this.renderer.toneMapping, u = this.renderer.outputColorSpace;
|
|
218
|
-
this.renderer.toneMapping = ae, this.renderer.outputColorSpace = z;
|
|
219
|
-
const y = new oe(1024, { type: S });
|
|
220
|
-
new ce(0.1, 1e3, y).update(this.renderer, g), this.renderer.toneMapping = B, this.renderer.outputColorSpace = u;
|
|
221
|
-
const I = this.pmrem.fromCubemap(y.texture);
|
|
222
|
-
this.cleanupEnv(), this.currentEnvRT = I, this.scene.environment = I.texture, this.options.useAsBackground ? (this.scene.background = y.texture, this.currentBackgroundCube && (this.currentBackgroundCube.texture.dispose(), this.currentBackgroundCube.dispose()), this.currentBackgroundCube = y) : (y.texture.dispose(), y.dispose(), this.isBackgroundReplaced && (this.scene.background = this.originalBackground, this.isBackgroundReplaced = !1)), this.applyEnvIntensity(
|
|
223
|
-
this.scene,
|
|
224
|
-
this.options.globalEnvIntensity ?? 1
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
applyEnvIntensity(t, c) {
|
|
228
|
-
t.traverse((g) => {
|
|
229
|
-
const m = g.material;
|
|
230
|
-
if (!m) return;
|
|
231
|
-
const a = Array.isArray(m) ? m : [m];
|
|
232
|
-
for (const B of a) {
|
|
233
|
-
const u = B;
|
|
234
|
-
u && "envMapIntensity" in u && (u.envMapIntensity = c, u.needsUpdate = !0), u && u.map && "colorSpace" in u.map && (u.map.colorSpace = Y);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
disableExistingLights() {
|
|
239
|
-
const t = [];
|
|
240
|
-
this.scene.traverse((c) => {
|
|
241
|
-
const g = c;
|
|
242
|
-
g.isLight && (g.visible = !1, t.push(g));
|
|
243
|
-
}), this.originalLights = t;
|
|
244
|
-
}
|
|
245
|
-
restoreLights() {
|
|
246
|
-
for (const t of this.originalLights)
|
|
247
|
-
t.visible = !0;
|
|
248
|
-
this.originalLights = [];
|
|
249
|
-
}
|
|
250
|
-
cleanupEnv() {
|
|
251
|
-
this.currentEnvRT && (this.currentEnvRT.texture.dispose(), this.currentEnvRT.dispose(), this.currentEnvRT = null), this.currentBackgroundCube && (this.currentBackgroundCube.texture.dispose(), this.currentBackgroundCube.dispose(), this.currentBackgroundCube = null);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
export {
|
|
255
|
-
pe as H,
|
|
256
|
-
ge as a
|
|
257
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../chunks/HDREnvorinment-CP2Uvq4_.cjs");exports.HDREnvironment=n.HDREnvironment;exports.HDREnvironmentDefaultSettings=n.HDREnvironmentDefaultSettings;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Scene, WebGLRenderer } from 'three';
|
|
2
|
-
import { HDREnvironmentSettings } from '../types/index.ts';
|
|
3
|
-
export declare const HDREnvironmentDefaultSettings: HDREnvironmentSettings;
|
|
4
|
-
/**
|
|
5
|
-
* Manages an image-based lighting setup with optional Y-rotation.
|
|
6
|
-
*
|
|
7
|
-
* Rotation is achieved by rendering the equirect HDR to a skybox that is
|
|
8
|
-
* rotated around Y, capturing it into a cubemap with CubeCamera, and then
|
|
9
|
-
* generating a PMREM for scene.environment.
|
|
10
|
-
*/
|
|
11
|
-
export declare class HDREnvironment {
|
|
12
|
-
private originalBackground;
|
|
13
|
-
private isBackgroundReplaced;
|
|
14
|
-
private renderer;
|
|
15
|
-
private scene;
|
|
16
|
-
private pmrem;
|
|
17
|
-
private currentEnvRT;
|
|
18
|
-
private currentBackgroundCube;
|
|
19
|
-
private sourceImage;
|
|
20
|
-
private originalLights;
|
|
21
|
-
private options;
|
|
22
|
-
constructor(renderer: WebGLRenderer, scene: Scene, options?: HDREnvironmentSettings);
|
|
23
|
-
enable(opts?: Partial<HDREnvironmentSettings>): Promise<void>;
|
|
24
|
-
setImageUrl(url: string): Promise<void>;
|
|
25
|
-
setRotationY(radians: number): Promise<void>;
|
|
26
|
-
setExposure(exposure: number): void;
|
|
27
|
-
setGlobalEnvIntensity(intensity: number): void;
|
|
28
|
-
disable(): void;
|
|
29
|
-
dispose(): Promise<void>;
|
|
30
|
-
private applyRotationAndSetEnvironment;
|
|
31
|
-
private applyEnvIntensity;
|
|
32
|
-
private disableExistingLights;
|
|
33
|
-
private restoreLights;
|
|
34
|
-
private cleanupEnv;
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './HDREnvorinment.ts';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export type HDREnvironmentSettings = {
|
|
2
|
-
/**
|
|
3
|
-
* Whether to enable the image-based lighting.
|
|
4
|
-
*
|
|
5
|
-
* @default false
|
|
6
|
-
*/
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* The URL of the HDR image.
|
|
10
|
-
*
|
|
11
|
-
* @default undefined
|
|
12
|
-
*/
|
|
13
|
-
imageUrl?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Whether to use the HDR image as a background image.
|
|
16
|
-
*
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
useAsBackground?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* The intensity of the environment lighting.
|
|
22
|
-
*
|
|
23
|
-
* @default 1
|
|
24
|
-
*/
|
|
25
|
-
globalEnvIntensity?: number;
|
|
26
|
-
/**
|
|
27
|
-
* The exposure of the HDR image.
|
|
28
|
-
*
|
|
29
|
-
* @default 1
|
|
30
|
-
*/
|
|
31
|
-
exposure?: number;
|
|
32
|
-
/**
|
|
33
|
-
* The rotation of the HDR image in radians.
|
|
34
|
-
*
|
|
35
|
-
* @default 0
|
|
36
|
-
*/
|
|
37
|
-
rotateY?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Whether to replace the existing lights (can be restored via `restoreLights`).
|
|
40
|
-
*
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
replaceLights?: boolean;
|
|
44
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './HDREnvironmentSettings.ts';
|