three-stdlib 2.22.1 → 2.22.2
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/_polyfill/CompressedArrayTexture.cjs.js +1 -0
- package/_polyfill/CompressedArrayTexture.js +13 -0
- package/_polyfill/Data3DTexture.cjs.js +1 -0
- package/_polyfill/Data3DTexture.js +23 -0
- package/index.cjs.js +1 -1
- package/loaders/KTX2Loader.cjs.js +1 -1
- package/loaders/KTX2Loader.js +3 -11
- package/loaders/LUT3dlLoader.cjs.js +1 -1
- package/loaders/LUT3dlLoader.js +2 -1
- package/loaders/LUTCubeLoader.cjs.js +1 -1
- package/loaders/LUTCubeLoader.js +2 -1
- package/loaders/VOXLoader.cjs.js +1 -1
- package/loaders/VOXLoader.js +2 -1
- package/package.json +1 -1
- package/postprocessing/SSRPass.js +5 -1
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("../utils/WorkerPool.cjs.js"),t=require("ktx-parse"),o=require("zstddec");class s extends e.CompressedTexture{constructor(r,t,o,s,a,n){super(r,t,o,a,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=e.ClampToEdgeWrapping}}const a=new WeakMap;let n,i=0;class _ extends e.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new r.WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}init(){if(!this.transcoderPending){const r=new e.FileLoader(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const t=r.loadAsync("basis_transcoder.js"),o=new e.FileLoader(this.manager);o.setPath(this.transcoderPath),o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const s=o.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,r])=>{const t=_.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(_.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(_.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(_.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=r,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),r=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:r},[r]),e}))})),i>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),i++}return this.transcoderPending}load(r,t,o,s){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new e.FileLoader(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(r,(e=>{if(a.has(e)){return a.get(e).promise.then(t).catch(s)}this._createTexture(e).then((e=>t?t(e):null)).catch(s)}),o,s)}_createTextureFrom(r,o){const{mipmaps:a,width:n,height:i,format:_,type:T,error:d,dfdTransferFn:c,dfdFlags:R}=r;if("error"===T)return Promise.reject(d);const F=o.layerCount>1?new s(a,n,i,o.layerCount,_,e.UnsignedByteType):new e.CompressedTexture(a,n,i,_,e.UnsignedByteType);return F.minFilter=1===a.length?e.LinearFilter:e.LinearMipmapLinearFilter,F.magFilter=e.LinearFilter,F.generateMipmaps=!1,F.needsUpdate=!0,"colorSpace"in F?F.colorSpace=c===t.KHR_DF_TRANSFER_SRGB?"srgb":"srgb-linear":F.encoding=c===t.KHR_DF_TRANSFER_SRGB?3001:3e3,F.premultiplyAlpha=!!(R&t.KHR_DF_FLAG_ALPHA_PREMULTIPLIED),F}async _createTexture(r,s={}){const i=t.read(new Uint8Array(r));if(i.vkFormat!==t.VK_FORMAT_UNDEFINED)return async function(r){const{vkFormat:s,pixelWidth:a,pixelHeight:i,pixelDepth:_}=r;if(void 0===T[s])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const R=r.levels[0];let F,p;if(r.supercompressionScheme===t.KHR_SUPERCOMPRESSION_NONE)F=R.levelData;else{if(r.supercompressionScheme!==t.KHR_SUPERCOMPRESSION_ZSTD)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");n||(n=new Promise((async e=>{const r=new o.ZSTDDecoder;await r.init(),e(r)}))),F=(await n).decode(R.levelData,R.uncompressedByteLength)}p=d[s]===e.FloatType?new Float32Array(F.buffer,F.byteOffset,F.byteLength/Float32Array.BYTES_PER_ELEMENT):d[s]===e.HalfFloatType?new Uint16Array(F.buffer,F.byteOffset,F.byteLength/Uint16Array.BYTES_PER_ELEMENT):F;const m=0===_?new e.DataTexture(p,a,i):new e.Data3DTexture(p,a,i,_);return m.type=d[s],m.format=T[s],m.encoding=c[s]||3e3,m.needsUpdate=!0,Promise.resolve(m)}(i);const _=s,R=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r]))).then((e=>this._createTextureFrom(e.data,i)));return a.set(r,{promise:R}),R}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),i--,this}}_.BasisFormat={ETC1S:0,UASTC_4x4:1},_.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},_.EngineFormat={RGBAFormat:e.RGBAFormat,RGBA_ASTC_4x4_Format:e.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:e.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:e.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:e.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:e.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:e.RGB_ETC1_Format,RGB_ETC2_Format:e.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:e.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:e.RGB_S3TC_DXT1_Format},_.BasisWorker=function(){let e,r,t;const o=_EngineFormat,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(n){const c=n.data;switch(c.type){case"init":e=c.config,R=c.transcoderBinary,r=new Promise((e=>{t={wasmBinary:R,onRuntimeInitialized:e},BASIS(t)})).then((()=>{t.initializeBasis(),void 0===t.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":r.then((()=>{try{const{width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:m,dfdFlags:l}=function(r){const n=new t.KTX2File(new Uint8Array(r));function c(){n.close(),n.delete()}if(!n.isValid())throw c(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const R=n.isUASTC()?a.UASTC_4x4:a.ETC1S,F=n.getWidth(),p=n.getHeight(),m=n.getLayers()||1,l=n.getLevels(),h=n.getHasAlpha(),A=n.getDFDTransferFunc(),B=n.getDFDFlags(),{transcoderFormat:u,engineFormat:S}=function(r,t,n,d){let c,R;const F=r===a.ETC1S?i:_;for(let o=0;o<F.length;o++){const s=F[o];if(e[s.if]&&(s.basisFormat.includes(r)&&!(d&&s.transcoderFormat.length<2)&&(!s.needsPowerOfTwo||T(t)&&T(n))))return c=s.transcoderFormat[d?1:0],R=s.engineFormat[d?1:0],{transcoderFormat:c,engineFormat:R}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),c=s.RGBA32,R=o.RGBAFormat,{transcoderFormat:c,engineFormat:R}}(R,F,p,h);if(!F||!p||!l)throw c(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!n.startTranscoding())throw c(),new Error("THREE.KTX2Loader: .startTranscoding failed");const C=[];for(let e=0;e<l;e++){const r=[];let t,o;for(let s=0;s<m;s++){const a=n.getImageLevelInfo(e,s,0);t=a.origWidth<4?a.origWidth:a.width,o=a.origHeight<4?a.origHeight:a.height;const i=new Uint8Array(n.getImageTranscodedSizeInBytes(e,s,0,u));if(!n.transcodeImage(i,e,s,0,u,0,-1,-1))throw c(),new Error("THREE.KTX2Loader: .transcodeImage failed.");r.push(i)}C.push({data:d(r),width:t,height:o})}return c(),{width:F,height:p,hasAlpha:h,mipmaps:C,format:S,dfdTransferFn:A,dfdFlags:B}}(c.buffer),h=[];for(let e=0;e<F.length;++e)h.push(F[e].data.buffer);self.postMessage({type:"transcode",id:c.id,width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:m,dfdFlags:l},h)}catch(e){console.error(e),self.postMessage({type:"error",id:c.id,error:e.message})}}))}var R}));const n=[{if:"astcSupported",basisFormat:[a.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[o.RGBA_ASTC_4x4_Format,o.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[o.RGBA_BPTC_Format,o.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC1,s.BC3],engineFormat:[o.RGB_S3TC_DXT1_Format,o.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[o.RGB_ETC2_Format,o.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1],engineFormat:[o.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[o.RGB_PVRTC_4BPPV1_Format,o.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],i=n.sort((function(e,r){return e.priorityETC1S-r.priorityETC1S})),_=n.sort((function(e,r){return e.priorityUASTC-r.priorityUASTC}));function T(e){return e<=2||0==(e&e-1)&&0!==e}function d(e){let r=0;for(let t=0;t<e.length;t++){r+=e[t].byteLength}const t=new Uint8Array(r);let o=0;for(let r=0;r<e.length;r++){const s=e[r];t.set(s,o),o+=s.byteLength}return t}};const T={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.RGBAFormat,[t.VK_FORMAT_R32G32_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R16G16_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R8G8_UNORM]:e.RGFormat,[t.VK_FORMAT_R8G8_SRGB]:e.RGFormat,[t.VK_FORMAT_R32_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R16_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R8_SRGB]:e.RedFormat,[t.VK_FORMAT_R8_UNORM]:e.RedFormat},d={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32G32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R8_UNORM]:e.UnsignedByteType},c={[t.VK_FORMAT_R8G8B8A8_SRGB]:3001,[t.VK_FORMAT_R8G8_SRGB]:3001,[t.VK_FORMAT_R8_SRGB]:3001};exports.KTX2Loader=_;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),r=require("../utils/WorkerPool.cjs.js"),t=require("ktx-parse"),o=require("zstddec"),s=require("../_polyfill/CompressedArrayTexture.cjs.js"),a=require("../_polyfill/Data3DTexture.cjs.js");const n=new WeakMap;let i,_=0;class T extends e.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new r.WorkerPool,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}init(){if(!this.transcoderPending){const r=new e.FileLoader(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const t=r.loadAsync("basis_transcoder.js"),o=new e.FileLoader(this.manager);o.setPath(this.transcoderPath),o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const s=o.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,s]).then((([e,r])=>{const t=T.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(T.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(T.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(T.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=r,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),r=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:r},[r]),e}))})),_>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_++}return this.transcoderPending}load(r,t,o,s){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const a=new e.FileLoader(this.manager);a.setResponseType("arraybuffer"),a.setWithCredentials(this.withCredentials),a.load(r,(e=>{if(n.has(e)){return n.get(e).promise.then(t).catch(s)}this._createTexture(e).then((e=>t?t(e):null)).catch(s)}),o,s)}_createTextureFrom(r,o){const{mipmaps:a,width:n,height:i,format:_,type:T,error:d,dfdTransferFn:c,dfdFlags:R}=r;if("error"===T)return Promise.reject(d);const F=o.layerCount>1?new s.CompressedArrayTexture(a,n,i,o.layerCount,_,e.UnsignedByteType):new e.CompressedTexture(a,n,i,_,e.UnsignedByteType);return F.minFilter=1===a.length?e.LinearFilter:e.LinearMipmapLinearFilter,F.magFilter=e.LinearFilter,F.generateMipmaps=!1,F.needsUpdate=!0,"colorSpace"in F?F.colorSpace=c===t.KHR_DF_TRANSFER_SRGB?"srgb":"srgb-linear":F.encoding=c===t.KHR_DF_TRANSFER_SRGB?3001:3e3,F.premultiplyAlpha=!!(R&t.KHR_DF_FLAG_ALPHA_PREMULTIPLIED),F}async _createTexture(r,s={}){const _=t.read(new Uint8Array(r));if(_.vkFormat!==t.VK_FORMAT_UNDEFINED)return async function(r){const{vkFormat:s,pixelWidth:n,pixelHeight:_,pixelDepth:T}=r;if(void 0===d[s])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const F=r.levels[0];let p,l;if(r.supercompressionScheme===t.KHR_SUPERCOMPRESSION_NONE)p=F.levelData;else{if(r.supercompressionScheme!==t.KHR_SUPERCOMPRESSION_ZSTD)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");i||(i=new Promise((async e=>{const r=new o.ZSTDDecoder;await r.init(),e(r)}))),p=(await i).decode(F.levelData,F.uncompressedByteLength)}l=c[s]===e.FloatType?new Float32Array(p.buffer,p.byteOffset,p.byteLength/Float32Array.BYTES_PER_ELEMENT):c[s]===e.HalfFloatType?new Uint16Array(p.buffer,p.byteOffset,p.byteLength/Uint16Array.BYTES_PER_ELEMENT):p;const m=0===T?new e.DataTexture(l,n,_):new a.Data3DTexture(l,n,_,T);return m.type=c[s],m.format=d[s],m.encoding=R[s]||3e3,m.needsUpdate=!0,Promise.resolve(m)}(_);const T=s,F=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:T},[r]))).then((e=>this._createTextureFrom(e.data,_)));return n.set(r,{promise:F}),F}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),_--,this}}T.BasisFormat={ETC1S:0,UASTC_4x4:1},T.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},T.EngineFormat={RGBAFormat:e.RGBAFormat,RGBA_ASTC_4x4_Format:e.RGBA_ASTC_4x4_Format,RGBA_BPTC_Format:e.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:e.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:e.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:e.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:e.RGB_ETC1_Format,RGB_ETC2_Format:e.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:e.RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:e.RGB_S3TC_DXT1_Format},T.BasisWorker=function(){let e,r,t;const o=_EngineFormat,s=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(n){const c=n.data;switch(c.type){case"init":e=c.config,R=c.transcoderBinary,r=new Promise((e=>{t={wasmBinary:R,onRuntimeInitialized:e},BASIS(t)})).then((()=>{t.initializeBasis(),void 0===t.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":r.then((()=>{try{const{width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:l,dfdFlags:m}=function(r){const n=new t.KTX2File(new Uint8Array(r));function c(){n.close(),n.delete()}if(!n.isValid())throw c(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const R=n.isUASTC()?a.UASTC_4x4:a.ETC1S,F=n.getWidth(),p=n.getHeight(),l=n.getLayers()||1,m=n.getLevels(),A=n.getHasAlpha(),h=n.getDFDTransferFunc(),B=n.getDFDFlags(),{transcoderFormat:u,engineFormat:S}=function(r,t,n,d){let c,R;const F=r===a.ETC1S?i:_;for(let o=0;o<F.length;o++){const s=F[o];if(e[s.if]&&(s.basisFormat.includes(r)&&!(d&&s.transcoderFormat.length<2)&&(!s.needsPowerOfTwo||T(t)&&T(n))))return c=s.transcoderFormat[d?1:0],R=s.engineFormat[d?1:0],{transcoderFormat:c,engineFormat:R}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),c=s.RGBA32,R=o.RGBAFormat,{transcoderFormat:c,engineFormat:R}}(R,F,p,A);if(!F||!p||!m)throw c(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!n.startTranscoding())throw c(),new Error("THREE.KTX2Loader: .startTranscoding failed");const f=[];for(let e=0;e<m;e++){const r=[];let t,o;for(let s=0;s<l;s++){const a=n.getImageLevelInfo(e,s,0);t=a.origWidth<4?a.origWidth:a.width,o=a.origHeight<4?a.origHeight:a.height;const i=new Uint8Array(n.getImageTranscodedSizeInBytes(e,s,0,u));if(!n.transcodeImage(i,e,s,0,u,0,-1,-1))throw c(),new Error("THREE.KTX2Loader: .transcodeImage failed.");r.push(i)}f.push({data:d(r),width:t,height:o})}return c(),{width:F,height:p,hasAlpha:A,mipmaps:f,format:S,dfdTransferFn:h,dfdFlags:B}}(c.buffer),A=[];for(let e=0;e<F.length;++e)A.push(F[e].data.buffer);self.postMessage({type:"transcode",id:c.id,width:r,height:n,hasAlpha:R,mipmaps:F,format:p,dfdTransferFn:l,dfdFlags:m},A)}catch(e){console.error(e),self.postMessage({type:"error",id:c.id,error:e.message})}}))}var R}));const n=[{if:"astcSupported",basisFormat:[a.UASTC_4x4],transcoderFormat:[s.ASTC_4x4,s.ASTC_4x4],engineFormat:[o.RGBA_ASTC_4x4_Format,o.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC7_M5,s.BC7_M5],engineFormat:[o.RGBA_BPTC_Format,o.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.BC1,s.BC3],engineFormat:[o.RGB_S3TC_DXT1_Format,o.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1,s.ETC2],engineFormat:[o.RGB_ETC2_Format,o.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.ETC1],engineFormat:[o.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[s.PVRTC1_4_RGB,s.PVRTC1_4_RGBA],engineFormat:[o.RGB_PVRTC_4BPPV1_Format,o.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],i=n.sort((function(e,r){return e.priorityETC1S-r.priorityETC1S})),_=n.sort((function(e,r){return e.priorityUASTC-r.priorityUASTC}));function T(e){return e<=2||0==(e&e-1)&&0!==e}function d(e){let r=0;for(let t=0;t<e.length;t++){r+=e[t].byteLength}const t=new Uint8Array(r);let o=0;for(let r=0;r<e.length;r++){const s=e[r];t.set(s,o),o+=s.byteLength}return t}};const d={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.RGBAFormat,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.RGBAFormat,[t.VK_FORMAT_R32G32_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R16G16_SFLOAT]:e.RGFormat,[t.VK_FORMAT_R8G8_UNORM]:e.RGFormat,[t.VK_FORMAT_R8G8_SRGB]:e.RGFormat,[t.VK_FORMAT_R32_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R16_SFLOAT]:e.RedFormat,[t.VK_FORMAT_R8_SRGB]:e.RedFormat,[t.VK_FORMAT_R8_UNORM]:e.RedFormat},c={[t.VK_FORMAT_R32G32B32A32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16B16A16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8B8A8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8B8A8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32G32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16G16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8G8_UNORM]:e.UnsignedByteType,[t.VK_FORMAT_R8G8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R32_SFLOAT]:e.FloatType,[t.VK_FORMAT_R16_SFLOAT]:e.HalfFloatType,[t.VK_FORMAT_R8_SRGB]:e.UnsignedByteType,[t.VK_FORMAT_R8_UNORM]:e.UnsignedByteType},R={[t.VK_FORMAT_R8G8B8A8_SRGB]:3001,[t.VK_FORMAT_R8G8_SRGB]:3001,[t.VK_FORMAT_R8_SRGB]:3001};exports.KTX2Loader=T;
|
package/loaders/KTX2Loader.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
import { Loader, FileLoader, UnsignedByteType, CompressedTexture, LinearFilter, LinearMipmapLinearFilter, RGBAFormat, RGBA_ASTC_4x4_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, FloatType, HalfFloatType, DataTexture,
|
1
|
+
import { Loader, FileLoader, UnsignedByteType, CompressedTexture, LinearFilter, LinearMipmapLinearFilter, RGBAFormat, RGBA_ASTC_4x4_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, FloatType, HalfFloatType, DataTexture, RGFormat, RedFormat } from 'three';
|
2
2
|
import { WorkerPool } from '../utils/WorkerPool.js';
|
3
3
|
import { KHR_DF_TRANSFER_SRGB, KHR_DF_FLAG_ALPHA_PREMULTIPLIED, read, VK_FORMAT_UNDEFINED, KHR_SUPERCOMPRESSION_NONE, KHR_SUPERCOMPRESSION_ZSTD, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SRGB, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R8_SRGB, VK_FORMAT_R8_UNORM } from 'ktx-parse';
|
4
4
|
import { ZSTDDecoder } from 'zstddec';
|
5
|
+
import { CompressedArrayTexture } from '../_polyfill/CompressedArrayTexture.js';
|
6
|
+
import { Data3DTexture } from '../_polyfill/Data3DTexture.js';
|
5
7
|
|
6
8
|
/**
|
7
9
|
* Loader for KTX 2.0 GPU Texture containers.
|
@@ -16,16 +18,6 @@ import { ZSTDDecoder } from 'zstddec';
|
|
16
18
|
* - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
|
17
19
|
*/
|
18
20
|
|
19
|
-
class CompressedArrayTexture extends CompressedTexture {
|
20
|
-
constructor(mipmaps, width, height, depth, format, type) {
|
21
|
-
super(mipmaps, width, height, format, type);
|
22
|
-
this.isCompressedArrayTexture = true;
|
23
|
-
this.image.depth = depth;
|
24
|
-
this.wrapR = ClampToEdgeWrapping;
|
25
|
-
}
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
21
|
const _taskCache = new WeakMap();
|
30
22
|
|
31
23
|
let _activeLoaders = 0;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../_polyfill/Data3DTexture.cjs.js");class r extends e.Loader{load(t,r,a,i){const n=new e.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("text"),n.load(t,(e=>{try{r(this.parse(e))}catch(e){i?i(e):console.error(e),this.manager.itemError(t)}}),a,i)}parse(r){const a=(r=r.replace(/^#.*?(\n|\r)/gm,"").replace(/^\s*?(\n|\r)/gm,"").trim()).split(/[\n\r]+/g),i=a[0].trim().split(/\s+/g).map((e=>parseFloat(e))),n=i[1]-i[0],p=i.length;for(let e=1,t=i.length;e<t;e++)if(n!==i[e]-i[e-1])throw new Error("LUT3dlLoader: Inconsistent grid size not supported.");const o=new Array(p*p*p*4);let s=0,l=0;for(let e=1,t=a.length;e<t;e++){const t=a[e].trim().split(/\s/g),r=parseFloat(t[0]),i=parseFloat(t[1]),n=parseFloat(t[2]);l=Math.max(l,r,i,n);const g=s%p*p*p+Math.floor(s/p)%p*p+Math.floor(s/(p*p))%p;o[4*g+0]=r,o[4*g+1]=i,o[4*g+2]=n,o[4*g+3]=1,s+=1}const g=Math.ceil(Math.log2(l)),m=Math.pow(2,g);for(let e=0,t=o.length;e<t;e+=4){const t=o[e+0],r=o[e+1],a=o[e+2];o[e+0]=255*t/m,o[e+1]=255*r/m,o[e+2]=255*a/m}const d=new Uint8Array(o),h=new e.DataTexture;h.image.data=d,h.image.width=p,h.image.height=p*p,h.format=e.RGBAFormat,h.type=e.UnsignedByteType,h.magFilter=e.LinearFilter,h.minFilter=e.LinearFilter,h.wrapS=e.ClampToEdgeWrapping,h.wrapT=e.ClampToEdgeWrapping,h.generateMipmaps=!1,h.needsUpdate=!0;const c=new t.Data3DTexture;return c.image.data=d,c.image.width=p,c.image.height=p,c.image.depth=p,c.format=e.RGBAFormat,c.type=e.UnsignedByteType,c.magFilter=e.LinearFilter,c.minFilter=e.LinearFilter,c.wrapS=e.ClampToEdgeWrapping,c.wrapT=e.ClampToEdgeWrapping,c.wrapR=e.ClampToEdgeWrapping,c.generateMipmaps=!1,c.needsUpdate=!0,{size:p,texture:h,texture3D:c}}}exports.LUT3dlLoader=r;
|
package/loaders/LUT3dlLoader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Loader, FileLoader, DataTexture, RGBAFormat, UnsignedByteType, LinearFilter, ClampToEdgeWrapping
|
1
|
+
import { Loader, FileLoader, DataTexture, RGBAFormat, UnsignedByteType, LinearFilter, ClampToEdgeWrapping } from 'three';
|
2
|
+
import { Data3DTexture } from '../_polyfill/Data3DTexture.js';
|
2
3
|
|
3
4
|
// http://download.autodesk.com/us/systemdocs/help/2011/lustre/index.html?url=./files/WSc4e151a45a3b785a24c3d9a411df9298473-7ffd.htm,topicNumber=d0e9492
|
4
5
|
class LUT3dlLoader extends Loader {
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),a=require("../_polyfill/Data3DTexture.cjs.js");class t extends e.Loader{load(a,t,r,i){const s=new e.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("text"),s.load(a,(e=>{try{t(this.parse(e))}catch(e){i?i(e):console.error(e),this.manager.itemError(a)}}),r,i)}parse(t){t=t.replace(/^#.*?(\n|\r)/gm,"").replace(/^\s*?(\n|\r)/gm,"").trim();let r=null,i=null;const s=new e.Vector3(0,0,0),n=new e.Vector3(1,1,1),p=t.split(/[\n\r]+/g);let l=null,o=0;for(let e=0,a=p.length;e<a;e++){const a=p[e].trim(),t=a.split(/\s/g);switch(t[0]){case"TITLE":r=a.substring(7,a.length-1);break;case"LUT_3D_SIZE":const e=t[1];i=parseFloat(e),l=new Uint8Array(i*i*i*4);break;case"DOMAIN_MIN":s.x=parseFloat(t[1]),s.y=parseFloat(t[2]),s.z=parseFloat(t[3]);break;case"DOMAIN_MAX":n.x=parseFloat(t[1]),n.y=parseFloat(t[2]),n.z=parseFloat(t[3]);break;default:const p=parseFloat(t[0]),g=parseFloat(t[1]),d=parseFloat(t[2]);if(p>1||p<0||g>1||g<0||d>1||d<0)throw new Error("LUTCubeLoader : Non normalized values not supported.");l[o+0]=255*p,l[o+1]=255*g,l[o+2]=255*d,l[o+3]=255,o+=4}}const g=new e.DataTexture;g.image.data=l,g.image.width=i,g.image.height=i*i,g.type=e.UnsignedByteType,g.magFilter=e.LinearFilter,g.minFilter=e.LinearFilter,g.wrapS=e.ClampToEdgeWrapping,g.wrapT=e.ClampToEdgeWrapping,g.generateMipmaps=!1,g.needsUpdate=!0;const d=new a.Data3DTexture;return d.image.data=l,d.image.width=i,d.image.height=i,d.image.depth=i,d.type=e.UnsignedByteType,d.magFilter=e.LinearFilter,d.minFilter=e.LinearFilter,d.wrapS=e.ClampToEdgeWrapping,d.wrapT=e.ClampToEdgeWrapping,d.wrapR=e.ClampToEdgeWrapping,d.generateMipmaps=!1,d.needsUpdate=!0,{title:r,size:i,domainMin:s,domainMax:n,texture:g,texture3D:d}}}exports.LUTCubeLoader=t;
|
package/loaders/LUTCubeLoader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Loader, FileLoader, Vector3, DataTexture, UnsignedByteType, LinearFilter, ClampToEdgeWrapping
|
1
|
+
import { Loader, FileLoader, Vector3, DataTexture, UnsignedByteType, LinearFilter, ClampToEdgeWrapping } from 'three';
|
2
|
+
import { Data3DTexture } from '../_polyfill/Data3DTexture.js';
|
2
3
|
|
3
4
|
// https://wwwimages2.adobe.com/content/dam/acom/en/products/speedgrade/cc/pdfs/cube-lut-specification-1.0.pdf
|
4
5
|
class LUTCubeLoader extends Loader {
|
package/loaders/VOXLoader.cjs.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("../_polyfill/Data3DTexture.cjs.js");class r extends e.Loader{load(t,r,s,n){const o=this,a=new e.FileLoader(o.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.setRequestHeader(o.requestHeader),a.load(t,(function(e){try{r(o.parse(e))}catch(e){n?n(e):console.error(e),o.manager.itemError(t)}}),s,n)}parse(e){const t=new DataView(e),r=t.getUint32(0,!0),s=t.getUint32(4,!0);if(542658390!==r||150!==s)return void console.error("Not a valid VOX file");const n=[0,4294967295,4291624959,4288282623,4284940287,4281597951,4278255615,4294954239,4291611903,4288269567,4284927231,4281584895,4278242559,4294941183,4291598847,4288256511,4284914175,4281571839,4278229503,4294928127,4291585791,4288243455,4284901119,4281558783,4278216447,4294915071,4291572735,4288230399,4284888063,4281545727,4278203391,4294902015,4291559679,4288217343,4284875007,4281532671,4278190335,4294967244,4291624908,4288282572,4284940236,4281597900,4278255564,4294954188,4291611852,4288269516,4284927180,4281584844,4278242508,4294941132,4291598796,4288256460,4284914124,4281571788,4278229452,4294928076,4291585740,4288243404,4284901068,4281558732,4278216396,4294915020,4291572684,4288230348,4284888012,4281545676,4278203340,4294901964,4291559628,4288217292,4284874956,4281532620,4278190284,4294967193,4291624857,4288282521,4284940185,4281597849,4278255513,4294954137,4291611801,4288269465,4284927129,4281584793,4278242457,4294941081,4291598745,4288256409,4284914073,4281571737,4278229401,4294928025,4291585689,4288243353,4284901017,4281558681,4278216345,4294914969,4291572633,4288230297,4284887961,4281545625,4278203289,4294901913,4291559577,4288217241,4284874905,4281532569,4278190233,4294967142,4291624806,4288282470,4284940134,4281597798,4278255462,4294954086,4291611750,4288269414,4284927078,4281584742,4278242406,4294941030,4291598694,4288256358,4284914022,4281571686,4278229350,4294927974,4291585638,4288243302,4284900966,4281558630,4278216294,4294914918,4291572582,4288230246,4284887910,4281545574,4278203238,4294901862,4291559526,4288217190,4284874854,4281532518,4278190182,4294967091,4291624755,4288282419,4284940083,4281597747,4278255411,4294954035,4291611699,4288269363,4284927027,4281584691,4278242355,4294940979,4291598643,4288256307,4284913971,4281571635,4278229299,4294927923,4291585587,4288243251,4284900915,4281558579,4278216243,4294914867,4291572531,4288230195,4284887859,4281545523,4278203187,4294901811,4291559475,4288217139,4284874803,4281532467,4278190131,4294967040,4291624704,4288282368,4284940032,4281597696,4278255360,4294953984,4291611648,4288269312,4284926976,4281584640,4278242304,4294940928,4291598592,4288256256,4284913920,4281571584,4278229248,4294927872,4291585536,4288243200,4284900864,4281558528,4278216192,4294914816,4291572480,4288230144,4284887808,4281545472,4278203136,4294901760,4291559424,4288217088,4284874752,4281532416,4278190318,4278190301,4278190267,4278190250,4278190216,4278190199,4278190165,4278190148,4278190114,4278190097,4278251008,4278246656,4278237952,4278233600,4278224896,4278220544,4278211840,4278207488,4278198784,4278194432,4293787648,4292673536,4290445312,4289331200,4287102976,4285988864,4283760640,4282646528,4280418304,4279304192,4293848814,4292730333,4290493371,4289374890,4287137928,4286019447,4283782485,4282664004,4280427042,4279308561];let o,a=8;const i=[];for(;a<t.byteLength;){let r="";for(let e=0;e<4;e++)r+=String.fromCharCode(t.getUint8(a++));const s=t.getUint32(a,!0);if(a+=4,a+=4,"SIZE"===r){const e=t.getUint32(a,!0);a+=4;const r=t.getUint32(a,!0);a+=4;const l=t.getUint32(a,!0);a+=4,o={palette:n,size:{x:e,y:r,z:l}},i.push(o),a+=s-12}else if("XYZI"===r){const r=t.getUint32(a,!0);a+=4,o.data=new Uint8Array(e,a,4*r),a+=4*r}else if("RGBA"===r){const e=[0];for(let r=0;r<256;r++)e[r+1]=t.getUint32(a,!0),a+=4;o.palette=e}else a+=s}return i}}class s extends e.Mesh{constructor(t){const r=t.data,s=t.size,n=t.palette,o=[],a=[],i=[0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1],l=[1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0],c=[0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1],u=[0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,0],f=[0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0],d=[0,1,1,1,1,1,0,1,0,1,1,0,0,1,0,1,1,1];function p(e,t,r,n,i,l,c){t-=s.x/2,r-=s.z/2,n+=s.y/2;for(let s=0;s<18;s+=3)o.push(e[s+0]+t,e[s+1]+r,e[s+2]+n),a.push(i,l,c)}const x=s.x,h=s.x*s.y,g=new Uint8Array(s.x*s.y*s.z);for(let e=0;e<r.length;e+=4){g[r[e+0]+r[e+1]*x+r[e+2]*h]=255}let y=!1;for(let e=0;e<r.length;e+=4){const t=r[e+0],o=r[e+1],a=r[e+2],U=n[r[e+3]],m=(U>>0&255)/255,w=(U>>8&255)/255,z=(U>>16&255)/255;(m>0||w>0||z>0)&&(y=!0);const A=t+o*x+a*h;0!==g[A+1]&&t!==s.x-1||p(l,t,a,-o,m,w,z),0!==g[A-1]&&0!==t||p(i,t,a,-o,m,w,z),0!==g[A+x]&&o!==s.y-1||p(u,t,a,-o,m,w,z),0!==g[A-x]&&0!==o||p(c,t,a,-o,m,w,z),0!==g[A+h]&&a!==s.z-1||p(d,t,a,-o,m,w,z),0!==g[A-h]&&0!==a||p(f,t,a,-o,m,w,z)}const U=new e.BufferGeometry;U.setAttribute("position",new e.Float32BufferAttribute(o,3)),U.computeVertexNormals();const m=new e.MeshStandardMaterial;y&&(U.setAttribute("color",new e.Float32BufferAttribute(a,3)),m.vertexColors=!0),super(U,m)}}class n extends t.Data3DTexture{constructor(t){const r=t.data,s=t.size,n=s.x,o=s.x*s.y,a=new Uint8Array(s.x*s.y*s.z);for(let e=0;e<r.length;e+=4){a[r[e+0]+r[e+1]*n+r[e+2]*o]=255}super(a,s.x,s.y,s.z),this.format=e.RedFormat,this.minFilter=e.NearestFilter,this.magFilter=e.LinearFilter,this.unpackAlignment=1,this.needsUpdate=!0}}exports.VOXData3DTexture=n,exports.VOXLoader=r,exports.VOXMesh=s;
|
package/loaders/VOXLoader.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import { Loader, FileLoader, Mesh, BufferGeometry, Float32BufferAttribute, MeshStandardMaterial,
|
1
|
+
import { Loader, FileLoader, Mesh, BufferGeometry, Float32BufferAttribute, MeshStandardMaterial, RedFormat, NearestFilter, LinearFilter } from 'three';
|
2
|
+
import { Data3DTexture } from '../_polyfill/Data3DTexture.js';
|
2
3
|
|
3
4
|
class VOXLoader extends Loader {
|
4
5
|
load(url, onLoad, onProgress, onError) {
|
package/package.json
CHANGED
@@ -295,7 +295,11 @@ SSRPass.prototype = Object.assign(Object.create(Pass.prototype), {
|
|
295
295
|
) {
|
296
296
|
// render beauty and depth
|
297
297
|
if (this.encoding) {
|
298
|
-
if ('colorSpace' in this.beautyRenderTarget.texture)
|
298
|
+
if ('colorSpace' in this.beautyRenderTarget.texture) {
|
299
|
+
this.beautyRenderTarget.texture.colorSpace = this.encoding === 3001 ? 'srgb' : 'srgb-linear';
|
300
|
+
} else {
|
301
|
+
this.beautyRenderTarget.texture.encoding = this.encoding;
|
302
|
+
}
|
299
303
|
}
|
300
304
|
|
301
305
|
renderer.setRenderTarget(this.beautyRenderTarget);
|