@woosh/meep-engine 2.47.42 → 2.48.0
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 +44161 -44112
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +44162 -44112
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +3 -3
- package/editor/view/node-graph/NodeGraphView.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/editor.js +4 -4
- package/src/core/{collection/table/DataType.js → binary/type/BinaryDataType.js} +1 -1
- package/src/core/binary/type/DataType2TypedArrayConstructorMapping.js +34 -0
- package/src/core/binary/type/DataTypeByteSizes.js +37 -0
- package/src/core/binary/type/DataTypeIndices.js +17 -0
- package/src/core/{collection/table → binary/type}/computeDataTypeByIndex.js +1 -1
- package/src/core/binary/type/dataTypeFromTypedArray.js +31 -0
- package/src/core/collection/array/typedArrayToDataType.js +10 -10
- package/src/core/collection/table/RowFirstTable.js +1 -1
- package/src/core/collection/table/RowFirstTable.spec.js +16 -16
- package/src/core/collection/table/RowFirstTableSpec.js +9 -9
- package/src/core/collection/table/deserializeRowFirstTable.js +1 -1
- package/src/core/collection/table/serializeRowFirstTable.js +1 -1
- package/src/core/geom/3d/matrix/MATRIX_4_IDENTITY.js +2 -1
- package/src/core/geom/3d/matrix/m4_multiply.js +67 -0
- package/src/core/geom/Quaternion.js +0 -85
- package/src/core/graph/SquareMatrix.js +3 -3
- package/src/core/graph/SquareMatrix.spec.js +5 -5
- package/src/core/graph/eigen/eigen.spec.js +2 -2
- package/src/core/graph/graph_k_means_cluster.js +2 -2
- package/src/core/graph/graph_laplacian_matrix.js +3 -3
- package/src/core/model/node-graph/node/NodeDescription.js +1 -1
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/ecs/foliage/InstancedFoliage.js +4 -4
- package/src/engine/ecs/fow/FogOfWar.js +4 -4
- package/src/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +1 -1
- package/src/engine/ecs/transform/Transform.d.ts +2 -0
- package/src/engine/ecs/transform/Transform.js +51 -58
- package/src/engine/ecs/transform/Transform.spec.js +22 -0
- package/src/engine/graphics/ecs/light/binding/three/applyRotation.js +1 -1
- package/src/engine/graphics/ecs/mesh/applyTransformToThreeObject.js +3 -1
- package/src/engine/graphics/ecs/mesh-v2/allocate_transform_m4.js +3 -12
- package/src/engine/graphics/geometry/AttributeSpec.js +5 -5
- package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +8 -8
- package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +4 -4
- package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +7 -7
- package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +6 -6
- package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +4 -4
- package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +1 -1
- package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +2 -2
- package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +1 -1
- package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +2 -2
- package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +1 -1
- package/src/engine/graphics/micron/format/serialization/serialize_patch.js +1 -1
- package/src/engine/graphics/micron/render/instanced/AttributeDataTexture.js +1 -1
- package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +2 -2
- package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionParameterSpecification.js +2 -2
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +2 -2
- package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +4 -4
- package/src/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +13 -13
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +3 -3
- package/src/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +8 -8
- package/src/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +1 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/src/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +5 -5
- package/src/engine/graphics/render/forward_plus/data/computeDataType.js +10 -10
- package/src/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +11 -11
- package/src/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +11 -11
- package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +4 -4
- package/src/engine/graphics/render/frame_graph/sample/meep-v1/ColorDepthPass.js +3 -3
- package/src/engine/graphics/texture/atlas/TextureAtlas.js +5 -5
- package/src/engine/graphics/texture/normalized_internal_format.js +5 -5
- package/src/engine/graphics/texture/sampler/Sampler2D.js +25 -51
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.js +2 -2
- package/src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js +3 -3
- package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.js → serialization/TextureBinaryBufferSerializer.js} +17 -46
- package/src/engine/graphics/texture/sampler/{TextureBinaryBufferSerializer.spec.js → serialization/TextureBinaryBufferSerializer.spec.js} +2 -2
- package/src/engine/graphics/trail/TemporalPath.js +3 -3
- package/src/engine/graphics/trail/x/ribbon_attributes_spec.js +18 -18
- package/src/engine/navigation/ecs/components/Path.js +5 -5
- package/src/generation/example/grid/configureMirGrid.js +6 -6
- package/src/generation/filtering/numeric/process/computeCellFilterGradient.spec.js +10 -10
- package/src/generation/grid/layers/GridDataLayer.js +4 -4
- package/src/generation/placement/action/GridCellActionPlaceTags.spec.js +2 -2
- package/src/generation/rules/CellMatcherContainsTag.spec.js +2 -2
- package/src/generation/rules/cell/GridPatternMatcher.spec.js +8 -8
- package/src/view/elements/image/HTMLElementCacheKey.js +111 -2
- package/src/view/elements/image/ImageView.js +1 -1
- package/src/view/elements/video/VideoView.js +1 -1
- package/src/core/collection/table/DataType2TypedArrayConstructorMapping.js +0 -34
- package/src/core/collection/table/DataTypeByteSizes.js +0 -37
- package/src/core/collection/table/DataTypeIndices.js +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
2
2
|
|
|
3
3
|
export const TextureInitialState = {
|
|
4
4
|
/**
|
|
@@ -26,9 +26,9 @@ export class TextureDescriptor {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Render texture type
|
|
29
|
-
* @type {
|
|
29
|
+
* @type {BinaryDataType}
|
|
30
30
|
*/
|
|
31
|
-
this.format =
|
|
31
|
+
this.format = BinaryDataType.Uint8;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
@@ -46,7 +46,7 @@ export class TextureDescriptor {
|
|
|
46
46
|
static from({
|
|
47
47
|
height = 0,
|
|
48
48
|
width = 0,
|
|
49
|
-
format =
|
|
49
|
+
format = BinaryDataType.Uint8,
|
|
50
50
|
channel_count = 1,
|
|
51
51
|
initial_state = TextureInitialState.Clear
|
|
52
52
|
}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderPass } from "../../RenderPass.js";
|
|
2
2
|
import { TextureDescriptor } from "../../TextureDescriptor.js";
|
|
3
3
|
import Vector2 from "../../../../../../core/geom/Vector2.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BinaryDataType } from "../../../../../../core/binary/type/BinaryDataType.js";
|
|
5
5
|
|
|
6
6
|
export class ColorDepthPass extends RenderPass {
|
|
7
7
|
resolution = new Vector2(1024, 724);
|
|
@@ -10,7 +10,7 @@ export class ColorDepthPass extends RenderPass {
|
|
|
10
10
|
const color = builder.create("Color", TextureDescriptor.from({
|
|
11
11
|
width: this.resolution.x,
|
|
12
12
|
height: this.resolution.y,
|
|
13
|
-
format:
|
|
13
|
+
format: BinaryDataType.Uint8,
|
|
14
14
|
channel_count: 4
|
|
15
15
|
}));
|
|
16
16
|
|
|
@@ -19,7 +19,7 @@ export class ColorDepthPass extends RenderPass {
|
|
|
19
19
|
const depth = builder.create("Depth", TextureDescriptor.from({
|
|
20
20
|
width: this.resolution.x,
|
|
21
21
|
height: this.resolution.y,
|
|
22
|
-
format:
|
|
22
|
+
format: BinaryDataType.Float32,
|
|
23
23
|
channel_count: 4
|
|
24
24
|
}));
|
|
25
25
|
|
|
@@ -7,10 +7,10 @@ import { AtlasPatch } from "./AtlasPatch.js";
|
|
|
7
7
|
import { AtlasPatchFlag } from "./AtlasPatchFlag.js";
|
|
8
8
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
9
9
|
import { assert } from "../../../../core/assert.js";
|
|
10
|
-
import {
|
|
10
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
11
11
|
import {
|
|
12
12
|
DataType2TypedArrayConstructorMapping
|
|
13
|
-
} from "../../../../core/
|
|
13
|
+
} from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
14
14
|
import { AbstractTextureAtlas } from "./AbstractTextureAtlas.js";
|
|
15
15
|
import { invokeObjectClone } from "../../../../core/model/object/invokeObjectClone.js";
|
|
16
16
|
import { ceilPowerOfTwo } from "../../../../core/binary/operations/ceilPowerOfTwo.js";
|
|
@@ -19,15 +19,15 @@ export class TextureAtlas extends AbstractTextureAtlas {
|
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
21
|
* @param {number} [size]
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {BinaryDataType} [data_type]
|
|
23
23
|
* @param {number} [channel_count]
|
|
24
24
|
* @constructor
|
|
25
25
|
*/
|
|
26
|
-
constructor(size = 16, data_type =
|
|
26
|
+
constructor(size = 16, data_type = BinaryDataType.Uint8, channel_count = 4) {
|
|
27
27
|
super();
|
|
28
28
|
|
|
29
29
|
assert.isNonNegativeInteger(size, 'size');
|
|
30
|
-
assert.enum(data_type,
|
|
30
|
+
assert.enum(data_type, BinaryDataType, 'data_type');
|
|
31
31
|
assert.isNonNegativeInteger(channel_count, 'channel_count');
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
2
2
|
import { assert } from "../../../core/assert.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @returns {string}
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {BinaryDataType} dt
|
|
8
8
|
* @param {number} channel_count
|
|
9
9
|
*/
|
|
10
10
|
export function normalized_internal_format(dt, channel_count) {
|
|
@@ -12,13 +12,13 @@ export function normalized_internal_format(dt, channel_count) {
|
|
|
12
12
|
|
|
13
13
|
let suffix = '';
|
|
14
14
|
switch (dt) {
|
|
15
|
-
case
|
|
15
|
+
case BinaryDataType.Uint8:
|
|
16
16
|
suffix = '8';
|
|
17
17
|
break;
|
|
18
|
-
case
|
|
18
|
+
case BinaryDataType.Int8:
|
|
19
19
|
suffix = '8_SNORM';
|
|
20
20
|
break;
|
|
21
|
-
case
|
|
21
|
+
case BinaryDataType.Uint16:
|
|
22
22
|
suffix = '16UI';
|
|
23
23
|
break;
|
|
24
24
|
default:
|
|
@@ -13,31 +13,33 @@ import { typedArrayConstructorByInstance } from "./typedArrayConstructorByInstan
|
|
|
13
13
|
import { typedArrayToDataType } from "../../../../core/collection/array/typedArrayToDataType.js";
|
|
14
14
|
import {
|
|
15
15
|
compute_typed_array_constructor_from_data_type
|
|
16
|
-
} from "../../../../core/
|
|
16
|
+
} from "../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
17
17
|
import { Base64 } from "../../../../core/binary/Base64.js";
|
|
18
18
|
import { computeStridedIntegerArrayHash } from "../../../computeStridedIntegerArrayHash.js";
|
|
19
19
|
import { is_typed_array_equals } from "../../../../core/collection/array/typed/is_typed_array_equals.js";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
+
* Data Texture class, providing an abstraction around 2d numerical arrays, mostly for sampling purposes
|
|
23
|
+
* Inspired by OpenGL's glsl sampler2d API
|
|
22
24
|
* @class
|
|
23
25
|
*/
|
|
24
26
|
export class Sampler2D {
|
|
25
27
|
/**
|
|
26
28
|
*
|
|
27
29
|
* @param {ArrayLike<number>|number[]|Uint8ClampedArray|Uint8Array|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array|Float32Array|Float64Array} data
|
|
28
|
-
* @param {number} itemSize
|
|
29
|
-
* @param {number} width
|
|
30
|
-
* @param {number} height
|
|
30
|
+
* @param {number} [itemSize]
|
|
31
|
+
* @param {number} [width]
|
|
32
|
+
* @param {number} [height]
|
|
31
33
|
* @constructor
|
|
32
34
|
*/
|
|
33
35
|
constructor(data = [], itemSize = 1, width = 0, height = 0) {
|
|
34
36
|
if (!Number.isInteger(itemSize) || itemSize < 0) {
|
|
35
37
|
throw new Error(`itemSize must be a non-negative integer, instead was ${itemSize}`);
|
|
36
38
|
}
|
|
37
|
-
if (!Number.isInteger(width) ||
|
|
39
|
+
if (!Number.isInteger(width) || width < 0) {
|
|
38
40
|
throw new Error(`width must be a non-negative integer, instead was ${width}`);
|
|
39
41
|
}
|
|
40
|
-
if (!Number.isInteger(height) ||
|
|
42
|
+
if (!Number.isInteger(height) || width < 0) {
|
|
41
43
|
throw new Error(`height must be a non-negative integer, instead was ${height}`);
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -86,7 +88,7 @@ export class Sampler2D {
|
|
|
86
88
|
* @returns {{x: number, index: number, y: number, value: number}}
|
|
87
89
|
*/
|
|
88
90
|
computeMax(channel = 0) {
|
|
89
|
-
|
|
91
|
+
throw new Error("deprecated, use sampler2d_channel_compute_max");
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
/**
|
|
@@ -205,7 +207,7 @@ export class Sampler2D {
|
|
|
205
207
|
* @returns {number}
|
|
206
208
|
*/
|
|
207
209
|
sampleChannelCatmullRom(x, y, channel) {
|
|
208
|
-
// We're going to sample a
|
|
210
|
+
// We're going to sample a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
|
209
211
|
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
|
210
212
|
// location [1, 1] in the grid, where [0, 0] is the top-left corner.
|
|
211
213
|
const texPos1_x = Math.floor(x - 0.5) + 0.5;
|
|
@@ -583,31 +585,6 @@ export class Sampler2D {
|
|
|
583
585
|
return temp[0];
|
|
584
586
|
}
|
|
585
587
|
|
|
586
|
-
/**
|
|
587
|
-
*
|
|
588
|
-
* @param {number} index
|
|
589
|
-
* @param {number[]} result
|
|
590
|
-
*/
|
|
591
|
-
computeNeighbors(index, result) {
|
|
592
|
-
const width = this.width;
|
|
593
|
-
const height = this.height;
|
|
594
|
-
|
|
595
|
-
const x = index % width;
|
|
596
|
-
const y = (index / width) | 0;
|
|
597
|
-
if (x > 0) {
|
|
598
|
-
result.push(index - 1);
|
|
599
|
-
}
|
|
600
|
-
if (x < width - 1) {
|
|
601
|
-
result.push(index + 1);
|
|
602
|
-
}
|
|
603
|
-
if (y > 0) {
|
|
604
|
-
result.push(index - width);
|
|
605
|
-
}
|
|
606
|
-
if (y < height - 1) {
|
|
607
|
-
result.push(index + width);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
588
|
/**
|
|
612
589
|
*
|
|
613
590
|
* @param {number} x
|
|
@@ -1351,8 +1328,7 @@ export class Sampler2D {
|
|
|
1351
1328
|
*/
|
|
1352
1329
|
static uint8clamped(itemSize, width, height) {
|
|
1353
1330
|
const data = new Uint8ClampedArray(width * height * itemSize);
|
|
1354
|
-
|
|
1355
|
-
return sampler;
|
|
1331
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1356
1332
|
}
|
|
1357
1333
|
|
|
1358
1334
|
/**
|
|
@@ -1364,8 +1340,7 @@ export class Sampler2D {
|
|
|
1364
1340
|
*/
|
|
1365
1341
|
static uint8(itemSize, width, height) {
|
|
1366
1342
|
const data = new Uint8Array(width * height * itemSize);
|
|
1367
|
-
|
|
1368
|
-
return sampler;
|
|
1343
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1369
1344
|
}
|
|
1370
1345
|
|
|
1371
1346
|
/**
|
|
@@ -1377,8 +1352,7 @@ export class Sampler2D {
|
|
|
1377
1352
|
*/
|
|
1378
1353
|
static uint16(itemSize, width, height) {
|
|
1379
1354
|
const data = new Uint16Array(width * height * itemSize);
|
|
1380
|
-
|
|
1381
|
-
return sampler;
|
|
1355
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1382
1356
|
}
|
|
1383
1357
|
|
|
1384
1358
|
/**
|
|
@@ -1390,8 +1364,7 @@ export class Sampler2D {
|
|
|
1390
1364
|
*/
|
|
1391
1365
|
static uint32(itemSize, width, height) {
|
|
1392
1366
|
const data = new Uint32Array(width * height * itemSize);
|
|
1393
|
-
|
|
1394
|
-
return sampler;
|
|
1367
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1395
1368
|
}
|
|
1396
1369
|
|
|
1397
1370
|
/**
|
|
@@ -1403,8 +1376,7 @@ export class Sampler2D {
|
|
|
1403
1376
|
*/
|
|
1404
1377
|
static int8(itemSize, width, height) {
|
|
1405
1378
|
const data = new Int8Array(width * height * itemSize);
|
|
1406
|
-
|
|
1407
|
-
return sampler;
|
|
1379
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1408
1380
|
}
|
|
1409
1381
|
|
|
1410
1382
|
/**
|
|
@@ -1416,8 +1388,7 @@ export class Sampler2D {
|
|
|
1416
1388
|
*/
|
|
1417
1389
|
static int16(itemSize, width, height) {
|
|
1418
1390
|
const data = new Int16Array(width * height * itemSize);
|
|
1419
|
-
|
|
1420
|
-
return sampler;
|
|
1391
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1421
1392
|
}
|
|
1422
1393
|
|
|
1423
1394
|
/**
|
|
@@ -1429,8 +1400,7 @@ export class Sampler2D {
|
|
|
1429
1400
|
*/
|
|
1430
1401
|
static int32(itemSize, width, height) {
|
|
1431
1402
|
const data = new Int32Array(width * height * itemSize);
|
|
1432
|
-
|
|
1433
|
-
return sampler;
|
|
1403
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1434
1404
|
}
|
|
1435
1405
|
|
|
1436
1406
|
/**
|
|
@@ -1442,8 +1412,7 @@ export class Sampler2D {
|
|
|
1442
1412
|
*/
|
|
1443
1413
|
static float32(itemSize, width, height) {
|
|
1444
1414
|
const data = new Float32Array(width * height * itemSize);
|
|
1445
|
-
|
|
1446
|
-
return sampler;
|
|
1415
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1447
1416
|
}
|
|
1448
1417
|
|
|
1449
1418
|
/**
|
|
@@ -1455,8 +1424,7 @@ export class Sampler2D {
|
|
|
1455
1424
|
*/
|
|
1456
1425
|
static float64(itemSize, width, height) {
|
|
1457
1426
|
const data = new Float64Array(width * height * itemSize);
|
|
1458
|
-
|
|
1459
|
-
return sampler;
|
|
1427
|
+
return new Sampler2D(data, itemSize, width, height);
|
|
1460
1428
|
}
|
|
1461
1429
|
|
|
1462
1430
|
}
|
|
@@ -1467,6 +1435,12 @@ export class Sampler2D {
|
|
|
1467
1435
|
*/
|
|
1468
1436
|
Sampler2D.prototype.isSampler2D = true;
|
|
1469
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* @readonly
|
|
1440
|
+
* @type {string}
|
|
1441
|
+
*/
|
|
1442
|
+
Sampler2D.typeName = "Sampler2D";
|
|
1443
|
+
|
|
1470
1444
|
/**
|
|
1471
1445
|
* Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
|
|
1472
1446
|
* @param {number} t
|
|
@@ -4,7 +4,7 @@ import { channelCountToThreeTextureFormat } from "../channelCountToThreeTextureF
|
|
|
4
4
|
import {
|
|
5
5
|
computeThreeTextureInternalFormatFromDataType
|
|
6
6
|
} from "../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
7
|
-
import {
|
|
7
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -31,7 +31,7 @@ export function sampler2DtoFloat32Texture(sampler) {
|
|
|
31
31
|
|
|
32
32
|
texture.type = FloatType;
|
|
33
33
|
texture.format = channelCountToThreeTextureFormat(sampler.itemSize);
|
|
34
|
-
texture.internalFormat = computeThreeTextureInternalFormatFromDataType(
|
|
34
|
+
texture.internalFormat = computeThreeTextureInternalFormatFromDataType(BinaryDataType.Float32, sampler.itemSize);
|
|
35
35
|
|
|
36
36
|
texture.needsUpdate = true;
|
|
37
37
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
2
2
|
import { min2 } from "../../../../core/math/min2.js";
|
|
3
3
|
import { max2 } from "../../../../core/math/max2.js";
|
|
4
4
|
import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
|
|
@@ -19,12 +19,12 @@ export function sampler2d_compute_texel_value_conversion_scale_to_uint8(sampler)
|
|
|
19
19
|
dataType = typedArrayToDataType(sampler.data);
|
|
20
20
|
} else {
|
|
21
21
|
// plain numeric array
|
|
22
|
-
dataType =
|
|
22
|
+
dataType = BinaryDataType.Float32;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
let min = 0, max = 0;
|
|
26
26
|
|
|
27
|
-
if (dataType ===
|
|
27
|
+
if (dataType === BinaryDataType.Uint8) {
|
|
28
28
|
min = 0;
|
|
29
29
|
max = 255;
|
|
30
30
|
} else {
|
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
import { DataTypeIndices } from "
|
|
2
|
-
import { Sampler2D } from "
|
|
3
|
-
import { EndianType } from "
|
|
4
|
-
import {
|
|
5
|
-
import { assert } from "
|
|
6
|
-
import { DataTypeByteSizes } from "
|
|
1
|
+
import { DataTypeIndices } from "../../../../../core/binary/type/DataTypeIndices.js";
|
|
2
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
3
|
+
import { EndianType } from "../../../../../core/binary/BinaryBuffer.js";
|
|
4
|
+
import { BinaryDataType } from "../../../../../core/binary/type/BinaryDataType.js";
|
|
5
|
+
import { assert } from "../../../../../core/assert.js";
|
|
6
|
+
import { DataTypeByteSizes } from "../../../../../core/binary/type/DataTypeByteSizes.js";
|
|
7
|
+
import { dataTypeFromTypedArray } from "../../../../../core/binary/type/dataTypeFromTypedArray.js";
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {TypedArray} arr
|
|
12
|
-
* @returns {DataType}
|
|
13
|
-
*/
|
|
14
|
-
function dataTypeFromTypedArray(arr) {
|
|
15
|
-
if (arr instanceof Float32Array) {
|
|
16
|
-
return DataType.Float32;
|
|
17
|
-
} else if (arr instanceof Float64Array) {
|
|
18
|
-
return DataType.Float64;
|
|
19
|
-
} else if (arr instanceof Uint8Array) {
|
|
20
|
-
return DataType.Uint8;
|
|
21
|
-
} else if (arr instanceof Uint16Array) {
|
|
22
|
-
return DataType.Uint16;
|
|
23
|
-
} else if (arr instanceof Uint32Array) {
|
|
24
|
-
return DataType.Uint32;
|
|
25
|
-
} else if (arr instanceof Int8Array) {
|
|
26
|
-
return DataType.Int8;
|
|
27
|
-
} else if (arr instanceof Int16Array) {
|
|
28
|
-
return DataType.Int16;
|
|
29
|
-
} else if (arr instanceof Int32Array) {
|
|
30
|
-
return DataType.Int32;
|
|
31
|
-
} else if (arr instanceof Array) {
|
|
32
|
-
//if array is untyped, use Float64 as numbers in JS are 64 bit
|
|
33
|
-
return DataType.Float64;
|
|
34
|
-
} else {
|
|
35
|
-
throw new TypeError(`Unknown array type`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
10
|
/**
|
|
40
11
|
*
|
|
41
12
|
* @param {number} index
|
|
42
|
-
* @returns {
|
|
13
|
+
* @returns {BinaryDataType}
|
|
43
14
|
*/
|
|
44
15
|
function dataTypeByTypeIndex(index) {
|
|
45
16
|
for (let type in DataTypeIndices) {
|
|
@@ -55,7 +26,7 @@ function dataTypeByTypeIndex(index) {
|
|
|
55
26
|
/**
|
|
56
27
|
*
|
|
57
28
|
* @param {BinaryBuffer} buffer
|
|
58
|
-
* @param {
|
|
29
|
+
* @param {BinaryDataType} type
|
|
59
30
|
* @param {number} length
|
|
60
31
|
*/
|
|
61
32
|
function readTypedArray(buffer, type, length) {
|
|
@@ -64,35 +35,35 @@ function readTypedArray(buffer, type, length) {
|
|
|
64
35
|
|
|
65
36
|
let result = null;
|
|
66
37
|
switch (type) {
|
|
67
|
-
case
|
|
38
|
+
case BinaryDataType.Uint8:
|
|
68
39
|
result = new Uint8Array(length);
|
|
69
40
|
buffer.readUint8Array(result, 0, length);
|
|
70
41
|
break;
|
|
71
|
-
case
|
|
42
|
+
case BinaryDataType.Uint16:
|
|
72
43
|
result = new Uint16Array(length);
|
|
73
44
|
buffer.readUint16Array(result, 0, length);
|
|
74
45
|
break;
|
|
75
|
-
case
|
|
46
|
+
case BinaryDataType.Uint32:
|
|
76
47
|
result = new Uint32Array(length);
|
|
77
48
|
buffer.readUint32Array(result, 0, length);
|
|
78
49
|
break;
|
|
79
|
-
case
|
|
50
|
+
case BinaryDataType.Int8:
|
|
80
51
|
result = new Int8Array(length);
|
|
81
52
|
buffer.readInt8Array(result, 0, length);
|
|
82
53
|
break;
|
|
83
|
-
case
|
|
54
|
+
case BinaryDataType.Int16:
|
|
84
55
|
result = new Int16Array(length);
|
|
85
56
|
buffer.readInt16Array(result, 0, length);
|
|
86
57
|
break;
|
|
87
|
-
case
|
|
58
|
+
case BinaryDataType.Int32:
|
|
88
59
|
result = new Int32Array(length);
|
|
89
60
|
buffer.readInt32Array(result, 0, length);
|
|
90
61
|
break;
|
|
91
|
-
case
|
|
62
|
+
case BinaryDataType.Float32:
|
|
92
63
|
result = new Float32Array(length);
|
|
93
64
|
buffer.readFloat32Array(result, 0, length);
|
|
94
65
|
break;
|
|
95
|
-
case
|
|
66
|
+
case BinaryDataType.Float64:
|
|
96
67
|
result = new Float64Array(length);
|
|
97
68
|
buffer.readFloat64Array(result, 0, length);
|
|
98
69
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Sampler2D } from "
|
|
1
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
2
2
|
import { deserializeTexture, serializeTexture } from "./TextureBinaryBufferSerializer.js";
|
|
3
|
-
import { BinaryBuffer } from "
|
|
3
|
+
import { BinaryBuffer } from "../../../../../core/binary/BinaryBuffer.js";
|
|
4
4
|
|
|
5
5
|
function makeSample() {
|
|
6
6
|
const width = 3;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function TemporalPath() {
|
|
@@ -20,8 +20,8 @@ function TemporalPath() {
|
|
|
20
20
|
* @type {RowFirstTable}
|
|
21
21
|
*/
|
|
22
22
|
this.data = new RowFirstTable([
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
BinaryDataType.Float32,
|
|
24
|
+
BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32
|
|
25
25
|
]);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { RowFirstTableSpec } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
2
|
-
import {
|
|
2
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
3
3
|
import { EndianType } from "../../../../core/binary/BinaryBuffer.js";
|
|
4
4
|
|
|
5
5
|
export const ribbon_attributes_spec = new RowFirstTableSpec([
|
|
6
6
|
// age
|
|
7
|
-
|
|
7
|
+
BinaryDataType.Float32,
|
|
8
8
|
|
|
9
9
|
// position
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
BinaryDataType.Float32,
|
|
11
|
+
BinaryDataType.Float32,
|
|
12
|
+
BinaryDataType.Float32,
|
|
13
13
|
|
|
14
14
|
// UV (uv is recorded as a single coordinate)
|
|
15
|
-
|
|
15
|
+
BinaryDataType.Float32,
|
|
16
16
|
|
|
17
17
|
// alpha
|
|
18
|
-
|
|
18
|
+
BinaryDataType.Float32,
|
|
19
19
|
|
|
20
20
|
// color
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
BinaryDataType.Uint8,
|
|
22
|
+
BinaryDataType.Uint8,
|
|
23
|
+
BinaryDataType.Uint8,
|
|
24
24
|
|
|
25
25
|
// Offset attribute
|
|
26
|
-
|
|
26
|
+
BinaryDataType.Uint8,
|
|
27
27
|
|
|
28
28
|
// Previous point
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
BinaryDataType.Float32,
|
|
30
|
+
BinaryDataType.Float32,
|
|
31
|
+
BinaryDataType.Float32,
|
|
32
32
|
|
|
33
33
|
// Next point
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
BinaryDataType.Float32,
|
|
35
|
+
BinaryDataType.Float32,
|
|
36
|
+
BinaryDataType.Float32,
|
|
37
37
|
|
|
38
38
|
// thickness
|
|
39
|
-
|
|
39
|
+
BinaryDataType.Float32,
|
|
40
40
|
|
|
41
41
|
], EndianType.LittleEndian);
|
|
42
42
|
|
|
@@ -9,7 +9,7 @@ import { CatmullRomCurve3 } from "three";
|
|
|
9
9
|
import { clamp } from "../../../../core/math/clamp.js";
|
|
10
10
|
import { assert } from "../../../../core/assert.js";
|
|
11
11
|
import { RowFirstTableSpec } from "../../../../core/collection/table/RowFirstTableSpec.js";
|
|
12
|
-
import {
|
|
12
|
+
import { BinaryDataType } from "../../../../core/binary/type/BinaryDataType.js";
|
|
13
13
|
import { RowFirstTable } from "../../../../core/collection/table/RowFirstTable.js";
|
|
14
14
|
import { min2 } from "../../../../core/math/min2.js";
|
|
15
15
|
import { computeNonuniformCatmullRomSplineSample } from "./computeNonuniformCatmullRomSplineSample.js";
|
|
@@ -58,9 +58,9 @@ const scratch_array_4 = [];
|
|
|
58
58
|
* @type {RowFirstTableSpec}
|
|
59
59
|
*/
|
|
60
60
|
const DEFAULT_SPEC = Object.freeze(new RowFirstTableSpec([
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
BinaryDataType.Float32, // position X
|
|
62
|
+
BinaryDataType.Float32, // position Y
|
|
63
|
+
BinaryDataType.Float32 // position Z
|
|
64
64
|
]));
|
|
65
65
|
|
|
66
66
|
class Path {
|
|
@@ -73,7 +73,7 @@ class Path {
|
|
|
73
73
|
this.__spec = VertexDataSpec.from(
|
|
74
74
|
AttributeSpec.fromJSON({
|
|
75
75
|
name: 'position',
|
|
76
|
-
type:
|
|
76
|
+
type: BinaryDataType.Float32,
|
|
77
77
|
itemSize: 3,
|
|
78
78
|
normalized: false
|
|
79
79
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridDataLayer } from "../../grid/layers/GridDataLayer.js";
|
|
2
2
|
import { MirGridLayers } from "./MirGridLayers.js";
|
|
3
|
-
import {
|
|
3
|
+
import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -8,12 +8,12 @@ import { DataType } from "../../../core/collection/table/DataType.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export function configureMirGrid(data) {
|
|
10
10
|
|
|
11
|
-
data.addLayer(GridDataLayer.from(MirGridLayers.Tags,
|
|
11
|
+
data.addLayer(GridDataLayer.from(MirGridLayers.Tags, BinaryDataType.Uint16, 1));
|
|
12
12
|
|
|
13
|
-
data.addLayer(GridDataLayer.from(MirGridLayers.DistanceFromStart,
|
|
14
|
-
data.addLayer(GridDataLayer.from(MirGridLayers.DistanceFromPlayArea,
|
|
13
|
+
data.addLayer(GridDataLayer.from(MirGridLayers.DistanceFromStart, BinaryDataType.Uint16, 1));
|
|
14
|
+
data.addLayer(GridDataLayer.from(MirGridLayers.DistanceFromPlayArea, BinaryDataType.Uint16, 1));
|
|
15
15
|
|
|
16
|
-
data.addLayer(GridDataLayer.from(MirGridLayers.Heights,
|
|
16
|
+
data.addLayer(GridDataLayer.from(MirGridLayers.Heights, BinaryDataType.Float32, 1));
|
|
17
17
|
|
|
18
|
-
data.addLayer(GridDataLayer.from(MirGridLayers.Moisture,
|
|
18
|
+
data.addLayer(GridDataLayer.from(MirGridLayers.Moisture, BinaryDataType.Float32, 1));
|
|
19
19
|
}
|