Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

claygl-next

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

claygl-next - npm Package Compare versions

Comparing version 2.0.0-alpha.15 to 2.0.0-alpha.16

5

lib/deferred/GBuffer.d.ts

@@ -48,5 +48,4 @@ import Texture2D from '../Texture2D';

private _frameBuffer;
private _gBufferMaterial1;
private _gBufferMaterial2;
private _gBufferMaterial3;
private _outputs;
private _gBufferMaterial?;
private _debugPass;

@@ -53,0 +52,0 @@ constructor(opts?: Partial<DeferredGBufferOpts>);

234

lib/deferred/GBuffer.js

@@ -11,3 +11,3 @@ import Texture2D from '../Texture2D';

import { optional } from '../core/util';
import { gBuffer1Fragment, gBuffer2Fragment, gBuffer3Fragment, gBufferDebugFragment, gBufferVertex } from '../shader/source/deferred/gbuffer.glsl';
import { createGBufferFrag, gBufferDebugFragment, gBufferVertex } from '../shader/source/deferred/gbuffer.glsl';
import { isPixelSource } from '../Texture';

@@ -25,62 +25,20 @@ const renderableGBufferData = new WeakMap();

// TODO Performance improvement
function getGetUniformHook1(defaultNormalMap, defaultRoughnessMap, defaultDiffuseMap) {
function getGetUniformHook(defaultDiffuseMap, defaultNormalMap, defaultRoughnessMap, defaultMetalnessMap) {
return function (renderable, gBufferMat, symbol) {
var _a, _b, _c, _d;
const standardMaterial = renderable.material;
if (symbol === 'doubleSided') {
return standardMaterial.isDefined('fragment', 'DOUBLE_SIDED');
}
else if (symbol === 'uvRepeat' || symbol === 'uvOffset' || symbol === 'alpha') {
return standardMaterial.get(symbol);
}
else if (symbol === 'normalMap') {
return standardMaterial.get(symbol) || defaultNormalMap;
}
else if (symbol === 'diffuseMap') {
return standardMaterial.get(symbol) || defaultDiffuseMap;
}
else if (symbol === 'alphaCutoff') {
// TODO DIFFUSEMAP_ALPHA_ALPHA
if (standardMaterial.isDefined('fragment', 'ALPHA_TEST')) {
const alphaCutoff = standardMaterial.get('alphaCutoff');
return alphaCutoff || 0;
}
return 0;
}
else {
const useRoughnessWorkflow = standardMaterial.isDefined('fragment', 'USE_ROUGHNESS');
const roughGlossMap = useRoughnessWorkflow
? standardMaterial.get('roughnessMap')
: standardMaterial.get('glossinessMap');
switch (symbol) {
case 'glossiness':
return useRoughnessWorkflow
? 1.0 - standardMaterial.get('roughness')
: standardMaterial.get('glossiness');
case 'roughGlossMap':
return roughGlossMap;
case 'useRoughGlossMap':
return !!roughGlossMap;
case 'useRoughness':
return useRoughnessWorkflow;
case 'roughGlossChannel':
return useRoughnessWorkflow
? standardMaterial.getDefine('fragment', 'ROUGHNESS_CHANNEL')
: standardMaterial.getDefine('fragment', 'GLOSSINESS_CHANNEL');
}
}
};
}
function getGetUniformHook2(defaultDiffuseMap, defaultMetalnessMap) {
return function (renderable, gBufferMat, symbol) {
const standardMaterial = renderable.material;
switch (symbol) {
case 'color':
case 'doubleSided':
return standardMaterial.isDefined('fragment', 'DOUBLE_SIDED');
case 'uvRepeat':
case 'uvOffset':
case 'alpha':
case 'color':
return standardMaterial.get(symbol);
case 'normalMap':
return standardMaterial.get(symbol) || defaultNormalMap;
case 'diffuseMap':
return standardMaterial.get(symbol) || defaultDiffuseMap;
case 'metalness':
return standardMaterial.get('metalness') || 0;
case 'diffuseMap':
return standardMaterial.get(symbol) || defaultDiffuseMap;
case 'metalnessMap':

@@ -96,5 +54,36 @@ return standardMaterial.get(symbol) || defaultMetalnessMap;

const alphaCutoff = standardMaterial.get('alphaCutoff');
return alphaCutoff || 0.0;
return alphaCutoff || 0;
}
return 0.0;
return 0;
case 'prevWorldViewProjection':
return (_a = renderableGBufferData.get(renderable)) === null || _a === void 0 ? void 0 : _a.prevWorldViewProjection;
case 'prevSkinMatrix':
return (_b = renderableGBufferData.get(renderable)) === null || _b === void 0 ? void 0 : _b.prevSkinMatricesArray;
case 'prevSkinMatricesTexture':
return (_c = renderableGBufferData.get(renderable)) === null || _c === void 0 ? void 0 : _c.prevSkinMatricesTexture;
case 'firstRender':
return !((_d = renderableGBufferData.get(renderable)) === null || _d === void 0 ? void 0 : _d.prevWorldViewProjection);
default:
const useRoughnessWorkflow = !standardMaterial.isDefined('fragment', 'SPECULAR_WORKFLOW');
const roughGlossMap = useRoughnessWorkflow
? standardMaterial.get('roughnessMap')
: standardMaterial.get('glossinessMap');
switch (symbol) {
case 'glossiness':
return useRoughnessWorkflow
? 1.0 - standardMaterial.get('roughness')
: standardMaterial.get('glossiness');
case 'roughGlossMap':
// PENDING defaultGlossinessMap?
return roughGlossMap || defaultRoughnessMap;
case 'useRoughGlossMap':
return !!roughGlossMap;
case 'useRoughness':
return useRoughnessWorkflow;
case 'roughGlossChannel':
return standardMaterial.getDefine('fragment', useRoughnessWorkflow ? 'ROUGHNESS_CHANNEL' : 'GLOSSINESS_CHANNEL');
default:
// Return directly
return standardMaterial.get(symbol);
}
}

@@ -155,26 +144,3 @@ };

this._frameBuffer = new FrameBuffer();
this._gBufferMaterial1 = new Material(new Shader(gBufferVertex, gBuffer1Fragment), {
vertexDefines: {
FIRST_PASS: null
},
fragmentDefines: {
FIRST_PASS: null
}
});
this._gBufferMaterial2 = new Material(new Shader(gBufferVertex, gBuffer2Fragment), {
vertexDefines: {
SECOND_PASS: null
},
fragmentDefines: {
SECOND_PASS: null
}
});
this._gBufferMaterial3 = new Material(new Shader(gBufferVertex, gBuffer3Fragment), {
vertexDefines: {
THIRD_PASS: null
},
fragmentDefines: {
THIRD_PASS: null
}
});
this._outputs = [];
this._debugPass = new FullscreenQuadPass(gBufferDebugFragment);

@@ -293,54 +259,43 @@ opts = opts || {};

}
const outputs = [];
// PENDING, scene.boundingBoxLastFrame needs be updated if have shadow
if (enableTargetTexture1) {
// Pass 1
frameBuffer.attach(opts.targetTexture1 || this._gBufferTex1);
const gBufferMaterial1 = this._gBufferMaterial1;
const renderHooks = {
prepare(gl) {
clearViewport();
},
getMaterial() {
return gBufferMaterial1;
},
getMaterialUniform: getGetUniformHook1(this._defaultNormalMap, this._defaultRoughnessMap, this._defaultDiffuseMap),
isMaterialChanged,
sortCompare: Renderer.opaqueSortCompare
};
// FIXME Use MRT if possible
renderer.renderPass(gBufferRenderList, camera, frameBuffer, renderHooks, scene);
frameBuffer.attach(opts.targetTexture1 || this._gBufferTex1, gl.COLOR_ATTACHMENT0);
outputs.push('color0');
}
if (enableTargetTexture3) {
// Pass 2
frameBuffer.attach(opts.targetTexture3 || this._gBufferTex3);
const gBufferMaterial2 = this._gBufferMaterial2;
const renderHooks = {
prepare(gl) {
clearViewport();
},
getMaterial() {
return gBufferMaterial2;
},
getMaterialUniform: getGetUniformHook2(this._defaultDiffuseMap, this._defaultMetalnessMap),
isMaterialChanged: isMaterialChanged,
sortCompare: Renderer.opaqueSortCompare
};
renderer.renderPass(gBufferRenderList, camera, frameBuffer, renderHooks, scene);
frameBuffer.attach(opts.targetTexture3 || this._gBufferTex3, gl.COLOR_ATTACHMENT1);
outputs.push('color1');
}
if (enableTargetTexture4) {
frameBuffer.attach(opts.targetTexture4 || this._gBufferTex4);
// Remove jittering in temporal aa.
// PENDING. Better solution?
camera.update();
const gBufferMaterial3 = this._gBufferMaterial3;
const cameraViewProj = mat4.create();
mat4.multiply(cameraViewProj, camera.projectionMatrix.array, camera.viewMatrix.array);
const renderHooks = {
prepare(gl) {
clearViewport();
},
getMaterial() {
return gBufferMaterial3;
},
afterRender(renderable) {
frameBuffer.attach(opts.targetTexture4 || this._gBufferTex4, gl.COLOR_ATTACHMENT2);
outputs.push('color2');
}
const cameraViewProj = mat4.create();
mat4.multiply(cameraViewProj, camera.projectionMatrix.array, camera.viewMatrix.array);
let gBufferMaterial = this._gBufferMaterial;
if (!gBufferMaterial || this._outputs.join('') !== outputs.join('')) {
gBufferMaterial = this._gBufferMaterial = new Material(new Shader(gBufferVertex, createGBufferFrag(outputs)));
if (enableTargetTexture1) {
gBufferMaterial.define('USE_TARGET_TEXTURE1');
}
if (enableTargetTexture3) {
gBufferMaterial.define('USE_TARGET_TEXTURE3');
}
if (enableTargetTexture4) {
gBufferMaterial.define('USE_TARGET_TEXTURE4');
}
}
const renderHooks = {
prepare(gl) {
clearViewport();
},
getMaterial() {
return gBufferMaterial;
},
getMaterialUniform: getGetUniformHook(this._defaultDiffuseMap, this._defaultNormalMap, this._defaultRoughnessMap, this._defaultMetalnessMap),
isMaterialChanged,
sortCompare: Renderer.opaqueSortCompare,
afterRender(renderable) {
if (enableTargetTexture4) {
let gbufferData = renderableGBufferData.get(renderable);

@@ -404,29 +359,6 @@ if (!gbufferData) {

}
},
getMaterialUniform(renderable, gBufferMat, symbol) {
const gbufferData = renderableGBufferData.get(renderable);
if (symbol === 'prevWorldViewProjection') {
return gbufferData && gbufferData.prevWorldViewProjection;
}
else if (symbol === 'prevSkinMatrix') {
return gbufferData && gbufferData.prevSkinMatricesArray;
}
else if (symbol === 'prevSkinMatricesTexture') {
return gbufferData && gbufferData.prevSkinMatricesTexture;
}
else if (symbol === 'firstRender') {
return !(gbufferData && gbufferData.prevWorldViewProjection);
}
else {
return gBufferMat.get(symbol);
}
},
isMaterialChanged() {
// Always update prevWorldViewProjection
return true;
},
sortCompare: Renderer.opaqueSortCompare
};
renderer.renderPass(gBufferRenderList, camera, frameBuffer, renderHooks, scene);
}
}
}
};
renderer.renderPass(gBufferRenderList, camera, frameBuffer, renderHooks, scene);
}

