created site just for chat
This commit is contained in:
66
site/game/node_modules/three/src/loaders/AnimationLoader.js
generated
vendored
Normal file
66
site/game/node_modules/three/src/loaders/AnimationLoader.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
import { AnimationClip } from '../animation/AnimationClip.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
class AnimationLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const loader = new FileLoader( this.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( JSON.parse( text ) ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( json ) {
|
||||
|
||||
const animations = [];
|
||||
|
||||
for ( let i = 0; i < json.length; i ++ ) {
|
||||
|
||||
const clip = AnimationClip.parse( json[ i ] );
|
||||
|
||||
animations.push( clip );
|
||||
|
||||
}
|
||||
|
||||
return animations;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { AnimationLoader };
|
66
site/game/node_modules/three/src/loaders/AudioLoader.js
generated
vendored
Normal file
66
site/game/node_modules/three/src/loaders/AudioLoader.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
import { AudioContext } from '../audio/AudioContext.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
class AudioLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const loader = new FileLoader( this.manager );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setPath( this.path );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
loader.load( url, function ( buffer ) {
|
||||
|
||||
try {
|
||||
|
||||
// Create a copy of the buffer. The `decodeAudioData` method
|
||||
// detaches the buffer when complete, preventing reuse.
|
||||
const bufferCopy = buffer.slice( 0 );
|
||||
|
||||
const context = AudioContext.getContext();
|
||||
context.decodeAudioData( bufferCopy, function ( audioBuffer ) {
|
||||
|
||||
onLoad( audioBuffer );
|
||||
|
||||
} ).catch( handleError );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
handleError( e );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
function handleError( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { AudioLoader };
|
217
site/game/node_modules/three/src/loaders/BufferGeometryLoader.js
generated
vendored
Normal file
217
site/game/node_modules/three/src/loaders/BufferGeometryLoader.js
generated
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
import { Sphere } from '../math/Sphere.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { BufferAttribute } from '../core/BufferAttribute.js';
|
||||
import { BufferGeometry } from '../core/BufferGeometry.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { Loader } from './Loader.js';
|
||||
import { InstancedBufferGeometry } from '../core/InstancedBufferGeometry.js';
|
||||
import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js';
|
||||
import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js';
|
||||
import { InterleavedBuffer } from '../core/InterleavedBuffer.js';
|
||||
import { getTypedArray } from '../utils.js';
|
||||
|
||||
class BufferGeometryLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const loader = new FileLoader( scope.manager );
|
||||
loader.setPath( scope.path );
|
||||
loader.setRequestHeader( scope.requestHeader );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( JSON.parse( text ) ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( json ) {
|
||||
|
||||
const interleavedBufferMap = {};
|
||||
const arrayBufferMap = {};
|
||||
|
||||
function getInterleavedBuffer( json, uuid ) {
|
||||
|
||||
if ( interleavedBufferMap[ uuid ] !== undefined ) return interleavedBufferMap[ uuid ];
|
||||
|
||||
const interleavedBuffers = json.interleavedBuffers;
|
||||
const interleavedBuffer = interleavedBuffers[ uuid ];
|
||||
|
||||
const buffer = getArrayBuffer( json, interleavedBuffer.buffer );
|
||||
|
||||
const array = getTypedArray( interleavedBuffer.type, buffer );
|
||||
const ib = new InterleavedBuffer( array, interleavedBuffer.stride );
|
||||
ib.uuid = interleavedBuffer.uuid;
|
||||
|
||||
interleavedBufferMap[ uuid ] = ib;
|
||||
|
||||
return ib;
|
||||
|
||||
}
|
||||
|
||||
function getArrayBuffer( json, uuid ) {
|
||||
|
||||
if ( arrayBufferMap[ uuid ] !== undefined ) return arrayBufferMap[ uuid ];
|
||||
|
||||
const arrayBuffers = json.arrayBuffers;
|
||||
const arrayBuffer = arrayBuffers[ uuid ];
|
||||
|
||||
const ab = new Uint32Array( arrayBuffer ).buffer;
|
||||
|
||||
arrayBufferMap[ uuid ] = ab;
|
||||
|
||||
return ab;
|
||||
|
||||
}
|
||||
|
||||
const geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();
|
||||
|
||||
const index = json.data.index;
|
||||
|
||||
if ( index !== undefined ) {
|
||||
|
||||
const typedArray = getTypedArray( index.type, index.array );
|
||||
geometry.setIndex( new BufferAttribute( typedArray, 1 ) );
|
||||
|
||||
}
|
||||
|
||||
const attributes = json.data.attributes;
|
||||
|
||||
for ( const key in attributes ) {
|
||||
|
||||
const attribute = attributes[ key ];
|
||||
let bufferAttribute;
|
||||
|
||||
if ( attribute.isInterleavedBufferAttribute ) {
|
||||
|
||||
const interleavedBuffer = getInterleavedBuffer( json.data, attribute.data );
|
||||
bufferAttribute = new InterleavedBufferAttribute( interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized );
|
||||
|
||||
} else {
|
||||
|
||||
const typedArray = getTypedArray( attribute.type, attribute.array );
|
||||
const bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;
|
||||
bufferAttribute = new bufferAttributeConstr( typedArray, attribute.itemSize, attribute.normalized );
|
||||
|
||||
}
|
||||
|
||||
if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
|
||||
if ( attribute.usage !== undefined ) bufferAttribute.setUsage( attribute.usage );
|
||||
|
||||
geometry.setAttribute( key, bufferAttribute );
|
||||
|
||||
}
|
||||
|
||||
const morphAttributes = json.data.morphAttributes;
|
||||
|
||||
if ( morphAttributes ) {
|
||||
|
||||
for ( const key in morphAttributes ) {
|
||||
|
||||
const attributeArray = morphAttributes[ key ];
|
||||
|
||||
const array = [];
|
||||
|
||||
for ( let i = 0, il = attributeArray.length; i < il; i ++ ) {
|
||||
|
||||
const attribute = attributeArray[ i ];
|
||||
let bufferAttribute;
|
||||
|
||||
if ( attribute.isInterleavedBufferAttribute ) {
|
||||
|
||||
const interleavedBuffer = getInterleavedBuffer( json.data, attribute.data );
|
||||
bufferAttribute = new InterleavedBufferAttribute( interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized );
|
||||
|
||||
} else {
|
||||
|
||||
const typedArray = getTypedArray( attribute.type, attribute.array );
|
||||
bufferAttribute = new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized );
|
||||
|
||||
}
|
||||
|
||||
if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name;
|
||||
array.push( bufferAttribute );
|
||||
|
||||
}
|
||||
|
||||
geometry.morphAttributes[ key ] = array;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const morphTargetsRelative = json.data.morphTargetsRelative;
|
||||
|
||||
if ( morphTargetsRelative ) {
|
||||
|
||||
geometry.morphTargetsRelative = true;
|
||||
|
||||
}
|
||||
|
||||
const groups = json.data.groups || json.data.drawcalls || json.data.offsets;
|
||||
|
||||
if ( groups !== undefined ) {
|
||||
|
||||
for ( let i = 0, n = groups.length; i !== n; ++ i ) {
|
||||
|
||||
const group = groups[ i ];
|
||||
|
||||
geometry.addGroup( group.start, group.count, group.materialIndex );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const boundingSphere = json.data.boundingSphere;
|
||||
|
||||
if ( boundingSphere !== undefined ) {
|
||||
|
||||
const center = new Vector3();
|
||||
|
||||
if ( boundingSphere.center !== undefined ) {
|
||||
|
||||
center.fromArray( boundingSphere.center );
|
||||
|
||||
}
|
||||
|
||||
geometry.boundingSphere = new Sphere( center, boundingSphere.radius );
|
||||
|
||||
}
|
||||
|
||||
if ( json.name ) geometry.name = json.name;
|
||||
if ( json.userData ) geometry.userData = json.userData;
|
||||
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { BufferGeometryLoader };
|
42
site/game/node_modules/three/src/loaders/Cache.js
generated
vendored
Normal file
42
site/game/node_modules/three/src/loaders/Cache.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
const Cache = {
|
||||
|
||||
enabled: false,
|
||||
|
||||
files: {},
|
||||
|
||||
add: function ( key, file ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
// console.log( 'THREE.Cache', 'Adding key:', key );
|
||||
|
||||
this.files[ key ] = file;
|
||||
|
||||
},
|
||||
|
||||
get: function ( key ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
// console.log( 'THREE.Cache', 'Checking key:', key );
|
||||
|
||||
return this.files[ key ];
|
||||
|
||||
},
|
||||
|
||||
remove: function ( key ) {
|
||||
|
||||
delete this.files[ key ];
|
||||
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
|
||||
this.files = {};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
export { Cache };
|
134
site/game/node_modules/three/src/loaders/CompressedTextureLoader.js
generated
vendored
Normal file
134
site/game/node_modules/three/src/loaders/CompressedTextureLoader.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
import { LinearFilter } from '../constants.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { CompressedTexture } from '../textures/CompressedTexture.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
/**
|
||||
* Abstract Base class to block based textures loader (dds, pvr, ...)
|
||||
*
|
||||
* Sub classes have to implement the parse() method which will be used in load().
|
||||
*/
|
||||
|
||||
class CompressedTextureLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const images = [];
|
||||
|
||||
const texture = new CompressedTexture();
|
||||
|
||||
const loader = new FileLoader( this.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
|
||||
let loaded = 0;
|
||||
|
||||
function loadTexture( i ) {
|
||||
|
||||
loader.load( url[ i ], function ( buffer ) {
|
||||
|
||||
const texDatas = scope.parse( buffer, true );
|
||||
|
||||
images[ i ] = {
|
||||
width: texDatas.width,
|
||||
height: texDatas.height,
|
||||
format: texDatas.format,
|
||||
mipmaps: texDatas.mipmaps
|
||||
};
|
||||
|
||||
loaded += 1;
|
||||
|
||||
if ( loaded === 6 ) {
|
||||
|
||||
if ( texDatas.mipmapCount === 1 ) texture.minFilter = LinearFilter;
|
||||
|
||||
texture.image = images;
|
||||
texture.format = texDatas.format;
|
||||
texture.needsUpdate = true;
|
||||
|
||||
if ( onLoad ) onLoad( texture );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
if ( Array.isArray( url ) ) {
|
||||
|
||||
for ( let i = 0, il = url.length; i < il; ++ i ) {
|
||||
|
||||
loadTexture( i );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// compressed cubemap texture stored in a single DDS file
|
||||
|
||||
loader.load( url, function ( buffer ) {
|
||||
|
||||
const texDatas = scope.parse( buffer, true );
|
||||
|
||||
if ( texDatas.isCubemap ) {
|
||||
|
||||
const faces = texDatas.mipmaps.length / texDatas.mipmapCount;
|
||||
|
||||
for ( let f = 0; f < faces; f ++ ) {
|
||||
|
||||
images[ f ] = { mipmaps: [] };
|
||||
|
||||
for ( let i = 0; i < texDatas.mipmapCount; i ++ ) {
|
||||
|
||||
images[ f ].mipmaps.push( texDatas.mipmaps[ f * texDatas.mipmapCount + i ] );
|
||||
images[ f ].format = texDatas.format;
|
||||
images[ f ].width = texDatas.width;
|
||||
images[ f ].height = texDatas.height;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
texture.image = images;
|
||||
|
||||
} else {
|
||||
|
||||
texture.image.width = texDatas.width;
|
||||
texture.image.height = texDatas.height;
|
||||
texture.mipmaps = texDatas.mipmaps;
|
||||
|
||||
}
|
||||
|
||||
if ( texDatas.mipmapCount === 1 ) {
|
||||
|
||||
texture.minFilter = LinearFilter;
|
||||
|
||||
}
|
||||
|
||||
texture.format = texDatas.format;
|
||||
texture.needsUpdate = true;
|
||||
|
||||
if ( onLoad ) onLoad( texture );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { CompressedTextureLoader };
|
58
site/game/node_modules/three/src/loaders/CubeTextureLoader.js
generated
vendored
Normal file
58
site/game/node_modules/three/src/loaders/CubeTextureLoader.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
import { ImageLoader } from './ImageLoader.js';
|
||||
import { CubeTexture } from '../textures/CubeTexture.js';
|
||||
import { Loader } from './Loader.js';
|
||||
import { SRGBColorSpace } from '../constants.js';
|
||||
|
||||
class CubeTextureLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( urls, onLoad, onProgress, onError ) {
|
||||
|
||||
const texture = new CubeTexture();
|
||||
texture.colorSpace = SRGBColorSpace;
|
||||
|
||||
const loader = new ImageLoader( this.manager );
|
||||
loader.setCrossOrigin( this.crossOrigin );
|
||||
loader.setPath( this.path );
|
||||
|
||||
let loaded = 0;
|
||||
|
||||
function loadTexture( i ) {
|
||||
|
||||
loader.load( urls[ i ], function ( image ) {
|
||||
|
||||
texture.images[ i ] = image;
|
||||
|
||||
loaded ++;
|
||||
|
||||
if ( loaded === 6 ) {
|
||||
|
||||
texture.needsUpdate = true;
|
||||
|
||||
if ( onLoad ) onLoad( texture );
|
||||
|
||||
}
|
||||
|
||||
}, undefined, onError );
|
||||
|
||||
}
|
||||
|
||||
for ( let i = 0; i < urls.length; ++ i ) {
|
||||
|
||||
loadTexture( i );
|
||||
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { CubeTextureLoader };
|
131
site/game/node_modules/three/src/loaders/DataTextureLoader.js
generated
vendored
Normal file
131
site/game/node_modules/three/src/loaders/DataTextureLoader.js
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
import { LinearFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping } from '../constants.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { DataTexture } from '../textures/DataTexture.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
/**
|
||||
* Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)
|
||||
*
|
||||
* Sub classes have to implement the parse() method which will be used in load().
|
||||
*/
|
||||
|
||||
class DataTextureLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const texture = new DataTexture();
|
||||
|
||||
const loader = new FileLoader( this.manager );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setPath( this.path );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
loader.load( url, function ( buffer ) {
|
||||
|
||||
let texData;
|
||||
|
||||
try {
|
||||
|
||||
texData = scope.parse( buffer );
|
||||
|
||||
} catch ( error ) {
|
||||
|
||||
if ( onError !== undefined ) {
|
||||
|
||||
onError( error );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( error );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( texData.image !== undefined ) {
|
||||
|
||||
texture.image = texData.image;
|
||||
|
||||
} else if ( texData.data !== undefined ) {
|
||||
|
||||
texture.image.width = texData.width;
|
||||
texture.image.height = texData.height;
|
||||
texture.image.data = texData.data;
|
||||
|
||||
}
|
||||
|
||||
texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;
|
||||
texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;
|
||||
|
||||
texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;
|
||||
texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter;
|
||||
|
||||
texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;
|
||||
|
||||
if ( texData.colorSpace !== undefined ) {
|
||||
|
||||
texture.colorSpace = texData.colorSpace;
|
||||
|
||||
}
|
||||
|
||||
if ( texData.flipY !== undefined ) {
|
||||
|
||||
texture.flipY = texData.flipY;
|
||||
|
||||
}
|
||||
|
||||
if ( texData.format !== undefined ) {
|
||||
|
||||
texture.format = texData.format;
|
||||
|
||||
}
|
||||
|
||||
if ( texData.type !== undefined ) {
|
||||
|
||||
texture.type = texData.type;
|
||||
|
||||
}
|
||||
|
||||
if ( texData.mipmaps !== undefined ) {
|
||||
|
||||
texture.mipmaps = texData.mipmaps;
|
||||
texture.minFilter = LinearMipmapLinearFilter; // presumably...
|
||||
|
||||
}
|
||||
|
||||
if ( texData.mipmapCount === 1 ) {
|
||||
|
||||
texture.minFilter = LinearFilter;
|
||||
|
||||
}
|
||||
|
||||
if ( texData.generateMipmaps !== undefined ) {
|
||||
|
||||
texture.generateMipmaps = texData.generateMipmaps;
|
||||
|
||||
}
|
||||
|
||||
texture.needsUpdate = true;
|
||||
|
||||
if ( onLoad ) onLoad( texture, texData );
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
|
||||
return texture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { DataTextureLoader };
|
288
site/game/node_modules/three/src/loaders/FileLoader.js
generated
vendored
Normal file
288
site/game/node_modules/three/src/loaders/FileLoader.js
generated
vendored
Normal file
@ -0,0 +1,288 @@
|
||||
import { Cache } from './Cache.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
const loading = {};
|
||||
|
||||
class HttpError extends Error {
|
||||
|
||||
constructor( message, response ) {
|
||||
|
||||
super( message );
|
||||
this.response = response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class FileLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
if ( url === undefined ) url = '';
|
||||
|
||||
if ( this.path !== undefined ) url = this.path + url;
|
||||
|
||||
url = this.manager.resolveURL( url );
|
||||
|
||||
const cached = Cache.get( url );
|
||||
|
||||
if ( cached !== undefined ) {
|
||||
|
||||
this.manager.itemStart( url );
|
||||
|
||||
setTimeout( () => {
|
||||
|
||||
if ( onLoad ) onLoad( cached );
|
||||
|
||||
this.manager.itemEnd( url );
|
||||
|
||||
}, 0 );
|
||||
|
||||
return cached;
|
||||
|
||||
}
|
||||
|
||||
// Check if request is duplicate
|
||||
|
||||
if ( loading[ url ] !== undefined ) {
|
||||
|
||||
loading[ url ].push( {
|
||||
|
||||
onLoad: onLoad,
|
||||
onProgress: onProgress,
|
||||
onError: onError
|
||||
|
||||
} );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Initialise array for duplicate requests
|
||||
loading[ url ] = [];
|
||||
|
||||
loading[ url ].push( {
|
||||
onLoad: onLoad,
|
||||
onProgress: onProgress,
|
||||
onError: onError,
|
||||
} );
|
||||
|
||||
// create request
|
||||
const req = new Request( url, {
|
||||
headers: new Headers( this.requestHeader ),
|
||||
credentials: this.withCredentials ? 'include' : 'same-origin',
|
||||
// An abort controller could be added within a future PR
|
||||
} );
|
||||
|
||||
// record states ( avoid data race )
|
||||
const mimeType = this.mimeType;
|
||||
const responseType = this.responseType;
|
||||
|
||||
// start the fetch
|
||||
fetch( req )
|
||||
.then( response => {
|
||||
|
||||
if ( response.status === 200 || response.status === 0 ) {
|
||||
|
||||
// Some browsers return HTTP Status 0 when using non-http protocol
|
||||
// e.g. 'file://' or 'data://'. Handle as success.
|
||||
|
||||
if ( response.status === 0 ) {
|
||||
|
||||
console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );
|
||||
|
||||
}
|
||||
|
||||
// Workaround: Checking if response.body === undefined for Alipay browser #23548
|
||||
|
||||
if ( typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined ) {
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
const callbacks = loading[ url ];
|
||||
const reader = response.body.getReader();
|
||||
|
||||
// Nginx needs X-File-Size check
|
||||
// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content
|
||||
const contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );
|
||||
const total = contentLength ? parseInt( contentLength ) : 0;
|
||||
const lengthComputable = total !== 0;
|
||||
let loaded = 0;
|
||||
|
||||
// periodically read data into the new stream tracking while download progress
|
||||
const stream = new ReadableStream( {
|
||||
start( controller ) {
|
||||
|
||||
readData();
|
||||
|
||||
function readData() {
|
||||
|
||||
reader.read().then( ( { done, value } ) => {
|
||||
|
||||
if ( done ) {
|
||||
|
||||
controller.close();
|
||||
|
||||
} else {
|
||||
|
||||
loaded += value.byteLength;
|
||||
|
||||
const event = new ProgressEvent( 'progress', { lengthComputable, loaded, total } );
|
||||
for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
|
||||
|
||||
const callback = callbacks[ i ];
|
||||
if ( callback.onProgress ) callback.onProgress( event );
|
||||
|
||||
}
|
||||
|
||||
controller.enqueue( value );
|
||||
readData();
|
||||
|
||||
}
|
||||
|
||||
}, ( e ) => {
|
||||
|
||||
controller.error( e );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
return new Response( stream );
|
||||
|
||||
} else {
|
||||
|
||||
throw new HttpError( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`, response );
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
.then( response => {
|
||||
|
||||
switch ( responseType ) {
|
||||
|
||||
case 'arraybuffer':
|
||||
|
||||
return response.arrayBuffer();
|
||||
|
||||
case 'blob':
|
||||
|
||||
return response.blob();
|
||||
|
||||
case 'document':
|
||||
|
||||
return response.text()
|
||||
.then( text => {
|
||||
|
||||
const parser = new DOMParser();
|
||||
return parser.parseFromString( text, mimeType );
|
||||
|
||||
} );
|
||||
|
||||
case 'json':
|
||||
|
||||
return response.json();
|
||||
|
||||
default:
|
||||
|
||||
if ( mimeType === undefined ) {
|
||||
|
||||
return response.text();
|
||||
|
||||
} else {
|
||||
|
||||
// sniff encoding
|
||||
const re = /charset="?([^;"\s]*)"?/i;
|
||||
const exec = re.exec( mimeType );
|
||||
const label = exec && exec[ 1 ] ? exec[ 1 ].toLowerCase() : undefined;
|
||||
const decoder = new TextDecoder( label );
|
||||
return response.arrayBuffer().then( ab => decoder.decode( ab ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
.then( data => {
|
||||
|
||||
// Add to cache only on HTTP success, so that we do not cache
|
||||
// error response bodies as proper responses to requests.
|
||||
Cache.add( url, data );
|
||||
|
||||
const callbacks = loading[ url ];
|
||||
delete loading[ url ];
|
||||
|
||||
for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
|
||||
|
||||
const callback = callbacks[ i ];
|
||||
if ( callback.onLoad ) callback.onLoad( data );
|
||||
|
||||
}
|
||||
|
||||
} )
|
||||
.catch( err => {
|
||||
|
||||
// Abort errors and other errors are handled the same
|
||||
|
||||
const callbacks = loading[ url ];
|
||||
|
||||
if ( callbacks === undefined ) {
|
||||
|
||||
// When onLoad was called and url was deleted in `loading`
|
||||
this.manager.itemError( url );
|
||||
throw err;
|
||||
|
||||
}
|
||||
|
||||
delete loading[ url ];
|
||||
|
||||
for ( let i = 0, il = callbacks.length; i < il; i ++ ) {
|
||||
|
||||
const callback = callbacks[ i ];
|
||||
if ( callback.onError ) callback.onError( err );
|
||||
|
||||
}
|
||||
|
||||
this.manager.itemError( url );
|
||||
|
||||
} )
|
||||
.finally( () => {
|
||||
|
||||
this.manager.itemEnd( url );
|
||||
|
||||
} );
|
||||
|
||||
this.manager.itemStart( url );
|
||||
|
||||
}
|
||||
|
||||
setResponseType( value ) {
|
||||
|
||||
this.responseType = value;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
setMimeType( value ) {
|
||||
|
||||
this.mimeType = value;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { FileLoader };
|
123
site/game/node_modules/three/src/loaders/ImageBitmapLoader.js
generated
vendored
Normal file
123
site/game/node_modules/three/src/loaders/ImageBitmapLoader.js
generated
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
import { Cache } from './Cache.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
class ImageBitmapLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
this.isImageBitmapLoader = true;
|
||||
|
||||
if ( typeof createImageBitmap === 'undefined' ) {
|
||||
|
||||
console.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' );
|
||||
|
||||
}
|
||||
|
||||
if ( typeof fetch === 'undefined' ) {
|
||||
|
||||
console.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' );
|
||||
|
||||
}
|
||||
|
||||
this.options = { premultiplyAlpha: 'none' };
|
||||
|
||||
}
|
||||
|
||||
setOptions( options ) {
|
||||
|
||||
this.options = options;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
if ( url === undefined ) url = '';
|
||||
|
||||
if ( this.path !== undefined ) url = this.path + url;
|
||||
|
||||
url = this.manager.resolveURL( url );
|
||||
|
||||
const scope = this;
|
||||
|
||||
const cached = Cache.get( url );
|
||||
|
||||
if ( cached !== undefined ) {
|
||||
|
||||
scope.manager.itemStart( url );
|
||||
|
||||
// If cached is a promise, wait for it to resolve
|
||||
if ( cached.then ) {
|
||||
|
||||
cached.then( imageBitmap => {
|
||||
|
||||
if ( onLoad ) onLoad( imageBitmap );
|
||||
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
} ).catch( e => {
|
||||
|
||||
if ( onError ) onError( e );
|
||||
|
||||
} );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// If cached is not a promise (i.e., it's already an imageBitmap)
|
||||
setTimeout( function () {
|
||||
|
||||
if ( onLoad ) onLoad( cached );
|
||||
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
}, 0 );
|
||||
|
||||
return cached;
|
||||
|
||||
}
|
||||
|
||||
const fetchOptions = {};
|
||||
fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
|
||||
fetchOptions.headers = this.requestHeader;
|
||||
|
||||
const promise = fetch( url, fetchOptions ).then( function ( res ) {
|
||||
|
||||
return res.blob();
|
||||
|
||||
} ).then( function ( blob ) {
|
||||
|
||||
return createImageBitmap( blob, Object.assign( scope.options, { colorSpaceConversion: 'none' } ) );
|
||||
|
||||
} ).then( function ( imageBitmap ) {
|
||||
|
||||
Cache.add( url, imageBitmap );
|
||||
|
||||
if ( onLoad ) onLoad( imageBitmap );
|
||||
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
return imageBitmap;
|
||||
|
||||
} ).catch( function ( e ) {
|
||||
|
||||
if ( onError ) onError( e );
|
||||
|
||||
Cache.remove( url );
|
||||
|
||||
scope.manager.itemError( url );
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
} );
|
||||
|
||||
Cache.add( url, promise );
|
||||
scope.manager.itemStart( url );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { ImageBitmapLoader };
|
91
site/game/node_modules/three/src/loaders/ImageLoader.js
generated
vendored
Normal file
91
site/game/node_modules/three/src/loaders/ImageLoader.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
import { Cache } from './Cache.js';
|
||||
import { Loader } from './Loader.js';
|
||||
import { createElementNS } from '../utils.js';
|
||||
|
||||
class ImageLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
if ( this.path !== undefined ) url = this.path + url;
|
||||
|
||||
url = this.manager.resolveURL( url );
|
||||
|
||||
const scope = this;
|
||||
|
||||
const cached = Cache.get( url );
|
||||
|
||||
if ( cached !== undefined ) {
|
||||
|
||||
scope.manager.itemStart( url );
|
||||
|
||||
setTimeout( function () {
|
||||
|
||||
if ( onLoad ) onLoad( cached );
|
||||
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
}, 0 );
|
||||
|
||||
return cached;
|
||||
|
||||
}
|
||||
|
||||
const image = createElementNS( 'img' );
|
||||
|
||||
function onImageLoad() {
|
||||
|
||||
removeEventListeners();
|
||||
|
||||
Cache.add( url, this );
|
||||
|
||||
if ( onLoad ) onLoad( this );
|
||||
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
}
|
||||
|
||||
function onImageError( event ) {
|
||||
|
||||
removeEventListeners();
|
||||
|
||||
if ( onError ) onError( event );
|
||||
|
||||
scope.manager.itemError( url );
|
||||
scope.manager.itemEnd( url );
|
||||
|
||||
}
|
||||
|
||||
function removeEventListeners() {
|
||||
|
||||
image.removeEventListener( 'load', onImageLoad, false );
|
||||
image.removeEventListener( 'error', onImageError, false );
|
||||
|
||||
}
|
||||
|
||||
image.addEventListener( 'load', onImageLoad, false );
|
||||
image.addEventListener( 'error', onImageError, false );
|
||||
|
||||
if ( url.slice( 0, 5 ) !== 'data:' ) {
|
||||
|
||||
if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin;
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemStart( url );
|
||||
|
||||
image.src = url;
|
||||
|
||||
return image;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { ImageLoader };
|
72
site/game/node_modules/three/src/loaders/Loader.js
generated
vendored
Normal file
72
site/game/node_modules/three/src/loaders/Loader.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
import { DefaultLoadingManager } from './LoadingManager.js';
|
||||
|
||||
class Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
|
||||
|
||||
this.crossOrigin = 'anonymous';
|
||||
this.withCredentials = false;
|
||||
this.path = '';
|
||||
this.resourcePath = '';
|
||||
this.requestHeader = {};
|
||||
|
||||
}
|
||||
|
||||
load( /* url, onLoad, onProgress, onError */ ) {}
|
||||
|
||||
loadAsync( url, onProgress ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
return new Promise( function ( resolve, reject ) {
|
||||
|
||||
scope.load( url, resolve, onProgress, reject );
|
||||
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
parse( /* data */ ) {}
|
||||
|
||||
setCrossOrigin( crossOrigin ) {
|
||||
|
||||
this.crossOrigin = crossOrigin;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
setWithCredentials( value ) {
|
||||
|
||||
this.withCredentials = value;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
setPath( path ) {
|
||||
|
||||
this.path = path;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
setResourcePath( resourcePath ) {
|
||||
|
||||
this.resourcePath = resourcePath;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
setRequestHeader( requestHeader ) {
|
||||
|
||||
this.requestHeader = requestHeader;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loader.DEFAULT_MATERIAL_NAME = '__DEFAULT';
|
||||
|
||||
export { Loader };
|
77
site/game/node_modules/three/src/loaders/LoaderUtils.js
generated
vendored
Normal file
77
site/game/node_modules/three/src/loaders/LoaderUtils.js
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
class LoaderUtils {
|
||||
|
||||
static decodeText( array ) { // @deprecated, r165
|
||||
|
||||
console.warn( 'THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead.' );
|
||||
|
||||
if ( typeof TextDecoder !== 'undefined' ) {
|
||||
|
||||
return new TextDecoder().decode( array );
|
||||
|
||||
}
|
||||
|
||||
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
|
||||
// throws a "maximum call stack size exceeded" error for large arrays.
|
||||
|
||||
let s = '';
|
||||
|
||||
for ( let i = 0, il = array.length; i < il; i ++ ) {
|
||||
|
||||
// Implicitly assumes little-endian.
|
||||
s += String.fromCharCode( array[ i ] );
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// merges multi-byte utf-8 characters.
|
||||
|
||||
return decodeURIComponent( escape( s ) );
|
||||
|
||||
} catch ( e ) { // see #16358
|
||||
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static extractUrlBase( url ) {
|
||||
|
||||
const index = url.lastIndexOf( '/' );
|
||||
|
||||
if ( index === - 1 ) return './';
|
||||
|
||||
return url.slice( 0, index + 1 );
|
||||
|
||||
}
|
||||
|
||||
static resolveURL( url, path ) {
|
||||
|
||||
// Invalid URL
|
||||
if ( typeof url !== 'string' || url === '' ) return '';
|
||||
|
||||
// Host Relative URL
|
||||
if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) {
|
||||
|
||||
path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' );
|
||||
|
||||
}
|
||||
|
||||
// Absolute URL http://,https://,//
|
||||
if ( /^(https?:)?\/\//i.test( url ) ) return url;
|
||||
|
||||
// Data URI
|
||||
if ( /^data:.*,.*$/i.test( url ) ) return url;
|
||||
|
||||
// Blob URL
|
||||
if ( /^blob:.*$/i.test( url ) ) return url;
|
||||
|
||||
// Relative URL
|
||||
return path + url;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { LoaderUtils };
|
142
site/game/node_modules/three/src/loaders/LoadingManager.js
generated
vendored
Normal file
142
site/game/node_modules/three/src/loaders/LoadingManager.js
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
class LoadingManager {
|
||||
|
||||
constructor( onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
let isLoading = false;
|
||||
let itemsLoaded = 0;
|
||||
let itemsTotal = 0;
|
||||
let urlModifier = undefined;
|
||||
const handlers = [];
|
||||
|
||||
// Refer to #5689 for the reason why we don't set .onStart
|
||||
// in the constructor
|
||||
|
||||
this.onStart = undefined;
|
||||
this.onLoad = onLoad;
|
||||
this.onProgress = onProgress;
|
||||
this.onError = onError;
|
||||
|
||||
this.itemStart = function ( url ) {
|
||||
|
||||
itemsTotal ++;
|
||||
|
||||
if ( isLoading === false ) {
|
||||
|
||||
if ( scope.onStart !== undefined ) {
|
||||
|
||||
scope.onStart( url, itemsLoaded, itemsTotal );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
isLoading = true;
|
||||
|
||||
};
|
||||
|
||||
this.itemEnd = function ( url ) {
|
||||
|
||||
itemsLoaded ++;
|
||||
|
||||
if ( scope.onProgress !== undefined ) {
|
||||
|
||||
scope.onProgress( url, itemsLoaded, itemsTotal );
|
||||
|
||||
}
|
||||
|
||||
if ( itemsLoaded === itemsTotal ) {
|
||||
|
||||
isLoading = false;
|
||||
|
||||
if ( scope.onLoad !== undefined ) {
|
||||
|
||||
scope.onLoad();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.itemError = function ( url ) {
|
||||
|
||||
if ( scope.onError !== undefined ) {
|
||||
|
||||
scope.onError( url );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.resolveURL = function ( url ) {
|
||||
|
||||
if ( urlModifier ) {
|
||||
|
||||
return urlModifier( url );
|
||||
|
||||
}
|
||||
|
||||
return url;
|
||||
|
||||
};
|
||||
|
||||
this.setURLModifier = function ( transform ) {
|
||||
|
||||
urlModifier = transform;
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
this.addHandler = function ( regex, loader ) {
|
||||
|
||||
handlers.push( regex, loader );
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
this.removeHandler = function ( regex ) {
|
||||
|
||||
const index = handlers.indexOf( regex );
|
||||
|
||||
if ( index !== - 1 ) {
|
||||
|
||||
handlers.splice( index, 2 );
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
this.getHandler = function ( file ) {
|
||||
|
||||
for ( let i = 0, l = handlers.length; i < l; i += 2 ) {
|
||||
|
||||
const regex = handlers[ i ];
|
||||
const loader = handlers[ i + 1 ];
|
||||
|
||||
if ( regex.global ) regex.lastIndex = 0; // see #17920
|
||||
|
||||
if ( regex.test( file ) ) {
|
||||
|
||||
return loader;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const DefaultLoadingManager = /*@__PURE__*/ new LoadingManager();
|
||||
|
||||
export { DefaultLoadingManager, LoadingManager };
|
374
site/game/node_modules/three/src/loaders/MaterialLoader.js
generated
vendored
Normal file
374
site/game/node_modules/three/src/loaders/MaterialLoader.js
generated
vendored
Normal file
@ -0,0 +1,374 @@
|
||||
import { Color } from '../math/Color.js';
|
||||
import { Vector2 } from '../math/Vector2.js';
|
||||
import { Vector3 } from '../math/Vector3.js';
|
||||
import { Vector4 } from '../math/Vector4.js';
|
||||
import { Matrix3 } from '../math/Matrix3.js';
|
||||
import { Matrix4 } from '../math/Matrix4.js';
|
||||
import { FileLoader } from './FileLoader.js';
|
||||
import { Loader } from './Loader.js';
|
||||
import {
|
||||
ShadowMaterial,
|
||||
SpriteMaterial,
|
||||
RawShaderMaterial,
|
||||
ShaderMaterial,
|
||||
PointsMaterial,
|
||||
MeshPhysicalMaterial,
|
||||
MeshStandardMaterial,
|
||||
MeshPhongMaterial,
|
||||
MeshToonMaterial,
|
||||
MeshNormalMaterial,
|
||||
MeshLambertMaterial,
|
||||
MeshDepthMaterial,
|
||||
MeshDistanceMaterial,
|
||||
MeshBasicMaterial,
|
||||
MeshMatcapMaterial,
|
||||
LineDashedMaterial,
|
||||
LineBasicMaterial,
|
||||
Material,
|
||||
} from '../materials/Materials.js';
|
||||
|
||||
class MaterialLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
this.textures = {};
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
|
||||
const loader = new FileLoader( scope.manager );
|
||||
loader.setPath( scope.path );
|
||||
loader.setRequestHeader( scope.requestHeader );
|
||||
loader.setWithCredentials( scope.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( JSON.parse( text ) ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( json ) {
|
||||
|
||||
const textures = this.textures;
|
||||
|
||||
function getTexture( name ) {
|
||||
|
||||
if ( textures[ name ] === undefined ) {
|
||||
|
||||
console.warn( 'THREE.MaterialLoader: Undefined texture', name );
|
||||
|
||||
}
|
||||
|
||||
return textures[ name ];
|
||||
|
||||
}
|
||||
|
||||
const material = MaterialLoader.createMaterialFromType( json.type );
|
||||
|
||||
if ( json.uuid !== undefined ) material.uuid = json.uuid;
|
||||
if ( json.name !== undefined ) material.name = json.name;
|
||||
if ( json.color !== undefined && material.color !== undefined ) material.color.setHex( json.color );
|
||||
if ( json.roughness !== undefined ) material.roughness = json.roughness;
|
||||
if ( json.metalness !== undefined ) material.metalness = json.metalness;
|
||||
if ( json.sheen !== undefined ) material.sheen = json.sheen;
|
||||
if ( json.sheenColor !== undefined ) material.sheenColor = new Color().setHex( json.sheenColor );
|
||||
if ( json.sheenRoughness !== undefined ) material.sheenRoughness = json.sheenRoughness;
|
||||
if ( json.emissive !== undefined && material.emissive !== undefined ) material.emissive.setHex( json.emissive );
|
||||
if ( json.specular !== undefined && material.specular !== undefined ) material.specular.setHex( json.specular );
|
||||
if ( json.specularIntensity !== undefined ) material.specularIntensity = json.specularIntensity;
|
||||
if ( json.specularColor !== undefined && material.specularColor !== undefined ) material.specularColor.setHex( json.specularColor );
|
||||
if ( json.shininess !== undefined ) material.shininess = json.shininess;
|
||||
if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat;
|
||||
if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness;
|
||||
if ( json.dispersion !== undefined ) material.dispersion = json.dispersion;
|
||||
if ( json.iridescence !== undefined ) material.iridescence = json.iridescence;
|
||||
if ( json.iridescenceIOR !== undefined ) material.iridescenceIOR = json.iridescenceIOR;
|
||||
if ( json.iridescenceThicknessRange !== undefined ) material.iridescenceThicknessRange = json.iridescenceThicknessRange;
|
||||
if ( json.transmission !== undefined ) material.transmission = json.transmission;
|
||||
if ( json.thickness !== undefined ) material.thickness = json.thickness;
|
||||
if ( json.attenuationDistance !== undefined ) material.attenuationDistance = json.attenuationDistance;
|
||||
if ( json.attenuationColor !== undefined && material.attenuationColor !== undefined ) material.attenuationColor.setHex( json.attenuationColor );
|
||||
if ( json.anisotropy !== undefined ) material.anisotropy = json.anisotropy;
|
||||
if ( json.anisotropyRotation !== undefined ) material.anisotropyRotation = json.anisotropyRotation;
|
||||
if ( json.fog !== undefined ) material.fog = json.fog;
|
||||
if ( json.flatShading !== undefined ) material.flatShading = json.flatShading;
|
||||
if ( json.blending !== undefined ) material.blending = json.blending;
|
||||
if ( json.combine !== undefined ) material.combine = json.combine;
|
||||
if ( json.side !== undefined ) material.side = json.side;
|
||||
if ( json.shadowSide !== undefined ) material.shadowSide = json.shadowSide;
|
||||
if ( json.opacity !== undefined ) material.opacity = json.opacity;
|
||||
if ( json.transparent !== undefined ) material.transparent = json.transparent;
|
||||
if ( json.alphaTest !== undefined ) material.alphaTest = json.alphaTest;
|
||||
if ( json.alphaHash !== undefined ) material.alphaHash = json.alphaHash;
|
||||
if ( json.depthFunc !== undefined ) material.depthFunc = json.depthFunc;
|
||||
if ( json.depthTest !== undefined ) material.depthTest = json.depthTest;
|
||||
if ( json.depthWrite !== undefined ) material.depthWrite = json.depthWrite;
|
||||
if ( json.colorWrite !== undefined ) material.colorWrite = json.colorWrite;
|
||||
if ( json.blendSrc !== undefined ) material.blendSrc = json.blendSrc;
|
||||
if ( json.blendDst !== undefined ) material.blendDst = json.blendDst;
|
||||
if ( json.blendEquation !== undefined ) material.blendEquation = json.blendEquation;
|
||||
if ( json.blendSrcAlpha !== undefined ) material.blendSrcAlpha = json.blendSrcAlpha;
|
||||
if ( json.blendDstAlpha !== undefined ) material.blendDstAlpha = json.blendDstAlpha;
|
||||
if ( json.blendEquationAlpha !== undefined ) material.blendEquationAlpha = json.blendEquationAlpha;
|
||||
if ( json.blendColor !== undefined && material.blendColor !== undefined ) material.blendColor.setHex( json.blendColor );
|
||||
if ( json.blendAlpha !== undefined ) material.blendAlpha = json.blendAlpha;
|
||||
if ( json.stencilWriteMask !== undefined ) material.stencilWriteMask = json.stencilWriteMask;
|
||||
if ( json.stencilFunc !== undefined ) material.stencilFunc = json.stencilFunc;
|
||||
if ( json.stencilRef !== undefined ) material.stencilRef = json.stencilRef;
|
||||
if ( json.stencilFuncMask !== undefined ) material.stencilFuncMask = json.stencilFuncMask;
|
||||
if ( json.stencilFail !== undefined ) material.stencilFail = json.stencilFail;
|
||||
if ( json.stencilZFail !== undefined ) material.stencilZFail = json.stencilZFail;
|
||||
if ( json.stencilZPass !== undefined ) material.stencilZPass = json.stencilZPass;
|
||||
if ( json.stencilWrite !== undefined ) material.stencilWrite = json.stencilWrite;
|
||||
|
||||
if ( json.wireframe !== undefined ) material.wireframe = json.wireframe;
|
||||
if ( json.wireframeLinewidth !== undefined ) material.wireframeLinewidth = json.wireframeLinewidth;
|
||||
if ( json.wireframeLinecap !== undefined ) material.wireframeLinecap = json.wireframeLinecap;
|
||||
if ( json.wireframeLinejoin !== undefined ) material.wireframeLinejoin = json.wireframeLinejoin;
|
||||
|
||||
if ( json.rotation !== undefined ) material.rotation = json.rotation;
|
||||
|
||||
if ( json.linewidth !== undefined ) material.linewidth = json.linewidth;
|
||||
if ( json.dashSize !== undefined ) material.dashSize = json.dashSize;
|
||||
if ( json.gapSize !== undefined ) material.gapSize = json.gapSize;
|
||||
if ( json.scale !== undefined ) material.scale = json.scale;
|
||||
|
||||
if ( json.polygonOffset !== undefined ) material.polygonOffset = json.polygonOffset;
|
||||
if ( json.polygonOffsetFactor !== undefined ) material.polygonOffsetFactor = json.polygonOffsetFactor;
|
||||
if ( json.polygonOffsetUnits !== undefined ) material.polygonOffsetUnits = json.polygonOffsetUnits;
|
||||
|
||||
if ( json.dithering !== undefined ) material.dithering = json.dithering;
|
||||
|
||||
if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage;
|
||||
if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha;
|
||||
if ( json.forceSinglePass !== undefined ) material.forceSinglePass = json.forceSinglePass;
|
||||
|
||||
if ( json.visible !== undefined ) material.visible = json.visible;
|
||||
|
||||
if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped;
|
||||
|
||||
if ( json.userData !== undefined ) material.userData = json.userData;
|
||||
|
||||
if ( json.vertexColors !== undefined ) {
|
||||
|
||||
if ( typeof json.vertexColors === 'number' ) {
|
||||
|
||||
material.vertexColors = ( json.vertexColors > 0 ) ? true : false;
|
||||
|
||||
} else {
|
||||
|
||||
material.vertexColors = json.vertexColors;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Shader Material
|
||||
|
||||
if ( json.uniforms !== undefined ) {
|
||||
|
||||
for ( const name in json.uniforms ) {
|
||||
|
||||
const uniform = json.uniforms[ name ];
|
||||
|
||||
material.uniforms[ name ] = {};
|
||||
|
||||
switch ( uniform.type ) {
|
||||
|
||||
case 't':
|
||||
material.uniforms[ name ].value = getTexture( uniform.value );
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
material.uniforms[ name ].value = new Color().setHex( uniform.value );
|
||||
break;
|
||||
|
||||
case 'v2':
|
||||
material.uniforms[ name ].value = new Vector2().fromArray( uniform.value );
|
||||
break;
|
||||
|
||||
case 'v3':
|
||||
material.uniforms[ name ].value = new Vector3().fromArray( uniform.value );
|
||||
break;
|
||||
|
||||
case 'v4':
|
||||
material.uniforms[ name ].value = new Vector4().fromArray( uniform.value );
|
||||
break;
|
||||
|
||||
case 'm3':
|
||||
material.uniforms[ name ].value = new Matrix3().fromArray( uniform.value );
|
||||
break;
|
||||
|
||||
case 'm4':
|
||||
material.uniforms[ name ].value = new Matrix4().fromArray( uniform.value );
|
||||
break;
|
||||
|
||||
default:
|
||||
material.uniforms[ name ].value = uniform.value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( json.defines !== undefined ) material.defines = json.defines;
|
||||
if ( json.vertexShader !== undefined ) material.vertexShader = json.vertexShader;
|
||||
if ( json.fragmentShader !== undefined ) material.fragmentShader = json.fragmentShader;
|
||||
if ( json.glslVersion !== undefined ) material.glslVersion = json.glslVersion;
|
||||
|
||||
if ( json.extensions !== undefined ) {
|
||||
|
||||
for ( const key in json.extensions ) {
|
||||
|
||||
material.extensions[ key ] = json.extensions[ key ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( json.lights !== undefined ) material.lights = json.lights;
|
||||
if ( json.clipping !== undefined ) material.clipping = json.clipping;
|
||||
|
||||
// for PointsMaterial
|
||||
|
||||
if ( json.size !== undefined ) material.size = json.size;
|
||||
if ( json.sizeAttenuation !== undefined ) material.sizeAttenuation = json.sizeAttenuation;
|
||||
|
||||
// maps
|
||||
|
||||
if ( json.map !== undefined ) material.map = getTexture( json.map );
|
||||
if ( json.matcap !== undefined ) material.matcap = getTexture( json.matcap );
|
||||
|
||||
if ( json.alphaMap !== undefined ) material.alphaMap = getTexture( json.alphaMap );
|
||||
|
||||
if ( json.bumpMap !== undefined ) material.bumpMap = getTexture( json.bumpMap );
|
||||
if ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale;
|
||||
|
||||
if ( json.normalMap !== undefined ) material.normalMap = getTexture( json.normalMap );
|
||||
if ( json.normalMapType !== undefined ) material.normalMapType = json.normalMapType;
|
||||
if ( json.normalScale !== undefined ) {
|
||||
|
||||
let normalScale = json.normalScale;
|
||||
|
||||
if ( Array.isArray( normalScale ) === false ) {
|
||||
|
||||
// Blender exporter used to export a scalar. See #7459
|
||||
|
||||
normalScale = [ normalScale, normalScale ];
|
||||
|
||||
}
|
||||
|
||||
material.normalScale = new Vector2().fromArray( normalScale );
|
||||
|
||||
}
|
||||
|
||||
if ( json.displacementMap !== undefined ) material.displacementMap = getTexture( json.displacementMap );
|
||||
if ( json.displacementScale !== undefined ) material.displacementScale = json.displacementScale;
|
||||
if ( json.displacementBias !== undefined ) material.displacementBias = json.displacementBias;
|
||||
|
||||
if ( json.roughnessMap !== undefined ) material.roughnessMap = getTexture( json.roughnessMap );
|
||||
if ( json.metalnessMap !== undefined ) material.metalnessMap = getTexture( json.metalnessMap );
|
||||
|
||||
if ( json.emissiveMap !== undefined ) material.emissiveMap = getTexture( json.emissiveMap );
|
||||
if ( json.emissiveIntensity !== undefined ) material.emissiveIntensity = json.emissiveIntensity;
|
||||
|
||||
if ( json.specularMap !== undefined ) material.specularMap = getTexture( json.specularMap );
|
||||
if ( json.specularIntensityMap !== undefined ) material.specularIntensityMap = getTexture( json.specularIntensityMap );
|
||||
if ( json.specularColorMap !== undefined ) material.specularColorMap = getTexture( json.specularColorMap );
|
||||
|
||||
if ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap );
|
||||
if ( json.envMapRotation !== undefined ) material.envMapRotation.fromArray( json.envMapRotation );
|
||||
if ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;
|
||||
|
||||
if ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity;
|
||||
if ( json.refractionRatio !== undefined ) material.refractionRatio = json.refractionRatio;
|
||||
|
||||
if ( json.lightMap !== undefined ) material.lightMap = getTexture( json.lightMap );
|
||||
if ( json.lightMapIntensity !== undefined ) material.lightMapIntensity = json.lightMapIntensity;
|
||||
|
||||
if ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap );
|
||||
if ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity;
|
||||
|
||||
if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap );
|
||||
|
||||
if ( json.clearcoatMap !== undefined ) material.clearcoatMap = getTexture( json.clearcoatMap );
|
||||
if ( json.clearcoatRoughnessMap !== undefined ) material.clearcoatRoughnessMap = getTexture( json.clearcoatRoughnessMap );
|
||||
if ( json.clearcoatNormalMap !== undefined ) material.clearcoatNormalMap = getTexture( json.clearcoatNormalMap );
|
||||
if ( json.clearcoatNormalScale !== undefined ) material.clearcoatNormalScale = new Vector2().fromArray( json.clearcoatNormalScale );
|
||||
|
||||
if ( json.iridescenceMap !== undefined ) material.iridescenceMap = getTexture( json.iridescenceMap );
|
||||
if ( json.iridescenceThicknessMap !== undefined ) material.iridescenceThicknessMap = getTexture( json.iridescenceThicknessMap );
|
||||
|
||||
if ( json.transmissionMap !== undefined ) material.transmissionMap = getTexture( json.transmissionMap );
|
||||
if ( json.thicknessMap !== undefined ) material.thicknessMap = getTexture( json.thicknessMap );
|
||||
|
||||
if ( json.anisotropyMap !== undefined ) material.anisotropyMap = getTexture( json.anisotropyMap );
|
||||
|
||||
if ( json.sheenColorMap !== undefined ) material.sheenColorMap = getTexture( json.sheenColorMap );
|
||||
if ( json.sheenRoughnessMap !== undefined ) material.sheenRoughnessMap = getTexture( json.sheenRoughnessMap );
|
||||
|
||||
return material;
|
||||
|
||||
}
|
||||
|
||||
setTextures( value ) {
|
||||
|
||||
this.textures = value;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
static createMaterialFromType( type ) {
|
||||
|
||||
const materialLib = {
|
||||
ShadowMaterial,
|
||||
SpriteMaterial,
|
||||
RawShaderMaterial,
|
||||
ShaderMaterial,
|
||||
PointsMaterial,
|
||||
MeshPhysicalMaterial,
|
||||
MeshStandardMaterial,
|
||||
MeshPhongMaterial,
|
||||
MeshToonMaterial,
|
||||
MeshNormalMaterial,
|
||||
MeshLambertMaterial,
|
||||
MeshDepthMaterial,
|
||||
MeshDistanceMaterial,
|
||||
MeshBasicMaterial,
|
||||
MeshMatcapMaterial,
|
||||
LineDashedMaterial,
|
||||
LineBasicMaterial,
|
||||
Material
|
||||
};
|
||||
|
||||
return new materialLib[ type ]();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { MaterialLoader };
|
1183
site/game/node_modules/three/src/loaders/ObjectLoader.js
generated
vendored
Normal file
1183
site/game/node_modules/three/src/loaders/ObjectLoader.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
41
site/game/node_modules/three/src/loaders/TextureLoader.js
generated
vendored
Normal file
41
site/game/node_modules/three/src/loaders/TextureLoader.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import { ImageLoader } from './ImageLoader.js';
|
||||
import { Texture } from '../textures/Texture.js';
|
||||
import { Loader } from './Loader.js';
|
||||
|
||||
class TextureLoader extends Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const texture = new Texture();
|
||||
|
||||
const loader = new ImageLoader( this.manager );
|
||||
loader.setCrossOrigin( this.crossOrigin );
|
||||
loader.setPath( this.path );
|
||||
|
||||
loader.load( url, function ( image ) {
|
||||
|
||||
texture.image = image;
|
||||
texture.needsUpdate = true;
|
||||
|
||||
if ( onLoad !== undefined ) {
|
||||
|
||||
onLoad( texture );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
return texture;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export { TextureLoader };
|
Reference in New Issue
Block a user