- Create class "player"
This commit is contained in:
Kum1ta
2024-08-18 01:48:50 +02:00
parent a265843b82
commit 44ad413120
1218 changed files with 638609 additions and 0 deletions

View File

@ -0,0 +1,49 @@
import { Material } from './Material.js';
import { Color } from '../math/Color.js';
class LineBasicMaterial extends Material {
constructor( parameters ) {
super();
this.isLineBasicMaterial = true;
this.type = 'LineBasicMaterial';
this.color = new Color( 0xffffff );
this.map = null;
this.linewidth = 1;
this.linecap = 'round';
this.linejoin = 'round';
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.linewidth = source.linewidth;
this.linecap = source.linecap;
this.linejoin = source.linejoin;
this.fog = source.fog;
return this;
}
}
export { LineBasicMaterial };

View File

@ -0,0 +1,35 @@
import { LineBasicMaterial } from './LineBasicMaterial.js';
class LineDashedMaterial extends LineBasicMaterial {
constructor( parameters ) {
super();
this.isLineDashedMaterial = true;
this.type = 'LineDashedMaterial';
this.scale = 1;
this.dashSize = 3;
this.gapSize = 1;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.scale = source.scale;
this.dashSize = source.dashSize;
this.gapSize = source.gapSize;
return this;
}
}
export { LineDashedMaterial };

View File

