@woosh/meep-engine 2.33.5 → 2.33.6
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/core/collection/RingBuffer.js +40 -10
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- package/core/geom/3d/aabb/aabb3_compute_projected_area.js +5 -4
- package/core/process/undo/ActionProcessor.d.ts +2 -0
- package/core/process/undo/ActionProcessor.js +59 -1
- package/core/process/undo/ActionProcessor.spec.js +59 -0
- package/core/process/undo/Mark.js +2 -1
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
- package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +25 -16
- package/engine/graphics/material/SplatMaterial.js +4 -97
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +1 -5
- package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -0
- package/engine/graphics/micron/format/MicronGeometryPatch.js +11 -3
- package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +24 -8
- package/engine/graphics/micron/render/refinement/ActivePatchList.js +6 -25
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
- package/engine/graphics/micron/render/refinement/array_normalize_plane.js +25 -0
- package/engine/graphics/micron/render/refinement/array_setFromProjectionMatrix.js +60 -0
- package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
- package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
- package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
- package/engine/graphics/texture/cubemap/load_environment_map.js +29 -3
- package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
- package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
- package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
- package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
- package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
- package/package.json +1 -1
- package/view/minimap/gl/MinimapMarkersGL.js +2 -2
- package/engine/graphics/micron/render/RefinementSpec.js +0 -181
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
import Vector4 from "../../../../core/geom/Vector4.js";
|
|
7
6
|
import { clamp } from "../../../../core/math/clamp.js";
|
|
8
7
|
import { max2 } from "../../../../core/math/max2.js";
|
|
9
8
|
import { min2 } from "../../../../core/math/min2.js";
|
|
10
9
|
import { mix } from "../../../../core/math/mix.js";
|
|
11
10
|
import { BlendingType } from "./BlendingType.js";
|
|
12
11
|
import { assert } from "../../../../core/assert.js";
|
|
12
|
+
import { typedArrayConstructorByInstance } from "./typedArrayConstructorByInstance.js";
|
|
13
13
|
|
|
14
14
|
function v2CrossMag(ax, ay, bx, by) {
|
|
15
15
|
return ax * by - ay * bx;
|
|
@@ -1319,8 +1319,8 @@ Sampler2D.prototype.fill = function (x, y, width, height, value) {
|
|
|
1319
1319
|
* @param {number} value
|
|
1320
1320
|
*/
|
|
1321
1321
|
Sampler2D.prototype.writeChannel = function (x, y, channel, value) {
|
|
1322
|
-
assert.
|
|
1323
|
-
assert.
|
|
1322
|
+
assert.isNumber(x, "x");
|
|
1323
|
+
assert.isNumber(y, "y");
|
|
1324
1324
|
|
|
1325
1325
|
assert.greaterThanOrEqual(x, 0);
|
|
1326
1326
|
assert.greaterThanOrEqual(y, 0);
|
|
@@ -1385,32 +1385,6 @@ Sampler2D.prototype.traverseCircle = function (centerX, centerY, radius, visitor
|
|
|
1385
1385
|
}
|
|
1386
1386
|
};
|
|
1387
1387
|
|
|
1388
|
-
export function arrayConstructorByInstance(a) {
|
|
1389
|
-
if (a instanceof Int8Array) {
|
|
1390
|
-
return Int8Array;
|
|
1391
|
-
} else if (a instanceof Int16Array) {
|
|
1392
|
-
return Int16Array;
|
|
1393
|
-
} else if (a instanceof Int32Array) {
|
|
1394
|
-
return Int32Array;
|
|
1395
|
-
} else if (a instanceof Uint8Array) {
|
|
1396
|
-
return Uint8Array;
|
|
1397
|
-
} else if (a instanceof Uint8ClampedArray) {
|
|
1398
|
-
return Uint8ClampedArray;
|
|
1399
|
-
} else if (a instanceof Uint16Array) {
|
|
1400
|
-
return Uint16Array;
|
|
1401
|
-
} else if (a instanceof Uint32Array) {
|
|
1402
|
-
return Uint32Array;
|
|
1403
|
-
} else if (a instanceof Float32Array) {
|
|
1404
|
-
return Float32Array;
|
|
1405
|
-
} else if (a instanceof Float64Array) {
|
|
1406
|
-
return Float64Array;
|
|
1407
|
-
} else if (Array.isArray(a)) {
|
|
1408
|
-
return Array;
|
|
1409
|
-
} else {
|
|
1410
|
-
throw new TypeError(`Unsupported array type`);
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
1388
|
/**
|
|
1415
1389
|
*
|
|
1416
1390
|
* @param {number} x
|
|
@@ -1419,31 +1393,40 @@ export function arrayConstructorByInstance(a) {
|
|
|
1419
1393
|
*/
|
|
1420
1394
|
Sampler2D.prototype.resize = function (x, y, preserveData = true) {
|
|
1421
1395
|
|
|
1396
|
+
const _w = this.width;
|
|
1397
|
+
const _h = this.height;
|
|
1398
|
+
|
|
1399
|
+
if (_w === x && _h === y) {
|
|
1400
|
+
// size didn't change
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1422
1404
|
const itemSize = this.itemSize;
|
|
1405
|
+
|
|
1423
1406
|
const length = x * y * itemSize;
|
|
1424
1407
|
|
|
1425
1408
|
const oldData = this.data;
|
|
1426
1409
|
|
|
1427
|
-
const Constructor =
|
|
1410
|
+
const Constructor = typedArrayConstructorByInstance(oldData);
|
|
1428
1411
|
|
|
1429
1412
|
const newData = new Constructor(length);
|
|
1430
1413
|
|
|
1431
1414
|
if (preserveData) {
|
|
1432
1415
|
//copy old data
|
|
1433
|
-
if (x ===
|
|
1416
|
+
if (x === _w) {
|
|
1434
1417
|
// number of columns is preserved, we can just copy the old data across
|
|
1435
1418
|
newData.set(oldData.subarray(0, Math.min(oldData.length, length)));
|
|
1436
1419
|
} else {
|
|
1437
1420
|
//we need to copy new data row-by-row
|
|
1438
|
-
const rowCount = min2(y,
|
|
1421
|
+
const rowCount = min2(y, _h);
|
|
1439
1422
|
|
|
1440
|
-
const columnCount = min2(x,
|
|
1423
|
+
const columnCount = min2(x, _w);
|
|
1441
1424
|
|
|
1442
1425
|
for (let i = 0; i < rowCount; i++) {
|
|
1443
1426
|
for (let j = 0; j < columnCount; j++) {
|
|
1444
1427
|
|
|
1445
1428
|
const targetItemAddress = (i * x + j) * itemSize;
|
|
1446
|
-
const sourceItemAddress = (i *
|
|
1429
|
+
const sourceItemAddress = (i * _w + j) * itemSize;
|
|
1447
1430
|
|
|
1448
1431
|
for (let k = 0; k < itemSize; k++) {
|
|
1449
1432
|
|
|
@@ -1457,6 +1440,7 @@ Sampler2D.prototype.resize = function (x, y, preserveData = true) {
|
|
|
1457
1440
|
|
|
1458
1441
|
this.width = x;
|
|
1459
1442
|
this.height = y;
|
|
1443
|
+
|
|
1460
1444
|
this.data = newData;
|
|
1461
1445
|
};
|
|
1462
1446
|
|
|
@@ -1563,31 +1547,3 @@ Sampler2D.prototype.traverseOrthogonalNeighbours = function (x, y, visitor, this
|
|
|
1563
1547
|
}
|
|
1564
1548
|
};
|
|
1565
1549
|
|
|
1566
|
-
/**
|
|
1567
|
-
*
|
|
1568
|
-
* @param {Sampler2D} sampler0
|
|
1569
|
-
* @param {Sampler2D} sampler1
|
|
1570
|
-
* @returns {Sampler2D}
|
|
1571
|
-
*/
|
|
1572
|
-
export function differenceSampler(sampler0, sampler1) {
|
|
1573
|
-
let v0 = new Vector4();
|
|
1574
|
-
let v1 = new Vector4();
|
|
1575
|
-
//
|
|
1576
|
-
const width = sampler0.width;
|
|
1577
|
-
const height = sampler0.height;
|
|
1578
|
-
//
|
|
1579
|
-
const difference = new Float32Array(width * height);
|
|
1580
|
-
for (let y = 0; y < height; y++) {
|
|
1581
|
-
for (let x = 0; x < width; x++) {
|
|
1582
|
-
v0 = sampler0.get(x, y, v0);
|
|
1583
|
-
v1 = sampler1.get(x, y, v1);
|
|
1584
|
-
v0.normalize();
|
|
1585
|
-
v1.normalize();
|
|
1586
|
-
//check distance
|
|
1587
|
-
difference[x + y * width] = 1 - v0.dot(v1);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
//
|
|
1591
|
-
const sampleD = new Sampler2D(difference, 1, width, height);
|
|
1592
|
-
return sampleD;
|
|
1593
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
2
2
|
import { scaleSampler2D } from "../scaleSampler2D.js";
|
|
3
3
|
import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
|
|
4
|
+
import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInstance.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -14,7 +15,7 @@ export function paintSamplerOnHTML(s, x, y, scale, offset) {
|
|
|
14
15
|
|
|
15
16
|
const d = 180;
|
|
16
17
|
|
|
17
|
-
const target = new Sampler2D(
|
|
18
|
+
const target = new Sampler2D(typedArrayConstructorByInstance(s.data), s.itemSize, d, d);
|
|
18
19
|
|
|
19
20
|
scaleSampler2D(s, target);
|
|
20
21
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Vector4 from "../../../../core/geom/Vector4.js";
|
|
2
|
+
import { Sampler2D } from "./Sampler2D.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Sampler2D} sampler0
|
|
7
|
+
* @param {Sampler2D} sampler1
|
|
8
|
+
* @returns {Sampler2D}
|
|
9
|
+
*/
|
|
10
|
+
export function differenceSampler(sampler0, sampler1) {
|
|
11
|
+
let v0 = new Vector4();
|
|
12
|
+
let v1 = new Vector4();
|
|
13
|
+
//
|
|
14
|
+
const width = sampler0.width;
|
|
15
|
+
const height = sampler0.height;
|
|
16
|
+
//
|
|
17
|
+
const difference = new Float32Array(width * height);
|
|
18
|
+
for (let y = 0; y < height; y++) {
|
|
19
|
+
for (let x = 0; x < width; x++) {
|
|
20
|
+
v0 = sampler0.get(x, y, v0);
|
|
21
|
+
v1 = sampler1.get(x, y, v1);
|
|
22
|
+
v0.normalize();
|
|
23
|
+
v1.normalize();
|
|
24
|
+
//check distance
|
|
25
|
+
difference[x + y * width] = 1 - v0.dot(v1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//
|
|
29
|
+
const sampleD = new Sampler2D(difference, 1, width, height);
|
|
30
|
+
return sampleD;
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function typedArrayConstructorByInstance(a) {
|
|
2
|
+
if (a instanceof Int8Array) {
|
|
3
|
+
return Int8Array;
|
|
4
|
+
} else if (a instanceof Int16Array) {
|
|
5
|
+
return Int16Array;
|
|
6
|
+
} else if (a instanceof Int32Array) {
|
|
7
|
+
return Int32Array;
|
|
8
|
+
} else if (a instanceof Uint8Array) {
|
|
9
|
+
return Uint8Array;
|
|
10
|
+
} else if (a instanceof Uint8ClampedArray) {
|
|
11
|
+
return Uint8ClampedArray;
|
|
12
|
+
} else if (a instanceof Uint16Array) {
|
|
13
|
+
return Uint16Array;
|
|
14
|
+
} else if (a instanceof Uint32Array) {
|
|
15
|
+
return Uint32Array;
|
|
16
|
+
} else if (a instanceof Float32Array) {
|
|
17
|
+
return Float32Array;
|
|
18
|
+
} else if (a instanceof Float64Array) {
|
|
19
|
+
return Float64Array;
|
|
20
|
+
} else if (Array.isArray(a)) {
|
|
21
|
+
return Array;
|
|
22
|
+
} else {
|
|
23
|
+
throw new TypeError(`Unsupported array type`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
2
2
|
import { scaleSampler2D } from "../scaleSampler2D.js";
|
|
3
3
|
import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
|
|
4
|
+
import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInstance.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -15,7 +16,7 @@ import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
|
|
|
15
16
|
export function drawSamplerHTML(parentNode, sampler, x, y, scale, offset, size) {
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
const target = new Sampler2D(
|
|
19
|
+
const target = new Sampler2D(typedArrayConstructorByInstance(sampler.data), sampler.itemSize, size, size);
|
|
19
20
|
|
|
20
21
|
scaleSampler2D(sampler, target);
|
|
21
22
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"productName": "Meep",
|
|
5
5
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
6
6
|
"author": "Alexander Goldring",
|
|
7
|
-
"version": "2.33.
|
|
7
|
+
"version": "2.33.6",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"fast-levenshtein": "2.0.6",
|
|
10
10
|
"opentype.js": "1.3.3",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataTexture,
|
|
3
|
-
LinearFilter,
|
|
4
3
|
LinearMipMapLinearFilter,
|
|
4
|
+
NearestFilter,
|
|
5
5
|
NormalBlending,
|
|
6
6
|
Points,
|
|
7
7
|
RGBAFormat,
|
|
@@ -82,7 +82,7 @@ function buildMaterial() {
|
|
|
82
82
|
dataTexture.flipY = false;
|
|
83
83
|
dataTexture.generateMipmaps = true;
|
|
84
84
|
dataTexture.minFilter = LinearMipMapLinearFilter;
|
|
85
|
-
dataTexture.magFilter =
|
|
85
|
+
dataTexture.magFilter = NearestFilter;
|
|
86
86
|
|
|
87
87
|
const uniforms = {
|
|
88
88
|
atlas: {
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
2
|
-
import { Matrix4 } from "three";
|
|
3
|
-
import { mat4 } from "gl-matrix";
|
|
4
|
-
import { v3_length } from "../../../../core/geom/Vector3.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Normalize a plane in-place
|
|
8
|
-
* @param {number[]} source
|
|
9
|
-
* @param {number} source_offset
|
|
10
|
-
*/
|
|
11
|
-
function array_normalize_plane(source, source_offset) {
|
|
12
|
-
const _x = source[source_offset];
|
|
13
|
-
const _y = source[source_offset + 1];
|
|
14
|
-
const _z = source[source_offset + 2];
|
|
15
|
-
|
|
16
|
-
const length = v3_length(_x, _y, _z);
|
|
17
|
-
|
|
18
|
-
const inverseNormalLength = 1.0 / length;
|
|
19
|
-
|
|
20
|
-
/*
|
|
21
|
-
By re-using values already in the registers instead of using *= we save a few extra READ ops
|
|
22
|
-
*/
|
|
23
|
-
source[source_offset] = _x * inverseNormalLength;
|
|
24
|
-
source[source_offset + 1] = _y * inverseNormalLength;
|
|
25
|
-
source[source_offset + 2] = _z * inverseNormalLength;
|
|
26
|
-
|
|
27
|
-
source[source_offset + 3] *= inverseNormalLength;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {number[]} destination
|
|
33
|
-
* @param {number} destination_offset
|
|
34
|
-
* @param {number} x
|
|
35
|
-
* @param {number} y
|
|
36
|
-
* @param {number} z
|
|
37
|
-
* @param {number} w
|
|
38
|
-
*/
|
|
39
|
-
function array_set_plane_normalized(destination, destination_offset, x, y, z, w) {
|
|
40
|
-
const length = v3_length(x, y, z);
|
|
41
|
-
|
|
42
|
-
const inverseNormalLength = 1.0 / length;
|
|
43
|
-
|
|
44
|
-
destination[destination_offset] = x * inverseNormalLength;
|
|
45
|
-
destination[destination_offset + 1] = y * inverseNormalLength;
|
|
46
|
-
destination[destination_offset + 2] = z * inverseNormalLength;
|
|
47
|
-
destination[destination_offset + 3] = w * inverseNormalLength;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
* @param {number[]|Float32Array} frustum_planes
|
|
53
|
-
* @param {number[]} me
|
|
54
|
-
*/
|
|
55
|
-
function array_setFromProjectionMatrix(frustum_planes, me) {
|
|
56
|
-
|
|
57
|
-
const me0 = me[0];
|
|
58
|
-
const me3 = me[3];
|
|
59
|
-
|
|
60
|
-
const me4 = me[4];
|
|
61
|
-
const me7 = me[7];
|
|
62
|
-
|
|
63
|
-
const me8 = me[8];
|
|
64
|
-
const me11 = me[11];
|
|
65
|
-
|
|
66
|
-
const me12 = me[12];
|
|
67
|
-
const me15 = me[15];
|
|
68
|
-
|
|
69
|
-
array_set_plane_normalized(frustum_planes, 0, me3 - me0, me7 - me4, me11 - me8, me15 - me12);
|
|
70
|
-
array_set_plane_normalized(frustum_planes, 4, me3 + me0, me7 + me4, me11 + me8, me15 + me12);
|
|
71
|
-
|
|
72
|
-
const me1 = me[1];
|
|
73
|
-
const me5 = me[5];
|
|
74
|
-
const me9 = me[9];
|
|
75
|
-
const me13 = me[13];
|
|
76
|
-
|
|
77
|
-
array_set_plane_normalized(frustum_planes, 8, me3 + me1, me7 + me5, me11 + me9, me15 + me13);
|
|
78
|
-
array_set_plane_normalized(frustum_planes, 12, me3 - me1, me7 - me5, me11 - me9, me15 - me13);
|
|
79
|
-
|
|
80
|
-
const me2 = me[2];
|
|
81
|
-
const me6 = me[6];
|
|
82
|
-
const me10 = me[10];
|
|
83
|
-
const me14 = me[14];
|
|
84
|
-
|
|
85
|
-
array_set_plane_normalized(frustum_planes, 16, me3 - me2, me7 - me6, me11 - me10, me15 - me14);
|
|
86
|
-
array_set_plane_normalized(frustum_planes, 20, me3 + me2, me7 + me6, me11 + me10, me15 + me14);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class RefinementSpec {
|
|
90
|
-
constructor() {
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Viewport resolution
|
|
94
|
-
* @type {Vector2}
|
|
95
|
-
*/
|
|
96
|
-
this.resolution = new Vector2();
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Number of pixels in the viewport
|
|
100
|
-
* @type {number}
|
|
101
|
-
*/
|
|
102
|
-
this.viewport_area = 0;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* How much error to accept when deciding to subdivide a cluster
|
|
106
|
-
* Measured in pixels
|
|
107
|
-
* Higher value will result in better performance but more visible artifacts
|
|
108
|
-
* @type {number}
|
|
109
|
-
*/
|
|
110
|
-
this.error_threshold = 1;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Error threshold as a fraction of the screen area instead of pixels, derived internally from pixel value
|
|
114
|
-
* @type {number}
|
|
115
|
-
*/
|
|
116
|
-
this.error_threshold_normalized = 1;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Object-space camera frustum
|
|
120
|
-
* Frustum planes in compact form
|
|
121
|
-
* @type {Float32Array}
|
|
122
|
-
*/
|
|
123
|
-
this.frustum_f32 = new Float32Array(24);
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Model world transform
|
|
127
|
-
* @type {Float32Array|number[]|mat4}
|
|
128
|
-
*/
|
|
129
|
-
this.transform = new Float32Array(16);
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Contains transformation from camera space to object space
|
|
133
|
-
* @type {Float32Array|number[]|mat4}
|
|
134
|
-
*/
|
|
135
|
-
this.projection_matrix = new Float32Array(16);
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* FOV in radians
|
|
139
|
-
* @type {number}
|
|
140
|
-
*/
|
|
141
|
-
this.focal_length = 0;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Object-space camera position
|
|
145
|
-
* @type {Float32Array}
|
|
146
|
-
*/
|
|
147
|
-
this.view_position = new Float32Array(3);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
get frustum() {
|
|
151
|
-
throw new Error('deprecated, use .frustum_f32 instead');
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
setResolution(x, y) {
|
|
155
|
-
this.resolution.set(x, y);
|
|
156
|
-
|
|
157
|
-
this.viewport_area = x * y;
|
|
158
|
-
|
|
159
|
-
this.error_threshold_normalized = this.error_threshold / this.viewport_area;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
*
|
|
164
|
-
* @param {Matrix4} transform world-space object transform
|
|
165
|
-
* @param {Matrix4} matrix_world_inverse camera's world inverse matrix
|
|
166
|
-
* @param {Matrix4} matrix_projection camera's projection matrix
|
|
167
|
-
*/
|
|
168
|
-
build(transform, matrix_world_inverse, matrix_projection) {
|
|
169
|
-
const _transform = this.transform;
|
|
170
|
-
_transform.set(transform.elements);
|
|
171
|
-
|
|
172
|
-
// build projection matrix
|
|
173
|
-
const projection_matrix = this.projection_matrix;
|
|
174
|
-
|
|
175
|
-
mat4.multiply(projection_matrix, matrix_world_inverse.elements, _transform);
|
|
176
|
-
mat4.multiply(projection_matrix, matrix_projection.elements, projection_matrix);
|
|
177
|
-
|
|
178
|
-
// compute view frustum in model-space
|
|
179
|
-
array_setFromProjectionMatrix(this.frustum_f32, projection_matrix);
|
|
180
|
-
}
|
|
181
|
-
}
|