This commit is contained in:
abdelrahman committed 2026-06-14 19:09:18 +01:00
1 parent 14bd1a9271
commit 13fa90a0e9
3958 files changed
+999286 -4

No files matched your search

+518
View File
@@ -0,0 +1,518 @@
/**
* @author Don McCurdy / https://www.donmccurdy.com
* @author Austin Eng / https://github.com/austinEng
* @author Shrek Shao / https://github.com/shrekshao
*/
/**
* Loader for Basis Universal GPU Texture Codec.
*
* Basis Universal is a "supercompressed" GPU texture and texture video
* compression system that outputs a highly compressed intermediate file format
* (.basis) that can be quickly transcoded to a wide variety of GPU texture
* compression formats.
*
* This loader parallelizes the transcoding process across a configurable number
* of web workers, before transferring the transcoded compressed texture back
* to the main thread.
*/
THREE.BasisTextureLoader = function ( manager ) {
THREE.Loader.call( this, manager );
this.transcoderPath = '';
this.transcoderBinary = null;
this.transcoderPending = null;
this.workerLimit = 4;
this.workerPool = [];
this.workerNextTaskID = 1;
this.workerSourceURL = '';
this.workerConfig = {
format: null,
astcSupported: false,
etcSupported: false,
dxtSupported: false,
pvrtcSupported: false,
};
};
THREE.BasisTextureLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
constructor: THREE.BasisTextureLoader,
setTranscoderPath: function ( path ) {
this.transcoderPath = path;
return this;
},
setWorkerLimit: function ( workerLimit ) {
this.workerLimit = workerLimit;
return this;
},
detectSupport: function ( renderer ) {
var config = this.workerConfig;
config.bc7Supported = !! renderer.extensions.get( 'EXT_texture_compression_bptc' );
config.astcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_astc' );
config.etcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_etc1' );
config.dxtSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_s3tc' );
config.pvrtcSupported = !! renderer.extensions.get( 'WEBGL_compressed_texture_pvrtc' )
|| !! renderer.extensions.get( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
if ( config.astcSupported ) {
config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4;
} else if ( config.bc7Supported ) {
config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC7_M6_OPAQUE_ONLY;
} else if ( config.dxtSupported ) {
config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3;
} else if ( config.etcSupported ) {
config.format = THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1;
} else if ( config.pvrtcSupported ) {
config.format = this.useAlpha ? THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA : THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;
} else {
throw new Error( 'THREE.BasisTextureLoader: No suitable compressed texture format found.' );
}
return this;
},
load: function ( url, onLoad, onProgress, onError ) {
var loader = new THREE.FileLoader( this.manager );
loader.setResponseType( 'arraybuffer' );
loader.load( url, ( buffer ) => {
this._createTexture( buffer )
.then( onLoad )
.catch( onError );
}, onProgress, onError );
},
/**
* @param {ArrayBuffer} buffer
* @return {Promise<THREE.CompressedTexture>}
*/
_createTexture: function ( buffer ) {
var worker;
var taskID;
var taskCost = buffer.byteLength;
var texturePending = this._allocateWorker( taskCost )
.then( ( _worker ) => {
worker = _worker;
taskID = this.workerNextTaskID ++;
return new Promise( ( resolve, reject ) => {
worker._callbacks[ taskID ] = { resolve, reject };
worker.postMessage( { type: 'transcode', id: taskID, buffer }, [ buffer ] );
} );
} )
.then( ( message ) => {
var config = this.workerConfig;
var { width, height, mipmaps, format } = message;
var texture;
switch ( format ) {
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGBA_ASTC_4x4_Format );
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC7_M6_OPAQUE_ONLY:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.BasisTextureLoader.COMPRESSED_RGBA_BPTC_UNORM );
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC1:
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.BasisTextureLoader.DXT_FORMAT_MAP[ config.format ], THREE.UnsignedByteType );
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_ETC1_Format );
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGB_PVRTC_4BPPV1_Format );
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA:
texture = new THREE.CompressedTexture( mipmaps, width, height, THREE.RGBA_PVRTC_4BPPV1_Format );
break;
default:
throw new Error( 'THREE.BasisTextureLoader: No supported format available.' );
}
texture.minFilter = mipmaps.length === 1 ? THREE.LinearFilter : THREE.LinearMipmapLinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
texture.needsUpdate = true;
return texture;
} );
texturePending
.finally( () => {
if ( worker && taskID ) {
worker._taskLoad -= taskCost;
delete worker._callbacks[ taskID ];
}
} );
return texturePending;
},
_initTranscoder: function () {
if ( ! this.transcoderPending ) {
// Load transcoder wrapper.
var jsLoader = new THREE.FileLoader( this.manager );
jsLoader.setPath( this.transcoderPath );
var jsContent = new Promise( ( resolve, reject ) => {
jsLoader.load( 'basis_transcoder.js', resolve, undefined, reject );
} );
// Load transcoder WASM binary.
var binaryLoader = new THREE.FileLoader( this.manager );
binaryLoader.setPath( this.transcoderPath );
binaryLoader.setResponseType( 'arraybuffer' );
var binaryContent = new Promise( ( resolve, reject ) => {
binaryLoader.load( 'basis_transcoder.wasm', resolve, undefined, reject );
} );
this.transcoderPending = Promise.all( [ jsContent, binaryContent ] )
.then( ( [ jsContent, binaryContent ] ) => {
var fn = THREE.BasisTextureLoader.BasisWorker.toString();
var body = [
'/* basis_transcoder.js */',
jsContent,
'/* worker */',
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
].join( '\n' );
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
this.transcoderBinary = binaryContent;
} );
}
return this.transcoderPending;
},
_allocateWorker: function ( taskCost ) {
return this._initTranscoder().then( () => {
if ( this.workerPool.length < this.workerLimit ) {
var worker = new Worker( this.workerSourceURL );
worker._callbacks = {};
worker._taskLoad = 0;
worker.postMessage( {
type: 'init',
config: this.workerConfig,
transcoderBinary: this.transcoderBinary,
} );
worker.onmessage = function ( e ) {
var message = e.data;
switch ( message.type ) {
case 'transcode':
worker._callbacks[ message.id ].resolve( message );
break;
case 'error':
worker._callbacks[ message.id ].reject( message );
break;
default:
console.error( 'THREE.BasisTextureLoader: Unexpected message, "' + message.type + '"' );
}
};
this.workerPool.push( worker );
} else {
this.workerPool.sort( function ( a, b ) {
return a._taskLoad > b._taskLoad ? - 1 : 1;
} );
}
var worker = this.workerPool[ this.workerPool.length - 1 ];
worker._taskLoad += taskCost;
return worker;
} );
},
dispose: function () {
for ( var i = 0; i < this.workerPool.length; i ++ ) {
this.workerPool[ i ].terminate();
}
this.workerPool.length = 0;
return this;
}
} );
/* CONSTANTS */
THREE.BasisTextureLoader.BASIS_FORMAT = {
cTFETC1: 0,
cTFETC2: 1,
cTFBC1: 2,
cTFBC3: 3,
cTFBC4: 4,
cTFBC5: 5,
cTFBC7_M6_OPAQUE_ONLY: 6,
cTFBC7_M5: 7,
cTFPVRTC1_4_RGB: 8,
cTFPVRTC1_4_RGBA: 9,
cTFASTC_4x4: 10,
cTFATC_RGB: 11,
cTFATC_RGBA_INTERPOLATED_ALPHA: 12,
cTFRGBA32: 13,
cTFRGB565: 14,
cTFBGR565: 15,
cTFRGBA4444: 16,
};
// DXT formats, from:
// http://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/
THREE.BasisTextureLoader.DXT_FORMAT = {
COMPRESSED_RGB_S3TC_DXT1_EXT: 0x83F0,
COMPRESSED_RGBA_S3TC_DXT1_EXT: 0x83F1,
COMPRESSED_RGBA_S3TC_DXT3_EXT: 0x83F2,
COMPRESSED_RGBA_S3TC_DXT5_EXT: 0x83F3,
};
THREE.BasisTextureLoader.DXT_FORMAT_MAP = {};
THREE.BasisTextureLoader.DXT_FORMAT_MAP[ THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC1 ] =
THREE.BasisTextureLoader.DXT_FORMAT.COMPRESSED_RGB_S3TC_DXT1_EXT;
THREE.BasisTextureLoader.DXT_FORMAT_MAP[ THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3 ] =
THREE.BasisTextureLoader.DXT_FORMAT.COMPRESSED_RGBA_S3TC_DXT5_EXT;
// ASTC formats, from:
// https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/
THREE.BasisTextureLoader.COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0;
// BC7/BPTC format, from:
// https://www.khronos.org/registry/webgl/extensions/EXT_texture_compression_bptc/
THREE.BasisTextureLoader.COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C;
/* WEB WORKER */
THREE.BasisTextureLoader.BasisWorker = function () {
var config;
var transcoderPending;
var _BasisFile;
onmessage = function ( e ) {
var message = e.data;
switch ( message.type ) {
case 'init':
config = message.config;
init( message.transcoderBinary );
break;
case 'transcode':
transcoderPending.then( () => {
try {
var { width, height, hasAlpha, mipmaps, format } = transcode( message.buffer );
var buffers = [];
for ( var i = 0; i < mipmaps.length; ++ i ) {
buffers.push( mipmaps[ i ].data.buffer );
}
self.postMessage( { type: 'transcode', id: message.id, width, height, hasAlpha, mipmaps, format }, buffers );
} catch ( error ) {
console.error( error );
self.postMessage( { type: 'error', id: message.id, error: error.message } );
}
} );
break;
}
};
function init( wasmBinary ) {
var BasisModule;
transcoderPending = new Promise( ( resolve ) => {
BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
BASIS( BasisModule );
} ).then( () => {
var { BasisFile, initializeBasis } = BasisModule;
_BasisFile = BasisFile;
initializeBasis();
} );
}
function transcode( buffer ) {
var basisFile = new _BasisFile( new Uint8Array( buffer ) );
var width = basisFile.getImageWidth( 0, 0 );
var height = basisFile.getImageHeight( 0, 0 );
var levels = basisFile.getNumLevels( 0 );
var hasAlpha = basisFile.getHasAlpha();
function cleanup() {
basisFile.close();
basisFile.delete();
}
if ( ! hasAlpha ) {
switch ( config.format ) {
case 9: // Hardcoded: THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA
config.format = 8; // Hardcoded: THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;
break;
default:
break;
}
}
if ( ! width || ! height || ! levels ) {
cleanup();
throw new Error( 'THREE.BasisTextureLoader: Invalid .basis file' );
}
if ( ! basisFile.startTranscoding() ) {
cleanup();
throw new Error( 'THREE.BasisTextureLoader: .startTranscoding failed' );
}
var mipmaps = [];
for ( var mip = 0; mip < levels; mip ++ ) {
var mipWidth = basisFile.getImageWidth( 0, mip );
var mipHeight = basisFile.getImageHeight( 0, mip );
var dst = new Uint8Array( basisFile.getImageTranscodedSizeInBytes( 0, mip, config.format ) );
var status = basisFile.transcodeImage(
dst,
0,
mip,
config.format,
0,
hasAlpha
);
if ( ! status ) {
cleanup();
throw new Error( 'THREE.BasisTextureLoader: .transcodeImage failed.' );
}
mipmaps.push( { data: dst, width: mipWidth, height: mipHeight } );
}
cleanup();
return { width, height, hasAlpha, mipmaps, format: config.format };
}
};
File diff suppressed because it is too large. Load diff
+8
View File
@@ -0,0 +1,8 @@
## Credits
* Contributors:
* [Don McCurdy](https://www.donmccurdy.com)
* [Austin Eng](https://github.com/austinEng)
* [Shrek Shao](https://github.com/shrekshao)
* Made with [three.js](https://threejs.org/).
* Thanks to [AGI](http://agi.com/) for providing the glTF model.
+254
View File
@@ -0,0 +1,254 @@
{
"accessors": [
{
"byteOffset": 0,
"componentType": 5126,
"type": "VEC3",
"count": 55381,
"min": [
-527.3590087890625,
-104.39354705810547,
-495.3590087890625
],
"max": [
599.3590087890625,
-33.72303009033203,
561.3590087890625
],
"bufferView": 0,
"name": "mesh-0-0_Accessor_POSITION"
},
{
"byteOffset": 0,
"componentType": 5126,
"type": "VEC2",
"count": 55381,
"min": [
0.0000017028407910402166,
0.00000289904824057885
],
"max": [
0.9993386268615723,
0.9999556541442871
],
"bufferView": 1,
"name": "mesh-0-0_Accessor_TEXCOORD_0"
},
{
"byteOffset": 0,
"componentType": 5123,
"type": "SCALAR",
"count": 151158,
"bufferView": 4,
"name": "mesh-0-0_Accessor_indices"
},
{
"byteOffset": 0,
"componentType": 5126,
"type": "VEC3",
"count": 30806,
"min": [
-527.3590087890625,
-105.48443603515625,
-495.3590087890625
],
"max": [
599.3590087890625,
-26.287290573120117,
561.3590087890625
],
"bufferView": 2,
"name": "mesh-1-0_Accessor_POSITION"
},
{
"byteOffset": 0,
"componentType": 5126,
"type": "VEC2",
"count": 30806,
"min": [
0.00000964943137660157,
0.000003775880941248033
],
"max": [
0.9999449253082275,
0.9999914169311523
],
"bufferView": 3,
"name": "mesh-1-0_Accessor_TEXCOORD_0"
},
{
"byteOffset": 302316,
"componentType": 5123,
"type": "SCALAR",
"count": 58476,
"bufferView": 4,
"name": "mesh-1-0_Accessor_indices"
}
],
"asset": {
"generator": "obj2gltf",
"version": "2.0"
},
"buffers": [
{
"name": "mesh-0-0_Buffer_POSITION",
"byteLength": 2143008,
"uri": "mesh-0-0_Buffer_POSITION.bin"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 664572,
"byteOffset": 0,
"target": 34962,
"name": "bufferView_0",
"byteStride": 12
},
{
"buffer": 0,
"byteLength": 443048,
"byteOffset": 664572,
"target": 34962,
"name": "bufferView_0",
"byteStride": 8
},
{
"buffer": 0,
"byteLength": 369672,
"byteOffset": 1107620,
"target": 34962,
"name": "bufferView_0",
"byteStride": 12
},
{
"buffer": 0,
"byteLength": 246448,
"byteOffset": 1477292,
"target": 34962,
"name": "bufferView_0",
"byteStride": 8
},
{
"buffer": 0,
"byteLength": 419268,
"byteOffset": 1723740,
"target": 34963,
"name": "bufferView_1"
}
],
"materials": [
{
"name": "Texture",
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0,
"texCoord": 0
},
"metallicFactor": 0,
"roughnessFactor": 1,
"baseColorFactor": [
1,
1,
1,
1
]
},
"emissiveTexture": {
"index": 0,
"texCoord": 0
},
"alphaMode": "OPAQUE",
"doubleSided": false,
"emissiveFactor": [
0,
0,
0
]
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"POSITION": 0,
"TEXCOORD_0": 1
},
"indices": 2,
"material": 0,
"mode": 4
}
],
"name": "mesh-split_1"
},
{
"primitives": [
{
"attributes": {
"POSITION": 3,
"TEXCOORD_0": 4
},
"indices": 5,
"material": 0,
"mode": 4
}
],
"name": "mesh-split_2"
}
],
"nodes": [
{
"children": [
1
],
"name": "rootNode_0",
"mesh": 0
},
{
"mesh": 1
}
],
"samplers": [
{
"magFilter": 9729,
"minFilter": 9729,
"wrapS": 33071,
"wrapT": 33071,
"name": "sampler_0"
}
],
"scene": 0,
"scenes": [
{
"nodes": [
0
],
"name": "scene"
}
],
"textures": [
{
"sampler": 0,
"name": "textureAtlas",
"extensions": {
"GOOGLE_texture_basis": {
"source": 0
}
}
}
],
"images": [
{
"name": "textureAtlasImage",
"mimeType": "image/basis",
"uri": "textureAtlasImage.basis"
}
],
"extensionsUsed": [
"GOOGLE_texture_basis"
],
"extensionsRequired": [
"GOOGLE_texture_basis"
]
}
Binary file not shown.
Binary file not shown.
+131
View File
@@ -0,0 +1,131 @@
<!DOCTYPE html>
<head>
<!-- <script src="https://cdn.jsdelivr.net/npm/three@v0.108.0"></script> -->
<script src="three.min.js"></script>
<script src="GLTFLoader.js"></script>
<script src="BasisTextureLoader.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@v0.104.0/examples/js/controls/OrbitControls.js"></script>
<style>
html, body { width:100%; height:100%; margin:0; padding:0; }
canvas { display:block; }
#panel { position: absolute; top: 10px; left: 10px; color: white; background-color:rgba(0.3, 0.3, 0.3, 0.3); padding: 0.5em; max-width: 400px;}
</style>
</head>
<body>
<div id="panel">
<strong>Basis Texture Transcoder glTF Demo</strong>
<div id="log"></div>
</div>
<script>
const renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
renderer.gammaFactor = 2.2;
const scene = new THREE.Scene();
scene.background = new THREE.Color( 0xf0f0f0 );
const light = new THREE.AmbientLight();
scene.add( light );
const light2 = new THREE.PointLight();
scene.add( light2 );
const camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 100 );
camera.position.set( 8, 6, 5 );
camera.lookAt( new THREE.Vector3( 0, -2, 0 ) );
const controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.autoRotate = true;
// Create BasisTextureLoader and detect supported target formats.
const basisLoader = new THREE.BasisTextureLoader();
basisLoader.setTranscoderPath( '../transcoder/build/' );
basisLoader.useAlpha = false;
basisLoader.detectSupport( renderer );
let formatName = 'Unknown format';
switch(basisLoader.workerConfig.format)
{
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFASTC_4x4:
formatName = 'ASTC';
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC1:
formatName = 'BC1';
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC3:
formatName = 'BC3';
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFBC7_M6_OPAQUE_ONLY:
formatName = 'BC7';
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB:
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA:
formatName = 'PVRTC';
break;
case THREE.BasisTextureLoader.BASIS_FORMAT.cTFETC1:
formatName = 'ETC1';
break;
default:
break;
}
log(`Transcode to: <strong>${formatName}</strong>`);
// Register BasisTextureLoader for .basis extension.
let loadingManager = new THREE.LoadingManager();
loadingManager.addHandler( /\.basis$/, basisLoader );
// Create GLTFLoader, load model, and render.
const loader = new THREE.GLTFLoader(loadingManager);
loader.load( 'assets/AgiHqSmall.gltf', ( gltf ) => {
const model = gltf.scene;
model.scale.set( 0.01, 0.01, 0.01 );
scene.add( model );
document.body.appendChild( renderer.domElement );
animate();
}, undefined, ( e ) => console.error( e ) );
// Main render loop.
function animate() {
requestAnimationFrame( animate );
controls.update();
renderer.render( scene, camera );
}
// Support viewport resizing.
window.addEventListener( 'resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}, false );
function log(s) {
const div = document.createElement('div');
div.innerHTML = s;
document.getElementById('log').appendChild(div);
}
</script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

+1
View File
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).THREE={})}(this,function(e){"use strict";void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t});var t=0,n=1,i=2,r=1,a=2,o=3,s=0,c=1,l=2,h=0,u=1,p=2,d=3,f=4,m=5,g=100,v=101,y=102,x=103,b=104,_=200,w=201,M=202,S=203,T=204,E=205,A=206,L=207,R=208,P=209,C=210,O=0,D=1,I=2,N=3,B=4,z=5,F=6,U=7,G=0,H=1,V=2,k=0,j=1,W=2,q=3,X=4,Y=5,Z=301,J=302,Q=303,K=304,$=305,ee=306,te=307,ne=1e3,ie=1001,re=1002,ae=1003,oe=1004,se=1005,ce=1006,le=1007,he=1008,ue=1009,pe=1010,de=1011,fe=1012,me=1013,ge=1014,ve=1015,ye=1016,xe=1017,be=1018,_e=1019,we=1020,Me=1021,Se=1022,Te=1023,Ee=1024,Ae=1025,Le=Te,Re=1026,Pe=1027,Ce=1028,Oe=1029,De=1030,Ie=1031,Ne=1032,Be=1033,ze=33776,Fe=33777,Ue=33778,Ge=33779,He=36492,Ve=35840,ke=35841,je=35842,We=35843,qe=36196,Xe=37492,Ye=37496,Ze=37808,Je=37809,Qe=37810,Ke=37811,$e=37812,et=37813,tt=37814,nt=37815,it=37816,rt=37817,at=37818,ot=37819,st=37820,ct=37821,lt=37840,ht=37841,ut=37842,pt=37843,dt=37844,ft=37845,mt=37846,gt=37847,vt=37848,yt=37849,xt=37850,bt=37851,_t=37852,wt=37853,Mt=2201,St=2400,Tt=3e3,Et=3001,At=3007,Lt=3002,Rt=3003,Pt=3004,Ct=3005,Ot=3006,Dt=3200,It=3201,Nt=0,Bt=1,zt=7680,Ft=519,Ut=35044,Gt=35048;function Ht(){}Object.assign(Ht.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){if(void 0!==this._listeners){var n=this._listeners[e];if(void 0!==n){var i=n.indexOf(t);-1!==i&&n.splice(i,1)}}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var n=t.slice(0),i=0,r=n.length;i<r;i++)n[i].call(this,e)}}}});for(var Vt=[],kt=0;kt<256;kt++)Vt[kt]=(kt<16?"0":"")+kt.toString(16);var jt,Wt={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Vt[255&e]+Vt[e>>8&255]+Vt[e>>16&255]+Vt[e>>24&255]+"-"+Vt[255&t]+Vt[t>>8&255]+"-"+Vt[t>>16&15|64]+Vt[t>>24&255]+"-"+Vt[63&n|128]+Vt[n>>8&255]+"-"+Vt[n>>16&255]+Vt[n>>24&255]+Vt[255&i]+Vt[i>>8&255]+Vt[i>>16&255]+Vt[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*Wt.DEG2RAD},radToDeg:function(e){return e*Wt.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){var a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+i)/2),h=o((t+i)/2),u=a((t-i)/2),p=o((t-i)/2),d=a((i-t)/2),f=o((i-t)/2);"XYX"===r?e.set(s*h,c*u,c*p,s*l):"YZY"===r?e.set(c*p,s*h,c*u,s*l):"ZXZ"===r?e.set(c*u,c*p,s*h,s*l):"XZX"===r?e.set(s*h,c*f,c*d,s*l):"YXY"===r?e.set(c*d,s*h,c*f,s*l):"ZYZ"===r?e.set(c*f,c*d,s*h,s*l):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}};function qt(e,t){this.x=e||0,this.y=t||0}function Xt(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(qt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(qt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,tLine truncated