Archived
Private
Public Access
1
0

Initial commit

This commit is contained in:
2022-09-04 12:45:01 +02:00
commit f4a01d6a69
11601 changed files with 4206660 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { Texture } from './Texture.js';
class CanvasTexture extends Texture {
constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.needsUpdate = true;
}
}
CanvasTexture.prototype.isCanvasTexture = true;
export { CanvasTexture };

View File

@@ -0,0 +1,28 @@
import { Texture } from './Texture.js';
class CompressedTexture extends Texture {
constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
this.image = { width: width, height: height };
this.mipmaps = mipmaps;
// no flipping for cube textures
// (also flipping doesn't work for compressed textures )
this.flipY = false;
// can't generate mipmaps for compressed textures
// mips must be embedded in DDS files
this.generateMipmaps = false;
}
}
CompressedTexture.prototype.isCompressedTexture = true;
export { CompressedTexture };

View File

@@ -0,0 +1,33 @@
import { Texture } from './Texture.js';
import { CubeReflectionMapping } from '../constants.js';
class CubeTexture extends Texture {
constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
images = images !== undefined ? images : [];
mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
this.flipY = false;
}
get images() {
return this.image;
}
set images( value ) {
this.image = value;
}
}
CubeTexture.prototype.isCubeTexture = true;
export { CubeTexture };

View File

@@ -0,0 +1,35 @@
import { Texture } from './Texture.js';
import { ClampToEdgeWrapping, NearestFilter } from '../constants.js';
class Data3DTexture extends Texture {
constructor( data = null, width = 1, height = 1, depth = 1 ) {
// We're going to add .setXXX() methods for setting properties later.
// Users can still set in DataTexture3D directly.
//
// const texture = new THREE.DataTexture3D( data, width, height, depth );
// texture.anisotropy = 16;
//
// See #14839
super( null );
this.image = { data, width, height, depth };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter;
this.wrapR = ClampToEdgeWrapping;
this.generateMipmaps = false;
this.flipY = false;
this.unpackAlignment = 1;
}
}
Data3DTexture.prototype.isData3DTexture = true;
export { Data3DTexture };

View File

@@ -0,0 +1,27 @@
import { Texture } from './Texture.js';
import { ClampToEdgeWrapping, NearestFilter } from '../constants.js';
class DataArrayTexture extends Texture {
constructor( data = null, width = 1, height = 1, depth = 1 ) {
super( null );
this.image = { data, width, height, depth };
this.magFilter = NearestFilter;
this.minFilter = NearestFilter;
this.wrapR = ClampToEdgeWrapping;
this.generateMipmaps = false;
this.flipY = false;
this.unpackAlignment = 1;
}
}
DataArrayTexture.prototype.isDataArrayTexture = true;
export { DataArrayTexture };

View File

@@ -0,0 +1,22 @@
import { Texture } from './Texture.js';
import { NearestFilter } from '../constants.js';
class DataTexture extends Texture {
constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding ) {
super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
this.image = { data: data, width: width, height: height };
this.generateMipmaps = false;
this.flipY = false;
this.unpackAlignment = 1;
}
}
DataTexture.prototype.isDataTexture = true;
export { DataTexture };

View File

@@ -0,0 +1,36 @@
import { Texture } from './Texture.js';
import { NearestFilter, UnsignedShortType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js';
class DepthTexture extends Texture {
constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {
format = format !== undefined ? format : DepthFormat;
if ( format !== DepthFormat && format !== DepthStencilFormat ) {
throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );
}
if ( type === undefined && format === DepthFormat ) type = UnsignedShortType;
if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;
super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.image = { width: width, height: height };
this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
this.flipY = false;
this.generateMipmaps = false;
}
}
DepthTexture.prototype.isDepthTexture = true;
export { DepthTexture };

View File

@@ -0,0 +1,25 @@
import { Texture } from './Texture.js';
import { NearestFilter } from '../constants.js';
class FramebufferTexture extends Texture {
constructor( width, height, format ) {
super( { width, height } );
this.format = format;
this.magFilter = NearestFilter;
this.minFilter = NearestFilter;
this.generateMipmaps = false;
this.needsUpdate = true;
}
}
FramebufferTexture.prototype.isFramebufferTexture = true;
export { FramebufferTexture };

