- The material object
Material.prototype = Object.assign(Object.create(EventDispatcher.prototype), {
constructor: Material,
clone: function () {
return new this.constructor().copy(this);
},
copy: function (source) {
this.name = source.name;
this.fog = source.fog;
this.blending = source.blending;
this.side = source.side;
this.flatShading = source.flatShading;
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.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.premultipliedAlpha = source.premultipliedAlpha;
this.visible = source.visible;
this.toneMapped = source.toneMapped;
this.userData = JSON.parse(JSON.stringify(source.userData));
return this;
},
dispose: function () {
this.dispatchEvent({ type: 'dispose'}); }});Object.defineProperty(Material.prototype, 'needsUpdate', {
set: function (value) {
if (value === true) this.version++; }});Copy the code
- PhysicalMaterial inherits the Material prototype and the material method;
function MeshPhysicalMaterial(parameters) {
MeshStandardMaterial.call(this); . } MeshPhysicalMaterial.prototype.copy =function (source) {
MeshStandardMaterial.prototype.copy.call(this, source); . }Copy the code