awv3
Version:
AWV client CAD framework
1 lines • 5.92 kB
JavaScript
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}exports.__esModule=!0;var _classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_three=require("three"),_three2=_interopRequireDefault(_three),MeshPhongMaterial=function(e){function t(n){(0,_classCallCheck3["default"])(this,t);var i=(0,_possibleConstructorReturn3["default"])(this,e.call(this));return i.type="AWV3.MeshPhongMaterial",i.fog=!1,i.transparent=!0,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=1,i.uniforms=_three2["default"].UniformsUtils.merge([_three2["default"].UniformsLib.common,_three2["default"].UniformsLib.aomap,_three2["default"].UniformsLib.lightmap,_three2["default"].UniformsLib.emissivemap,_three2["default"].UniformsLib.bumpmap,_three2["default"].UniformsLib.normalmap,_three2["default"].UniformsLib.displacementmap,_three2["default"].UniformsLib.fog,_three2["default"].UniformsLib.lights,{emissive:{type:"c",value:new _three2["default"].Color(0)},specular:{type:"c",value:new _three2["default"].Color(1118481)},shininess:{type:"1f",value:30},reflection:{type:"f",value:1},contrast:{type:"f",value:0},crosslight:{type:"f",value:1},intensity:{type:"f",value:0},flatspot:{type:"f",value:0}}]),i.vertexShader=_three2["default"].ShaderChunk.meshphong_vert,i.fragmentShader="\n #define PHONG\n\n uniform vec3 diffuse;\n uniform vec3 emissive;\n uniform vec3 specular;\n uniform float shininess;\n uniform float opacity;\n\n uniform float crosslight;\n uniform float reflection;\n uniform float contrast;\n uniform float intensity;\n uniform float flatspot;\n\n #include <common>\n #include <packing>\n #include <color_pars_fragment>\n #include <uv_pars_fragment>\n #include <uv2_pars_fragment>\n #include <map_pars_fragment>\n #include <alphamap_pars_fragment>\n #include <aomap_pars_fragment>\n #include <lightmap_pars_fragment>\n #include <emissivemap_pars_fragment>\n #include <envmap_pars_fragment>\n #include <fog_pars_fragment>\n #include <bsdfs>\n #include <lights_pars>\n #include <lights_phong_pars_fragment>\n #include <shadowmap_pars_fragment>\n #include <bumpmap_pars_fragment>\n #include <normalmap_pars_fragment>\n #include <specularmap_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n void main() {\n\n \t#include <clipping_planes_fragment>\n\n vec3 eyeDirection = normalize(vViewPosition.xyz);\n vec3 reflectionDirection = reflect(eyeDirection, vNormal);\n float specularLightWeighting = dot(reflectionDirection, eyeDirection);\n float specularLightWeighting2 = dot(-reflectionDirection, eyeDirection);\n float directionalLightWeighting = max(dot(vNormal, eyeDirection), 1.0-reflection);\n vec3 lightWeighting = max(specularLightWeighting, directionalLightWeighting) + vec3(contrast) * specularLightWeighting;\n float crossLevel = crosslight > 0.0 ? dot(lightWeighting, crosslight * eyeDirection) : 1.0;\n float spot = 1.0;\n if (flatspot != 0.0) spot = dot(flatspot * reflectionDirection, eyeDirection) > 0.5 ? 1.4 : 1.0;\n\n vec4 diffuseColor = vec4(diffuse * crossLevel * spot + diffuse * intensity, opacity);\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n\n #include <logdepthbuf_fragment>\n \t#include <map_fragment>\n \t#include <color_fragment>\n \t#include <alphamap_fragment>\n \t#include <alphatest_fragment>\n \t#include <specularmap_fragment>\n \t#include <normal_flip>\n \t#include <normal_fragment>\n \t#include <emissivemap_fragment>\n\n \t// accumulation\n \t#include <lights_phong_fragment>\n \t#include <lights_template>\n\n \t// modulation\n \t#include <aomap_fragment>\n\n \tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n \t#include <envmap_fragment>\n\n \tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n \t#include <premultiplied_alpha_fragment>\n \t#include <tonemapping_fragment>\n \t#include <encodings_fragment>\n \t#include <fog_fragment>\n }",i.setValues(n),i}return(0,_inherits3["default"])(t,e),t.prototype.clone=function(){var n=new t;return e.prototype.clone.call(this,n),n.color.copy(this.color),n.fragmentShader=this.fragmentShader,n.vertexShader=this.vertexShader,n.uniforms=_three2["default"].UniformsUtils.clone(this.uniforms),n.attributes=this.attributes,n.defines=this.defines,n.shading=this.shading,n.wireframe=this.wireframe,n.wireframeLinewidth=this.wireframeLinewidth,n.fog=this.fog,n.lights=this.lights,n.vertexColors=this.vertexColors,n.skinning=this.skinning,n.morphTargets=this.morphTargets,n.morphNormals=this.morphNormals,n},t}(_three2["default"].MeshPhongMaterial);exports["default"]=MeshPhongMaterial;