@ -0,0 +1,534 @@
import { Color } from '../math/Color.js';
import { EventDispatcher } from '../core/EventDispatcher.js';
import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
import * as MathUtils from '../math/MathUtils.js';
let _materialId = 0;
class Material extends EventDispatcher {
constructor() {
super();
this.isMaterial = true;
Object.defineProperty( this, 'id', { value: _materialId ++ } );
this.uuid = MathUtils.generateUUID();
this.name = '';
this.type = 'Material';
this.blending = NormalBlending;
this.side = FrontSide;
this.vertexColors = false;
this.opacity = 1;
this.transparent = false;
this.alphaHash = false;
this.blendSrc = SrcAlphaFactor;
this.blendDst = OneMinusSrcAlphaFactor;
this.blendEquation = AddEquation;
this.blendSrcAlpha = null;
this.blendDstAlpha = null;
this.blendEquationAlpha = null;
this.blendColor = new Color( 0, 0, 0 );
this.blendAlpha = 0;
this.depthFunc = LessEqualDepth;
this.depthTest = true;
this.depthWrite = true;
this.stencilWriteMask = 0xff;
this.stencilFunc = AlwaysStencilFunc;
this.stencilRef = 0;
this.stencilFuncMask = 0xff;
this.stencilFail = KeepStencilOp;
this.stencilZFail = KeepStencilOp;
this.stencilZPass = KeepStencilOp;
this.stencilWrite = false;
this.clippingPlanes = null;
this.clipIntersection = false;
this.clipShadows = false;
this.shadowSide = null;
this.colorWrite = true;
this.precision = null; // override the renderer's default precision for this material
this.polygonOffset = false;
this.polygonOffsetFactor = 0;
this.polygonOffsetUnits = 0;
this.dithering = false;
this.alphaToCoverage = false;
this.premultipliedAlpha = false;
this.forceSinglePass = false;
this.visible = true;
this.toneMapped = true;
this.userData = {};
this.version = 0;
this._alphaTest = 0;
}
get alphaTest() {
return this._alphaTest;
}
set alphaTest( value ) {
if ( this._alphaTest > 0 !== value > 0 ) {
this.version ++;
}
this._alphaTest = value;
}
onBeforeCompile( /* shaderobject, renderer */ ) {}
customProgramCacheKey() {
return this.onBeforeCompile.toString();
}
setValues( values ) {
if ( values === undefined ) return;
for ( const key in values ) {
const newValue = values[ key ];
if ( newValue === undefined ) {
console.warn( `THREE.Material: parameter '${ key }' has value of undefined.` );
continue;
}
const currentValue = this[ key ];
if ( currentValue === undefined ) {
console.warn( `THREE.Material: '${ key }' is not a property of THREE.${ this.type }.` );
continue;
}
if ( currentValue && currentValue.isColor ) {
currentValue.set( newValue );
} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {
currentValue.copy( newValue );
} else {
this[ key ] = newValue;
}
}
}
toJSON( meta ) {
const isRootObject = ( meta === undefined || typeof meta === 'string' );
if ( isRootObject ) {
meta = {
textures: {},
images: {}
};
}
const data = {
metadata: {
version: 4.6,
type: 'Material',
generator: 'Material.toJSON'
}
};
// standard Material serialization
data.uuid = this.uuid;
data.type = this.type;
if ( this.name !== '' ) data.name = this.name;
if ( this.color && this.color.isColor ) data.color = this.color.getHex();
if ( this.roughness !== undefined ) data.roughness = this.roughness;
if ( this.metalness !== undefined ) data.metalness = this.metalness;
if ( this.sheen !== undefined ) data.sheen = this.sheen;
if ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();
if ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;
if ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();
if ( this.emissiveIntensity !== undefined && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;
if ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();
if ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;
if ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();
if ( this.shininess !== undefined ) data.shininess = this.shininess;
if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;
if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;
if ( this.clearcoatMap && this.clearcoatMap.isTexture ) {
data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;
}
if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {
data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;
}
if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {
data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;
data.clearcoatNormalScale = this.clearcoatNormalScale.toArray();
}
if ( this.dispersion !== undefined ) data.dispersion = this.dispersion;
if ( this.iridescence !== undefined ) data.iridescence = this.iridescence;
if ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;
if ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;
if ( this.iridescenceMap && this.iridescenceMap.isTexture ) {
data.iridescenceMap = this.iridescenceMap.toJSON( meta ).uuid;
}
if ( this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture ) {
data.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON( meta ).uuid;
}
if ( this.anisotropy !== undefined ) data.anisotropy = this.anisotropy;
if ( this.anisotropyRotation !== undefined ) data.anisotropyRotation = this.anisotropyRotation;
if ( this.anisotropyMap && this.anisotropyMap.isTexture ) {
data.anisotropyMap = this.anisotropyMap.toJSON( meta ).uuid;
}
if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;
if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;
if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;
if ( this.lightMap && this.lightMap.isTexture ) {
data.lightMap = this.lightMap.toJSON( meta ).uuid;
data.lightMapIntensity = this.lightMapIntensity;
}
if ( this.aoMap && this.aoMap.isTexture ) {
data.aoMap = this.aoMap.toJSON( meta ).uuid;
data.aoMapIntensity = this.aoMapIntensity;
}
if ( this.bumpMap && this.bumpMap.isTexture ) {
data.bumpMap = this.bumpMap.toJSON( meta ).uuid;
data.bumpScale = this.bumpScale;
}
if ( this.normalMap && this.normalMap.isTexture ) {
data.normalMap = this.normalMap.toJSON( meta ).uuid;
data.normalMapType = this.normalMapType;
data.normalScale = this.normalScale.toArray();
}
if ( this.displacementMap && this.displacementMap.isTexture ) {
data.displacementMap = this.displacementMap.toJSON( meta ).uuid;
data.displacementScale = this.displacementScale;
data.displacementBias = this.displacementBias;
}
if ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;
if ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;
if ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;
if ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;
if ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;
if ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;
if ( this.envMap && this.envMap.isTexture ) {
data.envMap = this.envMap.toJSON( meta ).uuid;
if ( this.combine !== undefined ) data.combine = this.combine;
}
if ( this.envMapRotation !== undefined ) data.envMapRotation = this.envMapRotation.toArray();
if ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;
if ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;
if ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;
if ( this.gradientMap && this.gradientMap.isTexture ) {
data.gradientMap = this.gradientMap.toJSON( meta ).uuid;
}
if ( this.transmission !== undefined ) data.transmission = this.transmission;
if ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;
if ( this.thickness !== undefined ) data.thickness = this.thickness;
if ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;
if ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance;
if ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();
if ( this.size !== undefined ) data.size = this.size;
if ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;
if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;
if ( this.blending !== NormalBlending ) data.blending = this.blending;
if ( this.side !== FrontSide ) data.side = this.side;
if ( this.vertexColors === true ) data.vertexColors = true;
if ( this.opacity < 1 ) data.opacity = this.opacity;
if ( this.transparent === true ) data.transparent = true;
if ( this.blendSrc !== SrcAlphaFactor ) data.blendSrc = this.blendSrc;
if ( this.blendDst !== OneMinusSrcAlphaFactor ) data.blendDst = this.blendDst;
if ( this.blendEquation !== AddEquation ) data.blendEquation = this.blendEquation;
if ( this.blendSrcAlpha !== null ) data.blendSrcAlpha = this.blendSrcAlpha;
if ( this.blendDstAlpha !== null ) data.blendDstAlpha = this.blendDstAlpha;
if ( this.blendEquationAlpha !== null ) data.blendEquationAlpha = this.blendEquationAlpha;
if ( this.blendColor && this.blendColor.isColor ) data.blendColor = this.blendColor.getHex();
if ( this.blendAlpha !== 0 ) data.blendAlpha = this.blendAlpha;
if ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc;
if ( this.depthTest === false ) data.depthTest = this.depthTest;
if ( this.depthWrite === false ) data.depthWrite = this.depthWrite;
if ( this.colorWrite === false ) data.colorWrite = this.colorWrite;
if ( this.stencilWriteMask !== 0xff ) data.stencilWriteMask = this.stencilWriteMask;
if ( this.stencilFunc !== AlwaysStencilFunc ) data.stencilFunc = this.stencilFunc;
if ( this.stencilRef !== 0 ) data.stencilRef = this.stencilRef;
if ( this.stencilFuncMask !== 0xff ) data.stencilFuncMask = this.stencilFuncMask;
if ( this.stencilFail !== KeepStencilOp ) data.stencilFail = this.stencilFail;
if ( this.stencilZFail !== KeepStencilOp ) data.stencilZFail = this.stencilZFail;
if ( this.stencilZPass !== KeepStencilOp ) data.stencilZPass = this.stencilZPass;
if ( this.stencilWrite === true ) data.stencilWrite = this.stencilWrite;
// rotation (SpriteMaterial)
if ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;
if ( this.polygonOffset === true ) data.polygonOffset = true;
if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
if ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;
if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
if ( this.scale !== undefined ) data.scale = this.scale;
if ( this.dithering === true ) data.dithering = true;
if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
if ( this.alphaHash === true ) data.alphaHash = true;
if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
if ( this.forceSinglePass === true ) data.forceSinglePass = true;
if ( this.wireframe === true ) data.wireframe = true;
if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
if ( this.flatShading === true ) data.flatShading = true;
if ( this.visible === false ) data.visible = false;
if ( this.toneMapped === false ) data.toneMapped = false;
if ( this.fog === false ) data.fog = false;
if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
// TODO: Copied from Object3D.toJSON
function extractFromCache( cache ) {
const values = [];
for ( const key in cache ) {
const data = cache[ key ];
delete data.metadata;
values.push( data );
}
return values;
}
if ( isRootObject ) {
const textures = extractFromCache( meta.textures );
const images = extractFromCache( meta.images );
if ( textures.length > 0 ) data.textures = textures;
if ( images.length > 0 ) data.images = images;
}
return data;
}
clone() {
return new this.constructor().copy( this );
}
copy( source ) {
this.name = source.name;
this.blending = source.blending;
this.side = source.side;
this.vertexColors = source.vertexColors;
this.opacity = source.opacity;
this.transparent = source.transparent;
this.blendSrc = source.blendSrc;
this.blendDst = source.blendDst;
this.blendEquation = source.blendEquation;
this.blendSrcAlpha = source.blendSrcAlpha;
this.blendDstAlpha = source.blendDstAlpha;
this.blendEquationAlpha = source.blendEquationAlpha;
this.blendColor.copy( source.blendColor );
this.blendAlpha = source.blendAlpha;
this.depthFunc = source.depthFunc;
this.depthTest = source.depthTest;
this.depthWrite = source.depthWrite;
this.stencilWriteMask = source.stencilWriteMask;
this.stencilFunc = source.stencilFunc;
this.stencilRef = source.stencilRef;
this.stencilFuncMask = source.stencilFuncMask;
this.stencilFail = source.stencilFail;
this.stencilZFail = source.stencilZFail;
this.stencilZPass = source.stencilZPass;
this.stencilWrite = source.stencilWrite;
const srcPlanes = source.clippingPlanes;
let dstPlanes = null;
if ( srcPlanes !== null ) {
const n = srcPlanes.length;
dstPlanes = new Array( n );
for ( let i = 0; i !== n; ++ i ) {
dstPlanes[ i ] = srcPlanes[ i ].clone();
}
}
this.clippingPlanes = dstPlanes;
this.clipIntersection = source.clipIntersection;
this.clipShadows = source.clipShadows;
this.shadowSide = source.shadowSide;
this.colorWrite = source.colorWrite;
this.precision = source.precision;
this.polygonOffset = source.polygonOffset;
this.polygonOffsetFactor = source.polygonOffsetFactor;
this.polygonOffsetUnits = source.polygonOffsetUnits;
this.dithering = source.dithering;
this.alphaTest = source.alphaTest;
this.alphaHash = source.alphaHash;
this.alphaToCoverage = source.alphaToCoverage;
this.premultipliedAlpha = source.premultipliedAlpha;
this.forceSinglePass = source.forceSinglePass;
this.visible = source.visible;
this.toneMapped = source.toneMapped;
this.userData = JSON.parse( JSON.stringify( source.userData ) );
return this;
}
dispose() {
this.dispatchEvent( { type: 'dispose' } );
}
set needsUpdate( value ) {
if ( value === true ) this.version ++;
}
onBuild( /* shaderobject, renderer */ ) {
console.warn( 'Material: onBuild() has been removed.' ); // @deprecated, r166
}
onBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {
console.warn( 'Material: onBeforeRender() has been removed.' ); // @deprecated, r166
}
}
export { Material };

View File

@ -0,0 +1,39 @@
import { ShadowMaterial } from './ShadowMaterial.js';
import { SpriteMaterial } from './SpriteMaterial.js';
import { RawShaderMaterial } from './RawShaderMaterial.js';
import { ShaderMaterial } from './ShaderMaterial.js';
import { PointsMaterial } from './PointsMaterial.js';
import { MeshPhysicalMaterial } from './MeshPhysicalMaterial.js';
import { MeshStandardMaterial } from './MeshStandardMaterial.js';
import { MeshPhongMaterial } from './MeshPhongMaterial.js';
import { MeshToonMaterial } from './MeshToonMaterial.js';
import { MeshNormalMaterial } from './MeshNormalMaterial.js';
import { MeshLambertMaterial } from './MeshLambertMaterial.js';
import { MeshDepthMaterial } from './MeshDepthMaterial.js';
import { MeshDistanceMaterial } from './MeshDistanceMaterial.js';
import { MeshBasicMaterial } from './MeshBasicMaterial.js';
import { MeshMatcapMaterial } from './MeshMatcapMaterial.js';
import { LineDashedMaterial } from './LineDashedMaterial.js';
import { LineBasicMaterial } from './LineBasicMaterial.js';
import { Material } from './Material.js';
export {
ShadowMaterial,
SpriteMaterial,
RawShaderMaterial,
ShaderMaterial,
PointsMaterial,
MeshPhysicalMaterial,
MeshStandardMaterial,
MeshPhongMaterial,
MeshToonMaterial,
MeshNormalMaterial,
MeshLambertMaterial,
MeshDepthMaterial,
MeshDistanceMaterial,
MeshBasicMaterial,
MeshMatcapMaterial,
LineDashedMaterial,
LineBasicMaterial,
Material
};

View File

@ -0,0 +1,84 @@
import { Material } from './Material.js';
import { MultiplyOperation } from '../constants.js';
import { Color } from '../math/Color.js';
import { Euler } from '../math/Euler.js';
class MeshBasicMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshBasicMaterial = true;
this.type = 'MeshBasicMaterial';
this.color = new Color( 0xffffff ); // emissive
this.map = null;
this.lightMap = null;
this.lightMapIntensity = 1.0;
this.aoMap = null;
this.aoMapIntensity = 1.0;
this.specularMap = null;
this.alphaMap = null;
this.envMap = null;
this.envMapRotation = new Euler();
this.combine = MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.specularMap = source.specularMap;
this.alphaMap = source.alphaMap;
this.envMap = source.envMap;
this.envMapRotation.copy( source.envMapRotation );
this.combine = source.combine;
this.reflectivity = source.reflectivity;
this.refractionRatio = source.refractionRatio;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.fog = source.fog;
return this;
}
}
export { MeshBasicMaterial };

