Commit 31044481 authored by 邱旭's avatar 邱旭

增加shader编译错误打印shader代码

parent b068d4b0
This diff is collapsed.
This diff is collapsed.
......@@ -7488,7 +7488,8 @@
gl.shaderSource(shader, src);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.log(gl.getShaderInfoLog(shader));
console.error(src);
console.error(gl.getShaderInfoLog(shader));
return null;
}
return shader;
......@@ -13908,7 +13909,7 @@
*/
_this.renderObj = null;
/**
* 相对于stage的可见区域,考虑不对外开放,但是有些地方又有用,比如某点是否在舞台可见区域内viewRect.isPointIn(gp)
* 舞台在设备里截取后的可见区域,有些时候知道可见区域是非常重要的,因为这样你就可以根据舞台的可见区域做自适应了。
* @property viewRect
* @public
* @since 1.0.0
......@@ -14015,6 +14016,7 @@
_this.canvas = canvas;
var s = _this;
_this._instanceType = "Stage";
Stage._stageList["canvas"] = s;
s.stage = _this;
s.name = "stageInstance_" + s.instanceId;
s.desWidth = desWidth;
......@@ -14088,6 +14090,17 @@
// }, 200)
// }
}
/**
* 直接获取stage的引用,避免总是从Event.ADD_TO_STAGE 事件中去获取stage引用
* @property getStage
* @param {string} stageName
* @return {any}
* @since 2.0.0
*/
Stage.getStage = function (stageName) {
if (stageName === void 0) { stageName = "cusEngine"; }
return Stage._stageList[stageName];
};
Object.defineProperty(Stage.prototype, "bgColor", {
/**
* 舞台的背景色,暂时无效,渲染器默认透明背景,且webgl模式下clearColor不会跟着修改,TODO 以后修改
......@@ -14578,6 +14591,13 @@
s._ml = null;
_super.prototype.destroy.call(this);
};
/**
* @property _stageList
* @static
* @type {Object}
* @private
*/
Stage._stageList = {};
return Stage;
}(Container));
......@@ -32531,9 +32551,9 @@
if (frontVert)
frontVert += "\n";
var frontFrag = [
parameters.useNormalMap ? '#extension GL_OES_standard_derivatives : enable' : '',
'precision ' + parameters.precision + ' float;',
'precision ' + parameters.precision + ' int;',
parameters.useNormalMap ? '#extension GL_OES_standard_derivatives : enable' : '',
parameters.lightAffect ? '#define USE_LIGHT' : '',
parameters.useMap ? '#define USE_MAP' : '',
parameters.useNormalMap ? '#define USE_NORMAL_MAP' : '',
......@@ -32953,7 +32973,7 @@
" #ifdef USE_MAP",
" vec4 mapColor = texture2D( uMap, vTextureCoord );",
" color *= mapColor;",
" vec2 s = step(vec2(uFrameUvs.x,uFrameUvs.y),vTextureCoord) - step(vec2(uFrameUvs.z,uFrameUvs.w),vTextureCoord);",
" vec2 s = step(vec2(uFrameUvs.x, uFrameUvs.y),vTextureCoord) - step(vec2(uFrameUvs.z, uFrameUvs.w), vTextureCoord);",
// " vec2 s = step(vec2(0.6669921875,0.4111328125),vTextureCoord) - step(vec2(0.951171875,0.65625),vTextureCoord);",
" color *= abs(s.x * s.y);",
" #endif",
......@@ -33118,20 +33138,21 @@
if (!obj.geometry || !obj.material)
return;
var mat = obj.material;
obj.geometry;
var meshes = this.meshes;
//提取渲染对象及材质,分组渲染,怎么考虑同一个geometry只需要处理一次attr,
//分组按
// if (!this.meshes.length) {
// this.meshes.push(obj);
// } else {
for (var i = 0; i < this.meshes.length; i++) {
if (this.meshes[i].material == mat) { //没啥软用
this.meshes.splice(i, 0, obj);
var len = meshes.length;
for (var i = 0; i < len; i++) {
if (meshes[i].material == mat) { //没啥软用
meshes.splice(i, 0, obj);
return;
}
}
// }
this.meshes.push(obj);
meshes.push(obj);
};
D3Renderer.prototype.flush = function () {
//生成一张阴影的深度贴图
......@@ -33169,6 +33190,13 @@
//模型矩阵也默认加上
if (uniforms["uModelMatrix"])
uniforms["uModelMatrix"] = mesh._worldMatrix.toArray();
if (uniforms.uNormalMatrix) {
var modelViewMatrix_1 = tempMatrix4.multiplyMatrices(this.camera.worldMatrixInverse, mesh._worldMatrix);
var normalMatrix_1 = modelViewMatrix_1.invert().transpose();
// var normalMatrix = mesh._worldMatrix.invert().transpose();
uniforms["uNormalMatrix"] = normalMatrix_1.toArray();
// this.setShaderUniform(curShader, "uNormalMatrix", normalMatrix.toArray());
}
//处理所有自定义属性
for (var u in cusUniforms) {
var uniform = cusUniforms[u];
......@@ -39567,6 +39595,10 @@
exports.FloatDisplay = FloatDisplay;
exports.FpsPanel = FpsPanel;
exports.FrameAni = FrameAni;
exports.GLBuffer = GLBuffer;
exports.GLFramebuffer = GLFramebuffer;
exports.GLShader = GLShader;
exports.GLTexture = GLTexture;
exports.Geometry = Geometry;
exports.GlobalLoader = GlobalLoader;
exports.Graphics = Graphics;
......@@ -39627,20 +39659,24 @@
exports.VERSION = VERSION;
exports.Vector2 = Vector2;
exports.Vector3 = Vector3;
exports.VertexArrayObject = VertexArrayObject;
exports.WebglRenderer = WebglRenderer;
exports.abs = abs;
exports.calculatePlaneIndices = calculatePlaneIndices;
exports.cancelAnimationFrame = cancelAnimationFrame;
exports.checkMaxIfStatementsInShader = checkMaxIfStatementsInShader;
exports.clamp = clamp;
exports.clearTextureCache = clearTextureCache;
exports.cos = cos;
exports.countTrailingZeros = countTrailingZeros;
exports.createCanvas = createCanvas;
exports.createContext = createContext;
exports.createImage = createImage;
exports.createTextureSheet = createTextureSheet;
exports.createTexturesByAtlas = createTexturesByAtlas;
exports.decodeText = decodeText;
exports.defaultFragmentShader3d = defaultFragmentShader3d;
exports.defaultValue = defaultValue;
exports.defaultVertexShader3d = defaultVertexShader3d;
exports.deinterleave2 = deinterleave2;
exports.deinterleave3 = deinterleave3;
This diff is collapsed.
......@@ -176,22 +176,3 @@ function checkIntersection(
object: object
};
}
//交付分
var a = 5
//时间分每天
var b = 1
//极限时间
var j = 15
//项目基础时间
var i = 4
function aaa(t) {
t -= i
return a + t * b + (t * t) / j * a / i / i;
}
function bbb(t) {
//完整项目按4天
t -= i
return a + t * b + (t * t) / j * a / i / i;
}
\ No newline at end of file
import { EventDispatcher } from "../../2d/events";
import { GlobalLoader } from "../../2d/loader";
import { rgb2hex, decodeText, ArrayBufferToBase64 } from "../../2d/utils";
import { LightMaterial } from "../materials/LightMaterial";
import { Geometry } from "../Geometry";
import { Texture } from "../../2d/texture";
import { Scene3D } from "../Scene3D";
import { Object3D } from "../Object3D";
import { BaseMaterial, BaseMaterialParamsInt, RenderSideType } from "../materials/BaseMaterial";
import { Mesh3D } from "../Mesh3D";
import { PerspectiveCamera } from "../cameras/PerspectiveCamera";
import { RAD_TO_DEG } from "../../2d/const";
import { Matrix4 } from "../math/Matrix4";
import { arraySlice } from "../animation/utils";
import { InterpolateSmooth, InterpolateLinear, InterpolateDiscrete } from "../animation/utils";
import { AnimationType3D, AnimationTrack3D } from "../animation/AnimationTrack3D";
import {EventDispatcher} from "../../2d/events";
import {GlobalLoader} from "../../2d/loader";
import {rgb2hex, decodeText, ArrayBufferToBase64} from "../../2d/utils";
import {LightMaterial} from "../materials/LightMaterial";
import {Geometry} from "../Geometry";
import {Texture} from "../../2d/texture";
import {Scene3D} from "../Scene3D";
import {Object3D} from "../Object3D";
import {BaseMaterial, BaseMaterialParamsInt, RenderSideType} from "../materials/BaseMaterial";
import {Mesh3D} from "../Mesh3D";
import {PerspectiveCamera} from "../cameras/PerspectiveCamera";
import {RAD_TO_DEG} from "../../2d/const";
import {Matrix4} from "../math/Matrix4";
import {arraySlice} from "../animation/utils";
import {InterpolateSmooth, InterpolateLinear, InterpolateDiscrete} from "../animation/utils";
import {AnimationType3D, AnimationTrack3D} from "../animation/AnimationTrack3D";
// import { AnimationClip3D } from "../animation/AnimationClip3D";
import { Camera } from "../cameras/Camera";
import { SkinnedMesh3D } from "../bones/SkinnedMesh3D";
import { Skeleton3D } from "../bones/Skeleton3D";
import { Bone3D } from "../bones/Bone3D";
import { AnimationClip } from "../../2d/AnimationClip";
import { AnimationManager } from "../../2d/AnimationManager";
import { atob_base64Decode } from "./base64";
import {Camera} from "../cameras/Camera";
import {SkinnedMesh3D} from "../bones/SkinnedMesh3D";
import {Skeleton3D} from "../bones/Skeleton3D";
import {Bone3D} from "../bones/Bone3D";
import {AnimationClip} from "../../2d/AnimationClip";
import {AnimationManager} from "../../2d/AnimationManager";
import {atob_base64Decode} from "./base64";
// var THREE: any = {}
/* BINARY EXTENSION */
......@@ -30,7 +30,7 @@ import { atob_base64Decode } from "./base64";
var BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF';
var BINARY_EXTENSION_HEADER_MAGIC = 'glTF';//这个用到了
var BINARY_EXTENSION_HEADER_LENGTH = 12;
var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 };
var BINARY_EXTENSION_CHUNK_TYPES = {JSON: 0x4E4F534A, BIN: 0x004E4942};
/*********************************/
/********** EXTENSIONS ***********/
......@@ -676,6 +676,7 @@ class GLTFParser {
primitiveCache = [];
multiplePrimitivesCache = [];
multiPassGeometryCache = [];
constructor(
public json: any = {},
public extensions = {},
......@@ -688,6 +689,7 @@ class GLTFParser {
// this.fileLoader = new THREE.FileLoader(this.options.manager);
// this.fileLoader.setResponseType('arraybuffer');
}
parse(onLoad, onError) {
var json = this.json;
......@@ -715,6 +717,7 @@ class GLTFParser {
}).catch(onError);
}
/**
* Marks the special nodes/meshes in json for efficient parse.
*/
......@@ -776,6 +779,7 @@ class GLTFParser {
this.json.meshUses = meshUses;
}
/**
* Requests the specified dependency asynchronously, with caching.
* @param {string} type
......@@ -1310,6 +1314,10 @@ class GLTFParser {
pending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture.index));
}
if (materialDef.normalTexture !== undefined) {
pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture.index));
}
// materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
// materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
......@@ -1385,7 +1393,7 @@ class GLTFParser {
// }
return Promise.all(pending).then(function () {
return Promise.all(pending).then(function (v) {
var material: BaseMaterial;
......@@ -1499,7 +1507,7 @@ class GLTFParser {
var geometryPromise: any = Promise.resolve(geometry);
// Cache this geometry
cache.push({ primitive: primitive, promise: geometryPromise });
cache.push({primitive: primitive, promise: geometryPromise});
pending.push(geometryPromise);
......@@ -1932,7 +1940,7 @@ class GLTFParser {
var skinDef = this.json.skins[skinIndex];
var skinEntry: any = { joints: skinDef.joints };
var skinEntry: any = {joints: skinDef.joints};
if (skinDef.inverseBindMatrices === undefined) {
......@@ -2552,16 +2560,22 @@ function resolveURL(url, path) {
//改成只缓存自己一个praser的,否则多个模型加载会取错缓存
class GLTFRegistry {
private objects = {}
constructor() { }
constructor() {
}
get(key: string) {
return this.objects[key];
}
add(key: string, object: any) {
this.objects[key] = object;
}
remove(key: string) {
delete this.objects[key];
}
removeAll() {
this.objects = {};
}
......@@ -2571,6 +2585,7 @@ class GLTFRegistry {
class BufferAttribute {
public count: number;
public name: string;
/**
*
* @param array Int8Array,Uint8Array, Int16Array,Uint16Array,Uint32Array,Float32Array
......@@ -2587,6 +2602,7 @@ class BufferAttribute {
}
this.count = array !== undefined ? array.length / itemSize : 0;
}
/**
* 重写覆盖
* @param value 普通数组,或类型化数组
......@@ -2596,6 +2612,7 @@ class BufferAttribute {
this.array.set(value, offset);
return this;
}
/**
* 重置数据
* @param array
......@@ -2609,6 +2626,7 @@ class BufferAttribute {
return this;
}
/**
*
* @param index 第几个点
......@@ -2672,6 +2690,7 @@ class BufferAttribute {
this.array[index + 3] = w;
return this;
}
copy(source: BufferAttribute) {
this.name = source.name;
......@@ -2681,21 +2700,23 @@ class BufferAttribute {
this.normalized = source.normalized;
return this;
}
clone() {
return new BufferAttribute(this.array, this.itemSize).copy(this);
}
}
class InterleavedBuffer {
public count: number;
constructor(
public array?,
public stride?: number
) {
this.count = array !== undefined ? array.length / stride : 0;
}
setArray(array) {
if (Array.isArray(array)) {
......@@ -2710,6 +2731,7 @@ class InterleavedBuffer {
return this;
};
copy(source: InterleavedBuffer) {
this.array = new source.array.constructor(source.array);
this.count = source.count;
......@@ -2731,6 +2753,7 @@ class InterleavedBuffer {
class InterleavedBufferAttribute {
data: InterleavedBuffer;
isInterleavedBufferAttribute = true;
constructor(
interleavedBuffer: InterleavedBuffer,
public itemSize: number,
......@@ -2739,12 +2762,15 @@ class InterleavedBufferAttribute {
) {
this.data = interleavedBuffer;
};
get count() {
return this.data.count;
}
get array() {
return this.data.array;
}
setX(index, x) {
this.data.array[index * this.data.stride + this.offset] = x;
return this;
......@@ -2821,6 +2847,7 @@ function attributeToArray(attr: BufferAttribute) {
var reservedRe = new RegExp('[' + '\\[\\]\\.:\\/' + ']', 'g');
function sanitizeNodeName(name) {
return name.replace(/\s/g, '_').replace(reservedRe, '');
......
import { Dict } from "../../2d/utils";
import { Dict, hex2rgb } from "../../2d/utils";
import { HashObject } from "../../2d/HashObject";
import { WebglRenderer } from "../../2d/renderers/WebglRenderer";
import { GLShader } from "../../glCore";
......@@ -44,6 +44,30 @@ export class ShaderMaterial extends HashObject {
alpha: 1;
/**
* 十六进制 hex2rgb ,转成0到1的数组
*/
private _color: number = 0xffffff;
private _colorArr: Float32Array = new Float32Array([1.0, 1.0, 1.0]);
get color() {
return this._color;
}
set color(value: number) {
if (this._color === value) return;
this._color = value;
var arr = hex2rgb(value)
this._colorArr[0] = arr[0];
this._colorArr[1] = arr[1];
this._colorArr[2] = arr[2];
}
//获取
get colorArr() {
return this._colorArr;
}
/**
* key就是渲染器唯一id
*/
......
......@@ -33,6 +33,9 @@ export * from "./tween";
//3D
export * from "./3d";
// glCore
export * from "./glCore";
//spine
export * from "./spine";
......
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