@woosh/meep-engine 2.97.0 → 2.98.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +861 -670
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +861 -670
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +3 -2
- package/src/core/collection/array/arrayQuickSort.js +2 -2
- package/src/core/collection/array/array_compute_max.d.ts +9 -0
- package/src/core/collection/array/array_compute_max.d.ts.map +1 -0
- package/src/core/collection/array/{computeArrayMax.js → array_compute_max.js} +1 -1
- package/src/core/collection/array/array_compute_min.d.ts +9 -0
- package/src/core/collection/array/array_compute_min.d.ts.map +1 -0
- package/src/core/collection/array/{computeArrayMin.js → array_compute_min.js} +1 -1
- package/src/core/collection/array/array_compute_min_max.d.ts.map +1 -1
- package/src/core/collection/array/array_compute_min_max.js +1 -0
- package/src/core/collection/array/array_swap.d.ts.map +1 -1
- package/src/core/collection/array/array_swap.js +11 -8
- package/src/core/collection/array/array_swap_one.d.ts +8 -0
- package/src/core/collection/array/array_swap_one.d.ts.map +1 -0
- package/src/core/collection/array/{arraySwapElements.js → array_swap_one.js} +1 -1
- package/src/core/collection/array/iterator/AbstractArrayIterator.d.ts.map +1 -0
- package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts.map +1 -0
- package/src/core/collection/array/{ArrayIteratorRandom.js → iterator/ArrayIteratorRandom.js} +2 -2
- package/src/core/collection/array/iterator/ArrayIteratorSequential.d.ts.map +1 -0
- package/src/core/collection/array/randomizeArrayElementOrder.js +2 -2
- package/src/core/collection/map/HashMap.js +10 -10
- package/src/core/collection/map/ObservedMap.d.ts +7 -4
- package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
- package/src/core/collection/map/ObservedMap.js +4 -1
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +82 -36
- package/src/core/collection/set/compute_set_difference.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_difference.js +8 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_difference.spec.js +45 -0
- package/src/core/collection/set/compute_set_intersection.d.ts +1 -0
- package/src/core/collection/set/compute_set_intersection.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_intersection.js +9 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_intersection.spec.js +45 -0
- package/src/core/collection/set/set_remove.d.ts +2 -0
- package/src/core/collection/set/set_remove.d.ts.map +1 -1
- package/src/core/collection/set/set_remove.js +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts.map +1 -0
- package/src/core/color/oklab/XYZ.spec.js +17 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts +9 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.js +32 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts +2 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.js +31 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts +8 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.js +29 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts +2 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.js +31 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +16 -5
- package/src/core/color/sRGB/sRGB_to_linear.d.ts.map +1 -1
- package/src/core/color/sRGB/sRGB_to_linear.js +17 -5
- package/src/core/color/xyz/rgb_to_xyz.d.ts +1 -0
- package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
- package/src/core/color/xyz/rgb_to_xyz.js +4 -3
- package/src/core/color/xyz/xyz_to_rgb.d.ts +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +4 -4
- package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +10 -10
- package/src/core/parser/simple/ParserError.d.ts +11 -6
- package/src/core/parser/simple/ParserError.d.ts.map +1 -1
- package/src/core/parser/simple/ParserError.js +51 -4
- package/src/core/parser/simple/Token.d.ts.map +1 -1
- package/src/core/parser/simple/Token.js +8 -2
- package/src/core/parser/simple/TokenType.d.ts +1 -5
- package/src/core/parser/simple/TokenType.d.ts.map +1 -1
- package/src/core/parser/simple/TokenType.js +1 -1
- package/src/core/parser/simple/readBooleanToken.d.ts.map +1 -1
- package/src/core/parser/simple/readBooleanToken.js +6 -1
- package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
- package/src/core/parser/simple/readHexToken.js +7 -2
- package/src/core/parser/simple/readIdentifierToken.d.ts.map +1 -1
- package/src/core/parser/simple/readIdentifierToken.js +6 -1
- package/src/core/parser/simple/readLiteralToken.d.ts.map +1 -1
- package/src/core/parser/simple/readLiteralToken.js +8 -3
- package/src/core/parser/simple/readNumberToken.d.ts.map +1 -1
- package/src/core/parser/simple/readNumberToken.js +7 -2
- package/src/core/parser/simple/readReferenceToken.d.ts.map +1 -1
- package/src/core/parser/simple/readReferenceToken.js +6 -1
- package/src/core/parser/simple/readStringToken.d.ts.map +1 -1
- package/src/core/parser/simple/readStringToken.js +6 -1
- package/src/core/parser/simple/readUnsignedIntegerToken.d.ts.map +1 -1
- package/src/core/parser/simple/readUnsignedIntegerToken.js +7 -2
- package/src/core/parser/simple/skipWhitespace.d.ts.map +1 -1
- package/src/core/parser/simple/skipWhitespace.js +8 -0
- package/src/core/primitives/strings/string_repeat.d.ts +9 -0
- package/src/core/primitives/strings/string_repeat.d.ts.map +1 -0
- package/src/core/primitives/strings/string_repeat.js +26 -0
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/development/performance/RingBufferMetric.d.ts.map +1 -1
- package/src/engine/development/performance/RingBufferMetric.js +5 -5
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.js +15 -22
- package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +23 -16
- package/src/engine/graphics/filter/ImageFilter.d.ts +2 -2
- package/src/engine/graphics/filter/ImageFilter.d.ts.map +1 -1
- package/src/engine/graphics/filter/ImageFilter.js +3 -3
- package/src/engine/graphics/render/RendererPool.d.ts +14 -1
- package/src/engine/graphics/render/RendererPool.d.ts.map +1 -1
- package/src/engine/graphics/render/RendererPool.js +43 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +23 -50
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts +9 -0
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +53 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +3 -3
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +42 -36
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts +3 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.js +34 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts +10 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.js +89 -0
- package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.js → debug/prototypeSamplerFiltering.js} +105 -113
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +8 -8
- package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
- package/src/generation/markers/GridActionRuleSet.js +5 -5
- package/src/core/binary/byteArrayToString.d.ts +0 -9
- package/src/core/binary/byteArrayToString.d.ts.map +0 -1
- package/src/core/binary/byteArrayToString.js +0 -28
- package/src/core/collection/array/AbstractArrayIterator.d.ts.map +0 -1
- package/src/core/collection/array/ArrayIteratorRandom.d.ts.map +0 -1
- package/src/core/collection/array/ArrayIteratorSequential.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickMinElement.d.ts +0 -8
- package/src/core/collection/array/arrayPickMinElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickMinElement.js +0 -43
- package/src/core/collection/array/arraySwapElements.d.ts +0 -8
- package/src/core/collection/array/arraySwapElements.d.ts.map +0 -1
- package/src/core/collection/array/computeArrayMax.d.ts +0 -9
- package/src/core/collection/array/computeArrayMax.d.ts.map +0 -1
- package/src/core/collection/array/computeArrayMin.d.ts +0 -9
- package/src/core/collection/array/computeArrayMin.d.ts.map +0 -1
- package/src/core/color/hsluv/HSLuv.d.ts +0 -13
- package/src/core/color/hsluv/HSLuv.d.ts.map +0 -1
- package/src/core/color/hsluv/HSLuv.js +0 -187
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.d.ts.map +0 -1
- /package/src/core/collection/array/{AbstractArrayIterator.d.ts → iterator/AbstractArrayIterator.d.ts} +0 -0
- /package/src/core/collection/array/{AbstractArrayIterator.js → iterator/AbstractArrayIterator.js} +0 -0
- /package/src/core/collection/array/{ArrayIteratorRandom.d.ts → iterator/ArrayIteratorRandom.d.ts} +0 -0
- /package/src/core/collection/array/{ArrayIteratorSequential.d.ts → iterator/ArrayIteratorSequential.d.ts} +0 -0
- /package/src/core/collection/array/{ArrayIteratorSequential.js → iterator/ArrayIteratorSequential.js} +0 -0
- /package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.d.ts → debug/prototypeSamplerFiltering.d.ts} +0 -0
package/build/meep.module.js
CHANGED
|
@@ -53175,7 +53175,7 @@ const SCRATCH_UINT32_TRAVERSAL_STACK = new Uint32Array(781250);
|
|
|
53175
53175
|
*/
|
|
53176
53176
|
SCRATCH_UINT32_TRAVERSAL_STACK.pointer = 0;
|
|
53177
53177
|
|
|
53178
|
-
const
|
|
53178
|
+
const abs = Math.abs;
|
|
53179
53179
|
|
|
53180
53180
|
/**
|
|
53181
53181
|
* NOTES:
|
|
@@ -53212,7 +53212,7 @@ function aabb3_intersects_ray(
|
|
|
53212
53212
|
const diff_x = origin_x - center_x;
|
|
53213
53213
|
|
|
53214
53214
|
|
|
53215
|
-
if (diff_x * direction_x >= 0.0 &&
|
|
53215
|
+
if (diff_x * direction_x >= 0.0 && abs(diff_x) > extents_x) {
|
|
53216
53216
|
return false;
|
|
53217
53217
|
}
|
|
53218
53218
|
|
|
@@ -53224,7 +53224,7 @@ function aabb3_intersects_ray(
|
|
|
53224
53224
|
const diff_y = origin_y - center_y;
|
|
53225
53225
|
|
|
53226
53226
|
|
|
53227
|
-
if (diff_y * direction_y >= 0.0 &&
|
|
53227
|
+
if (diff_y * direction_y >= 0.0 && abs(diff_y) > extents_y) {
|
|
53228
53228
|
return false;
|
|
53229
53229
|
}
|
|
53230
53230
|
|
|
@@ -53236,28 +53236,28 @@ function aabb3_intersects_ray(
|
|
|
53236
53236
|
const diff_z = origin_z - center_z;
|
|
53237
53237
|
|
|
53238
53238
|
|
|
53239
|
-
if (diff_z * direction_z >= 0.0 &&
|
|
53239
|
+
if (diff_z * direction_z >= 0.0 && abs(diff_z) > extents_z) {
|
|
53240
53240
|
return false;
|
|
53241
53241
|
}
|
|
53242
53242
|
|
|
53243
|
-
const abs_direction_y =
|
|
53244
|
-
const abs_direction_z =
|
|
53243
|
+
const abs_direction_y = abs(direction_y);
|
|
53244
|
+
const abs_direction_z = abs(direction_z);
|
|
53245
53245
|
|
|
53246
|
-
const f0 =
|
|
53246
|
+
const f0 = abs(direction_y * diff_z - direction_z * diff_y);
|
|
53247
53247
|
|
|
53248
53248
|
if (f0 > extents_y * abs_direction_z + extents_z * abs_direction_y) {
|
|
53249
53249
|
return false;
|
|
53250
53250
|
}
|
|
53251
53251
|
|
|
53252
|
-
const abs_direction_x =
|
|
53252
|
+
const abs_direction_x = abs(direction_x);
|
|
53253
53253
|
|
|
53254
|
-
const f1 =
|
|
53254
|
+
const f1 = abs(direction_z * diff_x - direction_x * diff_z);
|
|
53255
53255
|
|
|
53256
53256
|
if (f1 > extents_x * abs_direction_z + extents_z * abs_direction_x) {
|
|
53257
53257
|
return false;
|
|
53258
53258
|
}
|
|
53259
53259
|
|
|
53260
|
-
const f2 =
|
|
53260
|
+
const f2 = abs(direction_x * diff_y - direction_y * diff_x);
|
|
53261
53261
|
|
|
53262
53262
|
return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
|
|
53263
53263
|
}
|
|
@@ -53336,8 +53336,8 @@ function bvh_query_leaves_ray(
|
|
|
53336
53336
|
if (child_1 !== NULL_NODE) {
|
|
53337
53337
|
|
|
53338
53338
|
// this is not a leaf node, push children onto traversal stack
|
|
53339
|
-
stack$9[stack$9.pointer++] = child_1;
|
|
53340
53339
|
stack$9[stack$9.pointer++] = uint32[address + COLUMN_CHILD_2];
|
|
53340
|
+
stack$9[stack$9.pointer++] = child_1;
|
|
53341
53341
|
|
|
53342
53342
|
} else {
|
|
53343
53343
|
// leaf node
|
|
@@ -53631,7 +53631,11 @@ function rgb2uint24(r, g, b) {
|
|
|
53631
53631
|
}
|
|
53632
53632
|
|
|
53633
53633
|
function convert(c) {
|
|
53634
|
-
|
|
53634
|
+
if (c < 0.0031308) {
|
|
53635
|
+
return c * 12.92;
|
|
53636
|
+
} else {
|
|
53637
|
+
return 1.055 * (Math.pow(c, 0.4166666666666667)) - 0.055;
|
|
53638
|
+
}
|
|
53635
53639
|
}
|
|
53636
53640
|
|
|
53637
53641
|
/**
|
|
@@ -53641,10 +53645,17 @@ function convert(c) {
|
|
|
53641
53645
|
* @param {number[]|ArrayLike<number>} input
|
|
53642
53646
|
* @param {number} input_offset
|
|
53643
53647
|
*/
|
|
53644
|
-
function linear_to_sRGB(
|
|
53645
|
-
output
|
|
53646
|
-
|
|
53647
|
-
|
|
53648
|
+
function linear_to_sRGB(
|
|
53649
|
+
output, output_offset,
|
|
53650
|
+
input, input_offset
|
|
53651
|
+
) {
|
|
53652
|
+
const r = input[input_offset];
|
|
53653
|
+
const g = input[input_offset + 1];
|
|
53654
|
+
const b = input[input_offset + 2];
|
|
53655
|
+
|
|
53656
|
+
output[output_offset] = convert(r);
|
|
53657
|
+
output[output_offset + 1] = convert(g);
|
|
53658
|
+
output[output_offset + 2] = convert(b);
|
|
53648
53659
|
}
|
|
53649
53660
|
|
|
53650
53661
|
/**
|
|
@@ -53653,7 +53664,11 @@ function linear_to_sRGB(output, output_offset, input, input_offset) {
|
|
|
53653
53664
|
* @return {number|number}
|
|
53654
53665
|
*/
|
|
53655
53666
|
function convert_channel_sRGB_to_linear(c) {
|
|
53656
|
-
|
|
53667
|
+
if (c < 0.04045) {
|
|
53668
|
+
return c * 0.0773993808;
|
|
53669
|
+
} else {
|
|
53670
|
+
return Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
|
|
53671
|
+
}
|
|
53657
53672
|
}
|
|
53658
53673
|
|
|
53659
53674
|
/**
|
|
@@ -53663,10 +53678,18 @@ function convert_channel_sRGB_to_linear(c) {
|
|
|
53663
53678
|
* @param {number[]} input
|
|
53664
53679
|
* @param {number} input_offset
|
|
53665
53680
|
*/
|
|
53666
|
-
function sRGB_to_linear(
|
|
53667
|
-
output
|
|
53668
|
-
|
|
53669
|
-
|
|
53681
|
+
function sRGB_to_linear(
|
|
53682
|
+
output, output_offset,
|
|
53683
|
+
input, input_offset
|
|
53684
|
+
) {
|
|
53685
|
+
|
|
53686
|
+
const sR = input[input_offset];
|
|
53687
|
+
const sG = input[input_offset + 1];
|
|
53688
|
+
const sB = input[input_offset + 2];
|
|
53689
|
+
|
|
53690
|
+
output[output_offset] = convert_channel_sRGB_to_linear(sR);
|
|
53691
|
+
output[output_offset + 1] = convert_channel_sRGB_to_linear(sG);
|
|
53692
|
+
output[output_offset + 2] = convert_channel_sRGB_to_linear(sB);
|
|
53670
53693
|
}
|
|
53671
53694
|
|
|
53672
53695
|
/**
|
|
@@ -54951,19 +54974,22 @@ function ceilPowerOfTwo(v) {
|
|
|
54951
54974
|
* @param {number} b_offset
|
|
54952
54975
|
* @param {number} length How many elements should be moved
|
|
54953
54976
|
*/
|
|
54954
|
-
function array_swap(
|
|
54955
|
-
|
|
54956
|
-
|
|
54977
|
+
function array_swap(
|
|
54978
|
+
a, a_offset,
|
|
54979
|
+
b, b_offset,
|
|
54980
|
+
length
|
|
54981
|
+
) {
|
|
54957
54982
|
|
|
54958
|
-
for (k = 0; k < length; k++) {
|
|
54959
|
-
i = a_offset + k;
|
|
54960
|
-
j = b_offset + k;
|
|
54983
|
+
for (let k = 0; k < length; k++) {
|
|
54984
|
+
const i = a_offset + k;
|
|
54985
|
+
const j = b_offset + k;
|
|
54961
54986
|
|
|
54962
|
-
const
|
|
54987
|
+
const swap = b[j];
|
|
54963
54988
|
|
|
54964
54989
|
b[j] = a[i];
|
|
54965
|
-
a[i] =
|
|
54990
|
+
a[i] = swap;
|
|
54966
54991
|
}
|
|
54992
|
+
|
|
54967
54993
|
}
|
|
54968
54994
|
|
|
54969
54995
|
//
|
|
@@ -58823,25 +58849,138 @@ class TerrainTileManager {
|
|
|
58823
58849
|
}
|
|
58824
58850
|
}
|
|
58825
58851
|
|
|
58852
|
+
class WebGLRendererPool {
|
|
58853
|
+
|
|
58854
|
+
used = new Set();
|
|
58855
|
+
|
|
58856
|
+
get() {
|
|
58857
|
+
const canvas = document.createElement('canvas');
|
|
58858
|
+
const context = canvas.getContext('webgl2', { antialias: true });
|
|
58859
|
+
|
|
58860
|
+
const renderer = new WebGLRenderer({
|
|
58861
|
+
alpha: true,
|
|
58862
|
+
context,
|
|
58863
|
+
canvas
|
|
58864
|
+
});
|
|
58865
|
+
|
|
58866
|
+
this.used.add(renderer);
|
|
58867
|
+
return renderer;
|
|
58868
|
+
}
|
|
58869
|
+
|
|
58870
|
+
/**
|
|
58871
|
+
*
|
|
58872
|
+
* @param {THREE.WebGLRenderer} renderer
|
|
58873
|
+
* @returns {boolean}
|
|
58874
|
+
*/
|
|
58875
|
+
release(renderer) {
|
|
58876
|
+
if (!this.used.has(renderer)) {
|
|
58877
|
+
//not from this pool
|
|
58878
|
+
return false;
|
|
58879
|
+
}
|
|
58880
|
+
this.used.delete(renderer);
|
|
58881
|
+
|
|
58882
|
+
renderer.forceContextLoss();
|
|
58883
|
+
renderer.dispose();
|
|
58884
|
+
renderer.domElement = null;
|
|
58885
|
+
|
|
58886
|
+
return true;
|
|
58887
|
+
}
|
|
58888
|
+
|
|
58889
|
+
/**
|
|
58890
|
+
* After callback returns, renderer is released back into the pool
|
|
58891
|
+
* @template T
|
|
58892
|
+
* @param {function(renderer:WebGLRenderer):T} callback
|
|
58893
|
+
* @param {*} [thisArg]
|
|
58894
|
+
*/
|
|
58895
|
+
use(callback, thisArg) {
|
|
58896
|
+
|
|
58897
|
+
const renderer = this.get();
|
|
58898
|
+
|
|
58899
|
+
try {
|
|
58900
|
+
const result = callback.call(thisArg, renderer);
|
|
58901
|
+
|
|
58902
|
+
if (result instanceof Promise) {
|
|
58903
|
+
}
|
|
58904
|
+
|
|
58905
|
+
return result;
|
|
58906
|
+
|
|
58907
|
+
} finally {
|
|
58908
|
+
|
|
58909
|
+
this.release(renderer);
|
|
58910
|
+
}
|
|
58911
|
+
|
|
58912
|
+
}
|
|
58913
|
+
|
|
58914
|
+
/**
|
|
58915
|
+
* @template T
|
|
58916
|
+
* @param {function(renderer:WebGLRenderer):Promise<T>} callback
|
|
58917
|
+
* @param {*} [thisArg]
|
|
58918
|
+
*/
|
|
58919
|
+
async useAsync(callback, thisArg) {
|
|
58920
|
+
|
|
58921
|
+
const renderer = this.get();
|
|
58922
|
+
|
|
58923
|
+
try {
|
|
58924
|
+
await callback.call(thisArg, renderer);
|
|
58925
|
+
} finally {
|
|
58926
|
+
this.release(renderer);
|
|
58927
|
+
}
|
|
58928
|
+
}
|
|
58929
|
+
|
|
58930
|
+
static global = new WebGLRendererPool();
|
|
58931
|
+
}
|
|
58932
|
+
|
|
58933
|
+
/**
|
|
58934
|
+
*
|
|
58935
|
+
* @param {Sampler2D} sampler
|
|
58936
|
+
* @param {THREE.DataTexture} texture
|
|
58937
|
+
*/
|
|
58938
|
+
function writeSample2DDataToDataTexture(sampler, texture) {
|
|
58939
|
+
if (sampler.itemSize === 1) {
|
|
58940
|
+
if (texture.format !== RedFormat && texture.format !== LuminanceFormat) {
|
|
58941
|
+
throw new Error('itemSize is 1 and texture.format is not RedFormat');
|
|
58942
|
+
}
|
|
58943
|
+
} else if (sampler.itemSize === 2) {
|
|
58944
|
+
if (texture.format !== RGFormat) {
|
|
58945
|
+
throw new Error('itemSize is 2 and texture.format is not RGFormat');
|
|
58946
|
+
}
|
|
58947
|
+
} else if (sampler.itemSize === 3) {
|
|
58948
|
+
if (texture.format !== RGBFormat) {
|
|
58949
|
+
throw new Error('itemSize is 2 and texture.format is not RGBFormat');
|
|
58950
|
+
}
|
|
58951
|
+
} else if (sampler.itemSize === 4) {
|
|
58952
|
+
if (texture.format !== RGBAFormat) {
|
|
58953
|
+
throw new Error('itemSize is 2 and texture.format is not RGBAFormat');
|
|
58954
|
+
}
|
|
58955
|
+
} else {
|
|
58956
|
+
throw new Error('Unsupported itemSize');
|
|
58957
|
+
}
|
|
58958
|
+
|
|
58959
|
+
if (texture.image.data !== sampler.data) {
|
|
58960
|
+
// dispose of previous texture data
|
|
58961
|
+
texture.dispose();
|
|
58962
|
+
}
|
|
58963
|
+
|
|
58964
|
+
texture.image.data = sampler.data;
|
|
58965
|
+
texture.image.width = sampler.width;
|
|
58966
|
+
texture.image.height = sampler.height;
|
|
58967
|
+
|
|
58968
|
+
texture.needsUpdate = true;
|
|
58969
|
+
}
|
|
58970
|
+
|
|
58826
58971
|
/**
|
|
58827
58972
|
* Created by Alex on 10/11/2014.
|
|
58828
58973
|
*/
|
|
58829
58974
|
|
|
58830
|
-
|
|
58975
|
+
|
|
58976
|
+
const NormalMapShader = function () {
|
|
58831
58977
|
return {
|
|
58832
58978
|
|
|
58833
58979
|
uniforms: {
|
|
58834
58980
|
|
|
58835
|
-
"normalMap": { type: "t", value: null },
|
|
58836
58981
|
"heightMap": { type: "t", value: null },
|
|
58837
|
-
"
|
|
58838
|
-
"rayLength": { type: 'f', value: 17 }
|
|
58839
|
-
|
|
58840
|
-
},
|
|
58982
|
+
"resolution": { type: "v2", value: new Vector2$1(512, 512) }
|
|
58841
58983
|
|
|
58842
|
-
defines: {
|
|
58843
|
-
'NUM_SAMPLES': 64,
|
|
58844
|
-
'NUM_RINGS': 7,
|
|
58845
58984
|
},
|
|
58846
58985
|
|
|
58847
58986
|
vertexShader: [
|
|
@@ -58857,102 +58996,53 @@ const AmbientOcclusionShader = function () {
|
|
|
58857
58996
|
|
|
58858
58997
|
].join("\n"),
|
|
58859
58998
|
|
|
58999
|
+
/**
|
|
59000
|
+
* Reference: https://stackoverflow.com/questions/49640250/calculate-normals-from-heightmap
|
|
59001
|
+
*/
|
|
58860
59002
|
fragmentShader: [
|
|
58861
|
-
|
|
58862
|
-
uniform sampler2D
|
|
58863
|
-
uniform sampler2D heightMap;
|
|
58864
|
-
uniform float rayLength;
|
|
58865
|
-
uniform vec2 world_size;
|
|
59003
|
+
"uniform vec2 resolution;",
|
|
59004
|
+
"uniform sampler2D heightMap;",
|
|
58866
59005
|
|
|
58867
|
-
|
|
59006
|
+
"#define sqrt2 1.41421356237;",
|
|
59007
|
+
|
|
59008
|
+
"varying vec2 vUv;",
|
|
59009
|
+
|
|
59010
|
+
"void main() {",
|
|
59011
|
+
" float uStep = 1.0/resolution.x;",
|
|
59012
|
+
" float vStep = 1.0/resolution.y;",
|
|
59013
|
+
//
|
|
59014
|
+
//
|
|
59015
|
+
" float top = texture2D( heightMap, vUv + vec2(0, -vStep)).x;",
|
|
59016
|
+
" float bottom = texture2D( heightMap, vUv + vec2(0, +vStep)).x;",
|
|
59017
|
+
" float left = texture2D( heightMap, vUv + vec2(-uStep, 0)).x;",
|
|
59018
|
+
" float right = texture2D( heightMap, vUv + vec2(+uStep, 0)).x;",
|
|
59019
|
+
//
|
|
59020
|
+
|
|
59021
|
+
" float dX = (right ) - ( left);",
|
|
59022
|
+
" float dY = ( bottom ) - ( top);",
|
|
59023
|
+
" float dZ = 2.0;",
|
|
59024
|
+
" vec3 n = normalize(vec3(dX, dY, dZ));",
|
|
59025
|
+
|
|
59026
|
+
" gl_FragColor = vec4( n*0.5+0.5, 1.0 );",
|
|
59027
|
+
|
|
59028
|
+
"}"
|
|
58868
59029
|
|
|
58869
|
-
vec3 get(float x, float y){
|
|
58870
|
-
vec2 _uv = vUv.xy + vec2(x,y) / world_size;
|
|
58871
|
-
float h = texture2D(heightMap, _uv).x;
|
|
58872
|
-
return vec3( _uv.x * world_size.x, h, _uv.y * world_size.y );
|
|
58873
|
-
}
|
|
58874
|
-
|
|
58875
|
-
float hash1( float n )
|
|
58876
|
-
{
|
|
58877
|
-
return fract( n*17.0*fract( n*0.3183099 ) );
|
|
58878
|
-
}
|
|
58879
|
-
|
|
58880
|
-
float hash1( vec2 p )
|
|
58881
|
-
{
|
|
58882
|
-
p = 50.0*fract( p*0.3183099 );
|
|
58883
|
-
return fract( p.x*p.y*(p.x+p.y) );
|
|
58884
|
-
}
|
|
58885
|
-
|
|
58886
|
-
// Non-sin based hash function, fast and has good randomness
|
|
58887
|
-
float hash12(vec2 p){
|
|
58888
|
-
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
|
58889
|
-
p3 += dot(p3, p3.yzx + 33.33);
|
|
58890
|
-
return fract((p3.x + p3.y) * p3.z);
|
|
58891
|
-
}
|
|
58892
|
-
|
|
58893
|
-
const float bias = 0.001;
|
|
58894
|
-
|
|
58895
|
-
float pow2(float x){
|
|
58896
|
-
return x*x;
|
|
58897
|
-
}
|
|
58898
|
-
|
|
58899
|
-
float getOcclusion(vec3 origin, vec3 normal, vec3 hit_position){
|
|
58900
|
-
vec3 viewDelta = hit_position - origin;
|
|
58901
|
-
|
|
58902
|
-
float viewDistance = length( viewDelta );
|
|
58903
|
-
|
|
58904
|
-
float vn = dot( normal, viewDelta );
|
|
58905
|
-
float a2 = (vn) / viewDistance - bias;
|
|
58906
|
-
float a1 = (1.0 + pow2( viewDistance ) );
|
|
58907
|
-
|
|
58908
|
-
return max(0.0, a2) / a1;
|
|
58909
|
-
}
|
|
58910
|
-
|
|
58911
|
-
const float PI2 = 6.28318530717958;
|
|
58912
|
-
const float kernelRadius = 100.0;
|
|
58913
|
-
|
|
58914
|
-
const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );
|
|
58915
|
-
const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );
|
|
58916
|
-
|
|
58917
|
-
float getAmbientOcclusion(vec3 world_position, vec3 world_normal){
|
|
58918
|
-
// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
|
|
58919
|
-
float angle = hash12( vUv ) * PI2;
|
|
58920
|
-
vec2 radius = vec2( rayLength * INV_NUM_SAMPLES );
|
|
58921
|
-
|
|
58922
|
-
float occlusionSum = 0.0;
|
|
58923
|
-
float weightSum = 0.0;
|
|
58924
|
-
|
|
58925
|
-
for( int i = 0; i < NUM_SAMPLES; i ++ ) {
|
|
58926
|
-
vec2 sampleUv = vec2( cos( angle ), sin( angle ) ) * radius * float(i+1);
|
|
58927
|
-
|
|
58928
|
-
angle += ANGLE_STEP;
|
|
58929
|
-
|
|
58930
|
-
vec3 sample_pos = get(sampleUv.x, sampleUv.y);
|
|
58931
|
-
|
|
58932
|
-
occlusionSum += getOcclusion(world_position, world_normal, sample_pos);
|
|
58933
|
-
weightSum += 1.0;
|
|
58934
|
-
}
|
|
58935
|
-
|
|
58936
|
-
return occlusionSum/weightSum;
|
|
58937
|
-
}
|
|
58938
|
-
|
|
58939
|
-
void main() {
|
|
58940
|
-
vec3 pos = get(0.0, 0.0);
|
|
58941
|
-
|
|
58942
|
-
vec3 normal = texture2D( normalMap, vUv ).xzy;
|
|
58943
|
-
|
|
58944
|
-
float occlusion = getAmbientOcclusion(pos, normal);
|
|
58945
|
-
|
|
58946
|
-
float incident = 1.0 - occlusion;
|
|
58947
|
-
|
|
58948
|
-
gl_FragColor = vec4(pow(incident,10.0), 0.0, 0.0, 1.0);
|
|
58949
|
-
}
|
|
58950
|
-
`
|
|
58951
59030
|
].join('\n')
|
|
58952
59031
|
|
|
58953
59032
|
}
|
|
58954
59033
|
};
|
|
58955
59034
|
|
|
59035
|
+
const FULL_SCREEN_QUAD_VERTEX_SHADER = `
|
|
59036
|
+
varying vec2 vUv;
|
|
59037
|
+
|
|
59038
|
+
void main() {
|
|
59039
|
+
|
|
59040
|
+
vUv = uv;
|
|
59041
|
+
|
|
59042
|
+
gl_Position = vec4( (uv - 0.5)*2.0, 0.0, 1.0 );
|
|
59043
|
+
|
|
59044
|
+
}`;
|
|
59045
|
+
|
|
58956
59046
|
const FULL_SCREEN_TRIANGLE_GEOMETRY = new BufferGeometry();
|
|
58957
59047
|
FULL_SCREEN_TRIANGLE_GEOMETRY.setAttribute(
|
|
58958
59048
|
'position',
|
|
@@ -58970,17 +59060,6 @@ FULL_SCREEN_TRIANGLE_GEOMETRY.setAttribute(
|
|
|
58970
59060
|
)
|
|
58971
59061
|
);
|
|
58972
59062
|
|
|
58973
|
-
const FULL_SCREEN_QUAD_VERTEX_SHADER = `
|
|
58974
|
-
varying vec2 vUv;
|
|
58975
|
-
|
|
58976
|
-
void main() {
|
|
58977
|
-
|
|
58978
|
-
vUv = uv;
|
|
58979
|
-
|
|
58980
|
-
gl_Position = vec4( (uv - 0.5)*2.0, 0.0, 1.0 );
|
|
58981
|
-
|
|
58982
|
-
}`;
|
|
58983
|
-
|
|
58984
59063
|
/**
|
|
58985
59064
|
* Created by Alex on 09/11/2014.
|
|
58986
59065
|
*/
|
|
@@ -58992,7 +59071,7 @@ const FULL_SCREEN_QUAD_VERTEX_SHADER = `
|
|
|
58992
59071
|
* @param {number} width
|
|
58993
59072
|
* @param {number} height
|
|
58994
59073
|
* @param {{vertexShader?:string,fragmentShader:string, uniforms?:Object, defines?:Object}} processShader
|
|
58995
|
-
* @param {Uint8Array} [destination]
|
|
59074
|
+
* @param {Uint8Array|Uint8ClampedArray} [destination]
|
|
58996
59075
|
* @return {{array: Uint8Array, renderer: WebGLRenderer}}
|
|
58997
59076
|
*/
|
|
58998
59077
|
function processTexture(
|
|
@@ -59003,7 +59082,7 @@ function processTexture(
|
|
|
59003
59082
|
destination
|
|
59004
59083
|
) {
|
|
59005
59084
|
if (destination === undefined) {
|
|
59006
|
-
destination = new
|
|
59085
|
+
destination = new Uint8ClampedArray(width * height * 4);
|
|
59007
59086
|
}
|
|
59008
59087
|
|
|
59009
59088
|
//make a webgl renderer with orthographic camera
|
|
@@ -59173,6 +59252,207 @@ function sampler2DtoFloat32Texture(sampler) {
|
|
|
59173
59252
|
return texture;
|
|
59174
59253
|
}
|
|
59175
59254
|
|
|
59255
|
+
/**
|
|
59256
|
+
* Created by Alex on 15/11/2014.
|
|
59257
|
+
*/
|
|
59258
|
+
|
|
59259
|
+
|
|
59260
|
+
|
|
59261
|
+
function convertChannel(v) {
|
|
59262
|
+
return (v) / 255 - 0.5;
|
|
59263
|
+
}
|
|
59264
|
+
|
|
59265
|
+
/**
|
|
59266
|
+
*
|
|
59267
|
+
* @param {number[]|Uint8Array} source
|
|
59268
|
+
* @returns {Float32Array}
|
|
59269
|
+
*/
|
|
59270
|
+
function rgbaArray2RGB(source) {
|
|
59271
|
+
const length = source.length;
|
|
59272
|
+
const numPixels = Math.floor(length / 4);
|
|
59273
|
+
const target = new Float32Array(numPixels * 3);
|
|
59274
|
+
//
|
|
59275
|
+
let h;
|
|
59276
|
+
for (let i = 0; i < numPixels; i++) {
|
|
59277
|
+
const j = i * 4;
|
|
59278
|
+
const k = i * 3;
|
|
59279
|
+
//normalize source to normal vectors
|
|
59280
|
+
let x = convertChannel(source[j]);
|
|
59281
|
+
let y = convertChannel(source[j + 1]);
|
|
59282
|
+
let z = convertChannel(source[j + 2]);
|
|
59283
|
+
//
|
|
59284
|
+
h = Math.sqrt(x * x + y * y + z * z);
|
|
59285
|
+
|
|
59286
|
+
x /= h;
|
|
59287
|
+
y /= h;
|
|
59288
|
+
z /= h;
|
|
59289
|
+
//
|
|
59290
|
+
target[k] = x;
|
|
59291
|
+
target[k + 1] = y;
|
|
59292
|
+
target[k + 2] = z;
|
|
59293
|
+
}
|
|
59294
|
+
return target;
|
|
59295
|
+
}
|
|
59296
|
+
|
|
59297
|
+
/**
|
|
59298
|
+
*
|
|
59299
|
+
* @param {WebGLRenderer} renderer
|
|
59300
|
+
* @param {Sampler2D} sampler
|
|
59301
|
+
* @returns {Sampler2D}
|
|
59302
|
+
*/
|
|
59303
|
+
function heightMap2NormalMap(renderer, sampler) {
|
|
59304
|
+
|
|
59305
|
+
const width = sampler.width;
|
|
59306
|
+
const height = sampler.height;
|
|
59307
|
+
|
|
59308
|
+
const texture = sampler2DtoFloat32Texture(sampler);
|
|
59309
|
+
|
|
59310
|
+
//construct shader
|
|
59311
|
+
const shader = new NormalMapShader();
|
|
59312
|
+
shader.uniforms.heightMap.value = texture;
|
|
59313
|
+
shader.uniforms.resolution.value.set(width, height);
|
|
59314
|
+
|
|
59315
|
+
//perform filtering
|
|
59316
|
+
const result = processTexture(renderer, width, height, shader);
|
|
59317
|
+
|
|
59318
|
+
//create the sampler
|
|
59319
|
+
const array = result.array;
|
|
59320
|
+
const rgb = rgbaArray2RGB(array);
|
|
59321
|
+
|
|
59322
|
+
//reduce array's alpha component
|
|
59323
|
+
return new Sampler2D(rgb, 3, width, height);
|
|
59324
|
+
}
|
|
59325
|
+
|
|
59326
|
+
/**
|
|
59327
|
+
* Created by Alex on 10/11/2014.
|
|
59328
|
+
*/
|
|
59329
|
+
|
|
59330
|
+
const AmbientOcclusionShader = function () {
|
|
59331
|
+
return {
|
|
59332
|
+
|
|
59333
|
+
uniforms: {
|
|
59334
|
+
|
|
59335
|
+
"normalMap": { type: "t", value: null },
|
|
59336
|
+
"heightMap": { type: "t", value: null },
|
|
59337
|
+
"world_size": { type: "v2", value: new Vector2$1(512, 512) },
|
|
59338
|
+
"rayLength": { type: 'f', value: 17 }
|
|
59339
|
+
|
|
59340
|
+
},
|
|
59341
|
+
|
|
59342
|
+
defines: {
|
|
59343
|
+
'NUM_SAMPLES': 64,
|
|
59344
|
+
'NUM_RINGS': 7,
|
|
59345
|
+
},
|
|
59346
|
+
|
|
59347
|
+
vertexShader: [
|
|
59348
|
+
|
|
59349
|
+
"varying vec2 vUv;",
|
|
59350
|
+
|
|
59351
|
+
"void main() {",
|
|
59352
|
+
|
|
59353
|
+
"vUv = uv;",
|
|
59354
|
+
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
|
|
59355
|
+
|
|
59356
|
+
"}"
|
|
59357
|
+
|
|
59358
|
+
].join("\n"),
|
|
59359
|
+
|
|
59360
|
+
fragmentShader: [
|
|
59361
|
+
`
|
|
59362
|
+
uniform sampler2D normalMap;
|
|
59363
|
+
uniform sampler2D heightMap;
|
|
59364
|
+
uniform float rayLength;
|
|
59365
|
+
uniform vec2 world_size;
|
|
59366
|
+
|
|
59367
|
+
varying vec2 vUv;
|
|
59368
|
+
|
|
59369
|
+
vec3 get(float x, float y){
|
|
59370
|
+
vec2 _uv = vUv.xy + vec2(x,y) / world_size;
|
|
59371
|
+
float h = texture2D(heightMap, _uv).x;
|
|
59372
|
+
return vec3( _uv.x * world_size.x, h, _uv.y * world_size.y );
|
|
59373
|
+
}
|
|
59374
|
+
|
|
59375
|
+
float hash1( float n )
|
|
59376
|
+
{
|
|
59377
|
+
return fract( n*17.0*fract( n*0.3183099 ) );
|
|
59378
|
+
}
|
|
59379
|
+
|
|
59380
|
+
float hash1( vec2 p )
|
|
59381
|
+
{
|
|
59382
|
+
p = 50.0*fract( p*0.3183099 );
|
|
59383
|
+
return fract( p.x*p.y*(p.x+p.y) );
|
|
59384
|
+
}
|
|
59385
|
+
|
|
59386
|
+
// Non-sin based hash function, fast and has good randomness
|
|
59387
|
+
float hash12(vec2 p){
|
|
59388
|
+
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
|
59389
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
59390
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
59391
|
+
}
|
|
59392
|
+
|
|
59393
|
+
const float bias = 0.001;
|
|
59394
|
+
|
|
59395
|
+
float pow2(float x){
|
|
59396
|
+
return x*x;
|
|
59397
|
+
}
|
|
59398
|
+
|
|
59399
|
+
float getOcclusion(vec3 origin, vec3 normal, vec3 hit_position){
|
|
59400
|
+
vec3 viewDelta = hit_position - origin;
|
|
59401
|
+
|
|
59402
|
+
float viewDistance = length( viewDelta );
|
|
59403
|
+
|
|
59404
|
+
float vn = dot( normal, viewDelta );
|
|
59405
|
+
float a2 = (vn) / viewDistance - bias;
|
|
59406
|
+
float a1 = (1.0 + pow2( viewDistance ) );
|
|
59407
|
+
|
|
59408
|
+
return max(0.0, a2) / a1;
|
|
59409
|
+
}
|
|
59410
|
+
|
|
59411
|
+
const float PI2 = 6.28318530717958;
|
|
59412
|
+
const float kernelRadius = 100.0;
|
|
59413
|
+
|
|
59414
|
+
const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );
|
|
59415
|
+
const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );
|
|
59416
|
+
|
|
59417
|
+
float getAmbientOcclusion(vec3 world_position, vec3 world_normal){
|
|
59418
|
+
// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
|
|
59419
|
+
float angle = hash12( vUv ) * PI2;
|
|
59420
|
+
vec2 radius = vec2( rayLength * INV_NUM_SAMPLES );
|
|
59421
|
+
|
|
59422
|
+
float occlusionSum = 0.0;
|
|
59423
|
+
float weightSum = 0.0;
|
|
59424
|
+
|
|
59425
|
+
for( int i = 0; i < NUM_SAMPLES; i ++ ) {
|
|
59426
|
+
vec2 sampleUv = vec2( cos( angle ), sin( angle ) ) * radius * float(i+1);
|
|
59427
|
+
|
|
59428
|
+
angle += ANGLE_STEP;
|
|
59429
|
+
|
|
59430
|
+
vec3 sample_pos = get(sampleUv.x, sampleUv.y);
|
|
59431
|
+
|
|
59432
|
+
occlusionSum += getOcclusion(world_position, world_normal, sample_pos);
|
|
59433
|
+
weightSum += 1.0;
|
|
59434
|
+
}
|
|
59435
|
+
|
|
59436
|
+
return occlusionSum/weightSum;
|
|
59437
|
+
}
|
|
59438
|
+
|
|
59439
|
+
void main() {
|
|
59440
|
+
vec3 pos = get(0.0, 0.0);
|
|
59441
|
+
|
|
59442
|
+
vec3 normal = texture2D( normalMap, vUv ).xzy;
|
|
59443
|
+
|
|
59444
|
+
float occlusion = getAmbientOcclusion(pos, normal);
|
|
59445
|
+
|
|
59446
|
+
float incident = 1.0 - occlusion;
|
|
59447
|
+
|
|
59448
|
+
gl_FragColor = vec4(pow(incident,10.0), 0.0, 0.0, 1.0);
|
|
59449
|
+
}
|
|
59450
|
+
`
|
|
59451
|
+
].join('\n')
|
|
59452
|
+
|
|
59453
|
+
}
|
|
59454
|
+
};
|
|
59455
|
+
|
|
59176
59456
|
const KERNEL_SIZE = 15;
|
|
59177
59457
|
|
|
59178
59458
|
const fragment$1 = `
|
|
@@ -59370,219 +59650,6 @@ function normalMap2OcclusionMap(
|
|
|
59370
59650
|
return result;
|
|
59371
59651
|
}
|
|
59372
59652
|
|
|
59373
|
-
/**
|
|
59374
|
-
* Created by Alex on 10/11/2014.
|
|
59375
|
-
*/
|
|
59376
|
-
|
|
59377
|
-
|
|
59378
|
-
const NormalMapShader = function () {
|
|
59379
|
-
return {
|
|
59380
|
-
|
|
59381
|
-
uniforms: {
|
|
59382
|
-
|
|
59383
|
-
"heightMap": { type: "t", value: null },
|
|
59384
|
-
"resolution": { type: "v2", value: new Vector2$1(512, 512) }
|
|
59385
|
-
|
|
59386
|
-
},
|
|
59387
|
-
|
|
59388
|
-
vertexShader: [
|
|
59389
|
-
|
|
59390
|
-
"varying vec2 vUv;",
|
|
59391
|
-
|
|
59392
|
-
"void main() {",
|
|
59393
|
-
|
|
59394
|
-
"vUv = uv;",
|
|
59395
|
-
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
|
|
59396
|
-
|
|
59397
|
-
"}"
|
|
59398
|
-
|
|
59399
|
-
].join("\n"),
|
|
59400
|
-
|
|
59401
|
-
/**
|
|
59402
|
-
* Reference: https://stackoverflow.com/questions/49640250/calculate-normals-from-heightmap
|
|
59403
|
-
*/
|
|
59404
|
-
fragmentShader: [
|
|
59405
|
-
"uniform vec2 resolution;",
|
|
59406
|
-
"uniform sampler2D heightMap;",
|
|
59407
|
-
|
|
59408
|
-
"#define sqrt2 1.41421356237;",
|
|
59409
|
-
|
|
59410
|
-
"varying vec2 vUv;",
|
|
59411
|
-
|
|
59412
|
-
"void main() {",
|
|
59413
|
-
" float uStep = 1.0/resolution.x;",
|
|
59414
|
-
" float vStep = 1.0/resolution.y;",
|
|
59415
|
-
//
|
|
59416
|
-
//
|
|
59417
|
-
" float top = texture2D( heightMap, vUv + vec2(0, -vStep)).x;",
|
|
59418
|
-
" float bottom = texture2D( heightMap, vUv + vec2(0, +vStep)).x;",
|
|
59419
|
-
" float left = texture2D( heightMap, vUv + vec2(-uStep, 0)).x;",
|
|
59420
|
-
" float right = texture2D( heightMap, vUv + vec2(+uStep, 0)).x;",
|
|
59421
|
-
//
|
|
59422
|
-
|
|
59423
|
-
" float dX = (right ) - ( left);",
|
|
59424
|
-
" float dY = ( bottom ) - ( top);",
|
|
59425
|
-
" float dZ = 2.0;",
|
|
59426
|
-
" vec3 n = normalize(vec3(dX, dY, dZ));",
|
|
59427
|
-
|
|
59428
|
-
" gl_FragColor = vec4( n*0.5+0.5, 1.0 );",
|
|
59429
|
-
|
|
59430
|
-
"}"
|
|
59431
|
-
|
|
59432
|
-
].join('\n')
|
|
59433
|
-
|
|
59434
|
-
}
|
|
59435
|
-
};
|
|
59436
|
-
|
|
59437
|
-
/**
|
|
59438
|
-
* Created by Alex on 15/11/2014.
|
|
59439
|
-
*/
|
|
59440
|
-
|
|
59441
|
-
|
|
59442
|
-
|
|
59443
|
-
function convertChannel(v) {
|
|
59444
|
-
return (v) / 255 - 0.5;
|
|
59445
|
-
}
|
|
59446
|
-
|
|
59447
|
-
/**
|
|
59448
|
-
*
|
|
59449
|
-
* @param {number[]|Uint8Array} source
|
|
59450
|
-
* @returns {Float32Array}
|
|
59451
|
-
*/
|
|
59452
|
-
function rgbaArray2RGB(source) {
|
|
59453
|
-
const length = source.length;
|
|
59454
|
-
const numPixels = Math.floor(length / 4);
|
|
59455
|
-
const target = new Float32Array(numPixels * 3);
|
|
59456
|
-
//
|
|
59457
|
-
let h;
|
|
59458
|
-
for (let i = 0; i < numPixels; i++) {
|
|
59459
|
-
const j = i * 4;
|
|
59460
|
-
const k = i * 3;
|
|
59461
|
-
//normalize source to normal vectors
|
|
59462
|
-
let x = convertChannel(source[j]);
|
|
59463
|
-
let y = convertChannel(source[j + 1]);
|
|
59464
|
-
let z = convertChannel(source[j + 2]);
|
|
59465
|
-
//
|
|
59466
|
-
h = Math.sqrt(x * x + y * y + z * z);
|
|
59467
|
-
|
|
59468
|
-
x /= h;
|
|
59469
|
-
y /= h;
|
|
59470
|
-
z /= h;
|
|
59471
|
-
//
|
|
59472
|
-
target[k] = x;
|
|
59473
|
-
target[k + 1] = y;
|
|
59474
|
-
target[k + 2] = z;
|
|
59475
|
-
}
|
|
59476
|
-
return target;
|
|
59477
|
-
}
|
|
59478
|
-
|
|
59479
|
-
/**
|
|
59480
|
-
*
|
|
59481
|
-
* @param {WebGLRenderer} renderer
|
|
59482
|
-
* @param {Sampler2D} sampler
|
|
59483
|
-
* @returns {Sampler2D}
|
|
59484
|
-
*/
|
|
59485
|
-
function heightMap2NormalMap(renderer, sampler) {
|
|
59486
|
-
|
|
59487
|
-
const width = sampler.width;
|
|
59488
|
-
const height = sampler.height;
|
|
59489
|
-
|
|
59490
|
-
const texture = sampler2DtoFloat32Texture(sampler);
|
|
59491
|
-
|
|
59492
|
-
//construct shader
|
|
59493
|
-
const shader = new NormalMapShader();
|
|
59494
|
-
shader.uniforms.heightMap.value = texture;
|
|
59495
|
-
shader.uniforms.resolution.value.set(width, height);
|
|
59496
|
-
|
|
59497
|
-
//perform filtering
|
|
59498
|
-
const result = processTexture(renderer, width, height, shader);
|
|
59499
|
-
|
|
59500
|
-
//create the sampler
|
|
59501
|
-
const array = result.array;
|
|
59502
|
-
const rgb = rgbaArray2RGB(array);
|
|
59503
|
-
|
|
59504
|
-
//reduce array's alpha component
|
|
59505
|
-
return new Sampler2D(rgb, 3, width, height);
|
|
59506
|
-
}
|
|
59507
|
-
|
|
59508
|
-
class WebGLRendererPool {
|
|
59509
|
-
|
|
59510
|
-
used = new Set();
|
|
59511
|
-
|
|
59512
|
-
get(options) {
|
|
59513
|
-
const canvas = document.createElement('canvas');
|
|
59514
|
-
const context = canvas.getContext('webgl2', { antialias: true });
|
|
59515
|
-
|
|
59516
|
-
const renderer = new WebGLRenderer({
|
|
59517
|
-
alpha: true,
|
|
59518
|
-
context,
|
|
59519
|
-
canvas
|
|
59520
|
-
});
|
|
59521
|
-
|
|
59522
|
-
this.used.add(renderer);
|
|
59523
|
-
return renderer;
|
|
59524
|
-
}
|
|
59525
|
-
|
|
59526
|
-
/**
|
|
59527
|
-
*
|
|
59528
|
-
* @param {THREE.WebGLRenderer} renderer
|
|
59529
|
-
* @returns {boolean}
|
|
59530
|
-
*/
|
|
59531
|
-
release(renderer) {
|
|
59532
|
-
if (!this.used.has(renderer)) {
|
|
59533
|
-
//not from this pool
|
|
59534
|
-
return false;
|
|
59535
|
-
}
|
|
59536
|
-
this.used.delete(renderer);
|
|
59537
|
-
|
|
59538
|
-
renderer.forceContextLoss();
|
|
59539
|
-
renderer.dispose();
|
|
59540
|
-
renderer.domElement = null;
|
|
59541
|
-
|
|
59542
|
-
return true;
|
|
59543
|
-
}
|
|
59544
|
-
|
|
59545
|
-
static global = new WebGLRendererPool();
|
|
59546
|
-
}
|
|
59547
|
-
|
|
59548
|
-
/**
|
|
59549
|
-
*
|
|
59550
|
-
* @param {Sampler2D} sampler
|
|
59551
|
-
* @param {THREE.DataTexture} texture
|
|
59552
|
-
*/
|
|
59553
|
-
function writeSample2DDataToDataTexture(sampler, texture) {
|
|
59554
|
-
if (sampler.itemSize === 1) {
|
|
59555
|
-
if (texture.format !== RedFormat && texture.format !== LuminanceFormat) {
|
|
59556
|
-
throw new Error('itemSize is 1 and texture.format is not RedFormat');
|
|
59557
|
-
}
|
|
59558
|
-
} else if (sampler.itemSize === 2) {
|
|
59559
|
-
if (texture.format !== RGFormat) {
|
|
59560
|
-
throw new Error('itemSize is 2 and texture.format is not RGFormat');
|
|
59561
|
-
}
|
|
59562
|
-
} else if (sampler.itemSize === 3) {
|
|
59563
|
-
if (texture.format !== RGBFormat) {
|
|
59564
|
-
throw new Error('itemSize is 2 and texture.format is not RGBFormat');
|
|
59565
|
-
}
|
|
59566
|
-
} else if (sampler.itemSize === 4) {
|
|
59567
|
-
if (texture.format !== RGBAFormat) {
|
|
59568
|
-
throw new Error('itemSize is 2 and texture.format is not RGBAFormat');
|
|
59569
|
-
}
|
|
59570
|
-
} else {
|
|
59571
|
-
throw new Error('Unsupported itemSize');
|
|
59572
|
-
}
|
|
59573
|
-
|
|
59574
|
-
if (texture.image.data !== sampler.data) {
|
|
59575
|
-
// dispose of previous texture data
|
|
59576
|
-
texture.dispose();
|
|
59577
|
-
}
|
|
59578
|
-
|
|
59579
|
-
texture.image.data = sampler.data;
|
|
59580
|
-
texture.image.width = sampler.width;
|
|
59581
|
-
texture.image.height = sampler.height;
|
|
59582
|
-
|
|
59583
|
-
texture.needsUpdate = true;
|
|
59584
|
-
}
|
|
59585
|
-
|
|
59586
59653
|
/**
|
|
59587
59654
|
*
|
|
59588
59655
|
* @param {WebGLRenderer} renderer
|
|
@@ -59651,32 +59718,25 @@ function promiseSamplerAO(
|
|
|
59651
59718
|
function buildLightTexture({
|
|
59652
59719
|
texture,
|
|
59653
59720
|
heightSampler,
|
|
59654
|
-
resolution= new Vector2(texture.image.width, texture.image.height),
|
|
59721
|
+
resolution = new Vector2(texture.image.width, texture.image.height),
|
|
59655
59722
|
rayLength = 11,
|
|
59656
59723
|
worldSize = resolution
|
|
59657
59724
|
}) {
|
|
59658
59725
|
|
|
59659
|
-
|
|
59726
|
+
return WebGLRendererPool.global.useAsync(async renderer => {
|
|
59727
|
+
const normal = promiseSamplerNormal(renderer, heightSampler);
|
|
59660
59728
|
|
|
59661
|
-
|
|
59662
|
-
|
|
59663
|
-
|
|
59664
|
-
|
|
59665
|
-
|
|
59666
|
-
|
|
59667
|
-
|
|
59668
|
-
|
|
59669
|
-
});
|
|
59670
|
-
|
|
59671
|
-
const promise = ao.then(sampler => {
|
|
59672
|
-
writeSample2DDataToDataTexture(sampler, texture);
|
|
59673
|
-
});
|
|
59729
|
+
const ao = await promiseSamplerAO({
|
|
59730
|
+
renderer: renderer,
|
|
59731
|
+
pSamplerNormal: normal,
|
|
59732
|
+
samplerHeight: heightSampler,
|
|
59733
|
+
resolution: resolution,
|
|
59734
|
+
rayLength: rayLength,
|
|
59735
|
+
worldSize
|
|
59736
|
+
});
|
|
59674
59737
|
|
|
59675
|
-
|
|
59676
|
-
WebGLRendererPool.global.release(renderer);
|
|
59738
|
+
writeSample2DDataToDataTexture(ao, texture);
|
|
59677
59739
|
});
|
|
59678
|
-
|
|
59679
|
-
return promise;
|
|
59680
59740
|
}
|
|
59681
59741
|
|
|
59682
59742
|
const GridTransformKind = {
|
|
@@ -59765,7 +59825,7 @@ function invokeObjectHash(object) {
|
|
|
59765
59825
|
* @param {number} index0
|
|
59766
59826
|
* @param {number} index1
|
|
59767
59827
|
*/
|
|
59768
|
-
function
|
|
59828
|
+
function array_swap_one(array, index0, index1) {
|
|
59769
59829
|
const t = array[index0];
|
|
59770
59830
|
|
|
59771
59831
|
array[index0] = array[index1];
|
|
@@ -59819,7 +59879,7 @@ function generate_next_linear_congruential_index(index, mask) {
|
|
|
59819
59879
|
/**
|
|
59820
59880
|
* @template K,V
|
|
59821
59881
|
*/
|
|
59822
|
-
class
|
|
59882
|
+
class HashMapEntry {
|
|
59823
59883
|
/**
|
|
59824
59884
|
*
|
|
59825
59885
|
* @param {K} key
|
|
@@ -59907,7 +59967,7 @@ const UNDEFINED_BIN_INDEX = ~0;
|
|
|
59907
59967
|
|
|
59908
59968
|
/**
|
|
59909
59969
|
* @template K,V
|
|
59910
|
-
* @param {
|
|
59970
|
+
* @param {HashMapEntry<K,V>} record
|
|
59911
59971
|
* @param {number} hash
|
|
59912
59972
|
* @param {K} key
|
|
59913
59973
|
* @param {function(a:K,b:K):boolean} equality_op
|
|
@@ -59947,7 +60007,7 @@ class HashMap {
|
|
|
59947
60007
|
|
|
59948
60008
|
/**
|
|
59949
60009
|
* Note that dead entries are marked as such with a special reserved hash values, so records can be reused for new entries
|
|
59950
|
-
* @type {Array<
|
|
60010
|
+
* @type {Array<HashMapEntry<K,V>>}
|
|
59951
60011
|
*/
|
|
59952
60012
|
#entries = new Array(0);
|
|
59953
60013
|
|
|
@@ -60125,7 +60185,7 @@ class HashMap {
|
|
|
60125
60185
|
entry.key = k;
|
|
60126
60186
|
entry.value = v;
|
|
60127
60187
|
} else {
|
|
60128
|
-
this.#entries[i] = new
|
|
60188
|
+
this.#entries[i] = new HashMapEntry(k, v, hash);
|
|
60129
60189
|
}
|
|
60130
60190
|
|
|
60131
60191
|
return i;
|
|
@@ -60133,7 +60193,7 @@ class HashMap {
|
|
|
60133
60193
|
|
|
60134
60194
|
/**
|
|
60135
60195
|
*
|
|
60136
|
-
* @param {
|
|
60196
|
+
* @param {HashMapEntry<K,V>} entry
|
|
60137
60197
|
*/
|
|
60138
60198
|
#deallocate(entry) {
|
|
60139
60199
|
|
|
@@ -60390,7 +60450,7 @@ class HashMap {
|
|
|
60390
60450
|
}
|
|
60391
60451
|
|
|
60392
60452
|
/**
|
|
60393
|
-
* @type {
|
|
60453
|
+
* @type {HashMapEntry<K,V>}
|
|
60394
60454
|
*/
|
|
60395
60455
|
const entry = this.#entries[bin - ENTRY_BASE];
|
|
60396
60456
|
|
|
@@ -60441,7 +60501,7 @@ class HashMap {
|
|
|
60441
60501
|
|
|
60442
60502
|
if (new_index !== existing_entry_index) {
|
|
60443
60503
|
// move entries to the new position, compacting holes
|
|
60444
|
-
|
|
60504
|
+
array_swap_one(entries, new_index, existing_entry_index);
|
|
60445
60505
|
}
|
|
60446
60506
|
|
|
60447
60507
|
let bin_index = this.#compute_bin_index(hash);
|
|
@@ -60495,7 +60555,7 @@ class HashMap {
|
|
|
60495
60555
|
}
|
|
60496
60556
|
|
|
60497
60557
|
/**
|
|
60498
|
-
* @type {
|
|
60558
|
+
* @type {HashMapEntry<K,V>}
|
|
60499
60559
|
*/
|
|
60500
60560
|
const entry = entries[bin - ENTRY_BASE];
|
|
60501
60561
|
|
|
@@ -60566,7 +60626,7 @@ class HashMap {
|
|
|
60566
60626
|
}
|
|
60567
60627
|
|
|
60568
60628
|
/**
|
|
60569
|
-
* @type {
|
|
60629
|
+
* @type {HashMapEntry<K,V>}
|
|
60570
60630
|
*/
|
|
60571
60631
|
const entry = entries[bin - ENTRY_BASE];
|
|
60572
60632
|
|
|
@@ -67264,6 +67324,37 @@ function computeFileExtension(path) {
|
|
|
67264
67324
|
}
|
|
67265
67325
|
}
|
|
67266
67326
|
|
|
67327
|
+
/**
|
|
67328
|
+
* @param {Uint8Array} input
|
|
67329
|
+
* @param {number} width
|
|
67330
|
+
* @param {number} height
|
|
67331
|
+
* @param {number} channel_count
|
|
67332
|
+
*/
|
|
67333
|
+
function flipArrayInPlace(input, width, height, channel_count = 4) {
|
|
67334
|
+
const row_size = width * channel_count;
|
|
67335
|
+
let t, x0, x1;
|
|
67336
|
+
let i = 0;
|
|
67337
|
+
const column_count = height >> 1;
|
|
67338
|
+
|
|
67339
|
+
for (; i < column_count; i++) {
|
|
67340
|
+
|
|
67341
|
+
//swap lines
|
|
67342
|
+
const k = (height - i - 1) * row_size;
|
|
67343
|
+
const m = i * row_size;
|
|
67344
|
+
|
|
67345
|
+
for (let j = 0; j < row_size; j++) {
|
|
67346
|
+
x0 = m + j;
|
|
67347
|
+
x1 = k + j;
|
|
67348
|
+
|
|
67349
|
+
t = input[x0];
|
|
67350
|
+
|
|
67351
|
+
input[x0] = input[x1];
|
|
67352
|
+
input[x1] = t;
|
|
67353
|
+
}
|
|
67354
|
+
|
|
67355
|
+
}
|
|
67356
|
+
}
|
|
67357
|
+
|
|
67267
67358
|
/**
|
|
67268
67359
|
* @author alteredq / http://alteredqualia.com/
|
|
67269
67360
|
*
|
|
@@ -67310,37 +67401,6 @@ const CopyShader = {
|
|
|
67310
67401
|
|
|
67311
67402
|
};
|
|
67312
67403
|
|
|
67313
|
-
/**
|
|
67314
|
-
* @param {Uint8Array} input
|
|
67315
|
-
* @param {number} width
|
|
67316
|
-
* @param {number} height
|
|
67317
|
-
* @param {number} channel_count
|
|
67318
|
-
*/
|
|
67319
|
-
function flipArrayInPlace(input, width, height, channel_count = 4) {
|
|
67320
|
-
const row_size = width * channel_count;
|
|
67321
|
-
let t, x0, x1;
|
|
67322
|
-
let i = 0;
|
|
67323
|
-
const column_count = height >> 1;
|
|
67324
|
-
|
|
67325
|
-
for (; i < column_count; i++) {
|
|
67326
|
-
|
|
67327
|
-
//swap lines
|
|
67328
|
-
const k = (height - i - 1) * row_size;
|
|
67329
|
-
const m = i * row_size;
|
|
67330
|
-
|
|
67331
|
-
for (let j = 0; j < row_size; j++) {
|
|
67332
|
-
x0 = m + j;
|
|
67333
|
-
x1 = k + j;
|
|
67334
|
-
|
|
67335
|
-
t = input[x0];
|
|
67336
|
-
|
|
67337
|
-
input[x0] = input[x1];
|
|
67338
|
-
input[x1] = t;
|
|
67339
|
-
}
|
|
67340
|
-
|
|
67341
|
-
}
|
|
67342
|
-
}
|
|
67343
|
-
|
|
67344
67404
|
const DEFAULT_TEXTURE_WIDTH = 512;
|
|
67345
67405
|
const DEFAULT_TEXTURE_HEIGHT = 512;
|
|
67346
67406
|
|
|
@@ -67349,39 +67409,47 @@ const DEFAULT_TEXTURE_HEIGHT = 512;
|
|
|
67349
67409
|
* @param {Texture} texture
|
|
67350
67410
|
* @param {number} [width]
|
|
67351
67411
|
* @param {number} [height]
|
|
67352
|
-
* @param {boolean} flipY
|
|
67412
|
+
* @param {boolean} [flipY]
|
|
67353
67413
|
* @return {Sampler2D}
|
|
67354
67414
|
*/
|
|
67355
|
-
function convertTexture2Sampler2D(
|
|
67415
|
+
function convertTexture2Sampler2D(
|
|
67416
|
+
texture,
|
|
67417
|
+
width,
|
|
67418
|
+
height,
|
|
67419
|
+
flipY = true
|
|
67420
|
+
) {
|
|
67421
|
+
let _height = height;
|
|
67422
|
+
let _width = width;
|
|
67423
|
+
|
|
67356
67424
|
// TODO take channel count into account
|
|
67357
67425
|
|
|
67358
|
-
if (
|
|
67426
|
+
if (_width === undefined || _height === undefined) {
|
|
67359
67427
|
|
|
67360
67428
|
//figure out texture size
|
|
67361
67429
|
const image = texture.image;
|
|
67362
67430
|
|
|
67363
67431
|
if (image !== undefined && image !== null) {
|
|
67364
|
-
if (
|
|
67432
|
+
if (_width === undefined) {
|
|
67365
67433
|
if (typeof image.width === "number") {
|
|
67366
|
-
|
|
67434
|
+
_width = image.width;
|
|
67367
67435
|
} else {
|
|
67368
|
-
|
|
67436
|
+
_width = DEFAULT_TEXTURE_WIDTH;
|
|
67369
67437
|
}
|
|
67370
67438
|
}
|
|
67371
|
-
if (
|
|
67439
|
+
if (_height === undefined) {
|
|
67372
67440
|
if (typeof image.height === "number") {
|
|
67373
|
-
|
|
67441
|
+
_height = image.height;
|
|
67374
67442
|
} else {
|
|
67375
|
-
|
|
67443
|
+
_height = DEFAULT_TEXTURE_HEIGHT;
|
|
67376
67444
|
}
|
|
67377
67445
|
}
|
|
67378
67446
|
} else {
|
|
67379
|
-
if (
|
|
67380
|
-
|
|
67447
|
+
if (_width === undefined) {
|
|
67448
|
+
_width = DEFAULT_TEXTURE_WIDTH;
|
|
67381
67449
|
}
|
|
67382
67450
|
|
|
67383
|
-
if (
|
|
67384
|
-
|
|
67451
|
+
if (_height === undefined) {
|
|
67452
|
+
_height = DEFAULT_TEXTURE_HEIGHT;
|
|
67385
67453
|
}
|
|
67386
67454
|
}
|
|
67387
67455
|
|
|
@@ -67389,34 +67457,32 @@ function convertTexture2Sampler2D(texture, width, height, flipY = true) {
|
|
|
67389
67457
|
|
|
67390
67458
|
// TODO add special case for DataTexture
|
|
67391
67459
|
|
|
67392
|
-
const
|
|
67460
|
+
const built = WebGLRendererPool.global.use(renderer => {
|
|
67393
67461
|
|
|
67394
|
-
|
|
67462
|
+
const ctx = renderer.getContext();
|
|
67395
67463
|
|
|
67396
|
-
|
|
67397
|
-
|
|
67464
|
+
//support for compressed textures
|
|
67465
|
+
ctx.getExtension("WEBGL_compressed_texture_s3tc");
|
|
67398
67466
|
|
|
67399
|
-
|
|
67400
|
-
|
|
67401
|
-
|
|
67402
|
-
|
|
67403
|
-
|
|
67404
|
-
|
|
67405
|
-
|
|
67406
|
-
|
|
67407
|
-
|
|
67408
|
-
|
|
67409
|
-
|
|
67467
|
+
return processTexture(renderer, _width, _height, {
|
|
67468
|
+
vertexShader: CopyShader.vertexShader,
|
|
67469
|
+
fragmentShader: CopyShader.fragmentShader,
|
|
67470
|
+
uniforms: {
|
|
67471
|
+
tDiffuse: {
|
|
67472
|
+
value: texture,
|
|
67473
|
+
type: 't'
|
|
67474
|
+
},
|
|
67475
|
+
opacity: { value: 1.0 }
|
|
67476
|
+
}
|
|
67477
|
+
});
|
|
67410
67478
|
|
|
67411
|
-
|
|
67479
|
+
});
|
|
67412
67480
|
|
|
67413
67481
|
if (flipY) {
|
|
67414
|
-
flipArrayInPlace(built.array,
|
|
67482
|
+
flipArrayInPlace(built.array, _width, _height);
|
|
67415
67483
|
}
|
|
67416
67484
|
|
|
67417
|
-
|
|
67418
|
-
|
|
67419
|
-
return sampler;
|
|
67485
|
+
return new Sampler2D(built.array, 4, _width, _height);
|
|
67420
67486
|
}
|
|
67421
67487
|
|
|
67422
67488
|
/**
|
|
@@ -69047,10 +69113,14 @@ class Camera {
|
|
|
69047
69113
|
* @param {Camera|THREE.PerspectiveCamera|THREE.OrthographicCamera} camera
|
|
69048
69114
|
* @param {number} x
|
|
69049
69115
|
* @param {number} y
|
|
69050
|
-
* @param {Vector3}
|
|
69051
|
-
* @param {Vector3}
|
|
69116
|
+
* @param {Vector3} out_source
|
|
69117
|
+
* @param {Vector3} out_direction
|
|
69052
69118
|
*/
|
|
69053
|
-
static projectRay(
|
|
69119
|
+
static projectRay(
|
|
69120
|
+
camera,
|
|
69121
|
+
x, y,
|
|
69122
|
+
out_source, out_direction
|
|
69123
|
+
) {
|
|
69054
69124
|
|
|
69055
69125
|
// assert.ok(x >= -1, `X(=${x}) must be greater than or equal to -1.0, not a clip-space coordinate`);
|
|
69056
69126
|
// assert.ok(x <= 1, `X(=${x}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
@@ -69059,7 +69129,10 @@ class Camera {
|
|
|
69059
69129
|
// assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
|
|
69060
69130
|
|
|
69061
69131
|
if (camera.isPerspectiveCamera || camera.isOrthographicCamera) {
|
|
69062
|
-
|
|
69132
|
+
const m4_world = camera.matrixWorld.elements;
|
|
69133
|
+
const m4_projection_inverse = camera.projectionMatrixInverse.elements;
|
|
69134
|
+
|
|
69135
|
+
scratch_v3_1.setFromMatrixPosition(m4_world);
|
|
69063
69136
|
|
|
69064
69137
|
scratch_v3_0.set(x, y, 0.5);
|
|
69065
69138
|
|
|
@@ -69068,16 +69141,16 @@ class Camera {
|
|
|
69068
69141
|
unprojectPoint(
|
|
69069
69142
|
scratch_v3_0,
|
|
69070
69143
|
scratch_v3_0,
|
|
69071
|
-
|
|
69072
|
-
|
|
69144
|
+
m4_projection_inverse,
|
|
69145
|
+
m4_world
|
|
69073
69146
|
);
|
|
69074
69147
|
|
|
69075
69148
|
//get direction
|
|
69076
69149
|
scratch_v3_0.sub(scratch_v3_1);
|
|
69077
69150
|
scratch_v3_0.normalize();
|
|
69078
69151
|
|
|
69079
|
-
|
|
69080
|
-
|
|
69152
|
+
out_source.copy(scratch_v3_1);
|
|
69153
|
+
out_direction.copy(scratch_v3_0);
|
|
69081
69154
|
|
|
69082
69155
|
} else {
|
|
69083
69156
|
throw new Error('Unsupported camera type');
|
|
@@ -74588,7 +74661,7 @@ function arrayQuickSort(
|
|
|
74588
74661
|
data,
|
|
74589
74662
|
score_function, score_function_context,
|
|
74590
74663
|
start, end,
|
|
74591
|
-
swap_operator =
|
|
74664
|
+
swap_operator = array_swap_one, swap_context = undefined
|
|
74592
74665
|
) {
|
|
74593
74666
|
if (start >= end) {
|
|
74594
74667
|
// section of 0 size, nothing to sort
|
|
@@ -81313,6 +81386,7 @@ class Token {
|
|
|
81313
81386
|
* @param {T} type
|
|
81314
81387
|
*/
|
|
81315
81388
|
constructor(value, start, end, name, type) {
|
|
81389
|
+
|
|
81316
81390
|
/**
|
|
81317
81391
|
* @readonly
|
|
81318
81392
|
* @type {V}
|
|
@@ -81362,8 +81436,7 @@ class Token {
|
|
|
81362
81436
|
* @return {number}
|
|
81363
81437
|
*/
|
|
81364
81438
|
hash() {
|
|
81365
|
-
|
|
81366
|
-
return 0;
|
|
81439
|
+
return this.start ^ (this.end << 16);
|
|
81367
81440
|
}
|
|
81368
81441
|
}
|
|
81369
81442
|
|
|
@@ -81379,10 +81452,71 @@ const TooltipTokenType = {
|
|
|
81379
81452
|
ReferenceValue: 4,
|
|
81380
81453
|
};
|
|
81381
81454
|
|
|
81382
|
-
|
|
81383
|
-
|
|
81384
|
-
|
|
81385
|
-
|
|
81455
|
+
/**
|
|
81456
|
+
* Repeat a given piece of text a {@link count} times
|
|
81457
|
+
* @example "ABC_" repeated 2 times results in "ABC_ABC_"
|
|
81458
|
+
* @param {string} what
|
|
81459
|
+
* @param {number} count
|
|
81460
|
+
* @return {string}
|
|
81461
|
+
*/
|
|
81462
|
+
function string_repeat(what, count) {
|
|
81463
|
+
|
|
81464
|
+
if (count <= 0) {
|
|
81465
|
+
// special case
|
|
81466
|
+
return "";
|
|
81467
|
+
}
|
|
81468
|
+
|
|
81469
|
+
let out = what;
|
|
81470
|
+
|
|
81471
|
+
for (let i = 1; i < count; i++) {
|
|
81472
|
+
out += what;
|
|
81473
|
+
}
|
|
81474
|
+
|
|
81475
|
+
return out;
|
|
81476
|
+
}
|
|
81477
|
+
|
|
81478
|
+
class ParserError extends Error {
|
|
81479
|
+
/**
|
|
81480
|
+
*
|
|
81481
|
+
* @param {number} position
|
|
81482
|
+
* @param {string} message
|
|
81483
|
+
* @param {string} input
|
|
81484
|
+
*/
|
|
81485
|
+
constructor(
|
|
81486
|
+
position,
|
|
81487
|
+
message,
|
|
81488
|
+
input
|
|
81489
|
+
) {
|
|
81490
|
+
|
|
81491
|
+
super();
|
|
81492
|
+
|
|
81493
|
+
this.position = position;
|
|
81494
|
+
this.message = message;
|
|
81495
|
+
this.input = input;
|
|
81496
|
+
}
|
|
81497
|
+
|
|
81498
|
+
getDetails() {
|
|
81499
|
+
const input = this.input;
|
|
81500
|
+
const position = this.position;
|
|
81501
|
+
|
|
81502
|
+
// get snippet around where the problem has occurred
|
|
81503
|
+
const input_start = max2(0, position - 10);
|
|
81504
|
+
|
|
81505
|
+
const input_end = min2(input.length, position + 10);
|
|
81506
|
+
|
|
81507
|
+
const snippet = input.slice(input_start, input_end);
|
|
81508
|
+
|
|
81509
|
+
const offset_into_snippet = position - input_start;
|
|
81510
|
+
|
|
81511
|
+
// a piece of text with marker to show where the error occurs
|
|
81512
|
+
const arrow_text = string_repeat(" ", offset_into_snippet) + "^";
|
|
81513
|
+
|
|
81514
|
+
return snippet + "\n" + arrow_text;
|
|
81515
|
+
}
|
|
81516
|
+
|
|
81517
|
+
toString() {
|
|
81518
|
+
return `[ParseError] ${this.message}. Error at position ${this.position} near:\n${this.getDetails()}`
|
|
81519
|
+
}
|
|
81386
81520
|
}
|
|
81387
81521
|
|
|
81388
81522
|
/**
|
|
@@ -81478,28 +81612,6 @@ class KeyValuePair {
|
|
|
81478
81612
|
}
|
|
81479
81613
|
}
|
|
81480
81614
|
|
|
81481
|
-
/**
|
|
81482
|
-
*
|
|
81483
|
-
* @param {string} text
|
|
81484
|
-
* @param {number} cursor
|
|
81485
|
-
* @param {number} length
|
|
81486
|
-
* @returns {number}
|
|
81487
|
-
*/
|
|
81488
|
-
function skipWhitespace(text, cursor, length) {
|
|
81489
|
-
let i = cursor;
|
|
81490
|
-
let char;
|
|
81491
|
-
while (i < length) {
|
|
81492
|
-
char = text.charAt(i);
|
|
81493
|
-
|
|
81494
|
-
if (char === ' ' || char === '\n' || char === '\t') {
|
|
81495
|
-
i++;
|
|
81496
|
-
} else {
|
|
81497
|
-
break;
|
|
81498
|
-
}
|
|
81499
|
-
}
|
|
81500
|
-
return i;
|
|
81501
|
-
}
|
|
81502
|
-
|
|
81503
81615
|
/**
|
|
81504
81616
|
*
|
|
81505
81617
|
* @enum {string}
|
|
@@ -81514,7 +81626,7 @@ const DataType = {
|
|
|
81514
81626
|
};
|
|
81515
81627
|
|
|
81516
81628
|
/**
|
|
81517
|
-
* @enum {
|
|
81629
|
+
* @enum {string}
|
|
81518
81630
|
*/
|
|
81519
81631
|
const TokenType = {
|
|
81520
81632
|
LiteralString: "literal-string",
|
|
@@ -81532,6 +81644,7 @@ const TokenType = {
|
|
|
81532
81644
|
* @returns {Token}
|
|
81533
81645
|
*/
|
|
81534
81646
|
function readBooleanToken(text, cursor, length) {
|
|
81647
|
+
|
|
81535
81648
|
const firstChar = text.charAt(cursor);
|
|
81536
81649
|
|
|
81537
81650
|
let value;
|
|
@@ -81558,96 +81671,6 @@ function readBooleanToken(text, cursor, length) {
|
|
|
81558
81671
|
return new Token(value, cursor, end, TokenType.LiteralBoolean, DataType.Boolean);
|
|
81559
81672
|
}
|
|
81560
81673
|
|
|
81561
|
-
/**
|
|
81562
|
-
*
|
|
81563
|
-
* @param {string} text
|
|
81564
|
-
* @param {number} cursor
|
|
81565
|
-
* @returns {string}
|
|
81566
|
-
*/
|
|
81567
|
-
function readQuote(text, cursor) {
|
|
81568
|
-
const char = text.charAt(cursor);
|
|
81569
|
-
|
|
81570
|
-
if (char !== '"' && char !== '\'') {
|
|
81571
|
-
throw new ParserError(cursor, "Expected \", found " + char + " instead", text);
|
|
81572
|
-
}
|
|
81573
|
-
|
|
81574
|
-
return char;
|
|
81575
|
-
}
|
|
81576
|
-
|
|
81577
|
-
/**
|
|
81578
|
-
*
|
|
81579
|
-
* @param {string} text
|
|
81580
|
-
* @param {number} cursor
|
|
81581
|
-
* @param {number} length
|
|
81582
|
-
* @returns {Token}
|
|
81583
|
-
*/
|
|
81584
|
-
function readStringToken(text, cursor, length) {
|
|
81585
|
-
let i = cursor;
|
|
81586
|
-
|
|
81587
|
-
const openingQuote = readQuote(text, i);
|
|
81588
|
-
|
|
81589
|
-
i++;
|
|
81590
|
-
|
|
81591
|
-
let char;
|
|
81592
|
-
|
|
81593
|
-
let value = '';
|
|
81594
|
-
const lastPossibleChar = length - 1;
|
|
81595
|
-
|
|
81596
|
-
for (; i < lastPossibleChar; i++) {
|
|
81597
|
-
char = text.charAt(i);
|
|
81598
|
-
|
|
81599
|
-
if (char === '\\') {
|
|
81600
|
-
i++;
|
|
81601
|
-
//read escape sequence
|
|
81602
|
-
char = text.charAt(i);
|
|
81603
|
-
|
|
81604
|
-
switch (char) {
|
|
81605
|
-
case 'n':
|
|
81606
|
-
value += '\n';
|
|
81607
|
-
break;
|
|
81608
|
-
case 't':
|
|
81609
|
-
value += '\t';
|
|
81610
|
-
break;
|
|
81611
|
-
case 'r':
|
|
81612
|
-
value += '\r';
|
|
81613
|
-
break;
|
|
81614
|
-
case 'b':
|
|
81615
|
-
value += '\b';
|
|
81616
|
-
break;
|
|
81617
|
-
case 'f':
|
|
81618
|
-
value += '\f';
|
|
81619
|
-
break;
|
|
81620
|
-
case 'v':
|
|
81621
|
-
value += '\v';
|
|
81622
|
-
break;
|
|
81623
|
-
case '0':
|
|
81624
|
-
value += '\0';
|
|
81625
|
-
break;
|
|
81626
|
-
case '\\':
|
|
81627
|
-
case "'":
|
|
81628
|
-
case '"':
|
|
81629
|
-
default:
|
|
81630
|
-
value += char;
|
|
81631
|
-
break;
|
|
81632
|
-
}
|
|
81633
|
-
} else if (char !== openingQuote) {
|
|
81634
|
-
value += char;
|
|
81635
|
-
} else {
|
|
81636
|
-
break;
|
|
81637
|
-
}
|
|
81638
|
-
}
|
|
81639
|
-
|
|
81640
|
-
char = text.charAt(i);
|
|
81641
|
-
|
|
81642
|
-
if (char !== openingQuote) {
|
|
81643
|
-
throw new ParserError(cursor, "Expected string terminator : " + openingQuote + ", but found '" + char + "' instead", text);
|
|
81644
|
-
}
|
|
81645
|
-
|
|
81646
|
-
i++;
|
|
81647
|
-
|
|
81648
|
-
return new Token(value, cursor, i, TokenType.LiteralString, DataType.String);
|
|
81649
|
-
}
|
|
81650
|
-
|
|
81651
81674
|
/**
|
|
81652
81675
|
*
|
|
81653
81676
|
* @param {string} text
|
|
@@ -81656,6 +81679,7 @@ function readStringToken(text, cursor, length) {
|
|
|
81656
81679
|
* @returns {Token}
|
|
81657
81680
|
*/
|
|
81658
81681
|
function readHexToken(text, cursor, length) {
|
|
81682
|
+
|
|
81659
81683
|
const c0 = text.charAt(cursor);
|
|
81660
81684
|
const c1 = text.charAt(cursor + 1);
|
|
81661
81685
|
|
|
@@ -81737,7 +81761,7 @@ function readHexToken(text, cursor, length) {
|
|
|
81737
81761
|
}
|
|
81738
81762
|
|
|
81739
81763
|
|
|
81740
|
-
return new Token(value, cursor, i,
|
|
81764
|
+
return new Token(value, cursor, i, "uint", DataType.Number);
|
|
81741
81765
|
}
|
|
81742
81766
|
|
|
81743
81767
|
/**
|
|
@@ -81748,6 +81772,7 @@ function readHexToken(text, cursor, length) {
|
|
|
81748
81772
|
* @returns {Token}
|
|
81749
81773
|
*/
|
|
81750
81774
|
function readUnsignedIntegerToken(text, cursor, length) {
|
|
81775
|
+
|
|
81751
81776
|
let i = cursor;
|
|
81752
81777
|
|
|
81753
81778
|
let value = 0;
|
|
@@ -81799,7 +81824,32 @@ function readUnsignedIntegerToken(text, cursor, length) {
|
|
|
81799
81824
|
}
|
|
81800
81825
|
|
|
81801
81826
|
|
|
81802
|
-
return new Token(value, cursor, i,
|
|
81827
|
+
return new Token(value, cursor, i, "uint", DataType.Number);
|
|
81828
|
+
}
|
|
81829
|
+
|
|
81830
|
+
/**
|
|
81831
|
+
*
|
|
81832
|
+
* @param {string} text
|
|
81833
|
+
* @param {number} cursor
|
|
81834
|
+
* @param {number} length
|
|
81835
|
+
* @returns {number}
|
|
81836
|
+
*/
|
|
81837
|
+
function skipWhitespace(text, cursor, length) {
|
|
81838
|
+
|
|
81839
|
+
let i = cursor;
|
|
81840
|
+
let char;
|
|
81841
|
+
|
|
81842
|
+
while (i < length) {
|
|
81843
|
+
char = text.charAt(i);
|
|
81844
|
+
|
|
81845
|
+
if (char === ' ' || char === '\n' || char === '\t') {
|
|
81846
|
+
i++;
|
|
81847
|
+
} else {
|
|
81848
|
+
break;
|
|
81849
|
+
}
|
|
81850
|
+
}
|
|
81851
|
+
|
|
81852
|
+
return i;
|
|
81803
81853
|
}
|
|
81804
81854
|
|
|
81805
81855
|
/**
|
|
@@ -81810,6 +81860,7 @@ function readUnsignedIntegerToken(text, cursor, length) {
|
|
|
81810
81860
|
* @returns {Token}
|
|
81811
81861
|
*/
|
|
81812
81862
|
function readNumberToken(text, cursor, length) {
|
|
81863
|
+
|
|
81813
81864
|
let i = cursor;
|
|
81814
81865
|
|
|
81815
81866
|
//read optional sign
|
|
@@ -81869,6 +81920,97 @@ function readNumberToken(text, cursor, length) {
|
|
|
81869
81920
|
return new Token(value, cursor, i, TokenType.LiteralNumber, DataType.Number);
|
|
81870
81921
|
}
|
|
81871
81922
|
|
|
81923
|
+
/**
|
|
81924
|
+
*
|
|
81925
|
+
* @param {string} text
|
|
81926
|
+
* @param {number} cursor
|
|
81927
|
+
* @returns {string}
|
|
81928
|
+
*/
|
|
81929
|
+
function readQuote(text, cursor) {
|
|
81930
|
+
const char = text.charAt(cursor);
|
|
81931
|
+
|
|
81932
|
+
if (char !== '"' && char !== '\'') {
|
|
81933
|
+
throw new ParserError(cursor, "Expected \", found " + char + " instead", text);
|
|
81934
|
+
}
|
|
81935
|
+
|
|
81936
|
+
return char;
|
|
81937
|
+
}
|
|
81938
|
+
|
|
81939
|
+
/**
|
|
81940
|
+
*
|
|
81941
|
+
* @param {string} text
|
|
81942
|
+
* @param {number} cursor
|
|
81943
|
+
* @param {number} length
|
|
81944
|
+
* @returns {Token}
|
|
81945
|
+
*/
|
|
81946
|
+
function readStringToken(text, cursor, length) {
|
|
81947
|
+
|
|
81948
|
+
let i = cursor;
|
|
81949
|
+
|
|
81950
|
+
const openingQuote = readQuote(text, i);
|
|
81951
|
+
|
|
81952
|
+
i++;
|
|
81953
|
+
|
|
81954
|
+
let char;
|
|
81955
|
+
|
|
81956
|
+
let value = '';
|
|
81957
|
+
const lastPossibleChar = length - 1;
|
|
81958
|
+
|
|
81959
|
+
for (; i < lastPossibleChar; i++) {
|
|
81960
|
+
char = text.charAt(i);
|
|
81961
|
+
|
|
81962
|
+
if (char === '\\') {
|
|
81963
|
+
i++;
|
|
81964
|
+
//read escape sequence
|
|
81965
|
+
char = text.charAt(i);
|
|
81966
|
+
|
|
81967
|
+
switch (char) {
|
|
81968
|
+
case 'n':
|
|
81969
|
+
value += '\n';
|
|
81970
|
+
break;
|
|
81971
|
+
case 't':
|
|
81972
|
+
value += '\t';
|
|
81973
|
+
break;
|
|
81974
|
+
case 'r':
|
|
81975
|
+
value += '\r';
|
|
81976
|
+
break;
|
|
81977
|
+
case 'b':
|
|
81978
|
+
value += '\b';
|
|
81979
|
+
break;
|
|
81980
|
+
case 'f':
|
|
81981
|
+
value += '\f';
|
|
81982
|
+
break;
|
|
81983
|
+
case 'v':
|
|
81984
|
+
value += '\v';
|
|
81985
|
+
break;
|
|
81986
|
+
case '0':
|
|
81987
|
+
value += '\0';
|
|
81988
|
+
break;
|
|
81989
|
+
case '\\':
|
|
81990
|
+
case "'":
|
|
81991
|
+
case '"':
|
|
81992
|
+
default:
|
|
81993
|
+
value += char;
|
|
81994
|
+
break;
|
|
81995
|
+
}
|
|
81996
|
+
} else if (char !== openingQuote) {
|
|
81997
|
+
value += char;
|
|
81998
|
+
} else {
|
|
81999
|
+
break;
|
|
82000
|
+
}
|
|
82001
|
+
}
|
|
82002
|
+
|
|
82003
|
+
char = text.charAt(i);
|
|
82004
|
+
|
|
82005
|
+
if (char !== openingQuote) {
|
|
82006
|
+
throw new ParserError(cursor, "Expected string terminator : " + openingQuote + ", but found '" + char + "' instead", text);
|
|
82007
|
+
}
|
|
82008
|
+
|
|
82009
|
+
i++;
|
|
82010
|
+
|
|
82011
|
+
return new Token(value, cursor, i, TokenType.LiteralString, DataType.String);
|
|
82012
|
+
}
|
|
82013
|
+
|
|
81872
82014
|
/**
|
|
81873
82015
|
*
|
|
81874
82016
|
* @param {string} text
|
|
@@ -81927,6 +82069,7 @@ function readArrayLiteral(text, cursor, length) {
|
|
|
81927
82069
|
* @returns {Token}
|
|
81928
82070
|
*/
|
|
81929
82071
|
function readLiteralToken(text, cursor, length) {
|
|
82072
|
+
|
|
81930
82073
|
const firstChar = text.charAt(cursor);
|
|
81931
82074
|
|
|
81932
82075
|
switch (firstChar) {
|
|
@@ -83906,11 +84049,14 @@ class BinaryHeap {
|
|
|
83906
84049
|
}
|
|
83907
84050
|
}
|
|
83908
84051
|
|
|
84052
|
+
/**
|
|
84053
|
+
* Decorator that wraps another map and lets you observe mutations
|
|
84054
|
+
* @template K,V
|
|
84055
|
+
*/
|
|
83909
84056
|
class ObservedMap {
|
|
83910
84057
|
/**
|
|
83911
84058
|
* @template K,V
|
|
83912
84059
|
* @constructor
|
|
83913
|
-
* @property {number} size
|
|
83914
84060
|
*/
|
|
83915
84061
|
constructor(source = new Map()) {
|
|
83916
84062
|
this.on = {
|
|
@@ -83993,10 +84139,11 @@ const STATUS_NORMAL = 2;
|
|
|
83993
84139
|
class Deque {
|
|
83994
84140
|
/**
|
|
83995
84141
|
* @template T
|
|
84142
|
+
* @param {number} [min_size]
|
|
83996
84143
|
*/
|
|
83997
|
-
constructor(
|
|
84144
|
+
constructor(min_size = DEFAULT_SIZE) {
|
|
83998
84145
|
|
|
83999
|
-
const size = ceilPowerOfTwo(max2(1,
|
|
84146
|
+
const size = ceilPowerOfTwo(max2(1, min_size));
|
|
84000
84147
|
|
|
84001
84148
|
/**
|
|
84002
84149
|
* Using static array allocator to preserve data locality.
|
|
@@ -84007,15 +84154,31 @@ class Deque {
|
|
|
84007
84154
|
*/
|
|
84008
84155
|
this.__data = new Array(size);
|
|
84009
84156
|
|
|
84157
|
+
/**
|
|
84158
|
+
*
|
|
84159
|
+
* @type {number}
|
|
84160
|
+
* @private
|
|
84161
|
+
*/
|
|
84010
84162
|
this.__head = 0;
|
|
84163
|
+
/**
|
|
84164
|
+
*
|
|
84165
|
+
* @type {number}
|
|
84166
|
+
* @private
|
|
84167
|
+
*/
|
|
84011
84168
|
this.__tail = 0;
|
|
84012
84169
|
|
|
84170
|
+
/**
|
|
84171
|
+
*
|
|
84172
|
+
* @type {number}
|
|
84173
|
+
* @private
|
|
84174
|
+
*/
|
|
84013
84175
|
this.__status = STATUS_EMPTY;
|
|
84014
84176
|
}
|
|
84015
84177
|
|
|
84016
84178
|
/**
|
|
84017
84179
|
*
|
|
84018
84180
|
* @param {boolean} adding
|
|
84181
|
+
* @private
|
|
84019
84182
|
*/
|
|
84020
84183
|
resetStatus(adding) {
|
|
84021
84184
|
const head = this.__head;
|
|
@@ -84034,11 +84197,12 @@ class Deque {
|
|
|
84034
84197
|
* @returns {number}
|
|
84035
84198
|
* @private
|
|
84036
84199
|
*/
|
|
84037
|
-
|
|
84038
|
-
// TODO this can be done faster using mod operator (%)
|
|
84200
|
+
__circular_next_position(current) {
|
|
84039
84201
|
const next = current + 1;
|
|
84040
84202
|
|
|
84041
|
-
|
|
84203
|
+
const length = this.__data.length;
|
|
84204
|
+
|
|
84205
|
+
return (next >= length) ? 0 : next;
|
|
84042
84206
|
}
|
|
84043
84207
|
|
|
84044
84208
|
/**
|
|
@@ -84047,43 +84211,57 @@ class Deque {
|
|
|
84047
84211
|
* @returns {number}
|
|
84048
84212
|
* @private
|
|
84049
84213
|
*/
|
|
84050
|
-
|
|
84214
|
+
__circular_previous_position(current) {
|
|
84051
84215
|
const prev = current - 1;
|
|
84052
84216
|
return (prev < 0) ? (this.__data.length - 1) : prev;
|
|
84053
84217
|
}
|
|
84054
84218
|
|
|
84055
|
-
|
|
84219
|
+
__check_and_expand() {
|
|
84056
84220
|
const status = this.__status;
|
|
84221
|
+
|
|
84057
84222
|
if (status !== STATUS_FULL) {
|
|
84223
|
+
// queue still has space, we're done
|
|
84058
84224
|
return;
|
|
84059
84225
|
}
|
|
84226
|
+
|
|
84060
84227
|
const length = this.__data.length;
|
|
84061
84228
|
|
|
84062
|
-
if (
|
|
84229
|
+
if (UINT32_MAX === length) {
|
|
84063
84230
|
throw new Error('Maximum array size exceeded');
|
|
84064
84231
|
}
|
|
84065
84232
|
|
|
84066
|
-
let
|
|
84233
|
+
let new_length = length * 2;
|
|
84234
|
+
|
|
84067
84235
|
// bigger than Integer.MAX_VALUE
|
|
84068
|
-
if (
|
|
84069
|
-
|
|
84236
|
+
if (new_length > UINT32_MAX) {
|
|
84237
|
+
new_length = UINT32_MAX;
|
|
84070
84238
|
}
|
|
84071
84239
|
|
|
84072
|
-
|
|
84240
|
+
/**
|
|
84241
|
+
*
|
|
84242
|
+
* @type {T[]}
|
|
84243
|
+
*/
|
|
84244
|
+
const new_data = new Array(new_length);
|
|
84073
84245
|
|
|
84074
|
-
// copy front portion of data
|
|
84075
84246
|
const head = this.__head;
|
|
84076
84247
|
|
|
84077
|
-
|
|
84078
|
-
array_copy(this.__data,
|
|
84248
|
+
// copy the front portion
|
|
84249
|
+
array_copy(this.__data, head, new_data, 0, length - head);
|
|
84250
|
+
// copy the remainder
|
|
84251
|
+
array_copy(this.__data, 0, new_data, length - head, head);
|
|
84079
84252
|
|
|
84080
84253
|
this.__head = 0;
|
|
84081
84254
|
this.__tail = length;
|
|
84255
|
+
|
|
84082
84256
|
this.__status = STATUS_NORMAL;
|
|
84083
84257
|
|
|
84084
|
-
this.__data =
|
|
84258
|
+
this.__data = new_data;
|
|
84085
84259
|
}
|
|
84086
84260
|
|
|
84261
|
+
/**
|
|
84262
|
+
*
|
|
84263
|
+
* @return {boolean}
|
|
84264
|
+
*/
|
|
84087
84265
|
isEmpty() {
|
|
84088
84266
|
return this.size() === 0;
|
|
84089
84267
|
}
|
|
@@ -84095,7 +84273,7 @@ class Deque {
|
|
|
84095
84273
|
|
|
84096
84274
|
do {
|
|
84097
84275
|
this.__data[cursor] = undefined;
|
|
84098
|
-
cursor = this.
|
|
84276
|
+
cursor = this.__circular_next_position(cursor);
|
|
84099
84277
|
} while (cursor !== tail);
|
|
84100
84278
|
|
|
84101
84279
|
this.__status = STATUS_EMPTY;
|
|
@@ -84124,32 +84302,45 @@ class Deque {
|
|
|
84124
84302
|
/**
|
|
84125
84303
|
*
|
|
84126
84304
|
* @param {number} current
|
|
84127
|
-
* @param {boolean}
|
|
84305
|
+
* @param {boolean} shift_front should we shift elements before the removed element or after?
|
|
84128
84306
|
* @private
|
|
84129
84307
|
*/
|
|
84130
|
-
|
|
84308
|
+
__remove_internal(current, shift_front) {
|
|
84131
84309
|
let cursor = current;
|
|
84132
|
-
|
|
84310
|
+
|
|
84311
|
+
if (shift_front) {
|
|
84312
|
+
|
|
84313
|
+
// shift towards tail
|
|
84314
|
+
|
|
84133
84315
|
const head = this.__head;
|
|
84316
|
+
|
|
84134
84317
|
while (cursor !== head) {
|
|
84135
|
-
const next = this.
|
|
84318
|
+
const next = this.__circular_previous_position(cursor);
|
|
84136
84319
|
this.__data[cursor] = this.__data[next];
|
|
84137
84320
|
cursor = next;
|
|
84138
84321
|
}
|
|
84139
|
-
|
|
84322
|
+
|
|
84323
|
+
this.__head = this.__circular_next_position(head);
|
|
84324
|
+
|
|
84140
84325
|
} else {
|
|
84326
|
+
|
|
84327
|
+
// shift towards head
|
|
84328
|
+
|
|
84141
84329
|
const tail = this.__tail;
|
|
84142
84330
|
|
|
84143
84331
|
while (cursor !== tail) {
|
|
84144
|
-
const next = this.
|
|
84332
|
+
const next = this.__circular_next_position(cursor);
|
|
84145
84333
|
this.__data[cursor] = this.__data[next];
|
|
84146
84334
|
cursor = next;
|
|
84147
84335
|
}
|
|
84148
84336
|
|
|
84149
|
-
this.__tail = this.
|
|
84337
|
+
this.__tail = this.__circular_previous_position(tail);
|
|
84338
|
+
|
|
84150
84339
|
}
|
|
84151
84340
|
|
|
84341
|
+
// fill in slot of last moved element
|
|
84152
84342
|
this.__data[cursor] = undefined;
|
|
84343
|
+
|
|
84153
84344
|
this.resetStatus(false);
|
|
84154
84345
|
}
|
|
84155
84346
|
|
|
@@ -84165,7 +84356,7 @@ class Deque {
|
|
|
84165
84356
|
return false;
|
|
84166
84357
|
}
|
|
84167
84358
|
|
|
84168
|
-
this.
|
|
84359
|
+
this.__remove_internal(i, true);
|
|
84169
84360
|
|
|
84170
84361
|
return true;
|
|
84171
84362
|
}
|
|
@@ -84209,20 +84400,20 @@ class Deque {
|
|
|
84209
84400
|
* @param {T} e
|
|
84210
84401
|
*/
|
|
84211
84402
|
addFirst(e) {
|
|
84212
|
-
this.
|
|
84213
|
-
this.__head = this.
|
|
84403
|
+
this.__check_and_expand();
|
|
84404
|
+
this.__head = this.__circular_previous_position(this.__head);
|
|
84214
84405
|
this.__data[this.__head] = e;
|
|
84215
84406
|
this.resetStatus(true);
|
|
84216
84407
|
}
|
|
84217
84408
|
|
|
84218
84409
|
/**
|
|
84219
84410
|
* Remove element from the front of the queue
|
|
84220
|
-
* @returns {T}
|
|
84411
|
+
* @returns {T|undefined}
|
|
84221
84412
|
*/
|
|
84222
84413
|
removeFirst() {
|
|
84223
84414
|
const element = this.__data[this.__head];
|
|
84224
84415
|
this.__data[this.__head] = undefined;
|
|
84225
|
-
this.__head = this.
|
|
84416
|
+
this.__head = this.__circular_next_position(this.__head);
|
|
84226
84417
|
this.resetStatus(false);
|
|
84227
84418
|
return element;
|
|
84228
84419
|
}
|
|
@@ -84240,9 +84431,9 @@ class Deque {
|
|
|
84240
84431
|
* @param {T} e
|
|
84241
84432
|
*/
|
|
84242
84433
|
addLast(e) {
|
|
84243
|
-
this.
|
|
84434
|
+
this.__check_and_expand();
|
|
84244
84435
|
this.__data[this.__tail] = e;
|
|
84245
|
-
this.__tail = this.
|
|
84436
|
+
this.__tail = this.__circular_next_position(this.__tail);
|
|
84246
84437
|
this.resetStatus(true);
|
|
84247
84438
|
}
|
|
84248
84439
|
|
|
@@ -84251,7 +84442,7 @@ class Deque {
|
|
|
84251
84442
|
* @returns {T}
|
|
84252
84443
|
*/
|
|
84253
84444
|
removeLast() {
|
|
84254
|
-
const last = this.
|
|
84445
|
+
const last = this.__circular_previous_position(this.__tail);
|
|
84255
84446
|
const element = this.__data[last];
|
|
84256
84447
|
this.__data[last] = undefined;
|
|
84257
84448
|
this.__tail = last;
|
|
@@ -84262,10 +84453,10 @@ class Deque {
|
|
|
84262
84453
|
|
|
84263
84454
|
/**
|
|
84264
84455
|
* Peek element from the end of the queue without removing it
|
|
84265
|
-
* @returns {T}
|
|
84456
|
+
* @returns {T|undefined}
|
|
84266
84457
|
*/
|
|
84267
84458
|
getLast() {
|
|
84268
|
-
const last = this.
|
|
84459
|
+
const last = this.__circular_previous_position(this.__tail);
|
|
84269
84460
|
return this.__data[last];
|
|
84270
84461
|
}
|
|
84271
84462
|
}
|
|
@@ -85973,35 +86164,44 @@ Preloader.prototype.load = function (assetManager) {
|
|
|
85973
86164
|
return this;
|
|
85974
86165
|
};
|
|
85975
86166
|
|
|
85976
|
-
|
|
85977
|
-
|
|
85978
|
-
|
|
85979
|
-
|
|
85980
|
-
|
|
85981
|
-
|
|
85982
|
-
|
|
85983
|
-
|
|
85984
|
-
|
|
86167
|
+
/**
|
|
86168
|
+
* @template V
|
|
86169
|
+
* @param {V[]} data
|
|
86170
|
+
* @param {number} [start]
|
|
86171
|
+
* @param {number} [end]
|
|
86172
|
+
* @return {number}
|
|
86173
|
+
*/
|
|
86174
|
+
function array_compute_max(data, start = 0, end = data.length) {
|
|
86175
|
+
let result = Number.NEGATIVE_INFINITY;
|
|
85985
86176
|
|
|
85986
|
-
|
|
85987
|
-
|
|
85988
|
-
|
|
85989
|
-
|
|
85990
|
-
|
|
86177
|
+
for (let i = start; i < end; i++) {
|
|
86178
|
+
const value = data[i];
|
|
86179
|
+
if (value > result) {
|
|
86180
|
+
result = value;
|
|
86181
|
+
}
|
|
85991
86182
|
}
|
|
85992
86183
|
|
|
85993
|
-
|
|
85994
|
-
|
|
85995
|
-
|
|
85996
|
-
|
|
85997
|
-
|
|
85998
|
-
|
|
85999
|
-
|
|
86000
|
-
|
|
86184
|
+
return result;
|
|
86185
|
+
}
|
|
86186
|
+
|
|
86187
|
+
/**
|
|
86188
|
+
* @template V
|
|
86189
|
+
* @param {V[]} data
|
|
86190
|
+
* @param {number} [start]
|
|
86191
|
+
* @param {number} [end]
|
|
86192
|
+
* @return {number}
|
|
86193
|
+
*/
|
|
86194
|
+
function array_compute_min(data, start = 0, end = data.length) {
|
|
86195
|
+
let result = Number.POSITIVE_INFINITY;
|
|
86001
86196
|
|
|
86002
|
-
|
|
86003
|
-
|
|
86197
|
+
for (let i = start; i < end; i++) {
|
|
86198
|
+
const value = data[i];
|
|
86199
|
+
if (value < result) {
|
|
86200
|
+
result = value;
|
|
86201
|
+
}
|
|
86004
86202
|
}
|
|
86203
|
+
|
|
86204
|
+
return result;
|
|
86005
86205
|
}
|
|
86006
86206
|
|
|
86007
86207
|
class RingBuffer {
|
|
@@ -86271,44 +86471,35 @@ function computeStatisticalPartialMedian(values, start, end) {
|
|
|
86271
86471
|
return copy[position];
|
|
86272
86472
|
}
|
|
86273
86473
|
|
|
86274
|
-
|
|
86275
|
-
|
|
86276
|
-
|
|
86277
|
-
|
|
86278
|
-
|
|
86279
|
-
|
|
86280
|
-
|
|
86281
|
-
|
|
86282
|
-
let result = Number.NEGATIVE_INFINITY;
|
|
86283
|
-
|
|
86284
|
-
for (let i = start; i < end; i++) {
|
|
86285
|
-
const value = data[i];
|
|
86286
|
-
if (value > result) {
|
|
86287
|
-
result = value;
|
|
86288
|
-
}
|
|
86474
|
+
class AbstractMetric {
|
|
86475
|
+
/**
|
|
86476
|
+
*
|
|
86477
|
+
* @param {number} value
|
|
86478
|
+
* @returns {void}
|
|
86479
|
+
*/
|
|
86480
|
+
record(value) {
|
|
86481
|
+
throw new Error('Not implemented');
|
|
86289
86482
|
}
|
|
86290
86483
|
|
|
86291
|
-
|
|
86292
|
-
}
|
|
86293
|
-
|
|
86294
|
-
|
|
86295
|
-
|
|
86296
|
-
|
|
86297
|
-
* @param {number} [start]
|
|
86298
|
-
* @param {number} [end]
|
|
86299
|
-
* @return {number}
|
|
86300
|
-
*/
|
|
86301
|
-
function computeArrayMin(data, start = 0, end = data.length) {
|
|
86302
|
-
let result = Number.POSITIVE_INFINITY;
|
|
86484
|
+
/**
|
|
86485
|
+
* @returns {number|undefined}
|
|
86486
|
+
*/
|
|
86487
|
+
getLastRecord() {
|
|
86488
|
+
throw new Error('Not implemented');
|
|
86489
|
+
}
|
|
86303
86490
|
|
|
86304
|
-
|
|
86305
|
-
|
|
86306
|
-
|
|
86307
|
-
|
|
86308
|
-
|
|
86491
|
+
/**
|
|
86492
|
+
*
|
|
86493
|
+
* @param {MetricStatistics} result
|
|
86494
|
+
* @returns {boolean} whether metric was successfully computed or not
|
|
86495
|
+
*/
|
|
86496
|
+
computeStats(result) {
|
|
86497
|
+
throw new Error('Not implemented');
|
|
86309
86498
|
}
|
|
86310
86499
|
|
|
86311
|
-
|
|
86500
|
+
clear() {
|
|
86501
|
+
throw new Error('Not implemented');
|
|
86502
|
+
}
|
|
86312
86503
|
}
|
|
86313
86504
|
|
|
86314
86505
|
class RingBufferMetric extends AbstractMetric {
|
|
@@ -86365,8 +86556,8 @@ class RingBufferMetric extends AbstractMetric {
|
|
|
86365
86556
|
|
|
86366
86557
|
result.mean = computeStatisticalMean(array, 0, data_count);
|
|
86367
86558
|
result.median = computeStatisticalPartialMedian(array, 0, data_count - 1);
|
|
86368
|
-
result.max =
|
|
86369
|
-
result.min =
|
|
86559
|
+
result.max = array_compute_max(array, 0, data_count);
|
|
86560
|
+
result.min = array_compute_min(array, 0, data_count);
|
|
86370
86561
|
|
|
86371
86562
|
return true;
|
|
86372
86563
|
|
|
@@ -110070,7 +110261,7 @@ class LightManager {
|
|
|
110070
110261
|
__build_view_frustum(camera) {
|
|
110071
110262
|
frustum_from_camera(camera, this.__view_frustum, false);
|
|
110072
110263
|
|
|
110073
|
-
|
|
110264
|
+
array_swap_one(this.__view_frustum.planes, 4, 5);
|
|
110074
110265
|
|
|
110075
110266
|
this.__build_view_frustum_points();
|
|
110076
110267
|
}
|