@woosh/meep-engine 2.33.8 → 2.33.12
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 +26 -2
- package/core/collection/table/DataType2TypedArrayConstructorMapping.js +2 -0
- package/core/collection/table/DataTypeByteSizes.js +21 -0
- package/core/collection/table/RowFirstTable.js +1 -88
- package/core/collection/table/RowFirstTable.spec.js +3 -1
- package/core/collection/table/RowFirstTableSpec.js +1 -19
- package/core/collection/table/computeDataTypeByIndex.js +21 -0
- package/core/collection/table/deserializeRowFirstTable.js +48 -0
- package/core/collection/table/serializeRowFirstTable.js +27 -0
- package/core/process/worker/WorkerBuilder.js +25 -8
- package/engine/ecs/foliage/InstancedFoliage.js +3 -5
- package/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +2 -1
- package/engine/graphics/micron/format/MicronGeometry.js +12 -0
- package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
- package/engine/graphics/micron/format/MicronGeometryPatch.js +6 -6
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +101 -0
- package/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +25 -0
- package/engine/graphics/micron/format/serialization/deserialize_patch.js +104 -0
- package/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +18 -0
- package/engine/graphics/micron/format/serialization/serialize_patch.js +84 -0
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +1 -1
- package/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +1 -1
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +11 -6
- package/engine/graphics/texture/sampler/TextureBinaryBufferSerializer.js +1 -1
- package/engine/network/convertPathToURL.js +7 -1
- package/package.json +1 -1
|
@@ -342,7 +342,7 @@ BinaryBuffer.prototype.readInt32Array = function (destination, destination_offse
|
|
|
342
342
|
*
|
|
343
343
|
* @param {number} destination_offset starting index in the destination array
|
|
344
344
|
* @param {number} length number of elements to read
|
|
345
|
-
* @param {Float32Array} destination
|
|
345
|
+
* @param {Float32Array|number[]} destination
|
|
346
346
|
*/
|
|
347
347
|
BinaryBuffer.prototype.readFloat32Array = function (destination, destination_offset, length) {
|
|
348
348
|
for (let i = 0; i < length; i++) {
|
|
@@ -366,7 +366,7 @@ BinaryBuffer.prototype.readFloat64Array = function (destination, destination_off
|
|
|
366
366
|
*
|
|
367
367
|
* @param {number} source_offset starting index in the source array
|
|
368
368
|
* @param {number} length number of elements to read
|
|
369
|
-
* @param {Float32Array} source
|
|
369
|
+
* @param {Float32Array|number[]} source
|
|
370
370
|
*/
|
|
371
371
|
BinaryBuffer.prototype.writeFloat32Array = function (source, source_offset, length) {
|
|
372
372
|
for (let i = 0; i < length; i++) {
|
|
@@ -452,6 +452,18 @@ BinaryBuffer.prototype.writeUint8 = function (value) {
|
|
|
452
452
|
this.position = end;
|
|
453
453
|
};
|
|
454
454
|
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* @param {Uint8Array|number[]} source
|
|
458
|
+
* @param {number} source_offset
|
|
459
|
+
* @param {number} length
|
|
460
|
+
*/
|
|
461
|
+
BinaryBuffer.prototype.writeUint8Array = function (source, source_offset, length) {
|
|
462
|
+
for (let i = 0; i < length; i++) {
|
|
463
|
+
this.writeUint8(source[source_offset + i]);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
455
467
|
/**
|
|
456
468
|
*
|
|
457
469
|
* @param {number} value
|
|
@@ -491,6 +503,18 @@ BinaryBuffer.prototype.writeUint16LE = function (value) {
|
|
|
491
503
|
this.position = end;
|
|
492
504
|
};
|
|
493
505
|
|
|
506
|
+
/**
|
|
507
|
+
*
|
|
508
|
+
* @param {Uint16Array|number[]} source
|
|
509
|
+
* @param {number} source_offset
|
|
510
|
+
* @param {number} length
|
|
511
|
+
*/
|
|
512
|
+
BinaryBuffer.prototype.writeUint16Array = function (source, source_offset, length) {
|
|
513
|
+
for (let i = 0; i < length; i++) {
|
|
514
|
+
this.writeUint16(source[source_offset + i]);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
494
518
|
/**
|
|
495
519
|
*
|
|
496
520
|
* @param {number} value
|
|
@@ -12,6 +12,8 @@ export const DataType2TypedArrayConstructorMapping = {
|
|
|
12
12
|
[DataType.Int8]: Int8Array,
|
|
13
13
|
[DataType.Int16]: Int16Array,
|
|
14
14
|
[DataType.Int32]: Int32Array,
|
|
15
|
+
// No float16 array type, using uint16 as a backing instead
|
|
16
|
+
[DataType.Float16]: Uint16Array,
|
|
15
17
|
[DataType.Float32]: Float32Array,
|
|
16
18
|
[DataType.Float64]: Float64Array,
|
|
17
19
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataType } from "./DataType.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @readonly
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export const DataTypeByteSizes = {
|
|
8
|
+
[DataType.Uint8]: 1,
|
|
9
|
+
[DataType.Uint16]: 2,
|
|
10
|
+
[DataType.Uint32]: 4,
|
|
11
|
+
[DataType.Uint64]: 8,
|
|
12
|
+
|
|
13
|
+
[DataType.Int8]: 1,
|
|
14
|
+
[DataType.Int16]: 2,
|
|
15
|
+
[DataType.Int32]: 4,
|
|
16
|
+
[DataType.Int64]: 8,
|
|
17
|
+
|
|
18
|
+
[DataType.Float16]: 2,
|
|
19
|
+
[DataType.Float32]: 4,
|
|
20
|
+
[DataType.Float64]: 8
|
|
21
|
+
};
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { assert } from "../../assert.js";
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
8
|
import { max2 } from "../../math/max2.js";
|
|
9
|
-
import { DataTypeIndices } from "./DataTypeIndices.js";
|
|
10
9
|
import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
|
|
11
10
|
|
|
12
11
|
|
|
@@ -439,92 +438,6 @@ RowFirstTable.prototype.printToConsole = function () {
|
|
|
439
438
|
console.table(rows);
|
|
440
439
|
};
|
|
441
440
|
|
|
442
|
-
/**
|
|
443
|
-
*
|
|
444
|
-
* @param {BinaryBuffer} buffer
|
|
445
|
-
* @param {RowFirstTable} table
|
|
446
|
-
*/
|
|
447
|
-
function serializeRowFirstTable(buffer, table) {
|
|
448
|
-
//write types
|
|
449
|
-
buffer.writeUint16(table.types.length);
|
|
450
|
-
table.types.forEach(function (type) {
|
|
451
|
-
const typeIndex = DataTypeIndices[type];
|
|
452
|
-
buffer.writeUint8(typeIndex);
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
//write record length
|
|
456
|
-
buffer.writeUint32(table.bytesPerRecord);
|
|
457
|
-
|
|
458
|
-
//write number of records
|
|
459
|
-
buffer.writeUint32(table.length);
|
|
460
|
-
|
|
461
|
-
//write data
|
|
462
|
-
const numDataBytes = table.length * table.bytesPerRecord;
|
|
463
|
-
buffer.writeBytes(new Uint8Array(table.data), 0, numDataBytes);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
*
|
|
468
|
-
* @param {BinaryBuffer} buffer
|
|
469
|
-
* @param {RowFirstTable} table
|
|
470
|
-
*/
|
|
471
|
-
function deserializeRowFirstTable(buffer, table) {
|
|
472
|
-
/**
|
|
473
|
-
*
|
|
474
|
-
* @param {number} index
|
|
475
|
-
* @returns {DataType|null}
|
|
476
|
-
*/
|
|
477
|
-
function typeByIndex(index) {
|
|
478
|
-
for (let type in DataTypeIndices) {
|
|
479
|
-
if (!DataTypeIndices.hasOwnProperty(type)) {
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
const typeIndex = DataTypeIndices[type];
|
|
484
|
-
if (typeIndex === index) {
|
|
485
|
-
return type;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
return null;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
//read types
|
|
493
|
-
const numTypes = buffer.readUint16();
|
|
494
|
-
const types = [];
|
|
495
|
-
for (let i = 0; i < numTypes; i++) {
|
|
496
|
-
const typeIndex = buffer.readUint8();
|
|
497
|
-
const type = typeByIndex(typeIndex);
|
|
498
|
-
if (type === null) {
|
|
499
|
-
throw new Error(`Unknown DataType index ${typeIndex}`);
|
|
500
|
-
}
|
|
501
|
-
types[i] = type;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
//record size
|
|
505
|
-
const bytesPerRecord = buffer.readUint32();
|
|
506
|
-
|
|
507
|
-
//read number of records
|
|
508
|
-
const numRecords = buffer.readUint32();
|
|
509
|
-
|
|
510
|
-
const numDataBytes = bytesPerRecord * numRecords;
|
|
511
|
-
const data = new Uint8Array(numDataBytes);
|
|
512
|
-
|
|
513
|
-
//read data
|
|
514
|
-
buffer.readBytes(data, 0, numDataBytes);
|
|
515
|
-
|
|
516
|
-
//update table
|
|
517
|
-
table.spec = RowFirstTableSpec.get(types);
|
|
518
|
-
table.length = numRecords;
|
|
519
|
-
table.capacity = numRecords;
|
|
520
|
-
table.data = data.buffer;
|
|
521
|
-
table.dataView = new DataView(table.data);
|
|
522
|
-
|
|
523
|
-
table.initialize();
|
|
524
|
-
}
|
|
525
|
-
|
|
526
441
|
export {
|
|
527
|
-
RowFirstTable
|
|
528
|
-
serializeRowFirstTable,
|
|
529
|
-
deserializeRowFirstTable
|
|
442
|
+
RowFirstTable
|
|
530
443
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BinaryBuffer } from "../../binary/BinaryBuffer.js";
|
|
2
2
|
import { DataType } from "./DataType.js";
|
|
3
|
-
import {
|
|
3
|
+
import { RowFirstTable } from "./RowFirstTable.js";
|
|
4
4
|
import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
|
|
5
|
+
import { serializeRowFirstTable } from "./serializeRowFirstTable.js";
|
|
6
|
+
import { deserializeRowFirstTable } from "./deserializeRowFirstTable.js";
|
|
5
7
|
|
|
6
8
|
test("constructor doesn't throw", () => {
|
|
7
9
|
new RowFirstTable(new RowFirstTableSpec([]));
|
|
@@ -8,6 +8,7 @@ import { FunctionCompiler } from "../../function/FunctionCompiler.js";
|
|
|
8
8
|
import { computeStringHash } from "../../primitives/strings/computeStringHash.js";
|
|
9
9
|
import { isArrayEqualStrict } from "../array/isArrayEqualStrict.js";
|
|
10
10
|
import { DataType } from "./DataType.js";
|
|
11
|
+
import { DataTypeByteSizes } from "./DataTypeByteSizes.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @readonly
|
|
@@ -47,25 +48,6 @@ export const DataType2DataViewWriters = {
|
|
|
47
48
|
"float64": "setFloat64"
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
/**
|
|
51
|
-
* @readonly
|
|
52
|
-
* @enum {number}
|
|
53
|
-
*/
|
|
54
|
-
export const DataTypeByteSizes = {
|
|
55
|
-
[DataType.Uint8]: 1,
|
|
56
|
-
[DataType.Uint16]: 2,
|
|
57
|
-
[DataType.Uint32]: 4,
|
|
58
|
-
[DataType.Uint64]: 8,
|
|
59
|
-
|
|
60
|
-
[DataType.Int8]: 1,
|
|
61
|
-
[DataType.Int16]: 2,
|
|
62
|
-
[DataType.Int32]: 4,
|
|
63
|
-
[DataType.Int64]: 8,
|
|
64
|
-
|
|
65
|
-
[DataType.Float32]: 4,
|
|
66
|
-
[DataType.Float64]: 8
|
|
67
|
-
};
|
|
68
|
-
|
|
69
51
|
/**
|
|
70
52
|
*
|
|
71
53
|
* @param {DataType[]} types
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataTypeIndices } from "./DataTypeIndices.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} index
|
|
6
|
+
* @returns {DataType|undefined}
|
|
7
|
+
*/
|
|
8
|
+
export function computeDataTypeByIndex(index) {
|
|
9
|
+
for (let type in DataTypeIndices) {
|
|
10
|
+
if (!DataTypeIndices.hasOwnProperty(type)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const typeIndex = DataTypeIndices[type];
|
|
15
|
+
if (typeIndex === index) {
|
|
16
|
+
return type;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RowFirstTableSpec } from "./RowFirstTableSpec.js";
|
|
2
|
+
import { computeDataTypeByIndex } from "./computeDataTypeByIndex.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {BinaryBuffer} buffer
|
|
7
|
+
* @param {RowFirstTable} table
|
|
8
|
+
*/
|
|
9
|
+
function deserializeRowFirstTable(buffer, table) {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
//read types
|
|
13
|
+
const numTypes = buffer.readUint16();
|
|
14
|
+
const types = [];
|
|
15
|
+
for (let i = 0; i < numTypes; i++) {
|
|
16
|
+
const typeIndex = buffer.readUint8();
|
|
17
|
+
|
|
18
|
+
const type = computeDataTypeByIndex(typeIndex);
|
|
19
|
+
|
|
20
|
+
if (type === undefined) {
|
|
21
|
+
throw new Error(`Unknown DataType index ${typeIndex}`);
|
|
22
|
+
}
|
|
23
|
+
types[i] = type;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//record size
|
|
27
|
+
const bytesPerRecord = buffer.readUint32();
|
|
28
|
+
|
|
29
|
+
//read number of records
|
|
30
|
+
const numRecords = buffer.readUint32();
|
|
31
|
+
|
|
32
|
+
const numDataBytes = bytesPerRecord * numRecords;
|
|
33
|
+
const data = new Uint8Array(numDataBytes);
|
|
34
|
+
|
|
35
|
+
//read data
|
|
36
|
+
buffer.readBytes(data, 0, numDataBytes);
|
|
37
|
+
|
|
38
|
+
//update table
|
|
39
|
+
table.spec = RowFirstTableSpec.get(types);
|
|
40
|
+
table.length = numRecords;
|
|
41
|
+
table.capacity = numRecords;
|
|
42
|
+
table.data = data.buffer;
|
|
43
|
+
table.dataView = new DataView(table.data);
|
|
44
|
+
|
|
45
|
+
table.initialize();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { deserializeRowFirstTable };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DataTypeIndices } from "./DataTypeIndices.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {RowFirstTable} table
|
|
7
|
+
*/
|
|
8
|
+
function serializeRowFirstTable(buffer, table) {
|
|
9
|
+
//write types
|
|
10
|
+
buffer.writeUint16(table.types.length);
|
|
11
|
+
table.types.forEach(function (type) {
|
|
12
|
+
const typeIndex = DataTypeIndices[type];
|
|
13
|
+
buffer.writeUint8(typeIndex);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//write record length
|
|
17
|
+
buffer.writeUint32(table.bytesPerRecord);
|
|
18
|
+
|
|
19
|
+
//write number of records
|
|
20
|
+
buffer.writeUint32(table.length);
|
|
21
|
+
|
|
22
|
+
//write data
|
|
23
|
+
const numDataBytes = table.length * table.bytesPerRecord;
|
|
24
|
+
buffer.writeBytes(new Uint8Array(table.data), 0, numDataBytes);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { serializeRowFirstTable };
|
|
@@ -52,17 +52,34 @@ WorkerBuilder.prototype.importScript = function (path) {
|
|
|
52
52
|
this.imports.push(path);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {string} code
|
|
58
|
+
* @return {string}
|
|
59
|
+
*/
|
|
55
60
|
function codeToURL(code) {
|
|
61
|
+
const js_mime = 'application/javascript';
|
|
62
|
+
|
|
56
63
|
let blob;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
|
|
65
|
+
if (Blob !== undefined) {
|
|
66
|
+
blob = new Blob([code], { type: js_mime });
|
|
67
|
+
} else if (window !== undefined) {
|
|
68
|
+
// Backwards-compatibility
|
|
69
|
+
const BlobBuilder = window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
|
|
70
|
+
if (BlobBuilder !== undefined) {
|
|
71
|
+
blob = new BlobBuilder();
|
|
72
|
+
blob.append(code);
|
|
73
|
+
blob = blob.getBlob();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (blob !== undefined && URL.createObjectURL !== undefined) {
|
|
78
|
+
return URL.createObjectURL(blob);
|
|
79
|
+
} else {
|
|
80
|
+
// build data URL in a slowest way possible
|
|
81
|
+
return `data:${js_mime},${encodeURIComponent(code)}`;
|
|
64
82
|
}
|
|
65
|
-
return URL.createObjectURL(blob);
|
|
66
83
|
}
|
|
67
84
|
|
|
68
85
|
/**
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { BinaryNode } from "../../../core/bvh2/BinaryNode.js";
|
|
2
|
-
import {
|
|
3
|
-
deserializeRowFirstTable,
|
|
4
|
-
RowFirstTable,
|
|
5
|
-
serializeRowFirstTable
|
|
6
|
-
} from "../../../core/collection/table/RowFirstTable.js";
|
|
2
|
+
import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
|
|
7
3
|
import { InstancedMeshGroup } from "../../graphics/geometry/instancing/InstancedMeshGroup.js";
|
|
8
4
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
9
5
|
import { LeafNode } from "../../../core/bvh2/LeafNode.js";
|
|
@@ -19,6 +15,8 @@ import { traverseBinaryNodeUsingVisitor } from "../../../core/bvh2/traversal/tra
|
|
|
19
15
|
import { serializeBinaryNodeToBinaryBuffer } from "../../../core/bvh2/serialization/serializeBinaryNodeToBinaryBuffer.js";
|
|
20
16
|
import { deserializeBinaryNodeFromBinaryBuffer } from "../../../core/bvh2/serialization/deserializeBinaryNodeFromBinaryBuffer.js";
|
|
21
17
|
import { computeGeometryBoundingSphereMiniball } from "../../graphics/geometry/buffered/computeGeometryBoundingSphereMiniball.js";
|
|
18
|
+
import { serializeRowFirstTable } from "../../../core/collection/table/serializeRowFirstTable.js";
|
|
19
|
+
import { deserializeRowFirstTable } from "../../../core/collection/table/deserializeRowFirstTable.js";
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* @readonly
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BinaryClassSerializationAdapter } from "../../storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
-
import { deserializeRowFirstTable, serializeRowFirstTable } from "../../../../core/collection/table/RowFirstTable.js";
|
|
3
2
|
import { FogOfWar } from "../FogOfWar.js";
|
|
3
|
+
import { serializeRowFirstTable } from "../../../../core/collection/table/serializeRowFirstTable.js";
|
|
4
|
+
import { deserializeRowFirstTable } from "../../../../core/collection/table/deserializeRowFirstTable.js";
|
|
4
5
|
|
|
5
6
|
export class FogOfWarSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
6
7
|
constructor() {
|
|
@@ -55,6 +55,18 @@ export class MicronGeometry {
|
|
|
55
55
|
this.__proxy = null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
get patches() {
|
|
59
|
+
return this.__patches;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {MicronGeometryPatch[]} v
|
|
65
|
+
*/
|
|
66
|
+
set patches(v) {
|
|
67
|
+
this.__patches = v;
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
/**
|
|
59
71
|
* @param {THREE.BufferGeometry} geometry
|
|
60
72
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
2
|
-
import { DataTypeByteSizes } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
3
2
|
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
3
|
+
import { DataTypeByteSizes } from "../../../../core/collection/table/DataTypeByteSizes.js";
|
|
4
4
|
|
|
5
5
|
export class MicronGeometryBufferAttributeSpec {
|
|
6
6
|
constructor() {
|
|
@@ -26,6 +26,12 @@ export class MicronGeometryPatch {
|
|
|
26
26
|
*/
|
|
27
27
|
this.bounding_box = new Float32Array(array_buffer, 0, 6);
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {vec4|number[]}
|
|
32
|
+
*/
|
|
33
|
+
this.bounding_sphere = vec4.create()
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
*
|
|
31
37
|
* @type {number[]|Float32Array}
|
|
@@ -50,12 +56,6 @@ export class MicronGeometryPatch {
|
|
|
50
56
|
*/
|
|
51
57
|
this.group_error = 0;
|
|
52
58
|
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @type {vec4}
|
|
56
|
-
*/
|
|
57
|
-
this.bounding_sphere = vec4.create()
|
|
58
|
-
|
|
59
59
|
/**
|
|
60
60
|
*
|
|
61
61
|
* @type {MicronGeometryPatch[]}
|
package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { MicronGeometry } from "../MicronGeometry.js";
|
|
3
|
+
import { MicronGeometryBufferAttributeSpec } from "../MicronGeometryBufferAttributeSpec.js";
|
|
4
|
+
import { MicronGeometryPatch } from "../MicronGeometryPatch.js";
|
|
5
|
+
import { serialize_patch } from "./serialize_patch.js";
|
|
6
|
+
import { deserialize_patch } from "./deserialize_patch.js";
|
|
7
|
+
import { serialize_attribute_spec } from "./serialize_attribute_spec.js";
|
|
8
|
+
import { deserialize_attribute_spec } from "./deserialize_attribute_spec.js";
|
|
9
|
+
|
|
10
|
+
export class MicronGeometryBinarySerializationAdapter extends BinaryClassSerializationAdapter {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.klass = MicronGeometry;
|
|
15
|
+
this.version = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {BinaryBuffer} buffer
|
|
21
|
+
* @param {MicronGeometry} value
|
|
22
|
+
*/
|
|
23
|
+
serialize(buffer, value) {
|
|
24
|
+
const spec = value.vertex_spec;
|
|
25
|
+
|
|
26
|
+
// serialize vertex spec
|
|
27
|
+
const attributes = spec.attributes;
|
|
28
|
+
const attribute_count = attributes.length;
|
|
29
|
+
buffer.writeUintVar(attribute_count);
|
|
30
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
31
|
+
const attribute = attributes[i];
|
|
32
|
+
|
|
33
|
+
serialize_attribute_spec(buffer, attribute);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// serialize patches
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {MicronGeometryPatch[]}
|
|
41
|
+
*/
|
|
42
|
+
const patches = value.patches;
|
|
43
|
+
const patch_count = patches.length;
|
|
44
|
+
|
|
45
|
+
const root_patch_index = patches.indexOf(value.root);
|
|
46
|
+
|
|
47
|
+
buffer.writeUintVar(root_patch_index);
|
|
48
|
+
|
|
49
|
+
buffer.writeUintVar(patch_count);
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < patch_count; i++) {
|
|
52
|
+
serialize_patch(buffer, patches[i], spec, patches);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {BinaryBuffer} buffer
|
|
59
|
+
* @param {MicronGeometry} value
|
|
60
|
+
*/
|
|
61
|
+
deserialize(buffer, value) {
|
|
62
|
+
// read spec
|
|
63
|
+
const attribute_count = buffer.readUintVar();
|
|
64
|
+
const attributes = [];
|
|
65
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
66
|
+
const spec = new MicronGeometryBufferAttributeSpec();
|
|
67
|
+
|
|
68
|
+
deserialize_attribute_spec(buffer, spec);
|
|
69
|
+
attributes[i] = spec;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const vertex_spec = value.vertex_spec;
|
|
73
|
+
vertex_spec.setAttributes(attributes);
|
|
74
|
+
|
|
75
|
+
// read patches
|
|
76
|
+
const root_patch_index = buffer.readUintVar();
|
|
77
|
+
|
|
78
|
+
const patch_count = buffer.readUintVar();
|
|
79
|
+
|
|
80
|
+
const patches = [];
|
|
81
|
+
|
|
82
|
+
// build initial patches
|
|
83
|
+
for (let i = 0; i < patch_count; i++) {
|
|
84
|
+
const patch = new MicronGeometryPatch();
|
|
85
|
+
|
|
86
|
+
patch.id = i;
|
|
87
|
+
|
|
88
|
+
patches[i] = patch;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//read patches
|
|
92
|
+
for (let i = 0; i < patch_count; i++) {
|
|
93
|
+
const patch = patches[i];
|
|
94
|
+
|
|
95
|
+
deserialize_patch(buffer, patch, vertex_spec, patches);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
value.patches = patches;
|
|
99
|
+
value.root = patches[root_patch_index];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computeDataTypeByIndex } from "../../../../../core/collection/table/computeDataTypeByIndex.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryBufferAttributeSpec} spec
|
|
7
|
+
*/
|
|
8
|
+
export function deserialize_attribute_spec(buffer, spec) {
|
|
9
|
+
|
|
10
|
+
spec.name = buffer.readUTF8String();
|
|
11
|
+
spec.itemSize = buffer.readUintVar();
|
|
12
|
+
|
|
13
|
+
const type_index = buffer.readUint8();
|
|
14
|
+
const type = computeDataTypeByIndex(type_index);
|
|
15
|
+
|
|
16
|
+
if (type === undefined) {
|
|
17
|
+
throw new Error(`Unknown data type marker '${type_index}'`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
spec.type = type;
|
|
21
|
+
|
|
22
|
+
const flags = buffer.readUint8();
|
|
23
|
+
|
|
24
|
+
spec.normalized = (flags & 0x1) !== 0;
|
|
25
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { aabb3_build_corners } from "../../../../../core/geom/3d/aabb/aabb3_build_corners.js";
|
|
2
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
3
|
+
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {BinaryBuffer} buffer
|
|
8
|
+
* @param {MicronGeometryPatch} patch
|
|
9
|
+
* @param {MicronVertexDataSpec} vertex_spec
|
|
10
|
+
* @param {MicronGeometryPatch[]} patch_array
|
|
11
|
+
*/
|
|
12
|
+
export function deserialize_patch(buffer, patch, vertex_spec, patch_array) {
|
|
13
|
+
// METADATA
|
|
14
|
+
buffer.readFloat32Array(patch.bounding_box, 0, 6);
|
|
15
|
+
buffer.readFloat32Array(patch.bounding_sphere, 0, 4);
|
|
16
|
+
|
|
17
|
+
const gbb = patch.group_bounding_box;
|
|
18
|
+
buffer.readFloat32Array(gbb, 0, 6);
|
|
19
|
+
buffer.readFloat32Array(patch.group_bounding_sphere, 0, 4);
|
|
20
|
+
|
|
21
|
+
// reconstruct corners
|
|
22
|
+
aabb3_build_corners(
|
|
23
|
+
patch.group_bounding_box_corners,
|
|
24
|
+
0,
|
|
25
|
+
gbb[0],
|
|
26
|
+
gbb[1],
|
|
27
|
+
gbb[2],
|
|
28
|
+
gbb[3],
|
|
29
|
+
gbb[4],
|
|
30
|
+
gbb[5]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
patch.group_error = buffer.readFloat32();
|
|
34
|
+
patch.lod = buffer.readUintVar();
|
|
35
|
+
patch.polygon_count = buffer.readUintVar();
|
|
36
|
+
patch.vertex_count = buffer.readUintVar();
|
|
37
|
+
|
|
38
|
+
// parents
|
|
39
|
+
const parents = [];
|
|
40
|
+
const parent_count = buffer.readUintVar();
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < parent_count; i++) {
|
|
43
|
+
const parent_index = buffer.readUintVar();
|
|
44
|
+
|
|
45
|
+
if (patch_array.length <= parent_index || parent_index < 0) {
|
|
46
|
+
throw new Error(`out of bounds parent index '${parent_index}'`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
parents[i] = patch_array[parent_index];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
patch.parents = parents;
|
|
53
|
+
|
|
54
|
+
// children
|
|
55
|
+
const children = [];
|
|
56
|
+
const child_count = buffer.readUintVar();
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < child_count; i++) {
|
|
59
|
+
const child_index = buffer.readUintVar();
|
|
60
|
+
|
|
61
|
+
if (patch_array.length <= child_index || child_index < 0) {
|
|
62
|
+
throw new Error(`out of bounds child index '${child_index}'`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
children[i] = patch_array[child_index];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
patch.children = children;
|
|
69
|
+
|
|
70
|
+
// INDICES
|
|
71
|
+
const index_count = patch.polygon_count * 3;
|
|
72
|
+
|
|
73
|
+
if (patch.vertex_count <= 256) {
|
|
74
|
+
patch.face_indices = new Uint8Array(index_count);
|
|
75
|
+
buffer.readUint8Array(patch.face_indices, 0, index_count);
|
|
76
|
+
} else if (patch.vertex_count <= 65536) {
|
|
77
|
+
patch.face_indices = new Uint16Array(index_count);
|
|
78
|
+
buffer.readUint16Array(patch.face_indices, 0, index_count);
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error(`Unsupported vertex count '${patch.vertex_count}'`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// VERTICES
|
|
84
|
+
const attributes = vertex_spec.attributes;
|
|
85
|
+
const attribute_count = attributes.length;
|
|
86
|
+
|
|
87
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
88
|
+
const spec = attributes[i];
|
|
89
|
+
|
|
90
|
+
const data_type = spec.type;
|
|
91
|
+
const item_size = spec.itemSize;
|
|
92
|
+
|
|
93
|
+
const byte_size = DataTypeByteSizes[data_type];
|
|
94
|
+
|
|
95
|
+
const ArrayConstructor = DataType2TypedArrayConstructorMapping[data_type];
|
|
96
|
+
|
|
97
|
+
const elment_count = item_size * patch.vertex_count;
|
|
98
|
+
const array = new ArrayConstructor(elment_count);
|
|
99
|
+
|
|
100
|
+
buffer.readUint8Array(new Uint8Array(array.buffer), 0, byte_size * elment_count);
|
|
101
|
+
|
|
102
|
+
patch.vertex_attribute_arrays[i] = array;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataTypeIndices } from "../../../../../core/collection/table/DataTypeIndices.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryBufferAttributeSpec} spec
|
|
7
|
+
*/
|
|
8
|
+
export function serialize_attribute_spec(buffer, spec) {
|
|
9
|
+
buffer.writeUTF8String(spec.name);
|
|
10
|
+
buffer.writeUintVar(spec.itemSize);
|
|
11
|
+
|
|
12
|
+
const dataTypeIndex = DataTypeIndices[spec.type];
|
|
13
|
+
buffer.writeUint8(dataTypeIndex);
|
|
14
|
+
|
|
15
|
+
const flags = spec.normalized ? 1 : 0;
|
|
16
|
+
|
|
17
|
+
buffer.writeUint8(flags);// flags
|
|
18
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {BinaryBuffer} buffer
|
|
6
|
+
* @param {MicronGeometryPatch} patch
|
|
7
|
+
* @param {MicronVertexDataSpec} vertex_spec
|
|
8
|
+
* @param {MicronGeometryPatch[]} patch_array
|
|
9
|
+
*/
|
|
10
|
+
export function serialize_patch(buffer, patch, vertex_spec, patch_array) {
|
|
11
|
+
// METADATA
|
|
12
|
+
buffer.writeFloat32Array(patch.bounding_box, 0, 6);
|
|
13
|
+
buffer.writeFloat32Array(patch.bounding_sphere, 0, 4);
|
|
14
|
+
|
|
15
|
+
buffer.writeFloat32Array(patch.group_bounding_box, 0, 6);
|
|
16
|
+
buffer.writeFloat32Array(patch.group_bounding_sphere, 0, 4);
|
|
17
|
+
|
|
18
|
+
buffer.writeFloat32(patch.group_error);
|
|
19
|
+
buffer.writeUintVar(patch.lod);
|
|
20
|
+
buffer.writeUintVar(patch.polygon_count);
|
|
21
|
+
buffer.writeUintVar(patch.vertex_count);
|
|
22
|
+
|
|
23
|
+
// write parents
|
|
24
|
+
const parents = patch.parents;
|
|
25
|
+
const parent_count = parents.length;
|
|
26
|
+
|
|
27
|
+
buffer.writeUintVar(parent_count);
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < parent_count; i++) {
|
|
30
|
+
const parent = parents[i];
|
|
31
|
+
|
|
32
|
+
const parent_index = patch_array.indexOf(parent);
|
|
33
|
+
|
|
34
|
+
if (parent_index === -1) {
|
|
35
|
+
throw new Error(`Patch '${parent.id}' not found in the lookup table`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buffer.writeUintVar(parent_index);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// write children
|
|
42
|
+
const children = patch.children;
|
|
43
|
+
const child_count = children.length;
|
|
44
|
+
|
|
45
|
+
buffer.writeUintVar(child_count);
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < child_count; i++) {
|
|
48
|
+
const child = children[i];
|
|
49
|
+
|
|
50
|
+
const child_index = patch_array.indexOf(child);
|
|
51
|
+
|
|
52
|
+
if (child_index === -1) {
|
|
53
|
+
throw new Error(`Patch '${child.id}' not found in the lookup table`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
buffer.writeUintVar(child_index);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// INDICES
|
|
60
|
+
if (patch.vertex_count <= 256) {
|
|
61
|
+
buffer.writeUint8Array(patch.face_indices, 0, patch.polygon_count * 3);
|
|
62
|
+
} else if (patch.vertex_count <= 65536) {
|
|
63
|
+
buffer.writeUint16Array(patch.face_indices, 0, patch.polygon_count * 3);
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(`Unsupported vertex count '${patch.vertex_count}'`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// VERTICES
|
|
69
|
+
const attributes = vertex_spec.attributes;
|
|
70
|
+
const attribute_count = attributes.length;
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < attribute_count; i++) {
|
|
73
|
+
const spec = attributes[i];
|
|
74
|
+
|
|
75
|
+
const data_type = spec.type;
|
|
76
|
+
const item_size = spec.itemSize;
|
|
77
|
+
|
|
78
|
+
const byte_size = DataTypeByteSizes[data_type];
|
|
79
|
+
|
|
80
|
+
const attribute_values = patch.vertex_attribute_arrays[i];
|
|
81
|
+
|
|
82
|
+
buffer.writeUint8Array(new Uint8Array(attribute_values.buffer), 0, item_size * byte_size * patch.vertex_count);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -3,11 +3,11 @@ import { MICRON_PATCH_SIZE_MAX } from "../../build/MICRON_PATCH_SIZE_MAX.js";
|
|
|
3
3
|
import { typed_array_copy } from "../../../../../core/collection/array/typed/typed_array_copy.js";
|
|
4
4
|
import { channelCountToThreeTextureFormat } from "../../../texture/channelCountToThreeTextureFormat.js";
|
|
5
5
|
import { DataTexture, NearestFilter } from "three";
|
|
6
|
-
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
6
|
import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
8
7
|
import { compute_micron_buffer_array_constructor } from "../../build/compute_micron_buffer_array_constructor.js";
|
|
9
8
|
import { computeThreeTextureTypeFromDataType } from "../../../render/forward_plus/data/computeThreeTextureTypeFromDataType.js";
|
|
10
9
|
import { computeThreeTextureInternalFormatFromDataType } from "../../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
10
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
@@ -3,12 +3,12 @@ import { DataType } from "../../../../../core/collection/table/DataType.js";
|
|
|
3
3
|
import { assert } from "../../../../../core/assert.js";
|
|
4
4
|
import { DataType2TypedArrayConstructorMapping } from "../../../../../core/collection/table/DataType2TypedArrayConstructorMapping.js";
|
|
5
5
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
6
|
-
import { DataTypeByteSizes } from "../../../../../core/collection/table/RowFirstTableSpec.js";
|
|
7
6
|
import { NumericType } from "./NumericType.js";
|
|
8
7
|
import { computeDataType } from "./computeDataType.js";
|
|
9
8
|
import { computeThreeTextureTypeFromDataType } from "./computeThreeTextureTypeFromDataType.js";
|
|
10
9
|
import { computeThreeTextureInternalFormatFromDataType } from "./computeThreeTextureInternalFormatFromDataType.js";
|
|
11
10
|
import { computeThreeTextureFormat } from "./computeThreeTextureFormat.js";
|
|
11
|
+
import { DataTypeByteSizes } from "../../../../../core/collection/table/DataTypeByteSizes.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* How wide a data texture is
|
|
@@ -65,13 +65,12 @@ import LabelView from "../../../../../view/common/LabelView.js";
|
|
|
65
65
|
import { randomFloatBetween } from "../../../../../core/math/MathUtils.js";
|
|
66
66
|
import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
|
|
67
67
|
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
68
|
-
import { RefinementSpec } from "../../../micron/render/refinement/RefinementSpec.js";
|
|
69
|
-
import { Matrix4 } from "three";
|
|
70
68
|
import { inverseLerp } from "../../../../../core/math/inverseLerp.js";
|
|
71
69
|
import { clamp } from "../../../../../core/math/clamp.js";
|
|
72
70
|
import { max2 } from "../../../../../core/math/max2.js";
|
|
73
71
|
import { min2 } from "../../../../../core/math/min2.js";
|
|
74
72
|
import { buildCubeURLs } from "../../../texture/cubemap/buildCubeURLs.js";
|
|
73
|
+
import { mat4 } from "gl-matrix";
|
|
75
74
|
|
|
76
75
|
const engineHarness = new EngineHarness();
|
|
77
76
|
|
|
@@ -219,8 +218,14 @@ function prepare_query_test(hiz, graphics, ecd) {
|
|
|
219
218
|
|
|
220
219
|
function prepare_query() {
|
|
221
220
|
|
|
222
|
-
const
|
|
223
|
-
|
|
221
|
+
const camera = graphics.camera;
|
|
222
|
+
|
|
223
|
+
const projection = mat4.create();
|
|
224
|
+
const world_inverse = camera.matrixWorldInverse.elements;
|
|
225
|
+
const camera_projection = camera.projectionMatrix.elements;
|
|
226
|
+
|
|
227
|
+
mat4.copy(projection, world_inverse);
|
|
228
|
+
mat4.multiply(projection, camera_projection, projection);
|
|
224
229
|
|
|
225
230
|
for (let i = 0; i < query.getSize(); i++) {
|
|
226
231
|
const entity = entities[i];
|
|
@@ -237,7 +242,7 @@ function prepare_query_test(hiz, graphics, ecd) {
|
|
|
237
242
|
|
|
238
243
|
mesh.bvh.writeToArray(aabb, 0);
|
|
239
244
|
|
|
240
|
-
query.setElement(i, aabb,
|
|
245
|
+
query.setElement(i, aabb, projection);
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
}
|
|
@@ -412,7 +417,7 @@ function main(engine) {
|
|
|
412
417
|
metrics.get('hiz_build').record(t1 - t0);
|
|
413
418
|
|
|
414
419
|
|
|
415
|
-
preview.texture = hiz.mips[
|
|
420
|
+
preview.texture = hiz.mips[1].texture;
|
|
416
421
|
|
|
417
422
|
preview.render();
|
|
418
423
|
|
|
@@ -2,8 +2,8 @@ import { DataTypeIndices } from "../../../../core/collection/table/DataTypeIndic
|
|
|
2
2
|
import { Sampler2D } from "./Sampler2D.js";
|
|
3
3
|
import { EndianType } from "../../../../core/binary/BinaryBuffer.js";
|
|
4
4
|
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
5
|
-
import { DataTypeByteSizes } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
6
5
|
import { assert } from "../../../../core/assert.js";
|
|
6
|
+
import { DataTypeByteSizes } from "../../../../core/collection/table/DataTypeByteSizes.js";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -11,8 +11,8 @@ function isGlobalPath(path) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// *** Environment setup code ***
|
|
14
|
-
const ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
|
|
15
14
|
const ENVIRONMENT_IS_WEB = typeof window === 'object';
|
|
15
|
+
const ENVIRONMENT_IS_NODE = typeof process === 'object' && !ENVIRONMENT_IS_WEB;
|
|
16
16
|
const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
|
17
17
|
const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
18
18
|
|
|
@@ -34,6 +34,12 @@ export function convertPathToURL(path) {
|
|
|
34
34
|
scope = window;
|
|
35
35
|
} else if (ENVIRONMENT_IS_WORKER) {
|
|
36
36
|
scope = self;
|
|
37
|
+
} else if (ENVIRONMENT_IS_NODE) {
|
|
38
|
+
scope = {
|
|
39
|
+
location: new URL(import.meta.url)
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error('Unknown environment');
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
const location = scope.location;
|
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.12",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"fast-levenshtein": "2.0.6",
|
|
10
10
|
"opentype.js": "1.3.3",
|