View File

@ -0,0 +1,54 @@
import { Material } from './Material.js';
import { BasicDepthPacking } from '../constants.js';
class MeshDepthMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshDepthMaterial = true;
this.type = 'MeshDepthMaterial';
this.depthPacking = BasicDepthPacking;
this.map = null;
this.alphaMap = null;
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.depthPacking = source.depthPacking;
this.map = source.map;
this.alphaMap = source.alphaMap;
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
return this;
}
}
export { MeshDepthMaterial };

View File

@ -0,0 +1,43 @@
import { Material } from './Material.js';
class MeshDistanceMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshDistanceMaterial = true;
this.type = 'MeshDistanceMaterial';
this.map = null;
this.alphaMap = null;
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.map = source.map;
this.alphaMap = source.alphaMap;
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
return this;
}
}
export { MeshDistanceMaterial };

View File

@ -0,0 +1,119 @@
import { MultiplyOperation, TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
import { Color } from '../math/Color.js';
import { Euler } from '../math/Euler.js';
class MeshLambertMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshLambertMaterial = true;
this.type = 'MeshLambertMaterial';
this.color = new Color( 0xffffff ); // diffuse
this.map = null;
this.lightMap = null;
this.lightMapIntensity = 1.0;
this.aoMap = null;
this.aoMapIntensity = 1.0;
this.emissive = new Color( 0x000000 );
this.emissiveIntensity = 1.0;
this.emissiveMap = null;
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.specularMap = null;
this.alphaMap = null;
this.envMap = null;
this.envMapRotation = new Euler();
this.combine = MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';
this.flatShading = false;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.emissive.copy( source.emissive );
this.emissiveMap = source.emissiveMap;
this.emissiveIntensity = source.emissiveIntensity;
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.specularMap = source.specularMap;
this.alphaMap = source.alphaMap;
this.envMap = source.envMap;
this.envMapRotation.copy( source.envMapRotation );
this.combine = source.combine;
this.reflectivity = source.reflectivity;
this.refractionRatio = source.refractionRatio;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.flatShading = source.flatShading;
this.fog = source.fog;
return this;
}
}
export { MeshLambertMaterial };

