import * as THREE from "../../../libs/three.js/build/three.module.js"; import {Shaders} from "../../../build/shaders/shaders.js"; /* let sid = 0 let getName = ()=>{ return sid ++ } */ class BasicMaterial extends THREE.ShaderMaterial{ constructor(o={}){ super( Object.assign({},{ uniforms:{ color: {type:'v3', value: o.color || new THREE.Color("#FFF")} , map: {type: 't', value: o.map }, opacity : {type:'f', value : o.opacity == void 0 ? 1 : o.opacity } }, vertexShader: Shaders['basicTextured.vs'], fragmentShader: Shaders['basicTextured.fs'], defines:{HasColor:'' } },o)) //this.name111 = getName() } copy(source){ super.copy(source) //console.log('copy', source.name111, this.name111, !!source.map ) this.map = source.map return this } set opacity(o){ this.uniforms && (this.uniforms.opacity.value = o) } get opacity(){ return this.uniforms.opacity.value } set map(o){ this.uniforms.map.value = o if(o){ this.defines.HasMap = ''; }else{ delete this.defines.HasMap } //可能需要needsUpdate //console.log('hasMap', !!o, this.name111 ) } get map(){ return this.uniforms.map.value } } export default BasicMaterial