@woosh/meep-engine 2.72.0 → 2.73.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/meep.cjs +34 -185
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +34 -185
- package/package.json +3 -2
- package/src/engine/graphics/ecs/camera/FrustumProjector.js +31 -182
- package/src/engine/graphics/texture/virtual/v2/NOTES.md +11 -1
- package/src/engine/graphics/texture/virtual/v2/ShaderUsage.js +7 -5
- package/src/engine/graphics/texture/virtual/v2/SparseTexture.js +182 -0
- package/src/engine/graphics/texture/virtual/v2/TextureTile.js +31 -0
- package/src/engine/graphics/texture/virtual/v2/TileLoader.js +215 -0
- package/src/engine/graphics/texture/virtual/v2/UsageDebugView.js +24 -11
- package/src/engine/graphics/texture/virtual/v2/UsageMetadata.js +77 -145
- package/src/engine/graphics/texture/virtual/v2/UsagePyramidDebugView.js +27 -14
- package/src/engine/graphics/texture/virtual/v2/VirtualTextureManager.js +13 -4
- package/src/engine/graphics/texture/virtual/v2/compose_finger_print.js +13 -0
- package/src/engine/graphics/texture/virtual/v2/finger_print_to_tile_index.js +37 -0
- package/src/engine/graphics/texture/virtual/v2/prototype.js +29 -11
- package/src/engine/graphics/texture/virtual/v2/tile_index_to_finger_print.js +31 -0
- package/src/engine/graphics/clouds/MaterialTransformer.js +0 -0
- package/src/engine/graphics/clouds/TerrainCloudsPlugin.js +0 -0
- package/src/engine/graphics/clouds/cs_build_fragment_shader.js +0 -0
- package/src/engine/graphics/clouds/cs_build_vertex_shader.js +0 -0
- package/src/engine/graphics/ecs/camera/TiltCameraController.js +0 -69
- package/src/engine/graphics/ecs/camera/is_valid_distance_value.js +0 -11
|
@@ -1,182 +1,121 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { arrayQuickSort } from "../../../../../core/collection/array/arrayQuickSort.js";
|
|
4
|
-
import { passThrough } from "../../../../../core/function/Functions.js";
|
|
5
|
-
import { split_by_2 } from "../../../../../core/geom/3d/morton/split_by_2.js";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_CAPACITY = 64;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {number} finger_print
|
|
12
|
-
* @returns {number}
|
|
13
|
-
*/
|
|
14
|
-
function finger_print_to_tile_index(finger_print) {
|
|
15
|
-
// decode fingerprint
|
|
16
|
-
const mip = (finger_print >> 24) & 0xFF;
|
|
17
|
-
const x = (finger_print >> 16) & 0xFF;
|
|
18
|
-
const y = (finger_print >> 8) & 0xFF;
|
|
19
|
-
|
|
20
|
-
// figure out resolution of this mip level
|
|
21
|
-
const mip_resolution = 1 << mip;
|
|
22
|
-
|
|
23
|
-
// this is basically converting something like 0100 to 0011;
|
|
24
|
-
const mip_mask = mip_resolution - 1;
|
|
25
|
-
|
|
26
|
-
// where data for this mip starts
|
|
27
|
-
const index_offset = split_by_2(mip_mask);
|
|
28
|
-
|
|
29
|
-
return index_offset + x + y * mip_resolution;
|
|
30
|
-
}
|
|
1
|
+
import { compose_finger_print } from "./compose_finger_print.js";
|
|
2
|
+
import { finger_print_to_tile_index } from "./finger_print_to_tile_index.js";
|
|
31
3
|
|
|
32
4
|
export class UsageMetadata {
|
|
33
5
|
|
|
34
|
-
#
|
|
6
|
+
#counts_intrinsic = new Uint32Array(0);
|
|
7
|
+
|
|
8
|
+
get counts() {
|
|
9
|
+
return this.#counts_intrinsic;
|
|
10
|
+
}
|
|
35
11
|
|
|
36
|
-
#
|
|
37
|
-
#counts = new Uint32Array(0);
|
|
12
|
+
#max_mip_level = 0;
|
|
38
13
|
|
|
39
|
-
|
|
14
|
+
set max_mip_level(v) {
|
|
15
|
+
this.#max_mip_level = v;
|
|
40
16
|
|
|
41
|
-
|
|
17
|
+
this.#ensureCapacity();
|
|
18
|
+
}
|
|
42
19
|
|
|
43
|
-
|
|
44
|
-
this.#
|
|
20
|
+
get max_mip_level() {
|
|
21
|
+
return this.#max_mip_level;
|
|
45
22
|
}
|
|
46
23
|
|
|
47
24
|
/**
|
|
48
25
|
*
|
|
49
|
-
* @param {number} min_size
|
|
50
26
|
*/
|
|
51
|
-
#ensureCapacity(
|
|
52
|
-
|
|
27
|
+
#ensureCapacity() {
|
|
28
|
+
|
|
29
|
+
const finger_print = compose_finger_print(this.#max_mip_level + 1, 0, 0);
|
|
30
|
+
|
|
31
|
+
const size = finger_print_to_tile_index(finger_print);
|
|
32
|
+
|
|
33
|
+
if (this.#counts_intrinsic.length >= size) {
|
|
34
|
+
// already large enough
|
|
53
35
|
return;
|
|
54
36
|
}
|
|
55
37
|
|
|
56
|
-
|
|
38
|
+
this.#counts_intrinsic = new Uint32Array(size);
|
|
39
|
+
}
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
#getIndexBy(mip, x, y) {
|
|
42
|
+
const finger_print = compose_finger_print(mip, x, y);
|
|
60
43
|
|
|
61
|
-
|
|
44
|
+
return finger_print_to_tile_index(finger_print);
|
|
62
45
|
}
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param {number} fingerprint
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
getCountByFingerprint(fingerprint) {
|
|
53
|
+
const index = finger_print_to_tile_index(fingerprint);
|
|
67
54
|
|
|
68
|
-
getTile(index) {
|
|
69
|
-
return this.#lookup[index];
|
|
70
|
-
}
|
|
71
55
|
|
|
72
|
-
|
|
73
|
-
return this.#counts[index];
|
|
56
|
+
return this.#counts_intrinsic[index];
|
|
74
57
|
}
|
|
75
58
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {number} mip
|
|
62
|
+
* @param {number} x
|
|
63
|
+
* @param {number} y
|
|
64
|
+
* @returns {number}
|
|
65
|
+
*/
|
|
66
|
+
getCountBy(mip, x, y) {
|
|
67
|
+
const finger_print = compose_finger_print(mip, x, y);
|
|
80
68
|
|
|
81
|
-
|
|
82
|
-
array_swap(
|
|
83
|
-
this.#lookup,
|
|
84
|
-
a,
|
|
85
|
-
this.#lookup,
|
|
86
|
-
b,
|
|
87
|
-
1
|
|
88
|
-
);
|
|
89
|
-
array_swap(
|
|
90
|
-
this.#counts,
|
|
91
|
-
a,
|
|
92
|
-
this.#counts,
|
|
93
|
-
b,
|
|
94
|
-
1
|
|
95
|
-
);
|
|
69
|
+
return this.getCountByFingerprint(finger_print);
|
|
96
70
|
}
|
|
97
71
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.swap(i, j);
|
|
101
|
-
});
|
|
72
|
+
clear() {
|
|
73
|
+
this.#counts_intrinsic.fill(0);
|
|
102
74
|
}
|
|
103
75
|
|
|
104
76
|
/**
|
|
105
77
|
* Given existing usage, award same usage to all tiles up the chain all the way to the root
|
|
106
78
|
* This helps avoid popping and ensures that when there's not enough space - at least the higher level LOD tiles are available
|
|
107
79
|
* @param {number} bias added to the ancestor tiles to make them more likely to be loaded
|
|
108
|
-
* @returns {number} number of tiles added
|
|
109
80
|
*/
|
|
110
|
-
promoteAncestors(bias =
|
|
111
|
-
const start_cursor = this.#cursor;
|
|
112
|
-
|
|
113
|
-
for (let tile_index = 0; tile_index < this.#cursor; tile_index++) {
|
|
114
|
-
let finger_print = this.#lookup[tile_index];
|
|
81
|
+
promoteAncestors(bias = 1) {
|
|
115
82
|
|
|
116
|
-
|
|
83
|
+
// traverse mip pyramid in reverse, so we can push counts to parents one level at a time
|
|
84
|
+
for (let mip = this.#max_mip_level - 1; mip > 0; mip--) {
|
|
117
85
|
|
|
118
|
-
|
|
86
|
+
const mip_resolution = 1 << mip;
|
|
119
87
|
|
|
120
|
-
|
|
88
|
+
for (let y = 0; y < mip_resolution; y++) {
|
|
89
|
+
for (let x = 0; x < mip_resolution; x++) {
|
|
121
90
|
|
|
122
|
-
|
|
123
|
-
const y = (finger_print >> 8) & 0xFF;
|
|
124
|
-
const texture_id = (finger_print) & 0xFF;
|
|
91
|
+
const count = this.getCountBy(mip, x, y);
|
|
125
92
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const parent_y = y >>> 1;
|
|
93
|
+
if (count <= 0) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
130
96
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
| (texture_id << 0);
|
|
97
|
+
// get higher-level lod
|
|
98
|
+
const parent_level = mip - 1;
|
|
99
|
+
const parent_x = x >>> 1;
|
|
100
|
+
const parent_y = y >>> 1;
|
|
136
101
|
|
|
137
|
-
|
|
102
|
+
const parent_index = this.#getIndexBy(parent_level, parent_x, parent_y);
|
|
138
103
|
|
|
139
|
-
|
|
140
|
-
const parent_count = this.#counts[parent_index];
|
|
141
|
-
|
|
142
|
-
if (parent_count >= push_value) {
|
|
143
|
-
// already high, no need to do anything
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
104
|
+
const parent_count = this.#counts_intrinsic[parent_index];
|
|
146
105
|
|
|
147
|
-
|
|
106
|
+
const expected_count = count + bias;
|
|
148
107
|
|
|
108
|
+
if (parent_count < expected_count) {
|
|
109
|
+
this.#counts_intrinsic[parent_index] = expected_count;
|
|
110
|
+
}
|
|
149
111
|
|
|
150
|
-
|
|
151
|
-
finger_print = parent_finger_print;
|
|
152
|
-
level = parent_level;
|
|
153
|
-
|
|
154
|
-
index = parent_index;
|
|
112
|
+
}
|
|
155
113
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return this.#cursor - start_cursor;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
*
|
|
163
|
-
* @param {number} finger_print
|
|
164
|
-
* @returns {number}
|
|
165
|
-
*/
|
|
166
|
-
bindTileIndex(finger_print) {
|
|
167
|
-
|
|
168
|
-
const lookup = this.#lookup;
|
|
169
114
|
|
|
170
|
-
let index = array_get_index_in_range(lookup, finger_print, 0, this.#cursor - 1);
|
|
171
|
-
|
|
172
|
-
if (index === -1) {
|
|
173
|
-
index = this.#cursor++;
|
|
174
|
-
lookup[index] = finger_print;
|
|
175
115
|
}
|
|
176
|
-
|
|
177
|
-
return index;
|
|
178
116
|
}
|
|
179
117
|
|
|
118
|
+
|
|
180
119
|
/**
|
|
181
120
|
*
|
|
182
121
|
* @param {Uint8Array} data usage texture data
|
|
@@ -188,10 +127,13 @@ export class UsageMetadata {
|
|
|
188
127
|
|
|
189
128
|
this.#ensureCapacity(data_size >> 2);
|
|
190
129
|
|
|
191
|
-
const counts = this.#counts;
|
|
192
|
-
|
|
193
130
|
for (let offset = 0; offset < data_size; offset += 4) {
|
|
194
131
|
|
|
132
|
+
if (data[offset + 3] === 0) {
|
|
133
|
+
// no data
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
195
137
|
const mip_level = data[offset];
|
|
196
138
|
|
|
197
139
|
// we create a mask to make sure we don't end up with invalid tile position values
|
|
@@ -200,21 +142,11 @@ export class UsageMetadata {
|
|
|
200
142
|
const tile_x = data[offset + 1] & max_tile_value;
|
|
201
143
|
const tile_y = data[offset + 2] & max_tile_value;
|
|
202
144
|
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
const finger_print =
|
|
206
|
-
(mip_level << 24)
|
|
207
|
-
| (tile_x << 16)
|
|
208
|
-
| (tile_y << 8)
|
|
209
|
-
| (texture_id << 0);
|
|
210
|
-
|
|
211
|
-
if (finger_print === 0) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
145
|
+
const finger_print = compose_finger_print(mip_level, tile_x, tile_y);
|
|
214
146
|
|
|
215
|
-
const
|
|
147
|
+
const index0 = finger_print_to_tile_index(finger_print);
|
|
216
148
|
|
|
217
|
-
|
|
149
|
+
this.#counts_intrinsic[index0]++;
|
|
218
150
|
}
|
|
219
151
|
|
|
220
152
|
}
|
|
@@ -213,27 +213,40 @@ export class UsagePyramidDebugView extends EmptyView {
|
|
|
213
213
|
}
|
|
214
214
|
this.#used_set_size = 0;
|
|
215
215
|
|
|
216
|
-
const tile_count = usage.tile_count;
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
const finger_print = usage.getTile(i);
|
|
217
|
+
const mip_count = this.#levels.length;
|
|
220
218
|
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
const y = (finger_print >> 8) & 0xFF;
|
|
219
|
+
for (let mip = 0; mip < mip_count; mip++) {
|
|
220
|
+
const size = 1 << mip;
|
|
224
221
|
|
|
225
|
-
|
|
222
|
+
for (let y = 0; y < size; y++) {
|
|
223
|
+
for (let x = 0; x < size; x++) {
|
|
224
|
+
const count = usage.getCountBy(mip,x,y);
|
|
226
225
|
|
|
227
|
-
|
|
226
|
+
if(count === 0){
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
-
background: "rgba(255,0,0,0.8)"
|
|
231
|
-
});
|
|
230
|
+
const mipView = this.#levels[mip];
|
|
232
231
|
|
|
233
|
-
|
|
232
|
+
const tile = mipView.getTile(x, y);
|
|
234
233
|
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
tile.css({
|
|
235
|
+
background: "rgba(255,0,0,0.8)"
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
tile.visible = true;
|
|
239
|
+
|
|
240
|
+
const finger_print = (mip << 24)
|
|
241
|
+
| (x << 16)
|
|
242
|
+
| (y << 8)
|
|
243
|
+
;
|
|
244
|
+
|
|
245
|
+
this.#used_set[this.#used_set_size] = finger_print;
|
|
246
|
+
this.#used_set_size++;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
237
249
|
}
|
|
250
|
+
|
|
238
251
|
}
|
|
239
252
|
}
|
|
@@ -95,6 +95,7 @@ export class VirtualTextureManager {
|
|
|
95
95
|
#texture_id = 3;
|
|
96
96
|
#texture_resolution = 65536;
|
|
97
97
|
#tile_resolution = 256;
|
|
98
|
+
#max_mip_level = 0;
|
|
98
99
|
|
|
99
100
|
get texture_resolution() {
|
|
100
101
|
return this.#texture_resolution;
|
|
@@ -104,6 +105,10 @@ export class VirtualTextureManager {
|
|
|
104
105
|
return this.#tile_resolution;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
get max_mip_level() {
|
|
109
|
+
return this.#max_mip_level;
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
/**
|
|
108
113
|
* Used to fetch higher resolution tiles
|
|
109
114
|
* @type {number}
|
|
@@ -124,8 +129,15 @@ export class VirtualTextureManager {
|
|
|
124
129
|
this.#texture_id = texture_id;
|
|
125
130
|
this.#texture_resolution = resolution;
|
|
126
131
|
this.#tile_resolution = tile_size;
|
|
132
|
+
this.#max_mip_level = Math.log2(this.#texture_resolution / this.#tile_resolution);
|
|
133
|
+
|
|
134
|
+
if (!Number.isInteger(this.#max_mip_level)) {
|
|
135
|
+
throw new Error(`texture resolution must be a power-of-two multiple of tile resolution`);
|
|
136
|
+
}
|
|
127
137
|
|
|
128
138
|
this.#initialize_usage_uniforms();
|
|
139
|
+
|
|
140
|
+
this.#usage_metadata.max_mip_level = this.#max_mip_level;
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
get usage_metadata() {
|
|
@@ -144,11 +156,8 @@ export class VirtualTextureManager {
|
|
|
144
156
|
|
|
145
157
|
const uniforms = usage_material.uniforms;
|
|
146
158
|
|
|
147
|
-
const max_mip_level =
|
|
159
|
+
const max_mip_level = this.#max_mip_level;
|
|
148
160
|
|
|
149
|
-
if (!Number.isInteger(max_mip_level)) {
|
|
150
|
-
throw new Error(`texture resolution must be a power-of-two multiple of tile resolution`);
|
|
151
|
-
}
|
|
152
161
|
|
|
153
162
|
uniforms.u_mt_params.value.set(
|
|
154
163
|
this.#usage_texture_bias,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { split_by_2 } from "../../../../../core/geom/3d/morton/split_by_2.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} finger_print
|
|
6
|
+
* @returns {{mip: number, x: number, y: number}}
|
|
7
|
+
*/
|
|
8
|
+
export function decompose_finger_print(finger_print) {
|
|
9
|
+
const mip = (finger_print >> 24) & 0xFF;
|
|
10
|
+
const x = (finger_print >> 16) & 0xFF;
|
|
11
|
+
const y = (finger_print >> 8) & 0xFF;
|
|
12
|
+
|
|
13
|
+
return { mip, x, y };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {number} finger_print
|
|
19
|
+
* @returns {number}
|
|
20
|
+
*/
|
|
21
|
+
export function finger_print_to_tile_index(finger_print) {
|
|
22
|
+
// decode fingerprint
|
|
23
|
+
const mip = (finger_print >> 24) & 0xFF;
|
|
24
|
+
const x = (finger_print >> 16) & 0xFF;
|
|
25
|
+
const y = (finger_print >> 8) & 0xFF;
|
|
26
|
+
|
|
27
|
+
// figure out resolution of this mip level
|
|
28
|
+
const mip_resolution = 1 << mip;
|
|
29
|
+
|
|
30
|
+
// this is basically converting something like 0100 to 0011;
|
|
31
|
+
const mip_mask = mip_resolution - 1;
|
|
32
|
+
|
|
33
|
+
// where data for this mip starts
|
|
34
|
+
const index_offset = split_by_2(mip_mask);
|
|
35
|
+
|
|
36
|
+
return index_offset + x + y * mip_resolution;
|
|
37
|
+
}
|
|
@@ -15,7 +15,11 @@ import {
|
|
|
15
15
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
16
16
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
17
17
|
import EmptyView from "../../../../../view/elements/EmptyView.js";
|
|
18
|
-
import {
|
|
18
|
+
import { AssetManager } from "../../../../asset/AssetManager.js";
|
|
19
|
+
import { GameAssetType } from "../../../../asset/GameAssetType.js";
|
|
20
|
+
import { ImageRGBADataLoader } from "../../../../asset/loaders/image/ImageRGBADataLoader.js";
|
|
21
|
+
import { SparseTexture } from "./SparseTexture.js";
|
|
22
|
+
import { UsageDebugView } from "./UsageDebugView.js";
|
|
19
23
|
import { VirtualTextureManager } from "./VirtualTextureManager.js";
|
|
20
24
|
|
|
21
25
|
let camera,
|
|
@@ -31,6 +35,10 @@ let camera,
|
|
|
31
35
|
|
|
32
36
|
let mesh;
|
|
33
37
|
|
|
38
|
+
const am = new AssetManager();
|
|
39
|
+
am.registerLoader(GameAssetType.Image, new ImageRGBADataLoader());
|
|
40
|
+
am.startup();
|
|
41
|
+
|
|
34
42
|
const virtualTextureManager = new VirtualTextureManager();
|
|
35
43
|
virtualTextureManager.setTextureParameters(
|
|
36
44
|
// 2048,
|
|
@@ -39,10 +47,12 @@ virtualTextureManager.setTextureParameters(
|
|
|
39
47
|
3
|
|
40
48
|
);
|
|
41
49
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
const sparseTexture = new SparseTexture();
|
|
51
|
+
sparseTexture.page_texture_size = [1024, 1024];
|
|
52
|
+
sparseTexture.tile_resolution = virtualTextureManager.tile_resolution;
|
|
53
|
+
sparseTexture.asset_manager = am;
|
|
54
|
+
|
|
55
|
+
console.log(sparseTexture);
|
|
46
56
|
|
|
47
57
|
// const TEXTURE_URL = "data/textures/utility/uv_map_reference.png";
|
|
48
58
|
// const TEXTURE_URL = "data/textures/utility/4096x4096TexelDensityTexture1.png";
|
|
@@ -50,10 +60,17 @@ const container_view = new EmptyView();
|
|
|
50
60
|
// const TEXTURE_URL = "data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_cards_a.png";
|
|
51
61
|
const TEXTURE_URL = "data/models/LowPolyTownshipSet/Town_Hall//diffuse_2048.png";
|
|
52
62
|
|
|
53
|
-
const
|
|
54
|
-
|
|
63
|
+
const container_view = new EmptyView();
|
|
64
|
+
//
|
|
65
|
+
const usageDebugView = new UsageDebugView();
|
|
66
|
+
usageDebugView.mip_levels = virtualTextureManager.max_mip_level;
|
|
67
|
+
container_view.addChild(usageDebugView);
|
|
55
68
|
|
|
56
|
-
|
|
69
|
+
|
|
70
|
+
// const usagePyramidDebugView = new UsagePyramidDebugView();
|
|
71
|
+
// usagePyramidDebugView.setImageURL(TEXTURE_URL);
|
|
72
|
+
//
|
|
73
|
+
// container_view.addChild(usagePyramidDebugView);
|
|
57
74
|
|
|
58
75
|
const options = {
|
|
59
76
|
spin: true
|
|
@@ -163,12 +180,13 @@ function render() {
|
|
|
163
180
|
|
|
164
181
|
virtualTextureManager.setViewportResolution(view_port_size.x, view_port_size.y);
|
|
165
182
|
virtualTextureManager.updateUsage(renderer, scene, camera);
|
|
183
|
+
sparseTexture.update_usage(virtualTextureManager.usage_metadata);
|
|
166
184
|
|
|
167
185
|
renderer.clear();
|
|
168
186
|
renderer.render(scene, camera)
|
|
169
187
|
|
|
170
|
-
|
|
188
|
+
usageDebugView.usage = virtualTextureManager.usage_metadata;
|
|
171
189
|
|
|
172
|
-
usagePyramidDebugView.setTextureParameters(virtualTextureManager.texture_resolution, virtualTextureManager.tile_resolution);
|
|
173
|
-
usagePyramidDebugView.usage = virtualTextureManager.usage_metadata;
|
|
190
|
+
// usagePyramidDebugView.setTextureParameters(virtualTextureManager.texture_resolution, virtualTextureManager.tile_resolution);
|
|
191
|
+
// usagePyramidDebugView.usage = virtualTextureManager.usage_metadata;
|
|
174
192
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { split_by_2 } from "../../../../../core/geom/3d/morton/split_by_2.js";
|
|
2
|
+
import { compose_finger_print } from "./compose_finger_print.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {number} index
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function tile_index_to_finger_print(index) {
|
|
10
|
+
for (let mip = 0; mip < 99; mip++) {
|
|
11
|
+
const resolution = 1 << mip;
|
|
12
|
+
|
|
13
|
+
const mip_mask = resolution - 1;
|
|
14
|
+
|
|
15
|
+
const index_offset = split_by_2(mip_mask);
|
|
16
|
+
|
|
17
|
+
if (index > index_offset) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const local_index = index - index_offset;
|
|
22
|
+
|
|
23
|
+
const y = (local_index / resolution) | 0;
|
|
24
|
+
const x = local_index % resolution;
|
|
25
|
+
|
|
26
|
+
return compose_finger_print(mip, x, y,);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// not found
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 30/06/2015.
|
|
3
|
-
*/
|
|
4
|
-
import { Object3D, Vector3 as ThreeVector3 } from 'three';
|
|
5
|
-
|
|
6
|
-
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
7
|
-
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
8
|
-
import { DEG_TO_RAD } from "../../../../core/math/DEG_TO_RAD.js";
|
|
9
|
-
|
|
10
|
-
const CC = function () {
|
|
11
|
-
this.target = new Vector3();
|
|
12
|
-
this.rotationAxis = new Vector3(0, 1, 0);
|
|
13
|
-
this.rotationAngle = DEG_TO_RAD * 0;
|
|
14
|
-
//angle between rotation axis and vector from target to position
|
|
15
|
-
this.tiltAngle = DEG_TO_RAD * 10;
|
|
16
|
-
|
|
17
|
-
this.distance = 100;
|
|
18
|
-
this.position = new Vector3();
|
|
19
|
-
this.rotation = new Vector3();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
CC.prototype.rotate = function (deltaAngle) {
|
|
23
|
-
this.tiltAngle += deltaAngle;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
CC.prototype.pan = function (deltaX, deltaY, cameraRotation) {
|
|
27
|
-
//vector pointing in the direction of travel
|
|
28
|
-
const vector = new ThreeVector3(deltaX, 0, deltaY);
|
|
29
|
-
//var rotationMatrix = new THREE.Matrix4().makeRotationFromQuaternion(cameraRotation);
|
|
30
|
-
//vector.applyMatrix4(rotationMatrix);
|
|
31
|
-
////add to delta vector
|
|
32
|
-
//vector.y = 0;
|
|
33
|
-
this.target.add(vector);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const object = new Object3D();
|
|
37
|
-
|
|
38
|
-
function eulerJSON(o) {
|
|
39
|
-
return { x: o.x, y: o.y, z: o.z };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
CC.prototype.updatePositionAndRotation = function (transform) {
|
|
43
|
-
const distance = this.distance;
|
|
44
|
-
const target = this.target;
|
|
45
|
-
const rotationAngle = this.rotationAngle;
|
|
46
|
-
let rotationAxis = this.rotationAxis;
|
|
47
|
-
const tiltAngle = this.tiltAngle;
|
|
48
|
-
|
|
49
|
-
//position
|
|
50
|
-
const dTilt = new Vector2();
|
|
51
|
-
dTilt.x = Math.sin(tiltAngle) * distance;
|
|
52
|
-
dTilt.y = Math.cos(tiltAngle) * distance;
|
|
53
|
-
|
|
54
|
-
const position = new Vector3();
|
|
55
|
-
position.x = Math.sin(rotationAngle) * dTilt.x;
|
|
56
|
-
position.z = Math.cos(rotationAngle) * dTilt.x;
|
|
57
|
-
position.y = dTilt.y;
|
|
58
|
-
|
|
59
|
-
position.add(target);
|
|
60
|
-
//finally look at the target
|
|
61
|
-
object.position.copy(position);
|
|
62
|
-
object.lookAt(target);
|
|
63
|
-
//console.log(position.toJSON(), target.toJSON());
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
//transform.position.copy(position);
|
|
67
|
-
//transform.rotation.setFromEuler(object.rotation);
|
|
68
|
-
};
|
|
69
|
-
export default CC;
|