123
HTML/ThreeJS/node_modules/three/src/textures/Source.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import { ImageUtils } from '../extras/ImageUtils.js';
import * as MathUtils from '../math/MathUtils.js';
class Source {
constructor( data = null ) {
this.uuid = MathUtils.generateUUID();
this.data = data;
this.version = 0;
}
set needsUpdate( value ) {
if ( value === true ) this.version ++;
}
toJSON( meta ) {
const isRootObject = ( meta === undefined || typeof meta === 'string' );
if ( ! isRootObject && meta.images[ this.uuid ] !== undefined ) {
return meta.images[ this.uuid ];
}
const output = {
uuid: this.uuid,
url: ''
};
const data = this.data;
if ( data !== null ) {
let url;
if ( Array.isArray( data ) ) {
// cube texture
url = [];
for ( let i = 0, l = data.length; i < l; i ++ ) {
if ( data[ i ].isDataTexture ) {
url.push( serializeImage( data[ i ].image ) );
} else {
url.push( serializeImage( data[ i ] ) );
}
}
} else {
// texture
url = serializeImage( data );
}
output.url = url;
}
if ( ! isRootObject ) {
meta.images[ this.uuid ] = output;
}
return output;
}
}
function serializeImage( image ) {
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
// default images
return ImageUtils.getDataURL( image );
} else {
if ( image.data ) {
// images of DataTexture
return {
data: Array.prototype.slice.call( image.data ),
width: image.width,
height: image.height,
type: image.data.constructor.name
};
} else {
console.warn( 'THREE.Texture: Unable to serialize Texture.' );
return {};
}
}
}
Source.prototype.isSource = true;
export { Source };

308
HTML/ThreeJS/node_modules/three/src/textures/Texture.js generated vendored Normal file
View File