View File

@ -0,0 +1,81 @@
import { TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
import { Color } from '../math/Color.js';
class MeshMatcapMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshMatcapMaterial = true;
this.defines = { 'MATCAP': '' };
this.type = 'MeshMatcapMaterial';
this.color = new Color( 0xffffff ); // diffuse
this.matcap = null;
this.map = null;
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.alphaMap = null;
this.flatShading = false;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.defines = { 'MATCAP': '' };
this.color.copy( source.color );
this.matcap = source.matcap;
this.map = source.map;
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.alphaMap = source.alphaMap;
this.flatShading = source.flatShading;
this.fog = source.fog;
return this;
}
}
export { MeshMatcapMaterial };

View File

@ -0,0 +1,61 @@
import { TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
class MeshNormalMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshNormalMaterial = true;
this.type = 'MeshNormalMaterial';
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.flatShading = false;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.flatShading = source.flatShading;
return this;
}
}
export { MeshNormalMaterial };

View File

@ -0,0 +1,123 @@
import { MultiplyOperation, TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
import { Color } from '../math/Color.js';
import { Euler } from '../math/Euler.js';
class MeshPhongMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshPhongMaterial = true;
this.type = 'MeshPhongMaterial';
this.color = new Color( 0xffffff ); // diffuse
this.specular = new Color( 0x111111 );
this.shininess = 30;
this.map = null;
this.lightMap = null;
this.lightMapIntensity = 1.0;
this.aoMap = null;
this.aoMapIntensity = 1.0;
this.emissive = new Color( 0x000000 );
this.emissiveIntensity = 1.0;
this.emissiveMap = null;
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.specularMap = null;
this.alphaMap = null;
this.envMap = null;
this.envMapRotation = new Euler();
this.combine = MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';
this.flatShading = false;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.specular.copy( source.specular );
this.shininess = source.shininess;
this.map = source.map;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.emissive.copy( source.emissive );
this.emissiveMap = source.emissiveMap;
this.emissiveIntensity = source.emissiveIntensity;
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.specularMap = source.specularMap;
this.alphaMap = source.alphaMap;
this.envMap = source.envMap;
this.envMapRotation.copy( source.envMapRotation );
this.combine = source.combine;
this.reflectivity = source.reflectivity;
this.refractionRatio = source.refractionRatio;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.flatShading = source.flatShading;
this.fog = source.fog;
return this;
}
}
export { MeshPhongMaterial };

View File

@ -0,0 +1,244 @@
import { Vector2 } from '../math/Vector2.js';
import { MeshStandardMaterial } from './MeshStandardMaterial.js';
import { Color } from '../math/Color.js';
import * as MathUtils from '../math/MathUtils.js';
class MeshPhysicalMaterial extends MeshStandardMaterial {
constructor( parameters ) {
super();
this.isMeshPhysicalMaterial = true;
this.defines = {
'STANDARD': '',
'PHYSICAL': ''
};
this.type = 'MeshPhysicalMaterial';
this.anisotropyRotation = 0;
this.anisotropyMap = null;
this.clearcoatMap = null;
this.clearcoatRoughness = 0.0;
this.clearcoatRoughnessMap = null;
this.clearcoatNormalScale = new Vector2( 1, 1 );
this.clearcoatNormalMap = null;
this.ior = 1.5;
Object.defineProperty( this, 'reflectivity', {
get: function () {
return ( MathUtils.clamp( 2.5 * ( this.ior - 1 ) / ( this.ior + 1 ), 0, 1 ) );
},
set: function ( reflectivity ) {
this.ior = ( 1 + 0.4 * reflectivity ) / ( 1 - 0.4 * reflectivity );
}
} );
this.iridescenceMap = null;
this.iridescenceIOR = 1.3;
this.iridescenceThicknessRange = [ 100, 400 ];
this.iridescenceThicknessMap = null;
this.sheenColor = new Color( 0x000000 );
this.sheenColorMap = null;
this.sheenRoughness = 1.0;
this.sheenRoughnessMap = null;
this.transmissionMap = null;
this.thickness = 0;
this.thicknessMap = null;
this.attenuationDistance = Infinity;
this.attenuationColor = new Color( 1, 1, 1 );
this.specularIntensity = 1.0;
this.specularIntensityMap = null;
this.specularColor = new Color( 1, 1, 1 );
this.specularColorMap = null;
this._anisotropy = 0;
this._clearcoat = 0;
this._dispersion = 0;
this._iridescence = 0;
this._sheen = 0.0;
this._transmission = 0;
this.setValues( parameters );
}
get anisotropy() {
return this._anisotropy;
}
set anisotropy( value ) {
if ( this._anisotropy > 0 !== value > 0 ) {
this.version ++;
}
this._anisotropy = value;
}
get clearcoat() {
return this._clearcoat;
}
set clearcoat( value ) {
if ( this._clearcoat > 0 !== value > 0 ) {
this.version ++;
}
this._clearcoat = value;
}
get iridescence() {
return this._iridescence;
}
set iridescence( value ) {
if ( this._iridescence > 0 !== value > 0 ) {
this.version ++;
}
this._iridescence = value;
}
get dispersion() {
return this._dispersion;
}
set dispersion( value ) {
if ( this._dispersion > 0 !== value > 0 ) {
this.version ++;
}
this._dispersion = value;
}
get sheen() {
return this._sheen;
}
set sheen( value ) {
if ( this._sheen > 0 !== value > 0 ) {
this.version ++;
}
this._sheen = value;
}
get transmission() {
return this._transmission;
}
set transmission( value ) {
if ( this._transmission > 0 !== value > 0 ) {
this.version ++;
}
this._transmission = value;
}
copy( source ) {
super.copy( source );
this.defines = {
'STANDARD': '',
'PHYSICAL': ''
};
this.anisotropy = source.anisotropy;
this.anisotropyRotation = source.anisotropyRotation;
this.anisotropyMap = source.anisotropyMap;
this.clearcoat = source.clearcoat;
this.clearcoatMap = source.clearcoatMap;
this.clearcoatRoughness = source.clearcoatRoughness;
this.clearcoatRoughnessMap = source.clearcoatRoughnessMap;
this.clearcoatNormalMap = source.clearcoatNormalMap;
this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
this.dispersion = source.dispersion;
this.ior = source.ior;
this.iridescence = source.iridescence;
this.iridescenceMap = source.iridescenceMap;
this.iridescenceIOR = source.iridescenceIOR;
this.iridescenceThicknessRange = [ ...source.iridescenceThicknessRange ];
this.iridescenceThicknessMap = source.iridescenceThicknessMap;
this.sheen = source.sheen;
this.sheenColor.copy( source.sheenColor );
this.sheenColorMap = source.sheenColorMap;
this.sheenRoughness = source.sheenRoughness;
this.sheenRoughnessMap = source.sheenRoughnessMap;
this.transmission = source.transmission;
this.transmissionMap = source.transmissionMap;
this.thickness = source.thickness;
this.thicknessMap = source.thicknessMap;
this.attenuationDistance = source.attenuationDistance;
this.attenuationColor.copy( source.attenuationColor );
this.specularIntensity = source.specularIntensity;
this.specularIntensityMap = source.specularIntensityMap;
this.specularColor.copy( source.specularColor );
this.specularColorMap = source.specularColorMap;
return this;
}
}
export { MeshPhysicalMaterial };

View File

@ -0,0 +1,127 @@
import { TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
import { Color } from '../math/Color.js';
import { Euler } from '../math/Euler.js';
class MeshStandardMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshStandardMaterial = true;
this.defines = { 'STANDARD': '' };
this.type = 'MeshStandardMaterial';
this.color = new Color( 0xffffff ); // diffuse
this.roughness = 1.0;
this.metalness = 0.0;
this.map = null;
this.lightMap = null;
this.lightMapIntensity = 1.0;
this.aoMap = null;
this.aoMapIntensity = 1.0;
this.emissive = new Color( 0x000000 );
this.emissiveIntensity = 1.0;
this.emissiveMap = null;
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.roughnessMap = null;
this.metalnessMap = null;
this.alphaMap = null;
this.envMap = null;
this.envMapRotation = new Euler();
this.envMapIntensity = 1.0;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';
this.flatShading = false;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.defines = { 'STANDARD': '' };
this.color.copy( source.color );
this.roughness = source.roughness;
this.metalness = source.metalness;
this.map = source.map;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.emissive.copy( source.emissive );
this.emissiveMap = source.emissiveMap;
this.emissiveIntensity = source.emissiveIntensity;
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.roughnessMap = source.roughnessMap;
this.metalnessMap = source.metalnessMap;
this.alphaMap = source.alphaMap;
this.envMap = source.envMap;
this.envMapRotation.copy( source.envMapRotation );
this.envMapIntensity = source.envMapIntensity;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.flatShading = source.flatShading;
this.fog = source.fog;
return this;
}
}
export { MeshStandardMaterial };

