123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- import * as THREE from "../../libs/three.js/build/three.module.js";
- !function() {
- if ("performance"in window == 0 && (window.performance = {}),
- "now"in window.performance == 0) {
- var e = Date.now();
- performance.timing && performance.timing.navigationStart && (e = performance.timing.navigationStart),
- window.performance.now = function() {
- return Date.now() - e
- }
- }
- }(),
- THREE.WebGLRenderer.prototype.paramThreeToGL = function(e) {
- var t, i = this.extensions, r = this.getContext();//context;
- if (e === THREE.RepeatWrapping)
- return r.REPEAT;
- if (e === THREE.ClampToEdgeWrapping)
- return r.CLAMP_TO_EDGE;
- if (e === THREE.MirroredRepeatWrapping)
- return r.MIRRORED_REPEAT;
- if (e === THREE.NearestFilter)
- return r.NEAREST;
- if (e === THREE.NearestMipMapNearestFilter)
- return r.NEAREST_MIPMAP_NEAREST;
- if (e === THREE.NearestMipMapLinearFilter)
- return r.NEAREST_MIPMAP_LINEAR;
- if (e === THREE.LinearFilter)
- return r.LINEAR;
- if (e === THREE.LinearMipMapNearestFilter)
- return r.LINEAR_MIPMAP_NEAREST;
- if (e === THREE.LinearMipMapLinearFilter)
- return r.LINEAR_MIPMAP_LINEAR;
- if (e === THREE.UnsignedByteType)
- return r.UNSIGNED_BYTE;
- if (e === THREE.UnsignedShort4444Type)
- return r.UNSIGNED_SHORT_4_4_4_4;
- if (e === THREE.UnsignedShort5551Type)
- return r.UNSIGNED_SHORT_5_5_5_1;
- if (e === THREE.UnsignedShort565Type)
- return r.UNSIGNED_SHORT_5_6_5;
- if (e === THREE.ByteType)
- return r.BYTE;
- if (e === THREE.ShortType)
- return r.SHORT;
- if (e === THREE.UnsignedShortType)
- return r.UNSIGNED_SHORT;
- if (e === THREE.IntType)
- return r.INT;
- if (e === THREE.UnsignedIntType)
- return r.UNSIGNED_INT;
- if (e === THREE.FloatType)
- return r.FLOAT;
- if (t = i.get("OES_texture_half_float"),
- null !== t && e === THREE.HalfFloatType)
- return t.HALF_FLOAT_OES;
- if (e === THREE.AlphaFormat)
- return r.ALPHA;
- if (e === THREE.RGBFormat)
- return r.RGB;
- if (e === THREE.RGBAFormat)
- return r.RGBA;
- if (e === THREE.LuminanceFormat)
- return r.LUMINANCE;
- if (e === THREE.LuminanceAlphaFormat)
- return r.LUMINANCE_ALPHA;
- if (e === THREE.AddEquation)
- return r.FUNC_ADD;
- if (e === THREE.SubtractEquation)
- return r.FUNC_SUBTRACT;
- if (e === THREE.ReverseSubtractEquation)
- return r.FUNC_REVERSE_SUBTRACT;
- if (e === THREE.ZeroFactor)
- return r.ZERO;
- if (e === THREE.OneFactor)
- return r.ONE;
- if (e === THREE.SrcColorFactor)
- return r.SRC_COLOR;
- if (e === THREE.OneMinusSrcColorFactor)
- return r.ONE_MINUS_SRC_COLOR;
- if (e === THREE.SrcAlphaFactor)
- return r.SRC_ALPHA;
- if (e === THREE.OneMinusSrcAlphaFactor)
- return r.ONE_MINUS_SRC_ALPHA;
- if (e === THREE.DstAlphaFactor)
- return r.DST_ALPHA;
- if (e === THREE.OneMinusDstAlphaFactor)
- return r.ONE_MINUS_DST_ALPHA;
- if (e === THREE.DstColorFactor)
- return r.DST_COLOR;
- if (e === THREE.OneMinusDstColorFactor)
- return r.ONE_MINUS_DST_COLOR;
- if (e === THREE.SrcAlphaSaturateFactor)
- return r.SRC_ALPHA_SATURATE;
- if (t = i.get("WEBGL_compressed_texture_s3tc"),
- null !== t) {
- if (e === THREE.RGB_S3TC_DXT1_Format)
- return t.COMPRESSED_RGB_S3TC_DXT1_EXT;
- if (e === THREE.RGBA_S3TC_DXT1_Format)
- return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;
- if (e === THREE.RGBA_S3TC_DXT3_Format)
- return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;
- if (e === THREE.RGBA_S3TC_DXT5_Format)
- return t.COMPRESSED_RGBA_S3TC_DXT5_EXT
- }
- if (t = i.get("WEBGL_compressed_texture_pvrtc"),
- null !== t) {
- if (e === THREE.RGB_PVRTC_4BPPV1_Format)
- return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
- if (e === THREE.RGB_PVRTC_2BPPV1_Format)
- return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
- if (e === THREE.RGBA_PVRTC_4BPPV1_Format)
- return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
- if (e === THREE.RGBA_PVRTC_2BPPV1_Format)
- return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
- }
- if (t = i.get("WEBGL_compressed_texture_etc1"),
- null !== t && e === THREE.RGB_ETC1_Format)
- return t.COMPRESSED_RGB_ETC1_WEBGL;
- if (t = i.get("EXT_blend_minmax"),
- null !== t) {
- if (e === THREE.MinEquation)
- return t.MIN_EXT;
- if (e === THREE.MaxEquation)
- return t.MAX_EXT
- }
- return 0
- }
- /* ,
- THREE.WebGLState = function(e, t, i) {
- var r = this
- , o = new THREE.Vector4
- , a = e.getParameter(e.MAX_VERTEX_ATTRIBS)
- , s = new Uint8Array(a)
- , l = new Uint8Array(a)
- , c = new Uint8Array(a)
- , h = {}
- , u = null
- , d = null
- , p = null
- , f = null
- , g = null
- , m = null
- , v = null
- , A = null
- , y = !1
- , C = null
- , I = null
- , E = null
- , b = null
- , w = null
- , _ = null
- , T = null
- , x = null
- , S = null
- , M = null
- , R = null
- , P = null
- , O = null
- , L = null
- , D = null
- , N = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)
- , B = void 0
- , F = {}
- , V = new THREE.Vector4
- , U = null
- , k = null
- , H = new THREE.Vector4
- , G = new THREE.Vector4;
- this.init = function() {
- this.clearColor(0, 0, 0, 1),
- this.clearDepth(1),
- this.clearStencil(0),
- this.enable(e.DEPTH_TEST),
- e.depthFunc(e.LEQUAL),
- e.frontFace(e.CCW),
- e.cullFace(e.BACK),
- this.enable(e.CULL_FACE),
- this.enable(e.BLEND),
- e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA)
- }
- ,
- this.initAttributes = function() {
- for (var e = 0, t = s.length; e < t; e++)
- s[e] = 0
- }
- ,
- this.enableAttribute = function(i) {
- if (s[i] = 1,
- 0 === l[i] && (e.enableVertexAttribArray(i),
- l[i] = 1),
- 0 !== c[i]) {
- var n = t.get("ANGLE_instanced_arrays");
- n.vertexAttribDivisorANGLE(i, 0),
- c[i] = 0
- }
- }
- ,
- this.enableAttributeAndDivisor = function(t, i, n) {
- s[t] = 1,
- 0 === l[t] && (e.enableVertexAttribArray(t),
- l[t] = 1),
- c[t] !== i && (n.vertexAttribDivisorANGLE(t, i),
- c[t] = i)
- }
- ,
- this.disableUnusedAttributes = function() {
- for (var t = 0, i = l.length; t < i; t++)
- l[t] !== s[t] && (e.disableVertexAttribArray(t),
- l[t] = 0)
- }
- ,
- this.enable = function(t) {
- h[t] !== !0 && (e.enable(t),
- h[t] = !0)
- }
- ,
- this.disable = function(t) {
- h[t] !== !1 && (e.disable(t),
- h[t] = !1)
- }
- ,
- this.getCompressedTextureFormats = function() {
- if (null === u && (u = [],
- t.get("WEBGL_compressed_texture_pvrtc") || t.get("WEBGL_compressed_texture_s3tc") || t.get("WEBGL_compressed_texture_etc1")))
- for (var i = e.getParameter(e.COMPRESSED_TEXTURE_FORMATS), n = 0; n < i.length; n++)
- u.push(i[n]);
- return u
- }
- ,
- this.setBlending = function(t, r, o, a, s, l, c, h) {
- t === THREE.NoBlending ? this.disable(e.BLEND) : this.enable(e.BLEND),
- t === d && h === y || (t === THREE.AdditiveBlending ? h ? (e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.ONE, e.ONE, e.ONE, e.ONE)) : (e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.SRC_ALPHA, e.ONE)) : t === THREE.SubtractiveBlending ? h ? (e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.ZERO, e.ZERO, e.ONE_MINUS_SRC_COLOR, e.ONE_MINUS_SRC_ALPHA)) : (e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.ZERO, e.ONE_MINUS_SRC_COLOR)) : t === THREE.MultiplyBlending ? h ? (e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.ZERO, e.ZERO, e.SRC_COLOR, e.SRC_ALPHA)) : (e.blendEquation(e.FUNC_ADD),
- e.blendFunc(e.ZERO, e.SRC_COLOR)) : h ? (e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA)) : (e.blendEquationSeparate(e.FUNC_ADD, e.FUNC_ADD),
- e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA)),
- d = t,
- y = h),
- t === THREE.CustomBlending ? (s = s || r,
- l = l || o,
- c = c || a,
- r === p && s === m || (e.blendEquationSeparate(i(r), i(s)),
- p = r,
- m = s),
- o === f && a === g && l === v && c === A || (e.blendFuncSeparate(i(o), i(a), i(l), i(c)),
- f = o,
- g = a,
- v = l,
- A = c)) : (p = null,
- f = null,
- g = null,
- m = null,
- v = null,
- A = null)
- }
- ,
- this.setDepthFunc = function(t) {
- if (C !== t) {
- if (t)
- switch (t) {
- case THREE.NeverDepth:
- e.depthFunc(e.NEVER);
- break;
- case THREE.AlwaysDepth:
- e.depthFunc(e.ALWAYS);
- break;
- case THREE.LessDepth:
- e.depthFunc(e.LESS);
- break;
- case THREE.LessEqualDepth:
- e.depthFunc(e.LEQUAL);
- break;
- case THREE.EqualDepth:
- e.depthFunc(e.EQUAL);
- break;
- case THREE.GreaterEqualDepth:
- e.depthFunc(e.GEQUAL);
- break;
- case THREE.GreaterDepth:
- e.depthFunc(e.GREATER);
- break;
- case THREE.NotEqualDepth:
- e.depthFunc(e.NOTEQUAL);
- break;
- default:
- e.depthFunc(e.LEQUAL)
- }
- else
- e.depthFunc(e.LEQUAL);
- C = t
- }
- }
- ,
- this.setDepthTest = function(t) {
- t ? this.enable(e.DEPTH_TEST) : this.disable(e.DEPTH_TEST)
- }
- ,
- this.setDepthWrite = function(t) {
- I !== t && (e.depthMask(t),
- I = t)
- }
- ,
- this.setColorWrite = function(t) {
- E !== t && (e.colorMask(t, t, t, t),
- E = t)
- }
- ,
- this.setStencilFunc = function(t, i, n) {
- w === t && _ === i && T === n || (e.stencilFunc(t, i, n),
- w = t,
- _ = i,
- T = n)
- }
- ,
- this.setStencilOp = function(t, i, n) {
- x === t && S === i && M === n || (e.stencilOp(t, i, n),
- x = t,
- S = i,
- M = n)
- }
- ,
- this.setStencilTest = function(t) {
- t ? this.enable(e.STENCIL_TEST) : this.disable(e.STENCIL_TEST)
- }
- ,
- this.setStencilWrite = function(t) {
- b !== t && (e.stencilMask(t),
- b = t)
- }
- ,
- this.setFlipSided = function(t) {
- R !== t && (t ? e.frontFace(e.CW) : e.frontFace(e.CCW),
- R = t)
- }
- ,
- this.setLineWidth = function(t) {
- t !== P && (e.lineWidth(t),
- P = t)
- }
- ,
- this.setPolygonOffset = function(t, i, n) {
- t ? this.enable(e.POLYGON_OFFSET_FILL) : this.disable(e.POLYGON_OFFSET_FILL),
- !t || O === i && L === n || (e.polygonOffset(i, n),
- O = i,
- L = n)
- }
- ,
- this.getScissorTest = function() {
- return D
- }
- ,
- this.setScissorTest = function(t) {
- D = t,
- t ? this.enable(e.SCISSOR_TEST) : this.disable(e.SCISSOR_TEST)
- }
- ,
- this.activeTexture = function(t) {
- void 0 === t && (t = e.TEXTURE0 + N - 1),
- B !== t && (e.activeTexture(t),
- B = t)
- }
- ,
- this.bindTexture = function(t, i) {
- void 0 === B && r.activeTexture();
- var n = F[B];
- void 0 === n && (n = {
- type: void 0,
- texture: void 0
- },
- F[B] = n),
- n.type === t && n.texture === i || (e.bindTexture(t, i),
- n.type = t,
- n.texture = i)
- }
- ,
- this.compressedTexImage2D = function() {
- try {
- e.compressedTexImage2D.apply(e, arguments)
- } catch (e) {
- console.error(e)
- }
- }
- ,
- this.texImage2D = function() {
- try {
- e.texImage2D.apply(e, arguments)
- } catch (e) {
- console.error(e)
- }
- }
- ,
- this.clearColor = function(t, i, n, r) {
- o.set(t, i, n, r),
- V.equals(o) === !1 && (e.clearColor(t, i, n, r),
- V.copy(o))
- }
- ,
- this.clearDepth = function(t) {
- U !== t && (e.clearDepth(t),
- U = t)
- }
- ,
- this.clearStencil = function(t) {
- k !== t && (e.clearStencil(t),
- k = t)
- }
- ,
- this.scissor = function(t) {
- H.equals(t) === !1 && (e.scissor(t.x, t.y, t.z, t.w),
- H.copy(t))
- }
- ,
- this.viewport = function(t) {
- G.equals(t) === !1 && (e.viewport(t.x, t.y, t.z, t.w),
- G.copy(t))
- }
- ,
- this.reset = function() {
- for (var t = 0; t < l.length; t++)
- 1 === l[t] && (e.disableVertexAttribArray(t),
- l[t] = 0);
- h = {},
- u = null,
- B = void 0,
- F = {},
- d = null,
- E = null,
- I = null,
- b = null,
- R = null
- }
- } */
|