@woosh/meep-engine 2.39.43 → 2.40.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/core/binary/BinaryBuffer.js +14 -1
- package/core/bvh2/aabb3/AABB3.js +0 -133
- package/core/bvh2/aabb3/aabb3_intersects_line_segment.js +1 -1
- package/core/geom/3d/matrix/MATRIX_4_IDENTITY.js +9 -0
- package/core/geom/Quaternion.js +8 -8
- package/core/geom/Quaternion.spec.js +13 -0
- package/core/geom/Vector1.d.ts +2 -0
- package/core/parser/simple/DataType.js +2 -2
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +28 -4
- package/editor/view/EditorView.js +25 -22
- package/editor/view/ecs/components/common/NumberController.js +56 -9
- package/engine/EngineHarness.js +2 -4
- package/engine/asset/loaders/image/png/PNG.js +6 -0
- package/engine/asset/loaders/image/png/PNGReader.js +82 -2
- package/engine/asset/loaders/image/png/crc.js +66 -0
- package/engine/ecs/speaker/VoiceSystem.js +1 -1
- package/engine/ecs/terrain/ecs/Terrain.js +58 -36
- package/engine/ecs/terrain/ecs/TerrainSystem.js +22 -4
- package/engine/ecs/terrain/tiles/TerrainTile.js +109 -131
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +100 -121
- package/engine/graphics/ecs/camera/Camera.js +1 -1
- package/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +4 -4
- package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +0 -78
- package/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +0 -9
- package/engine/graphics/render/forward_plus/LightManager.js +25 -0
- package/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +6 -2
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +6 -11
- package/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +268 -2
- package/engine/graphics/texture/atlas/AtlasPatch.js +12 -6
- package/engine/intelligence/behavior/util/LogMessageBehavior.js +29 -0
- package/engine/logging/ConsoleLoggerBackend.js +15 -0
- package/engine/logging/Logger.js +24 -1
- package/engine/logging/LoggerBackend.js +1 -0
- package/engine/physics/fluid/FluidField.js +9 -0
- package/engine/physics/fluid/effector/AbstractFluidEffector.js +6 -0
- package/engine/physics/fluid/effector/GlobalFluidEffector.js +12 -0
- package/engine/physics/fluid/effector/WakeFluidEffector.js +8 -0
- package/package.json +1 -1
|
@@ -7,7 +7,14 @@ import { PNG } from './PNG.js';
|
|
|
7
7
|
import { BinaryBuffer } from "../../../../../core/binary/BinaryBuffer.js";
|
|
8
8
|
import { isArrayEqualStrict } from "../../../../../core/collection/array/isArrayEqualStrict.js";
|
|
9
9
|
import { PNG_HEADER_BYTES } from "./PNG_HEADER_BYTES.js";
|
|
10
|
+
import { crc } from "./crc.js";
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {Uint8Array} buffer
|
|
15
|
+
* @param {number} offset
|
|
16
|
+
* @return {number}
|
|
17
|
+
*/
|
|
11
18
|
function readUInt32(buffer, offset) {
|
|
12
19
|
return (buffer[offset] << 24) +
|
|
13
20
|
(buffer[offset + 1] << 16) +
|
|
@@ -16,6 +23,12 @@ function readUInt32(buffer, offset) {
|
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {Uint8Array} buffer
|
|
29
|
+
* @param {number} offset
|
|
30
|
+
* @return {number}
|
|
31
|
+
*/
|
|
19
32
|
function readUInt8(buffer, offset) {
|
|
20
33
|
return buffer[offset];
|
|
21
34
|
}
|
|
@@ -37,8 +50,19 @@ export function PNGReader(bytes) {
|
|
|
37
50
|
|
|
38
51
|
this.buffer = new BinaryBuffer();
|
|
39
52
|
this.buffer.fromArrayBuffer(bytes);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Whether CRC should be performed or not
|
|
56
|
+
* @type {boolean}
|
|
57
|
+
*/
|
|
58
|
+
this.crc_enabled = false;
|
|
40
59
|
}
|
|
41
60
|
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {number} length
|
|
64
|
+
* @return {Uint8Array}
|
|
65
|
+
*/
|
|
42
66
|
PNGReader.prototype.readBytes = function (length) {
|
|
43
67
|
const result = new Uint8Array(length);
|
|
44
68
|
|
|
@@ -91,16 +115,31 @@ PNGReader.prototype.decodeChunk = function () {
|
|
|
91
115
|
throw new Error('Bad chunk length ' + (0xFFFFFFFF & length));
|
|
92
116
|
}
|
|
93
117
|
|
|
118
|
+
|
|
119
|
+
const chunk_address = buffer.position;
|
|
120
|
+
|
|
94
121
|
const type = buffer.readASCIICharacters(4);
|
|
95
122
|
|
|
96
123
|
/**
|
|
97
124
|
*
|
|
98
125
|
* @type {Uint8Array}
|
|
99
126
|
*/
|
|
100
|
-
|
|
127
|
+
const chunk = this.readBytes(length);
|
|
101
128
|
|
|
102
129
|
// checksum
|
|
103
|
-
|
|
130
|
+
const crc_expected = buffer.readUint32();
|
|
131
|
+
|
|
132
|
+
if (this.crc_enabled) {
|
|
133
|
+
|
|
134
|
+
// NOTE: CRC includes the "type" tag, not just the chunk bytes
|
|
135
|
+
const crc_actual = crc(buffer.raw_bytes, chunk_address, length + 4);
|
|
136
|
+
|
|
137
|
+
if (crc_actual !== crc_expected) {
|
|
138
|
+
console.warn(`CRC (Cyclic Redundancy Check) error at block '${type}' at address ${chunk_address}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
104
143
|
|
|
105
144
|
switch (type) {
|
|
106
145
|
case 'IHDR':
|
|
@@ -118,12 +157,53 @@ PNGReader.prototype.decodeChunk = function () {
|
|
|
118
157
|
case 'IEND':
|
|
119
158
|
this.decodeIEND(chunk);
|
|
120
159
|
break;
|
|
160
|
+
default:
|
|
161
|
+
//console.log(`Unsupported block ${type}`);
|
|
162
|
+
break;
|
|
121
163
|
}
|
|
122
164
|
|
|
123
165
|
return type;
|
|
124
166
|
|
|
125
167
|
};
|
|
126
168
|
|
|
169
|
+
/**
|
|
170
|
+
* https://www.w3.org/TR/PNG/#11tEXt
|
|
171
|
+
* @param {Uint8Array} chunk
|
|
172
|
+
*/
|
|
173
|
+
PNGReader.prototype.decodetEXt = function (chunk) {
|
|
174
|
+
const buff = BinaryBuffer.fromArrayBuffer(chunk.buffer);
|
|
175
|
+
const keyword = buff.readASCIICharacters(Number.POSITIVE_INFINITY, true);
|
|
176
|
+
|
|
177
|
+
const value = buff.readASCIICharacters(keyword.length - 1, false);
|
|
178
|
+
|
|
179
|
+
this.png.text[keyword] = value;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* NOTE: untested
|
|
183
|
+
* https://www.w3.org/TR/PNG/#11iEXt
|
|
184
|
+
* @param {Uint8Array} chunk
|
|
185
|
+
*/
|
|
186
|
+
PNGReader.prototype.decodeiEXt = function (chunk) {
|
|
187
|
+
const buff = BinaryBuffer.fromArrayBuffer(chunk.buffer);
|
|
188
|
+
|
|
189
|
+
const keyword = buff.readASCIICharacters(Number.POSITIVE_INFINITY, true);
|
|
190
|
+
|
|
191
|
+
const compression_flag = buff.readUint8();
|
|
192
|
+
const compression_method = buff.readUint8();
|
|
193
|
+
const language_tag = buff.readASCIICharacters(Number.POSITIVE_INFINITY, true);
|
|
194
|
+
const translated_keyword = buff.readUTF8String();
|
|
195
|
+
|
|
196
|
+
const separator = buff.readUint8();
|
|
197
|
+
|
|
198
|
+
if (separator !== 0) {
|
|
199
|
+
throw new Error('Expected Null Separator after Translated keyword');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const text = buff.readUTF8String();
|
|
203
|
+
|
|
204
|
+
this.png.text[keyword] = text;
|
|
205
|
+
}
|
|
206
|
+
|
|
127
207
|
/**
|
|
128
208
|
* http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR
|
|
129
209
|
* http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.IHDR
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ported from C source at https://www.w3.org/TR/PNG-CRCAppendix.html
|
|
3
|
+
* See also ISO 3309 [ISO-3309] or ITU-T V.42 [ITU-V42] for a formal specification
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {Uint32Array}
|
|
9
|
+
*/
|
|
10
|
+
const crc_table = new Uint32Array(256);
|
|
11
|
+
|
|
12
|
+
// Precompute checksum table
|
|
13
|
+
for (let n = 0; n < 256; n++) {
|
|
14
|
+
let c = n;
|
|
15
|
+
for (let k = 0; k < 8; k++) {
|
|
16
|
+
if (c & 1) {
|
|
17
|
+
c = 0xedb88320 ^ (c >>> 1);
|
|
18
|
+
} else {
|
|
19
|
+
c = c >>> 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
crc_table[n] = c;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const INITIAL = 0xffffffff;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Update a running CRC with the bytes buf[0..len-1]--the CRC
|
|
29
|
+
* should be initialized to all 1's, and the transmitted value
|
|
30
|
+
* is the 1's complement of the final running CRC (see the
|
|
31
|
+
* crc() routine below)).
|
|
32
|
+
* @param {number} crc
|
|
33
|
+
* @param {Uint8Array} buf
|
|
34
|
+
* @param {number} offset
|
|
35
|
+
* @param {number} len
|
|
36
|
+
* @return {number}
|
|
37
|
+
*/
|
|
38
|
+
function update_crc(
|
|
39
|
+
crc,
|
|
40
|
+
buf,
|
|
41
|
+
offset,
|
|
42
|
+
len,
|
|
43
|
+
) {
|
|
44
|
+
let c = crc;
|
|
45
|
+
|
|
46
|
+
const end = offset + len;
|
|
47
|
+
|
|
48
|
+
for (let n = offset; n < end; n++) {
|
|
49
|
+
const lookup_index = (c ^ buf[n]) & 0xff;
|
|
50
|
+
|
|
51
|
+
c = crc_table[lookup_index] ^ (c >>> 8);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return c;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns CRC of the bytes buf[0..len-1]
|
|
59
|
+
* @param {Uint8Array} buf byte buffer
|
|
60
|
+
* @param {number} offset
|
|
61
|
+
* @param {number} len how many bytes to include in checksum calculation
|
|
62
|
+
* @return {number}
|
|
63
|
+
*/
|
|
64
|
+
export function crc(buf, offset, len) {
|
|
65
|
+
return (update_crc(INITIAL, buf, offset, len) ^ INITIAL) >>> 0;
|
|
66
|
+
}
|
|
@@ -429,7 +429,7 @@ export class VoiceSystem extends AbstractContextSystem {
|
|
|
429
429
|
const bb = ecd.getComponent(entity, Blackboard);
|
|
430
430
|
|
|
431
431
|
if (bb !== undefined) {
|
|
432
|
-
bb.
|
|
432
|
+
bb.incrementNumber(`voice.line_spoken.${line_id}.count`);
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
}
|
|
@@ -37,6 +37,8 @@ import { buildLightTexture } from "./BuildLightTexture.js";
|
|
|
37
37
|
import { promiseSamplerHeight } from "./PromiseSamplerHeight.js";
|
|
38
38
|
import { loadLegacyTerrainSplats } from "./splat/loadLegacyTerrainSplats.js";
|
|
39
39
|
import { WHITE_PIXEL_DATA_URL } from "../../../graphics/WHITE_PIXEL_DATA_URL.js";
|
|
40
|
+
import { mat4 } from "gl-matrix";
|
|
41
|
+
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
40
42
|
|
|
41
43
|
let idCounter = 0;
|
|
42
44
|
|
|
@@ -157,6 +159,13 @@ class Terrain {
|
|
|
157
159
|
*/
|
|
158
160
|
this.frustumCulled = true;
|
|
159
161
|
|
|
162
|
+
/**
|
|
163
|
+
* 4x4 transform matrix
|
|
164
|
+
* @private
|
|
165
|
+
* @type {Float32Array}
|
|
166
|
+
*/
|
|
167
|
+
this.__transform_matrix = mat4.create();
|
|
168
|
+
|
|
160
169
|
|
|
161
170
|
/**
|
|
162
171
|
*
|
|
@@ -176,6 +185,11 @@ class Terrain {
|
|
|
176
185
|
*/
|
|
177
186
|
this.__buildWorker = makeTerrainWorkerProxy();
|
|
178
187
|
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* @type {TerrainTileManager}
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
179
193
|
this.__tiles = new TerrainTileManager({
|
|
180
194
|
material: this.material,
|
|
181
195
|
buildWorker: this.__buildWorker
|
|
@@ -393,26 +407,17 @@ class Terrain {
|
|
|
393
407
|
* @param {function} errorCallback
|
|
394
408
|
*/
|
|
395
409
|
sampleHeight(x, y, callback, missCallback, errorCallback) {
|
|
396
|
-
assert.
|
|
397
|
-
assert.
|
|
398
|
-
assert.
|
|
410
|
+
assert.isFunction(callback, 'callback');
|
|
411
|
+
assert.isFunction(missCallback, 'missCallback');
|
|
412
|
+
assert.isFunction(errorCallback, 'errorCallback');
|
|
399
413
|
|
|
400
|
-
|
|
414
|
+
const hit = new SurfacePoint3();
|
|
401
415
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
* @param geometry
|
|
407
|
-
*/
|
|
408
|
-
function processHit(hit, face, geometry) {
|
|
409
|
-
if (!processed) {
|
|
410
|
-
processed = true;
|
|
411
|
-
callback(hit.y);
|
|
412
|
-
}
|
|
416
|
+
if (this.raycastVerticalFirstSync(hit, x, y)) {
|
|
417
|
+
callback(hit.position.y);
|
|
418
|
+
} else {
|
|
419
|
+
missCallback();
|
|
413
420
|
}
|
|
414
|
-
|
|
415
|
-
this.raycastVertical(x, y, processHit, missCallback, errorCallback);
|
|
416
421
|
}
|
|
417
422
|
|
|
418
423
|
/**
|
|
@@ -426,27 +431,27 @@ class Terrain {
|
|
|
426
431
|
* @param {number} directionZ
|
|
427
432
|
* @returns {boolean}
|
|
428
433
|
*/
|
|
429
|
-
raycastFirstSync(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
+
raycastFirstSync(
|
|
435
|
+
result,
|
|
436
|
+
originX, originY, originZ,
|
|
437
|
+
directionX, directionY, directionZ
|
|
438
|
+
) {
|
|
434
439
|
return this.__tiles.raycastFirstSync(result, originX, originY, originZ, directionX, directionY, directionZ);
|
|
435
440
|
}
|
|
436
441
|
|
|
437
442
|
/**
|
|
438
|
-
*
|
|
443
|
+
* @deprecated
|
|
439
444
|
* @param {Vector3} origin
|
|
440
445
|
* @param {Vector3} direction
|
|
441
446
|
* @param {function(hit:Vector3, normal:Vector3, geometry:BufferGeometry)} callback
|
|
442
447
|
* @param {function} missCallback
|
|
443
448
|
*/
|
|
444
449
|
raycast(origin, direction, callback, missCallback) {
|
|
445
|
-
|
|
450
|
+
throw new Error('Deprecated, use raycastFirstSync instead');
|
|
446
451
|
}
|
|
447
452
|
|
|
448
453
|
/**
|
|
449
|
-
*
|
|
454
|
+
* @deprecated
|
|
450
455
|
* @param {number} x
|
|
451
456
|
* @param {number} y
|
|
452
457
|
* @param {function} callback
|
|
@@ -454,11 +459,7 @@ class Terrain {
|
|
|
454
459
|
* @param {function} errorCallback
|
|
455
460
|
*/
|
|
456
461
|
raycastVertical(x, y, callback, missCallback, errorCallback) {
|
|
457
|
-
|
|
458
|
-
assert.typeOf(missCallback, 'function', 'missCallback');
|
|
459
|
-
assert.typeOf(errorCallback, 'function', 'errorCallback');
|
|
460
|
-
|
|
461
|
-
this.__tiles.raycastVertical(x, y, callback, missCallback);
|
|
462
|
+
throw new Error('Deprecated, use raycastVerticalFirstSync instead');
|
|
462
463
|
}
|
|
463
464
|
|
|
464
465
|
/**
|
|
@@ -469,12 +470,7 @@ class Terrain {
|
|
|
469
470
|
* @return {boolean}
|
|
470
471
|
*/
|
|
471
472
|
raycastVerticalFirstSync(contact, x, y) {
|
|
472
|
-
|
|
473
|
-
//tiles don't exist
|
|
474
|
-
return false;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
return this.__tiles.raycastVerticalFirstSync(contact, x, y);
|
|
473
|
+
return this.__tiles.raycastVerticalFirstSync(contact, x, y);
|
|
478
474
|
}
|
|
479
475
|
|
|
480
476
|
/**
|
|
@@ -649,6 +645,24 @@ class Terrain {
|
|
|
649
645
|
m.uniformsNeedUpdate = true;
|
|
650
646
|
}
|
|
651
647
|
|
|
648
|
+
/**
|
|
649
|
+
*
|
|
650
|
+
* @param {mat4|Float32Array|number[]} m4
|
|
651
|
+
*/
|
|
652
|
+
set transform(m4) {
|
|
653
|
+
mat4.copy(this.__transform_matrix, m4);
|
|
654
|
+
|
|
655
|
+
this.__tiles.transform = m4;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
*
|
|
660
|
+
* @return {Float32Array}
|
|
661
|
+
*/
|
|
662
|
+
get transform() {
|
|
663
|
+
return this.__transform_matrix;
|
|
664
|
+
}
|
|
665
|
+
|
|
652
666
|
/**
|
|
653
667
|
*
|
|
654
668
|
* @param {TerrainLayer} layer
|
|
@@ -846,6 +860,14 @@ class Terrain {
|
|
|
846
860
|
this.setFlag(TerrainFlags.Built);
|
|
847
861
|
}
|
|
848
862
|
|
|
863
|
+
/**
|
|
864
|
+
* Note: For advanced users only. You can seriously mess up how things look and function with respect to terrain here
|
|
865
|
+
* @return {TerrainTileManager}
|
|
866
|
+
*/
|
|
867
|
+
get tiles() {
|
|
868
|
+
return this.__tiles;
|
|
869
|
+
}
|
|
870
|
+
|
|
849
871
|
/**
|
|
850
872
|
*
|
|
851
873
|
* @returns {Texture|null}
|
|
@@ -5,6 +5,8 @@ import { assert } from "../../../../core/assert.js";
|
|
|
5
5
|
import { noop } from "../../../../core/function/Functions.js";
|
|
6
6
|
import { TerrainFlags } from "./TerrainFlags.js";
|
|
7
7
|
import { ImageRGBADataLoader } from "../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
8
|
+
import { Transform } from "../../transform/Transform.js";
|
|
9
|
+
import { MATRIX_4_IDENTITY } from "../../../../core/geom/3d/matrix/MATRIX_4_IDENTITY.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
*
|
|
@@ -157,9 +159,12 @@ class TerrainSystem extends System {
|
|
|
157
159
|
this.__time_delta = timeDelta;
|
|
158
160
|
|
|
159
161
|
|
|
160
|
-
if (dataset
|
|
161
|
-
|
|
162
|
+
if (dataset === null) {
|
|
163
|
+
return;
|
|
162
164
|
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
dataset.traverseComponents(Terrain, this.__visitTerrainComponent, this);
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
/**
|
|
@@ -171,13 +176,26 @@ class TerrainSystem extends System {
|
|
|
171
176
|
__visitTerrainComponent(terrain, entity) {
|
|
172
177
|
const em = this.entityManager;
|
|
173
178
|
|
|
174
|
-
const
|
|
179
|
+
const ecd = em.dataset;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @type {Transform|undefined}
|
|
184
|
+
*/
|
|
185
|
+
const transform = ecd.getComponent(entity, Transform);
|
|
186
|
+
|
|
187
|
+
if (transform !== undefined) {
|
|
188
|
+
// terrain has a transform
|
|
189
|
+
terrain.transform = transform.matrix;
|
|
190
|
+
}else{
|
|
191
|
+
terrain.transform = MATRIX_4_IDENTITY;
|
|
192
|
+
}
|
|
175
193
|
|
|
176
194
|
terrain.update(this.__time_delta);
|
|
177
195
|
|
|
178
196
|
//do frustum culling
|
|
179
197
|
if (terrain.frustumCulled) {
|
|
180
|
-
TerrainSystem.traverseVisibleTiles(
|
|
198
|
+
TerrainSystem.traverseVisibleTiles(ecd, terrain, ensureTileBuilt);
|
|
181
199
|
}
|
|
182
200
|
}
|
|
183
201
|
|