@@ -0,0 +1,308 @@
import { EventDispatcher } from '../core/EventDispatcher.js';
import {
MirroredRepeatWrapping,
ClampToEdgeWrapping,
RepeatWrapping,
LinearEncoding,
UnsignedByteType,
RGBAFormat,
LinearMipmapLinearFilter,
LinearFilter,
UVMapping
} from '../constants.js';
import * as MathUtils from '../math/MathUtils.js';
import { Vector2 } from '../math/Vector2.js';
import { Matrix3 } from '../math/Matrix3.js';
import { Source } from './Source.js';
let textureId = 0;
class Texture extends EventDispatcher {
constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) {
super();
Object.defineProperty( this, 'id', { value: textureId ++ } );
this.uuid = MathUtils.generateUUID();
this.name = '';
this.source = new Source( image );
this.mipmaps = [];
this.mapping = mapping;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.magFilter = magFilter;
this.minFilter = minFilter;
this.anisotropy = anisotropy;
this.format = format;
this.internalFormat = null;
this.type = type;
this.offset = new Vector2( 0, 0 );
this.repeat = new Vector2( 1, 1 );
this.center = new Vector2( 0, 0 );
this.rotation = 0;
this.matrixAutoUpdate = true;
this.matrix = new Matrix3();
this.generateMipmaps = true;
this.premultiplyAlpha = false;
this.flipY = true;
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
//
// Also changing the encoding after already used by a Material will not automatically make the Material
// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
this.encoding = encoding;
this.userData = {};
this.version = 0;
this.onUpdate = null;
this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not
this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures)
}
get image() {
return this.source.data;
}
set image( value ) {
this.source.data = value;
}
updateMatrix() {
this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
}
clone() {
return new this.constructor().copy( this );
}
copy( source ) {
this.name = source.name;
this.source = source.source;
this.mipmaps = source.mipmaps.slice( 0 );
this.mapping = source.mapping;
this.wrapS = source.wrapS;
this.wrapT = source.wrapT;
this.magFilter = source.magFilter;
this.minFilter = source.minFilter;
this.anisotropy = source.anisotropy;
this.format = source.format;
this.internalFormat = source.internalFormat;
this.type = source.type;
this.offset.copy( source.offset );
this.repeat.copy( source.repeat );
this.center.copy( source.center );
this.rotation = source.rotation;
this.matrixAutoUpdate = source.matrixAutoUpdate;
this.matrix.copy( source.matrix );
this.generateMipmaps = source.generateMipmaps;
this.premultiplyAlpha = source.premultiplyAlpha;
this.flipY = source.flipY;
this.unpackAlignment = source.unpackAlignment;
this.encoding = source.encoding;
this.userData = JSON.parse( JSON.stringify( source.userData ) );
this.needsUpdate = true;
return this;
}
toJSON( meta ) {
const isRootObject = ( meta === undefined || typeof meta === 'string' );
if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
return meta.textures[ this.uuid ];
}
const output = {
metadata: {
version: 4.5,
type: 'Texture',
generator: 'Texture.toJSON'
},
uuid: this.uuid,
name: this.name,
image: this.source.toJSON( meta ).uuid,
mapping: this.mapping,
repeat: [ this.repeat.x, this.repeat.y ],
offset: [ this.offset.x, this.offset.y ],
center: [ this.center.x, this.center.y ],
rotation: this.rotation,
wrap: [ this.wrapS, this.wrapT ],
format: this.format,
type: this.type,
encoding: this.encoding,
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
flipY: this.flipY,
premultiplyAlpha: this.premultiplyAlpha,
unpackAlignment: this.unpackAlignment
};
if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData;
if ( ! isRootObject ) {
meta.textures[ this.uuid ] = output;
}
return output;
}
dispose() {
this.dispatchEvent( { type: 'dispose' } );
}
transformUv( uv ) {
if ( this.mapping !== UVMapping ) return uv;
uv.applyMatrix3( this.matrix );
if ( uv.x < 0 || uv.x > 1 ) {
switch ( this.wrapS ) {
case RepeatWrapping:
uv.x = uv.x - Math.floor( uv.x );
break;
case ClampToEdgeWrapping:
uv.x = uv.x < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
uv.x = Math.ceil( uv.x ) - uv.x;
} else {
uv.x = uv.x - Math.floor( uv.x );
}
break;
}
}
if ( uv.y < 0 || uv.y > 1 ) {
switch ( this.wrapT ) {
case RepeatWrapping:
uv.y = uv.y - Math.floor( uv.y );
break;
case ClampToEdgeWrapping:
uv.y = uv.y < 0 ? 0 : 1;
break;
case MirroredRepeatWrapping:
if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
uv.y = Math.ceil( uv.y ) - uv.y;
} else {
uv.y = uv.y - Math.floor( uv.y );
}
break;
}
}
if ( this.flipY ) {
uv.y = 1 - uv.y;
}
return uv;
}
set needsUpdate( value ) {
if ( value === true ) {
this.version ++;
this.source.needsUpdate = true;
}
}
}
Texture.DEFAULT_IMAGE = null;
Texture.DEFAULT_MAPPING = UVMapping;
Texture.prototype.isTexture = true;
export { Texture };

View File

@@ -0,0 +1,55 @@
import { LinearFilter } from '../constants.js';
import { Texture } from './Texture.js';
class VideoTexture extends Texture {
constructor( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.minFilter = minFilter !== undefined ? minFilter : LinearFilter;
this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
this.generateMipmaps = false;
const scope = this;
function updateVideo() {
scope.needsUpdate = true;
video.requestVideoFrameCallback( updateVideo );
}
if ( 'requestVideoFrameCallback' in video ) {
video.requestVideoFrameCallback( updateVideo );
}
}
clone() {
return new this.constructor( this.image ).copy( this );
}
update() {
const video = this.image;
const hasVideoFrameCallback = 'requestVideoFrameCallback' in video;
if ( hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA ) {
this.needsUpdate = true;
}
}
}
VideoTexture.prototype.isVideoTexture = true;
export { VideoTexture };