View File

@ -0,0 +1,102 @@
import { TangentSpaceNormalMap } from '../constants.js';
import { Material } from './Material.js';
import { Vector2 } from '../math/Vector2.js';
import { Color } from '../math/Color.js';
class MeshToonMaterial extends Material {
constructor( parameters ) {
super();
this.isMeshToonMaterial = true;
this.defines = { 'TOON': '' };
this.type = 'MeshToonMaterial';
this.color = new Color( 0xffffff );
this.map = null;
this.gradientMap = null;
this.lightMap = null;
this.lightMapIntensity = 1.0;
this.aoMap = null;
this.aoMapIntensity = 1.0;
this.emissive = new Color( 0x000000 );
this.emissiveIntensity = 1.0;
this.emissiveMap = null;
this.bumpMap = null;
this.bumpScale = 1;
this.normalMap = null;
this.normalMapType = TangentSpaceNormalMap;
this.normalScale = new Vector2( 1, 1 );
this.displacementMap = null;
this.displacementScale = 1;
this.displacementBias = 0;
this.alphaMap = null;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.wireframeLinecap = 'round';
this.wireframeLinejoin = 'round';
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.gradientMap = source.gradientMap;
this.lightMap = source.lightMap;
this.lightMapIntensity = source.lightMapIntensity;
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
this.emissive.copy( source.emissive );
this.emissiveMap = source.emissiveMap;
this.emissiveIntensity = source.emissiveIntensity;
this.bumpMap = source.bumpMap;
this.bumpScale = source.bumpScale;
this.normalMap = source.normalMap;
this.normalMapType = source.normalMapType;
this.normalScale.copy( source.normalScale );
this.displacementMap = source.displacementMap;
this.displacementScale = source.displacementScale;
this.displacementBias = source.displacementBias;
this.alphaMap = source.alphaMap;
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.wireframeLinecap = source.wireframeLinecap;
this.wireframeLinejoin = source.wireframeLinejoin;
this.fog = source.fog;
return this;
}
}
export { MeshToonMaterial };

View File

@ -0,0 +1,50 @@
import { Material } from './Material.js';
import { Color } from '../math/Color.js';
class PointsMaterial extends Material {
constructor( parameters ) {
super();
this.isPointsMaterial = true;
this.type = 'PointsMaterial';
this.color = new Color( 0xffffff );
this.map = null;
this.alphaMap = null;
this.size = 1;
this.sizeAttenuation = true;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.alphaMap = source.alphaMap;
this.size = source.size;
this.sizeAttenuation = source.sizeAttenuation;
this.fog = source.fog;
return this;
}
}
export { PointsMaterial };

View File

@ -0,0 +1,17 @@
import { ShaderMaterial } from './ShaderMaterial.js';
class RawShaderMaterial extends ShaderMaterial {
constructor( parameters ) {
super( parameters );
this.isRawShaderMaterial = true;
this.type = 'RawShaderMaterial';
}
}
export { RawShaderMaterial };

View File

