Commit 69254e50 authored by wjf's avatar wjf

l

parent 1d455127
...@@ -1643,7 +1643,8 @@ var Stage = (function (_super) { ...@@ -1643,7 +1643,8 @@ var Stage = (function (_super) {
this.renderObj.render(this); this.renderObj.render(this);
}; };
Stage.prototype.onMouseEvent = function (e) { Stage.prototype.onMouseEvent = function (e) {
e.preventDefault(); if (!my)
e.preventDefault();
var s = this; var s = this;
if (EventDispatcher_1.EventDispatcher._totalMEC > 0) { if (EventDispatcher_1.EventDispatcher._totalMEC > 0) {
var points = void 0; var points = void 0;
...@@ -20177,6 +20178,7 @@ var FRAG = [ ...@@ -20177,6 +20178,7 @@ var FRAG = [
" vec4 color = mapColor *vec4(vColor,1.0);", " vec4 color = mapColor *vec4(vColor,1.0);",
" vec4 matColor = vec4( uMatColor, uMatAlpha );", " vec4 matColor = vec4( uMatColor, uMatAlpha );",
" color *=matColor;", " color *=matColor;",
" gl_FragColor = color;",
' #ifdef USE_LIGHT', ' #ifdef USE_LIGHT',
" vec3 totalDiffuseLight = vec3( 0.0 );", " vec3 totalDiffuseLight = vec3( 0.0 );",
" vec3 totalSpecularLight = vec3( 0.0 );", " vec3 totalSpecularLight = vec3( 0.0 );",
...@@ -20204,9 +20206,8 @@ var FRAG = [ ...@@ -20204,9 +20206,8 @@ var FRAG = [
" totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeightFull;", " totalDiffuseLight += directionalLights[ i ].color * dirDiffuseWeightFull;",
" }", " }",
" #endif", " #endif",
" color = vec4((totalDiffuseLight + uAmbientLightColor + totalSpecularLight) * color.rgb, color.a);", " gl_FragColor.rgb = (totalDiffuseLight + uAmbientLightColor + totalSpecularLight) * color.rgb;",
' #endif', ' #endif',
" gl_FragColor = color;",
"}" "}"
].join("\n"); ].join("\n");
......
This diff is collapsed.
...@@ -198,6 +198,8 @@ export class D3Renderer extends ObjectRenderer { ...@@ -198,6 +198,8 @@ export class D3Renderer extends ObjectRenderer {
//不修改,估计都不要变,需要修改时候 //不修改,估计都不要变,需要修改时候
// glVaoBuffer.attrBuffer.upload(glVaoBuffer._attrBuffer.vertices, 0, true) // glVaoBuffer.attrBuffer.upload(glVaoBuffer._attrBuffer.vertices, 0, true)
// glVaoBuffer.indexBuffer.upload(glVaoBuffer._indexBuffer, 0, true) // glVaoBuffer.indexBuffer.upload(glVaoBuffer._indexBuffer, 0, true)
//变形的数据可能传入的会改变,所以需要upload
} }
//根据材质切换渲染面 //根据材质切换渲染面
if (mat.side == RenderSideType.DoubleSide) { if (mat.side == RenderSideType.DoubleSide) {
......
...@@ -45,16 +45,24 @@ export class Geometry extends HashObject { ...@@ -45,16 +45,24 @@ export class Geometry extends HashObject {
_glVaoBuffer: { [key: number]: VaoBufferInt } _glVaoBuffer: { [key: number]: VaoBufferInt }
/** /**
* 记录顶点数据用 * 记录顶点数据用,包括坐标,颜色,uv,法线
*/ */
_attrBuffer: BatchBuffer; _attrBuffer: BatchBuffer;
/**
* 顶点变形数据数组
*/
/** /**
* 索引数据 * 法线顶点数据数组
*
*/ */
/** /**
* *
* @param vertices * @param vertices
* @param indices * @param indices
* @param normals
* @param colors * @param colors
* @param uvs * @param uvs
*/ */
......
...@@ -156,7 +156,7 @@ export class Object3D extends EventDispatcher { ...@@ -156,7 +156,7 @@ export class Object3D extends EventDispatcher {
}; };
copy(source: Object3D, recursive: boolean = true) { copy(source: Object3D, recursive: boolean = true) {
this.name = source.name; this.name = source.name;
this.visible = this.visible; this.visible = source.visible;
this.up.copy(source.up); this.up.copy(source.up);
this.position.copy(source.position); this.position.copy(source.position);
......
...@@ -72,13 +72,15 @@ class CusShader extends GLShader { ...@@ -72,13 +72,15 @@ class CusShader extends GLShader {
gl: WebGLRenderingContext, gl: WebGLRenderingContext,
parameters: ShaderParametersInt parameters: ShaderParametersInt
) { ) {
//预处理参数
var frontVert = [ var frontVert = [
parameters.lightAffect ? '#define USE_LIGHT' : '', parameters.lightAffect ? '#define USE_LIGHT' : '',
parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '',
parameters.morphNormals ? '#define USE_MORPHNORMALS' : '', parameters.morphNormals ? '#define USE_MORPHNORMALS' : '',
].filter(e => e !== '').join('\n'); ].filter(e => e !== '').join('\n');
//不为空加个换行
if (frontVert) frontVert += "\n"; if (frontVert) frontVert += "\n";
var frontFrag = [ var frontFrag = [
parameters.lightAffect ? '#define USE_LIGHT' : '', parameters.lightAffect ? '#define USE_LIGHT' : '',
].filter(e => e !== '').join('\n'); ].filter(e => e !== '').join('\n');
...@@ -147,14 +149,6 @@ const parameterNames = [ ...@@ -147,14 +149,6 @@ const parameterNames = [
"lightAffect", "lightAffect",
] ]
/**
* 着色器替换的一些文案
*/
enum shaderReplaceStr {
POINT_LIGHTS_NUM = "POINT_LIGHTS_NUM",
DIR_LIGHTS_NUM = "DIR_LIGHTS_NUM",
}
/** /**
* 着色器编译参数接口 * 着色器编译参数接口
*/ */
...@@ -166,6 +160,13 @@ interface ShaderParametersInt { ...@@ -166,6 +160,13 @@ interface ShaderParametersInt {
lightAffect: boolean lightAffect: boolean
} }
/**
* 着色器替换的一些文案
*/
enum shaderReplaceStr {
POINT_LIGHTS_NUM = "POINT_LIGHTS_NUM",
DIR_LIGHTS_NUM = "DIR_LIGHTS_NUM",
}
const VERT = [ const VERT = [
...@@ -311,7 +312,8 @@ const FRAG = [ ...@@ -311,7 +312,8 @@ const FRAG = [
" vec4 matColor = vec4( uMatColor, uMatAlpha );", " vec4 matColor = vec4( uMatColor, uMatAlpha );",
//总颜色 //总颜色
" color *=matColor;", " color *=matColor;",
//先把颜色算了
" gl_FragColor = color;",
//光照颜色计算 //光照颜色计算
' #ifdef USE_LIGHT', ' #ifdef USE_LIGHT',
" vec3 totalDiffuseLight = vec3( 0.0 );", " vec3 totalDiffuseLight = vec3( 0.0 );",
...@@ -355,9 +357,8 @@ const FRAG = [ ...@@ -355,9 +357,8 @@ const FRAG = [
" #endif", " #endif",
//计算环境光颜色,是否要乘材质本身颜色,待定,效果待调整,镜面反射是否要乘color.rgb, //计算环境光颜色,是否要乘材质本身颜色,待定,效果待调整,镜面反射是否要乘color.rgb,
" color = vec4((totalDiffuseLight + uAmbientLightColor + totalSpecularLight) * color.rgb, color.a);", " gl_FragColor.rgb = (totalDiffuseLight + uAmbientLightColor + totalSpecularLight) * color.rgb;",
' #endif', ' #endif',
" gl_FragColor = color;",
"}" "}"
].join("\n") ].join("\n")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment