Skip to content

Commit ad2d035

Browse files
committed
Updated builds.
1 parent 3e97fb1 commit ad2d035

File tree

4 files changed

+203
-117
lines changed

4 files changed

+203
-117
lines changed

build/three.cjs

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14099,7 +14099,7 @@ function WebGLState(gl, extensions, capabilities) {
1409914099
const depthBuffer = new DepthBuffer();
1410014100
const stencilBuffer = new StencilBuffer();
1410114101
const uboBindings = new WeakMap();
14102-
const uboProgamMap = new WeakMap();
14102+
const uboProgramMap = new WeakMap();
1410314103
let enabledCapabilities = {};
1410414104
let currentBoundFramebuffers = {};
1410514105
let currentDrawbuffers = new WeakMap();
@@ -14560,10 +14560,10 @@ function WebGLState(gl, extensions, capabilities) {
1456014560
}
1456114561
}
1456214562
function updateUBOMapping(uniformsGroup, program) {
14563-
let mapping = uboProgamMap.get(program);
14563+
let mapping = uboProgramMap.get(program);
1456414564
if (mapping === undefined) {
1456514565
mapping = new WeakMap();
14566-
uboProgamMap.set(program, mapping);
14566+
uboProgramMap.set(program, mapping);
1456714567
}
1456814568
let blockIndex = mapping.get(uniformsGroup);
1456914569
if (blockIndex === undefined) {
@@ -14572,13 +14572,12 @@ function WebGLState(gl, extensions, capabilities) {
1457214572
}
1457314573
}
1457414574
function uniformBlockBinding(uniformsGroup, program) {
14575-
const mapping = uboProgamMap.get(program);
14575+
const mapping = uboProgramMap.get(program);
1457614576
const blockIndex = mapping.get(uniformsGroup);
14577-
if (uboBindings.get(uniformsGroup) !== blockIndex) {
14577+
if (uboBindings.get(program) !== blockIndex) {
1457814578
// bind shader specific block index to global block point
14579-
1458014579
gl.uniformBlockBinding(program, blockIndex, uniformsGroup.__bindingPointIndex);
14581-
uboBindings.set(uniformsGroup, blockIndex);
14580+
uboBindings.set(program, blockIndex);
1458214581
}
1458314582
}
1458414583

@@ -17242,32 +17241,36 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1724217241
// partly update the buffer if necessary
1724317242

1724417243
if (hasUniformChanged(uniform, i, cache) === true) {
17245-
const value = uniform.value;
1724617244
const offset = uniform.__offset;
17247-
if (typeof value === 'number') {
17248-
uniform.__data[0] = value;
17249-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
17250-
} else {
17251-
if (uniform.value.isMatrix3) {
17245+
const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
17246+
let arrayOffset = 0;
17247+
for (let i = 0; i < values.length; i++) {
17248+
const value = values[i];
17249+
const info = getUniformSize(value);
17250+
if (typeof value === 'number') {
17251+
uniform.__data[0] = value;
17252+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data);
17253+
} else if (value.isMatrix3) {
1725217254
// manually converting 3x3 to 3x4
1725317255

17254-
uniform.__data[0] = uniform.value.elements[0];
17255-
uniform.__data[1] = uniform.value.elements[1];
17256-
uniform.__data[2] = uniform.value.elements[2];
17257-
uniform.__data[3] = uniform.value.elements[0];
17258-
uniform.__data[4] = uniform.value.elements[3];
17259-
uniform.__data[5] = uniform.value.elements[4];
17260-
uniform.__data[6] = uniform.value.elements[5];
17261-
uniform.__data[7] = uniform.value.elements[0];
17262-
uniform.__data[8] = uniform.value.elements[6];
17263-
uniform.__data[9] = uniform.value.elements[7];
17264-
uniform.__data[10] = uniform.value.elements[8];
17265-
uniform.__data[11] = uniform.value.elements[0];
17256+
uniform.__data[0] = value.elements[0];
17257+
uniform.__data[1] = value.elements[1];
17258+
uniform.__data[2] = value.elements[2];
17259+
uniform.__data[3] = value.elements[0];
17260+
uniform.__data[4] = value.elements[3];
17261+
uniform.__data[5] = value.elements[4];
17262+
uniform.__data[6] = value.elements[5];
17263+
uniform.__data[7] = value.elements[0];
17264+
uniform.__data[8] = value.elements[6];
17265+
uniform.__data[9] = value.elements[7];
17266+
uniform.__data[10] = value.elements[8];
17267+
uniform.__data[11] = value.elements[0];
1726617268
} else {
17267-
value.toArray(uniform.__data);
17269+
value.toArray(uniform.__data, arrayOffset);
17270+
arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
1726817271
}
17269-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
1727017272
}
17273+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
1727117274
}
1727217275
}
1727317276
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
@@ -17280,7 +17283,12 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1728017283
if (typeof value === 'number') {
1728117284
cache[index] = value;
1728217285
} else {
17283-
cache[index] = value.clone();
17286+
const values = Array.isArray(value) ? value : [value];
17287+
const tempValues = [];
17288+
for (let i = 0; i < values.length; i++) {
17289+
tempValues.push(values[i].clone());
17290+
}
17291+
cache[index] = tempValues;
1728417292
}
1728517293
return true;
1728617294
} else {
@@ -17292,10 +17300,14 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1729217300
return true;
1729317301
}
1729417302
} else {
17295-
const cachedObject = cache[index];
17296-
if (cachedObject.equals(value) === false) {
17297-
cachedObject.copy(value);
17298-
return true;
17303+
const cachedObjects = Array.isArray(cache[index]) ? cache[index] : [cache[index]];
17304+
const values = Array.isArray(value) ? value : [value];
17305+
for (let i = 0; i < cachedObjects.length; i++) {
17306+
const cachedObject = cachedObjects[i];
17307+
if (cachedObject.equals(values[i]) === false) {
17308+
cachedObject.copy(values[i]);
17309+
return true;
17310+
}
1729917311
}
1730017312
}
1730117313
}
@@ -17312,11 +17324,23 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1731217324

1731317325
for (let i = 0, l = uniforms.length; i < l; i++) {
1731417326
const uniform = uniforms[i];
17315-
const info = getUniformSize(uniform);
17327+
const infos = {
17328+
boundary: 0,
17329+
// bytes
17330+
storage: 0 // bytes
17331+
};
17332+
17333+
const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
17334+
for (let j = 0, jl = values.length; j < jl; j++) {
17335+
const value = values[j];
17336+
const info = getUniformSize(value);
17337+
infos.boundary += info.boundary;
17338+
infos.storage += info.storage;
17339+
}
1731617340

1731717341
// the following two properties will be used for partial buffer updates
1731817342

17319-
uniform.__data = new Float32Array(info.storage / Float32Array.BYTES_PER_ELEMENT);
17343+
uniform.__data = new Float32Array(infos.storage / Float32Array.BYTES_PER_ELEMENT);
1732017344
uniform.__offset = offset;
1732117345

1732217346
//
@@ -17327,14 +17351,14 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1732717351

1732817352
// check for chunk overflow
1732917353

17330-
if (chunkOffset !== 0 && remainingSizeInChunk - info.boundary < 0) {
17354+
if (chunkOffset !== 0 && remainingSizeInChunk - infos.boundary < 0) {
1733117355
// add padding and adjust offset
1733217356

1733317357
offset += chunkSize - chunkOffset;
1733417358
uniform.__offset = offset;
1733517359
}
1733617360
}
17337-
offset += info.storage;
17361+
offset += infos.storage;
1733817362
}
1733917363

1734017364
// ensure correct final padding
@@ -17348,8 +17372,7 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
1734817372
uniformsGroup.__cache = {};
1734917373
return this;
1735017374
}
17351-
function getUniformSize(uniform) {
17352-
const value = uniform.value;
17375+
function getUniformSize(value) {
1735317376
const info = {
1735417377
boundary: 0,
1735517378
// bytes

build/three.js

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14101,7 +14101,7 @@
1410114101
const depthBuffer = new DepthBuffer();
1410214102
const stencilBuffer = new StencilBuffer();
1410314103
const uboBindings = new WeakMap();
14104-
const uboProgamMap = new WeakMap();
14104+
const uboProgramMap = new WeakMap();
1410514105
let enabledCapabilities = {};
1410614106
let currentBoundFramebuffers = {};
1410714107
let currentDrawbuffers = new WeakMap();
@@ -14562,10 +14562,10 @@
1456214562
}
1456314563
}
1456414564
function updateUBOMapping(uniformsGroup, program) {
14565-
let mapping = uboProgamMap.get(program);
14565+
let mapping = uboProgramMap.get(program);
1456614566
if (mapping === undefined) {
1456714567
mapping = new WeakMap();
14568-
uboProgamMap.set(program, mapping);
14568+
uboProgramMap.set(program, mapping);
1456914569
}
1457014570
let blockIndex = mapping.get(uniformsGroup);
1457114571
if (blockIndex === undefined) {
@@ -14574,13 +14574,12 @@
1457414574
}
1457514575
}
1457614576
function uniformBlockBinding(uniformsGroup, program) {
14577-
const mapping = uboProgamMap.get(program);
14577+
const mapping = uboProgramMap.get(program);
1457814578
const blockIndex = mapping.get(uniformsGroup);
14579-
if (uboBindings.get(uniformsGroup) !== blockIndex) {
14579+
if (uboBindings.get(program) !== blockIndex) {
1458014580
// bind shader specific block index to global block point
14581-
1458214581
gl.uniformBlockBinding(program, blockIndex, uniformsGroup.__bindingPointIndex);
14583-
uboBindings.set(uniformsGroup, blockIndex);
14582+
uboBindings.set(program, blockIndex);
1458414583
}
1458514584
}
1458614585

@@ -17244,32 +17243,36 @@
1724417243
// partly update the buffer if necessary
1724517244

1724617245
if (hasUniformChanged(uniform, i, cache) === true) {
17247-
const value = uniform.value;
1724817246
const offset = uniform.__offset;
17249-
if (typeof value === 'number') {
17250-
uniform.__data[0] = value;
17251-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
17252-
} else {
17253-
if (uniform.value.isMatrix3) {
17247+
const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
17248+
let arrayOffset = 0;
17249+
for (let i = 0; i < values.length; i++) {
17250+
const value = values[i];
17251+
const info = getUniformSize(value);
17252+
if (typeof value === 'number') {
17253+
uniform.__data[0] = value;
17254+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data);
17255+
} else if (value.isMatrix3) {
1725417256
// manually converting 3x3 to 3x4
1725517257

17256-
uniform.__data[0] = uniform.value.elements[0];
17257-
uniform.__data[1] = uniform.value.elements[1];
17258-
uniform.__data[2] = uniform.value.elements[2];
17259-
uniform.__data[3] = uniform.value.elements[0];
17260-
uniform.__data[4] = uniform.value.elements[3];
17261-
uniform.__data[5] = uniform.value.elements[4];
17262-
uniform.__data[6] = uniform.value.elements[5];
17263-
uniform.__data[7] = uniform.value.elements[0];
17264-
uniform.__data[8] = uniform.value.elements[6];
17265-
uniform.__data[9] = uniform.value.elements[7];
17266-
uniform.__data[10] = uniform.value.elements[8];
17267-
uniform.__data[11] = uniform.value.elements[0];
17258+
uniform.__data[0] = value.elements[0];
17259+
uniform.__data[1] = value.elements[1];
17260+
uniform.__data[2] = value.elements[2];
17261+
uniform.__data[3] = value.elements[0];
17262+
uniform.__data[4] = value.elements[3];
17263+
uniform.__data[5] = value.elements[4];
17264+
uniform.__data[6] = value.elements[5];
17265+
uniform.__data[7] = value.elements[0];
17266+
uniform.__data[8] = value.elements[6];
17267+
uniform.__data[9] = value.elements[7];
17268+
uniform.__data[10] = value.elements[8];
17269+
uniform.__data[11] = value.elements[0];
1726817270
} else {
17269-
value.toArray(uniform.__data);
17271+
value.toArray(uniform.__data, arrayOffset);
17272+
arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT;
1727017273
}
17271-
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
1727217274
}
17275+
gl.bufferSubData(gl.UNIFORM_BUFFER, offset, uniform.__data);
1727317276
}
1727417277
}
1727517278
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
@@ -17282,7 +17285,12 @@
1728217285
if (typeof value === 'number') {
1728317286
cache[index] = value;
1728417287
} else {
17285-
cache[index] = value.clone();
17288+
const values = Array.isArray(value) ? value : [value];
17289+
const tempValues = [];
17290+
for (let i = 0; i < values.length; i++) {
17291+
tempValues.push(values[i].clone());
17292+
}
17293+
cache[index] = tempValues;
1728617294
}
1728717295
return true;
1728817296
} else {
@@ -17294,10 +17302,14 @@
1729417302
return true;
1729517303
}
1729617304
} else {
17297-
const cachedObject = cache[index];
17298-
if (cachedObject.equals(value) === false) {
17299-
cachedObject.copy(value);
17300-
return true;
17305+
const cachedObjects = Array.isArray(cache[index]) ? cache[index] : [cache[index]];
17306+
const values = Array.isArray(value) ? value : [value];
17307+
for (let i = 0; i < cachedObjects.length; i++) {
17308+
const cachedObject = cachedObjects[i];
17309+
if (cachedObject.equals(values[i]) === false) {
17310+
cachedObject.copy(values[i]);
17311+
return true;
17312+
}
1730117313
}
1730217314
}
1730317315
}
@@ -17314,11 +17326,23 @@
1731417326

1731517327
for (let i = 0, l = uniforms.length; i < l; i++) {
1731617328
const uniform = uniforms[i];
17317-
const info = getUniformSize(uniform);
17329+
const infos = {
17330+
boundary: 0,
17331+
// bytes
17332+
storage: 0 // bytes
17333+
};
17334+
17335+
const values = Array.isArray(uniform.value) ? uniform.value : [uniform.value];
17336+
for (let j = 0, jl = values.length; j < jl; j++) {
17337+
const value = values[j];
17338+
const info = getUniformSize(value);
17339+
infos.boundary += info.boundary;
17340+
infos.storage += info.storage;
17341+
}
1731817342

1731917343
// the following two properties will be used for partial buffer updates
1732017344

17321-
uniform.__data = new Float32Array(info.storage / Float32Array.BYTES_PER_ELEMENT);
17345+
uniform.__data = new Float32Array(infos.storage / Float32Array.BYTES_PER_ELEMENT);
1732217346
uniform.__offset = offset;
1732317347

1732417348
//
@@ -17329,14 +17353,14 @@
1732917353

1733017354
// check for chunk overflow
1733117355

17332-
if (chunkOffset !== 0 && remainingSizeInChunk - info.boundary < 0) {
17356+
if (chunkOffset !== 0 && remainingSizeInChunk - infos.boundary < 0) {
1733317357
// add padding and adjust offset
1733417358

1733517359
offset += chunkSize - chunkOffset;
1733617360
uniform.__offset = offset;
1733717361
}
1733817362
}
17339-
offset += info.storage;
17363+
offset += infos.storage;
1734017364
}
1734117365

1734217366
// ensure correct final padding
@@ -17350,8 +17374,7 @@
1735017374
uniformsGroup.__cache = {};
1735117375
return this;
1735217376
}
17353-
function getUniformSize(uniform) {
17354-
const value = uniform.value;
17377+
function getUniformSize(value) {
1735517378
const info = {
1735617379
boundary: 0,
1735717380
// bytes

build/three.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)