@ -0,0 +1,185 @@
import { Material } from './Material.js';
import { cloneUniforms, cloneUniformsGroups } from '../renderers/shaders/UniformsUtils.js';
import default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js';
import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js';
class ShaderMaterial extends Material {
constructor( parameters ) {
super();
this.isShaderMaterial = true;
this.type = 'ShaderMaterial';
this.defines = {};
this.uniforms = {};
this.uniformsGroups = [];
this.vertexShader = default_vertex;
this.fragmentShader = default_fragment;
this.linewidth = 1;
this.wireframe = false;
this.wireframeLinewidth = 1;
this.fog = false; // set to use scene fog
this.lights = false; // set to use scene lights
this.clipping = false; // set to use user-defined clipping planes
this.forceSinglePass = true;
this.extensions = {
clipCullDistance: false, // set to use vertex shader clipping
multiDraw: false // set to use vertex shader multi_draw / enable gl_DrawID
};
// When rendered geometry doesn't include these attributes but the material does,
// use these default values in WebGL. This avoids errors when buffer data is missing.
this.defaultAttributeValues = {
'color': [ 1, 1, 1 ],
'uv': [ 0, 0 ],
'uv1': [ 0, 0 ]
};
this.index0AttributeName = undefined;
this.uniformsNeedUpdate = false;
this.glslVersion = null;
if ( parameters !== undefined ) {
this.setValues( parameters );
}
}
copy( source ) {
super.copy( source );
this.fragmentShader = source.fragmentShader;
this.vertexShader = source.vertexShader;
this.uniforms = cloneUniforms( source.uniforms );
this.uniformsGroups = cloneUniformsGroups( source.uniformsGroups );
this.defines = Object.assign( {}, source.defines );
this.wireframe = source.wireframe;
this.wireframeLinewidth = source.wireframeLinewidth;
this.fog = source.fog;
this.lights = source.lights;
this.clipping = source.clipping;
this.extensions = Object.assign( {}, source.extensions );
this.glslVersion = source.glslVersion;
return this;
}
toJSON( meta ) {
const data = super.toJSON( meta );
data.glslVersion = this.glslVersion;
data.uniforms = {};
for ( const name in this.uniforms ) {
const uniform = this.uniforms[ name ];
const value = uniform.value;
if ( value && value.isTexture ) {
data.uniforms[ name ] = {
type: 't',
value: value.toJSON( meta ).uuid
};
} else if ( value && value.isColor ) {
data.uniforms[ name ] = {
type: 'c',
value: value.getHex()
};
} else if ( value && value.isVector2 ) {
data.uniforms[ name ] = {
type: 'v2',
value: value.toArray()
};
} else if ( value && value.isVector3 ) {
data.uniforms[ name ] = {
type: 'v3',
value: value.toArray()
};
} else if ( value && value.isVector4 ) {
data.uniforms[ name ] = {
type: 'v4',
value: value.toArray()
};
} else if ( value && value.isMatrix3 ) {
data.uniforms[ name ] = {
type: 'm3',
value: value.toArray()
};
} else if ( value && value.isMatrix4 ) {
data.uniforms[ name ] = {
type: 'm4',
value: value.toArray()
};
} else {
data.uniforms[ name ] = {
value: value
};
// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far
}
}
if ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;
data.vertexShader = this.vertexShader;
data.fragmentShader = this.fragmentShader;
data.lights = this.lights;
data.clipping = this.clipping;
const extensions = {};
for ( const key in this.extensions ) {
if ( this.extensions[ key ] === true ) extensions[ key ] = true;
}
if ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;
return data;
}
}
export { ShaderMaterial };

View File

@ -0,0 +1,37 @@
import { Material } from './Material.js';
import { Color } from '../math/Color.js';
class ShadowMaterial extends Material {
constructor( parameters ) {
super();
this.isShadowMaterial = true;
this.type = 'ShadowMaterial';
this.color = new Color( 0x000000 );
this.transparent = true;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.fog = source.fog;
return this;
}
}
export { ShadowMaterial };

View File

@ -0,0 +1,54 @@
import { Material } from './Material.js';
import { Color } from '../math/Color.js';
class SpriteMaterial extends Material {
constructor( parameters ) {
super();
this.isSpriteMaterial = true;
this.type = 'SpriteMaterial';
this.color = new Color( 0xffffff );
this.map = null;
this.alphaMap = null;
this.rotation = 0;
this.sizeAttenuation = true;
this.transparent = true;
this.fog = true;
this.setValues( parameters );
}
copy( source ) {
super.copy( source );
this.color.copy( source.color );
this.map = source.map;
this.alphaMap = source.alphaMap;
this.rotation = source.rotation;
this.sizeAttenuation = source.sizeAttenuation;
this.fog = source.fog;
return this;
}
}
export { SpriteMaterial };