@woosh/meep-engine 2.75.7 → 2.75.8
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/meep.cjs +268 -252
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +268 -252
- package/editor/ecs/component/createObjectEditor.js +2 -2
- package/package.json +1 -1
- package/src/core/model/object/ImmutableObjectPool.js +14 -5
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +7 -9
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +15 -16
- package/src/engine/ecs/storage/binary/BinaryClassUpgrader.js +10 -59
- package/src/engine/ecs/storage/binary/BinarySerializationRegistry.js +14 -15
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +3 -3
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +60 -62
- package/src/engine/ecs/storage/binary/executeBinaryClassUpgraderChain.js +46 -0
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter.js +2 -2
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayer.js +37 -31
- package/src/engine/ecs/terrain/ecs/layers/TerrainLayers.js +8 -7
- package/src/engine/graphics/render/RendererPool.js +36 -40
- package/src/engine/graphics/render/buffer/FrameBuffer.js +25 -24
- package/src/engine/graphics/render/buffer/RenderGraph.js +21 -21
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/frame_graph/IRenderContext.js +31 -1
- package/src/engine/graphics/render/frame_graph/RenderGraph.js +5 -5
- package/src/engine/graphics/render/frame_graph/RenderTarget.js +9 -0
- package/src/engine/graphics/render/frame_graph/RenderTextureManager.js +57 -0
- package/src/engine/graphics/render/frame_graph/ResourceEntry.js +7 -5
- package/src/engine/graphics/render/frame_graph/TextureDescriptor.js +48 -33
- package/src/engine/graphics/render/frame_graph/TextureInitialState.js +14 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/CopyPass.js +20 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/LightingPass.js +4 -0
- package/src/engine/graphics/render/frame_graph/sample/deferred/run.js +34 -6
- package/src/engine/graphics/render/frame_graph/webgl/WebGLRenderContext.js +34 -0
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +3 -2
- package/src/engine/graphics/sh3/gi/prototypeSHGI.js +92 -0
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMemoryMapping.js → VirtualTextureMemoryMapping.js} +2 -26
- package/src/engine/graphics/texture/virtual/{v2/VirtualTexturePage.js → VirtualTexturePage.js} +10 -10
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureTileLoader.js → VirtualTextureTileLoader.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsage.js → VirtualTextureUsage.js} +1 -1
- package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageUpdater.js → VirtualTextureUsageUpdater.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/ResidencyDebugView.js +4 -4
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsageDebugView.js +2 -2
- package/src/engine/graphics/texture/virtual/{v2/debug → debug}/UsagePyramidDebugView.js +4 -4
- package/src/engine/graphics/texture/virtual/{v2/prototype.js → prototype.js} +7 -7
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_finger_print.js +1 -1
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/compose_tile_address.js +2 -2
- package/src/engine/graphics/texture/virtual/{v2/tile → tile}/tile_address_to_finger_print.js +1 -1
- package/src/engine/ecs/storage/json/Blueprint.js +0 -129
- package/src/engine/ecs/storage/json/EntityFactory.js +0 -207
- package/src/engine/ecs/storage/json/JSONDeSerializer.js +0 -148
- package/src/engine/ecs/storage/json/JSONSerializer.js +0 -132
- package/src/engine/ecs/storage/json/README.md +0 -5
- package/src/engine/graphics/render/webgpu/sample/MeshInstance.js +0 -108
- package/src/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +0 -71
- package/src/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +0 -39
- package/src/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +0 -21
- package/src/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +0 -41
- package/src/engine/graphics/render/webgpu/sample/main.js +0 -605
- package/src/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +0 -9
- package/src/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +0 -30
- package/src/engine/graphics/texture/virtual/TileOperation.js +0 -13
- package/src/engine/graphics/texture/virtual/TileTree.js +0 -150
- package/src/engine/graphics/texture/virtual/TileTree.spec.js +0 -58
- package/src/engine/graphics/texture/virtual/TileUsage.js +0 -137
- package/src/engine/graphics/texture/virtual/VirtualTexture.js +0 -238
- package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +0 -39
- package/src/engine/graphics/texture/virtual/page/TilePage.js +0 -148
- package/src/engine/graphics/texture/virtual/page/TilePageSlot.js +0 -36
- package/src/engine/graphics/texture/virtual/tile/Tile.js +0 -44
- package/src/engine/graphics/texture/virtual/tile/Tile.spec.js +0 -11
- package/src/engine/graphics/texture/virtual/tile/TileAddress.js +0 -63
- package/src/engine/graphics/texture/virtual/tile/TileAddress.spec.js +0 -30
- package/src/engine/graphics/texture/virtual/tile/TileLoader.js +0 -178
- package/src/engine/graphics/texture/virtual/tile/TileRequest.js +0 -40
- package/src/engine/graphics/texture/virtual/tile/TileStatus.js +0 -10
- /package/src/engine/graphics/texture/virtual/{v2/NOTES.md → NOTES.md} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureMaterial.js → VirtualTextureMaterial.js} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/VirtualTextureUsageShader.js → VirtualTextureUsageShader.js} +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/VirtualTextureTile.js +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/decompose_finger_print.js +0 -0
- /package/src/engine/graphics/texture/virtual/{v2/tile → tile}/finger_print_to_tile_address.js +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
2
|
-
import { Cache } from "../../../../../core/cache/Cache.js";
|
|
3
|
-
import { TilePageSlot } from "./TilePageSlot.js";
|
|
4
|
-
|
|
5
|
-
function TilePage() {
|
|
6
|
-
this.size = new Vector2(0, 0);
|
|
7
|
-
this.capacity = 0;
|
|
8
|
-
this.emptySlots = [];
|
|
9
|
-
|
|
10
|
-
this.padding = 0;
|
|
11
|
-
|
|
12
|
-
this.queueWrite = [];
|
|
13
|
-
|
|
14
|
-
const self = this;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @type {Cache.<Tile, TilePageSlot>}
|
|
19
|
-
*/
|
|
20
|
-
this.active = new Cache({
|
|
21
|
-
keyWeigher: function () {
|
|
22
|
-
return 0;
|
|
23
|
-
},
|
|
24
|
-
valueWeigher: function () {
|
|
25
|
-
return 1;
|
|
26
|
-
},
|
|
27
|
-
removeListener: function (tile, slot) {
|
|
28
|
-
slot.empty();
|
|
29
|
-
self.emptySlots.push(slot);
|
|
30
|
-
|
|
31
|
-
//remove from write queue
|
|
32
|
-
const i = self.queueWrite.indexOf(slot);
|
|
33
|
-
if (i !== -1) {
|
|
34
|
-
self.queueWrite.splice(i, 1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
TilePage.prototype.init = function (pageResolution, tileResolution, padding = 4) {
|
|
42
|
-
this.padding = padding;
|
|
43
|
-
|
|
44
|
-
//compute size of the page in tiles
|
|
45
|
-
this.size.set(Math.floor(pageResolution.x / (tileResolution.x + padding * 2)), Math.floor(pageResolution.y / (tileResolution.y + padding * 2)));
|
|
46
|
-
|
|
47
|
-
//figure out how many tiles we can hold
|
|
48
|
-
this.capacity = this.size.x * this.size.y;
|
|
49
|
-
|
|
50
|
-
//empty out write queue
|
|
51
|
-
this.queueWrite = [];
|
|
52
|
-
|
|
53
|
-
//create slots
|
|
54
|
-
this.emptySlots = [];
|
|
55
|
-
|
|
56
|
-
for (let x = 0; x < this.size.x; x++) {
|
|
57
|
-
for (let y = 0; y < this.size.y; y++) {
|
|
58
|
-
const slot = new TilePageSlot();
|
|
59
|
-
slot.position.set(x, y);
|
|
60
|
-
this.emptySlots.push(slot);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.active.drop();
|
|
66
|
-
this.active.setMaxWeight(this.capacity);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get a slot with best matching tile, if requested tile is not found, its closest mip ancestor will be returned, if no mip ancestor exists - null will be returned
|
|
72
|
-
* @param {number} x
|
|
73
|
-
* @param {number} y
|
|
74
|
-
* @param {number} mip
|
|
75
|
-
* @returns {TilePageSlot}
|
|
76
|
-
*/
|
|
77
|
-
TilePage.prototype.getBestTile = function (x, y, mip) {
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @type {TilePageSlot|null}
|
|
81
|
-
*/
|
|
82
|
-
let best = null;
|
|
83
|
-
|
|
84
|
-
for (let [tile, slot] of this.active) {
|
|
85
|
-
//check if it's a tile we are interested in
|
|
86
|
-
const address = tile.address;
|
|
87
|
-
if (address._includes(x, y, mip)) {
|
|
88
|
-
if (best === null || address.mip < best.tile.address.mip) {
|
|
89
|
-
|
|
90
|
-
best = slot;
|
|
91
|
-
|
|
92
|
-
if (tile.address.mip === mip) {
|
|
93
|
-
//found exact match
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return best;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {Tile} tile
|
|
106
|
-
*/
|
|
107
|
-
TilePage.prototype.put = function (tile) {
|
|
108
|
-
if (this.active.contains(tile)) {
|
|
109
|
-
return false;
|
|
110
|
-
} else {
|
|
111
|
-
if (this.emptySlots.length === 0) {
|
|
112
|
-
this.active.evictOne();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
//pick free slot
|
|
116
|
-
const slot = this.emptySlots.pop();
|
|
117
|
-
if (slot === undefined) {
|
|
118
|
-
//something went wrong
|
|
119
|
-
throw new Error(`Failed to obtain a free page slot`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
slot.tile = tile;
|
|
123
|
-
|
|
124
|
-
this.active.put(tile, slot);
|
|
125
|
-
|
|
126
|
-
//add to write queue
|
|
127
|
-
this.queueWrite.push(slot);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
TilePage.prototype.update = function () {
|
|
132
|
-
const queueWrite = this.queueWrite;
|
|
133
|
-
|
|
134
|
-
const length = queueWrite.length;
|
|
135
|
-
for (let i = 0; i < length; i++) {
|
|
136
|
-
const slot = queueWrite[i];
|
|
137
|
-
//TODO write slot
|
|
138
|
-
|
|
139
|
-
this.sampler.copyWithPadding(slot.tile.sampler, x, y, width, height, padding);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
//drop the queue
|
|
143
|
-
this.queueWrite.length = 0;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
TilePage
|
|
148
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Vector2 from "../../../../../core/geom/Vector2.js";
|
|
2
|
-
|
|
3
|
-
export class TilePageSlot {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {number} index
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
constructor(index) {
|
|
10
|
-
/**
|
|
11
|
-
* @type {number}
|
|
12
|
-
*/
|
|
13
|
-
this.index = index;
|
|
14
|
-
/**
|
|
15
|
-
* Sequential 2D position of the tile slot on the page
|
|
16
|
-
* @type {Vector2}
|
|
17
|
-
*/
|
|
18
|
-
this.position = new Vector2();
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @type {Tile|null}
|
|
23
|
-
*/
|
|
24
|
-
this.tile = null;
|
|
25
|
-
|
|
26
|
-
this.isWritten = false;
|
|
27
|
-
this.isDirty = false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
empty() {
|
|
31
|
-
this.tile = null;
|
|
32
|
-
this.isDirty = this.isWritten;
|
|
33
|
-
this.isWritten = false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @constructor
|
|
4
|
-
* @class
|
|
5
|
-
*/
|
|
6
|
-
import { TileAddress } from "./TileAddress.js";
|
|
7
|
-
import { TileStatus } from "./TileStatus.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export class Tile {
|
|
11
|
-
constructor() {
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @type {TileAddress}
|
|
15
|
-
*/
|
|
16
|
-
this.address = new TileAddress();
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @type {Sampler2D|null}
|
|
20
|
-
*/
|
|
21
|
-
this.sampler = null;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {TileStatus}
|
|
25
|
-
*/
|
|
26
|
-
this.status = TileStatus.Initial;
|
|
27
|
-
this.referenceCount = 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @returns {number}
|
|
33
|
-
*/
|
|
34
|
-
byteSize() {
|
|
35
|
-
const sampler = this.sampler;
|
|
36
|
-
|
|
37
|
-
if (sampler === null) {
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return sampler.computeByteSize();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Tile } from "./Tile.js";
|
|
2
|
-
import { TileStatus } from "./TileStatus.js";
|
|
3
|
-
|
|
4
|
-
test("Tile constructor doesn't throw", () => {
|
|
5
|
-
new Tile();
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
test("new tile has Initial status", () => {
|
|
9
|
-
const tile = new Tile();
|
|
10
|
-
expect(tile.status).toBe(TileStatus.Initial);
|
|
11
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents address of a tile in the overall texture pyramid
|
|
3
|
-
*/
|
|
4
|
-
export class TileAddress {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @constructor
|
|
8
|
-
*/
|
|
9
|
-
constructor() {
|
|
10
|
-
/**
|
|
11
|
-
* Mip level of the tile
|
|
12
|
-
* @type {number}
|
|
13
|
-
*/
|
|
14
|
-
this.mip = 0;
|
|
15
|
-
/**
|
|
16
|
-
* X address of the tile, this is a sequential integer
|
|
17
|
-
* @type {number}
|
|
18
|
-
*/
|
|
19
|
-
this.x = 0;
|
|
20
|
-
/**
|
|
21
|
-
* Y address of the tile, this is a sequential integer
|
|
22
|
-
* @type {number}
|
|
23
|
-
*/
|
|
24
|
-
this.y = 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {TileAddress} other
|
|
30
|
-
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
equals(other) {
|
|
33
|
-
return this.x === other.x && this.y === other.y && this.mip === other.mip;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns true if this address is a equal or higher mip level of what requested address
|
|
38
|
-
* @returns {boolean}
|
|
39
|
-
*/
|
|
40
|
-
_includes(x, y, mip) {
|
|
41
|
-
if (this.mip < mip) {
|
|
42
|
-
//lower level mip
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const mipDelta = this.mip - mip;
|
|
46
|
-
|
|
47
|
-
const expectedX = x << mipDelta;
|
|
48
|
-
|
|
49
|
-
if (this.x !== expectedX) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const expectedY = y << mipDelta;
|
|
54
|
-
|
|
55
|
-
if (this.y !== expectedY) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//match
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { TileAddress } from "./TileAddress.js";
|
|
2
|
-
|
|
3
|
-
test("TileAddress equals works correctly", () => {
|
|
4
|
-
const a = new TileAddress();
|
|
5
|
-
const b = new TileAddress();
|
|
6
|
-
|
|
7
|
-
expect(a.equals(b)).toBeTruthy();
|
|
8
|
-
|
|
9
|
-
a.x = 1;
|
|
10
|
-
a.y = 3;
|
|
11
|
-
a.mip = 7;
|
|
12
|
-
|
|
13
|
-
expect(a.equals(b)).toBeFalsy();
|
|
14
|
-
expect(b.equals(a)).toBeFalsy();
|
|
15
|
-
|
|
16
|
-
b.x = 1;
|
|
17
|
-
|
|
18
|
-
expect(a.equals(b)).toBeFalsy();
|
|
19
|
-
expect(b.equals(a)).toBeFalsy();
|
|
20
|
-
|
|
21
|
-
b.y = 3;
|
|
22
|
-
|
|
23
|
-
expect(a.equals(b)).toBeFalsy();
|
|
24
|
-
expect(b.equals(a)).toBeFalsy();
|
|
25
|
-
|
|
26
|
-
b.mip = 7;
|
|
27
|
-
|
|
28
|
-
expect(a.equals(b)).toBeTruthy();
|
|
29
|
-
expect(b.equals(a)).toBeTruthy();
|
|
30
|
-
});
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @constructor
|
|
4
|
-
*/
|
|
5
|
-
import { Tile } from "./Tile.js";
|
|
6
|
-
import { TileStatus } from "./TileStatus.js";
|
|
7
|
-
import { TileRequest } from "./TileRequest.js";
|
|
8
|
-
import { assert } from "../../../../../core/assert.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export class TileLoader {
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {AssetManager} assetManager
|
|
15
|
-
*/
|
|
16
|
-
constructor(assetManager) {
|
|
17
|
-
assert.defined(assetManager, 'assetManager');
|
|
18
|
-
assert.notNull(assetManager, 'assetManager');
|
|
19
|
-
assert.equal(assetManager.isAssetManager, true, 'assetManager.isAssetManager !== true');
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @type {AssetManager}
|
|
23
|
-
*/
|
|
24
|
-
this.assetManager = assetManager;
|
|
25
|
-
/**
|
|
26
|
-
* number of tiles to be loaded concurrently
|
|
27
|
-
* @type {number}
|
|
28
|
-
*/
|
|
29
|
-
this.concurrency = 3;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Set of tiles that are currently being loaded
|
|
33
|
-
* @type {Set<TileRequest>}
|
|
34
|
-
*/
|
|
35
|
-
this.pending = new Set();
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Requested tiles that are not yet being loaded
|
|
39
|
-
* @type {TileRequest[]}
|
|
40
|
-
*/
|
|
41
|
-
this.queue = [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {TileAddress} address
|
|
47
|
-
*/
|
|
48
|
-
promote(address) {
|
|
49
|
-
const i = this.indexOfQueueRequestByTile(address);
|
|
50
|
-
if (i === -1) {
|
|
51
|
-
//couldn't find, nothing to do
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
//cut and put in the front
|
|
55
|
-
const requests = this.queue.splice(i, 1);
|
|
56
|
-
this.queue.unshift(requests[0]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param {TileAddress} address
|
|
62
|
-
* @returns {number}
|
|
63
|
-
*/
|
|
64
|
-
indexOfQueueRequestByTile(address) {
|
|
65
|
-
const queue = this.queue;
|
|
66
|
-
const l = queue.length;
|
|
67
|
-
for (let i = 0; i < l; i++) {
|
|
68
|
-
const request = queue[i];
|
|
69
|
-
const tile = request.tile;
|
|
70
|
-
if (tile.address.equals(address)) {
|
|
71
|
-
return i;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return -1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {TileAddress} address
|
|
81
|
-
* @returns {boolean}
|
|
82
|
-
*/
|
|
83
|
-
remove(address) {
|
|
84
|
-
const i = this.indexOfQueueRequestByTile(address);
|
|
85
|
-
if (i !== -1) {
|
|
86
|
-
this.queue.splice(i, 1);
|
|
87
|
-
return true;
|
|
88
|
-
} else {
|
|
89
|
-
//TODO check pending queue, cancel load
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {Tile} tile
|
|
96
|
-
* @param {function(tile:Tile)} successCallback
|
|
97
|
-
* @param {function(tile:Tile)} failureCallback
|
|
98
|
-
*/
|
|
99
|
-
add(tile, successCallback, failureCallback) {
|
|
100
|
-
for (let request of this.pending) {
|
|
101
|
-
if (request.tile.address.equals(tile.address)) {
|
|
102
|
-
//tile is already being loaded
|
|
103
|
-
request.attach(successCallback, failureCallback);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
tile.status = TileStatus.Queued;
|
|
109
|
-
|
|
110
|
-
const request = new TileRequest(tile, successCallback, failureCallback);
|
|
111
|
-
|
|
112
|
-
this.queue.push(request);
|
|
113
|
-
this.prod();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Initialize loading of a tile
|
|
118
|
-
* @param {TileRequest} request
|
|
119
|
-
*/
|
|
120
|
-
load(request) {
|
|
121
|
-
this.pending.add(request);
|
|
122
|
-
|
|
123
|
-
const tile = request.tile;
|
|
124
|
-
const url = tileToURL(tile);
|
|
125
|
-
tile.status = TileStatus.Loading;
|
|
126
|
-
|
|
127
|
-
const self = this;
|
|
128
|
-
|
|
129
|
-
function loadFinished() {
|
|
130
|
-
self.pending.delete(request);
|
|
131
|
-
self.prod();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function success(asset) {
|
|
135
|
-
tile.status = TileStatus.Loaded;
|
|
136
|
-
tile.sampler = asset.create();
|
|
137
|
-
|
|
138
|
-
request.successCallbacks.forEach(function (cb) {
|
|
139
|
-
cb(tile);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
loadFinished();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function failure() {
|
|
146
|
-
//oh well?
|
|
147
|
-
request.failureCallbacks.forEach(function (cb) {
|
|
148
|
-
cb(tile);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
loadFinished();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//do load
|
|
155
|
-
this.assetManager.get({ path: 'image', type: url, callback: success, failure: failure });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Attempt to start loading another tile as long as it's within the concurrency limit, otherwise does nothing
|
|
160
|
-
* @private
|
|
161
|
-
*/
|
|
162
|
-
prod() {
|
|
163
|
-
while (this.pending < this.concurrency) {
|
|
164
|
-
const request = this.queue.shift();
|
|
165
|
-
this.load(request);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Constructs a tile URL
|
|
172
|
-
* @param {Tile} tile
|
|
173
|
-
* @returns {string}
|
|
174
|
-
*/
|
|
175
|
-
function tileToURL(tile) {
|
|
176
|
-
const address = tile.address;
|
|
177
|
-
return `${address.mip}$${address.x}_${address.y}`;
|
|
178
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Representation of a load request for a virtual texture tile
|
|
3
|
-
*/
|
|
4
|
-
export class TileRequest {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Tile} tile
|
|
8
|
-
* @param successCallback
|
|
9
|
-
* @param failureCallback
|
|
10
|
-
*/
|
|
11
|
-
constructor(tile, successCallback, failureCallback) {
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @type {Tile}
|
|
15
|
-
*/
|
|
16
|
-
this.tile = tile;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @type {Function[]}
|
|
21
|
-
*/
|
|
22
|
-
this.successCallbacks = [successCallback];
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @type {Function[]}
|
|
27
|
-
*/
|
|
28
|
-
this.failureCallbacks = [failureCallback];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {function} success
|
|
34
|
-
* @param {function} failure
|
|
35
|
-
*/
|
|
36
|
-
attach(success, failure) {
|
|
37
|
-
this.successCallbacks.push(success);
|
|
38
|
-
this.failureCallbacks.push(failure);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/engine/graphics/texture/virtual/{v2/tile → tile}/finger_print_to_tile_address.js
RENAMED
|
File without changes
|