@@ -433,0 +365,0 @@ /**

@@ -123,5 +123,5 @@ import * as constants from '../core/constants';

_gl.texStorage3D(constants.TEXTURE_2D_ARRAY, 1, glInternalFormat, width, height, source.length);
source.forEach((sourceSlice, idx) =>
// TODO check image size are equal
_gl.texSubImage3D(constants.TEXTURE_2D_ARRAY, 0, 0, 0, idx, width, height, 1, glFormat, glType, (isPixelSource(sourceSlice) ? sourceSlice.data : sourceSlice)));
source.forEach((sourceSlice, idx) => _gl.texSubImage3D(constants.TEXTURE_2D_ARRAY, 0, 0, 0, idx,
// Layer width and layer height.
sourceSlice.width, sourceSlice.height, 1, glFormat, glType, (isPixelSource(sourceSlice) ? sourceSlice.data : sourceSlice)));
}

@@ -128,0 +128,0 @@ }

@@ -627,4 +627,2 @@ /**

});
material.define('fragment', 'USE_ROUGHNESS');
material.define('fragment', 'USE_METALNESS');
material.define('fragment', 'ROUGHNESS_CHANNEL', 1);

@@ -679,8 +677,8 @@ material.define('fragment', 'METALNESS_CHANNEL', 2);

const commonProperties = {
diffuseMap: diffuseMap,
glossinessMap: glossinessMap,
specularMap: specularMap,
normalMap: normalMap,
emissiveMap: emissiveMap,
occlusionMap: occlusionMap,
diffuseMap,
glossinessMap,
specularMap,
normalMap,
emissiveMap,
occlusionMap,
color: diffuseColor.slice(0, 3),

@@ -687,0 +685,0 @@ alpha: diffuseColor[3],

@@ -105,3 +105,3 @@ import { FragmentShader, VertexShader } from '../../../Shader';

/**
* First pass
* First texture
* - R: normal.x

@@ -111,4 +111,13 @@ * - G: normal.y

* - A: metalness
*
* Second texture
* - R: albedo.r
* - G: albedo.g
* - B: albedo.b
* - A: metalness
*
* Third texture
* - Velocity
*/
export declare const gBuffer1Fragment: FragmentShader<import("../../../core/type").Dict<import("../../../Shader").ShaderDefineValue>, {
export declare const createGBufferFrag: (outputs: string[]) => FragmentShader<import("../../../core/type").Dict<import("../../../Shader").ShaderDefineValue>, {
viewInverse: {

@@ -123,3 +132,3 @@ type: "mat4";

};
normalMap: {
diffuseMap: {
type: "sampler2D";

@@ -129,3 +138,3 @@ value: import("../../../Texture2D").default;

};
diffuseMap: {
metalnessMap: {
type: "sampler2D";

@@ -135,13 +144,13 @@ value: import("../../../Texture2D").default;

};
roughGlossMap: {
type: "sampler2D";
value: import("../../../Texture2D").default;
color: {
type: "vec3";
value: import("../../../glmatrix/common").Vec3Array;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
useRoughGlossMap: {
type: "bool";
metalness: {
type: "float";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
useRoughness: {
useMetalnessMap: {
type: "bool";

@@ -151,3 +160,3 @@ value: number;

};
doubleSided: {
linear: {
type: "bool";

@@ -157,27 +166,3 @@ value: number;

};
alphaCutoff: {
type: "float";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
alpha: {
type: "float";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
roughGlossChannel: {
type: "int";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
}, never>;
/**
* Second pass
* - R: albedo.r
* - G: albedo.g
* - B: albedo.b
* - A: metalness
*/
export declare const gBuffer2Fragment: FragmentShader<import("../../../core/type").Dict<import("../../../Shader").ShaderDefineValue>, {
diffuseMap: {
normalMap: {
type: "sampler2D";

@@ -187,3 +172,3 @@ value: import("../../../Texture2D").default;

};
metalnessMap: {
roughGlossMap: {
type: "sampler2D";

@@ -193,13 +178,8 @@ value: import("../../../Texture2D").default;

};
color: {
type: "vec3";
value: import("../../../glmatrix/common").Vec3Array;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
metalness: {
type: "float";
useRoughGlossMap: {
type: "bool";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
useMetalnessMap: {
useRoughness: {
type: "bool";

@@ -209,3 +189,3 @@ value: number;

};
linear: {
doubleSided: {
type: "bool";

@@ -225,2 +205,12 @@ value: number;

};
roughGlossChannel: {
type: "int";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
firstRender: {
type: "bool";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
}, {

@@ -234,12 +224,2 @@ defines: {};

}[]>;
/**
* Velocity
*/
export declare const gBuffer3Fragment: FragmentShader<import("../../../core/type").Dict<import("../../../Shader").ShaderDefineValue>, {
firstRender: {
type: "bool";
value: number;
semantic: import("../../../Shader").UniformSemantic | import("../../../Shader").MatrixSemantic | undefined;
};
}, never>;
export declare const gBufferDebugFragment: FragmentShader<import("../../../core/type").Dict<import("../../../Shader").ShaderDefineValue>, {

@@ -246,0 +226,0 @@ /**

@@ -50,3 +50,3 @@ import { createArrayUniform, createUniform as uniform, createVarying as varying, FragmentShader, glsl, VertexShader } from '../../../Shader';

#ifdef FIRST_PASS
#ifdef USE_TARGET_TEXTURE1
vec3 skinnedNormal = normal;

@@ -63,3 +63,3 @@ vec3 skinnedTangent = tangent.xyz;

#ifdef FIRST_PASS
#ifdef USE_TARGET_TEXTURE1
// Upper skinMatrix

@@ -72,3 +72,3 @@ skinnedNormal = (skinMatrixWS * vec4(normal, 0.0)).xyz;

#ifdef THIRD_PASS
#ifdef USE_TARGET_TEXTURE4
// Weighted Sum Skinning Matrix

@@ -88,7 +88,7 @@ // PENDING Must be assigned.

#if defined(SECOND_PASS) || defined(FIRST_PASS)
#if defined(USE_TARGET_TEXTURE3) || defined(USE_TARGET_TEXTURE1)
v_Texcoord = texcoord * uvRepeat + uvOffset;
#endif
#ifdef FIRST_PASS
#ifdef USE_TARGET_TEXTURE1
v_Normal = normalize((worldInverseTranspose * vec4(skinnedNormal, 0.0)).xyz);

@@ -103,3 +103,3 @@

#ifdef THIRD_PASS
#ifdef USE_TARGET_TEXTURE4
v_ViewPosition = worldViewProjection * vec4(skinnedPosition, 1.0);

@@ -114,3 +114,3 @@ v_PrevViewPosition = prevWorldViewProjection * vec4(prevSkinnedPosition, 1.0);

/**
* First pass
* First texture
* - R: normal.x

@@ -120,10 +120,25 @@ * - G: normal.y

* - A: metalness
*
* Second texture
* - R: albedo.r
* - G: albedo.g
* - B: albedo.b
* - A: metalness
*
* Third texture
* - Velocity
*/
export const gBuffer1Fragment = new FragmentShader({
name: 'gBuffer1Frag',
export const createGBufferFrag = (outputs) => new FragmentShader({
name: 'gBufferFrag',
outputs: outputs,
uniforms: {
viewInverse: VIEWINVERSE(),
glossiness: uniform('float'),
diffuseMap: uniform('sampler2D'),
metalnessMap: uniform('sampler2D'),
color: uniform('vec3'),
metalness: uniform('float'),
useMetalnessMap: uniform('bool'),
linear: uniform('bool'),
normalMap: uniform('sampler2D'),
diffuseMap: uniform('sampler2D'),
roughGlossMap: uniform('sampler2D'),

@@ -135,4 +150,6 @@ useRoughGlossMap: uniform('bool'),

alpha: uniform('float', 1.0),
roughGlossChannel: uniform('int', 0)
roughGlossChannel: uniform('int', 0),
firstRender: uniform('bool')
},
includes: [sRGBMixin],
main: glsl `

@@ -148,2 +165,9 @@ float indexingTexel(in vec4 texel, in int idx) {

if (alphaCutoff > 0.0) {
float a = texture(diffuseMap, v_Texcoord).a * alpha;
if (a < alphaCutoff) {
discard;
}
}
#ifdef USE_TARGET_TEXTURE1
vec3 N = v_Normal;

@@ -158,9 +182,2 @@

}
if (alphaCutoff > 0.0) {
float a = texture(diffuseMap, v_Texcoord).a * alpha;
if (a < alphaCutoff) {
discard;
}
}
if (dot(v_Tangent, v_Tangent) > 0.0) {

@@ -176,8 +193,3 @@ vec3 normalTexel = texture(normalMap, v_Texcoord).xyz;

out_color.rgb = (N + 1.0) * 0.5;
// FIXME Have precision problem http://aras-p.info/texts/CompactNormalStorage.html
// N.z can be recovered from sqrt(1 - dot(N.xy, N.xy));
// out_color.rg = (N.xy + 1.0) * 0.5;
float g = glossiness;

@@ -193,33 +205,12 @@

// FIXME Have precision problem http://aras-p.info/texts/CompactNormalStorage.html
// N.z can be recovered from sqrt(1 - dot(N.xy, N.xy));
// out_color.rg = (N.xy + 1.0) * 0.5;
// PENDING Alpha can't be zero.
out_color.a = g + 0.005;
out_color0 = vec4((N + 1.0) * 0.5, g + 0.005);
#endif
// Pack sign of normal to metalness
// Add 0.001 to avoid m is 0
// out_color.a = sign(N.z) * (m + 0.001) * 0.5 + 0.5;
}`
});
/**
* Second pass
* - R: albedo.r
* - G: albedo.g
* - B: albedo.b
* - A: metalness
*/
export const gBuffer2Fragment = new FragmentShader({
name: 'gBuffer2Frag',
uniforms: {
diffuseMap: uniform('sampler2D'),
metalnessMap: uniform('sampler2D'),
color: uniform('vec3'),
metalness: uniform('float'),
useMetalnessMap: uniform('bool'),
linear: uniform('bool'),
alphaCutoff: uniform('float', 0.0),
alpha: uniform('float', 1.0)
},
includes: [sRGBMixin],
main: glsl `
void main()
{
// Texture 2
#ifdef USE_TARGET_TEXTURE3
float m = metalness;

@@ -235,25 +226,8 @@

}
if (alphaCutoff > 0.0) {
float a = texel.a * alpha;
if (a < alphaCutoff) {
discard;
}
}
out_color.rgb = texel.rgb * color;
out_color1 = vec4(texel.rgb * color, m + 0.005);
#endif
// PENDING Alpha can't be zero.
out_color.a = m + 0.005;
}`
});
/**
* Velocity
*/
export const gBuffer3Fragment = new FragmentShader({
name: 'gBuffer3Frag',
uniforms: {
firstRender: uniform('bool')
},
main: glsl `
void main() {
#ifdef USE_TARGET_TEXTURE4
// Velocity
vec2 a = v_ViewPosition.xy / v_ViewPosition.w;

@@ -263,7 +237,8 @@ vec2 b = v_PrevViewPosition.xy / v_PrevViewPosition.w;

if (firstRender) {
out_color = vec4(0.0);
out_color2 = vec4(0.0);
}
else {
out_color = vec4((a - b) * 0.5 + 0.5, 0.0, 1.0);
out_color2 = vec4((a - b) * 0.5 + 0.5, 0.0, 1.0);
}
#endif
}`

@@ -270,0 +245,0 @@ });

@@ -1,2 +0,2 @@

import Texture, { getDefaultTextureFormatBySource, getDefaultTypeBySource } from './Texture';
import Texture, { getDefaultTextureFormatBySource, getDefaultTypeBySource, isPixelSource } from './Texture';
import vendor from './core/vendor';

@@ -38,6 +38,8 @@ /**

const oldWidth = this.width;
if (this.source) {
this.source.width = value;
const source = this.source;
if (isPixelSource(source)) {
// PENDING should not change the size of source?
source.width = value;
}
else {
else if (!source) {
this._width = value;

@@ -60,6 +62,7 @@ }

const oldHeight = this.height;
if (this.source) {
this.source.height = value;
const source = this.source;
if (isPixelSource(source)) {
source.height = value;
}
else {
else if (!source) {
this._height = value;

@@ -66,0 +69,0 @@ }

@@ -15,3 +15,8 @@ import Texture, { getDefaultTextureFormatBySource, getDefaultTypeBySource } from './Texture';

if (this._hasSource()) {
return this.source[0].width;
let maxWidth = 0;
const source = this.source;
for (let i = 0; i < source.length; i++) {
maxWidth = Math.max(maxWidth, source[i].width);
}
return maxWidth;
}

@@ -22,7 +27,8 @@ return this._width || 0;

const oldWidth = this.width;
if (this._hasSource()) {
this.source.forEach((source) => (source.width = value));
if (!this._hasSource()) {
this._width = value;
}
else {
this._width = value;
// PENDING Should not change the source size.
// this.source!.forEach((source) => isPixelSource(source) && (source.width = value));
}

@@ -33,3 +39,7 @@ oldWidth !== value && this.dirty();

if (this._hasSource()) {
return this.source[0].height;
let maxHeight = 0;
const source = this.source;
for (let i = 0; i < source.length; i++) {
maxHeight = Math.max(maxHeight, source[i].height);
}
}

@@ -40,7 +50,7 @@ return this._height || 0;

const oldHeight = this.height;
if (this._hasSource()) {
this.source.forEach((source) => (source.height = value));
if (!this._hasSource()) {
this._height = value;
}
else {
this._height = value;
// this.source!.forEach((source) => (source.height = value));
}

@@ -47,0 +57,0 @@ oldHeight !== value && this.dirty();

@@ -1,2 +0,2 @@

import Texture, { getDefaultTextureFormatBySource, getDefaultTypeBySource } from './Texture';
import Texture, { getDefaultTextureFormatBySource, getDefaultTypeBySource, isPixelSource } from './Texture';
import * as mathUtil from './math/util';

@@ -55,3 +55,3 @@ import vendor from './core/vendor';

keys(source).forEach((target) => {
source[target] && (source[target].width = value);
isPixelSource(source[target]) && (source[target].width = value);
});

@@ -80,3 +80,3 @@ }

keys(source).forEach((target) => {
source[target] && (source[target].height = value);
isPixelSource(source[target]) && (source[target].height = value);
});

@@ -83,0 +83,0 @@ }

// Cubemap prefilter utility
// http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf
// http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
// https://blog.selfshadow.com/publications/s2013-shading-course/#course_content
import Texture2D from '../Texture2D';

@@ -156,5 +155,2 @@ import TextureCube, { cubeTargets } from '../TextureCube';

const tmp = [];
// function sortFunc(a, b) {
// return Math.abs(b) - Math.abs(a);
// }
for (let j = 0; j < roughnessLevels; j++) {

@@ -165,5 +161,3 @@ const roughness = j / roughnessLevels;

// http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
// http://stackoverflow.com/questions/1908492/unsigned-integer-in-javascript
// http://stackoverflow.com/questions/1822350/what-is-the-javascript-operator-and-how-do-you-use-it
let y = ((i << 16) | (i >>> 16)) >>> 0;

@@ -170,0 +164,0 @@ y = (((y & 1431655765) << 1) | ((y & 2863311530) >>> 1)) >>> 0;

{
"name": "claygl-next",
"version": "2.0.0-alpha.15",
"version": "2.0.0-alpha.16",
"description": "A 3D graphic library",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc