@woosh/meep-engine 2.40.1 → 2.42.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/core/collection/HashMap.d.ts +2 -0
- package/core/collection/HashMap.js +22 -0
- package/core/geom/3d/apply_mat4_transform_to_v3_array.js +2 -4
- package/core/geom/3d/normal/hemioct/encode_unit3_hemioct.js +5 -0
- package/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +31 -0
- package/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +33 -0
- package/core/geom/3d/normal/octahedron/encoding.spec.js +29 -0
- package/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +28 -0
- package/core/geom/3d/topology/struct/BinaryTopology.js +112 -0
- package/core/geom/Quaternion.js +14 -0
- package/core/math/sign_not_zero.js +8 -0
- package/core/parser/simple/SimpleParser.js +3 -86
- package/core/parser/simple/readUnsignedInteger.js +66 -0
- package/core/parser/simple/skipWhitespace.js +21 -0
- package/engine/EngineHarness.js +13 -3
- package/engine/asset/AssetDescription.spec.js +27 -0
- package/engine/asset/loaders/GLTFAssetLoader.js +5 -3
- package/engine/ecs/foliage/ImpostorFoliage.js +4 -0
- package/engine/ecs/transform/Transform.js +23 -3
- package/engine/graphics/ecs/decal/v2/Decal.d.ts +11 -0
- package/engine/graphics/ecs/decal/v2/Decal.js +50 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +8 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +213 -0
- package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +237 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +8 -1
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +4 -0
- package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +22 -7
- package/engine/graphics/filter/ImageFilter.js +2 -1
- package/engine/graphics/geometry/MikkT/MikkTSpace.js +466 -305
- package/engine/graphics/geometry/MikkT/MikkTSpace.spec.js +7 -1
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeBufferAttributeHash.js +1 -1
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryEquality.js +2 -2
- package/engine/{asset/loaders/geometry/geometry → graphics/geometry/buffered}/computeGeometryHash.js +1 -1
- package/engine/graphics/geometry/optimization/merge/merge_geometry_hierarchy.js +2 -2
- package/engine/graphics/impostors/card_cluster/FacePlaneAssignment.js +30 -0
- package/engine/graphics/impostors/card_cluster/README.md +13 -0
- package/engine/graphics/impostors/octahedral/ImpostorBaker.js +345 -0
- package/engine/graphics/impostors/octahedral/ImpostorCaptureType.js +10 -0
- package/engine/graphics/impostors/octahedral/ImpostorDescription.js +69 -0
- package/engine/graphics/impostors/octahedral/README.md +30 -0
- package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +45 -0
- package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere_radius_only.js +37 -0
- package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +117 -0
- package/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +20 -0
- package/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +25 -0
- package/engine/graphics/impostors/octahedral/grid/UvEncoder.js +21 -0
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +237 -0
- package/engine/graphics/impostors/octahedral/shader/BakeShaderStandard.js +196 -0
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderStandard.js +306 -0
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +349 -0
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV1.js +74 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/common.glsl +206 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/common.glsl +209 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/flagment.glsl +80 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/vertex.glsl +350 -0
- package/engine/graphics/micron/convert_three_object_to_micron.js +2 -2
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +2 -2
- package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
- package/engine/graphics/particles/node-based/codegen/CodeGenerator.js +1 -1
- package/engine/graphics/particles/node-based/nodes/noise/CurlNoiseNode.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +1 -1
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +1 -3
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +2 -1
- package/engine/graphics/render/forward_plus/model/Decal.js +19 -2
- package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +32 -10
- package/engine/graphics/shaders/ScreenSpaceQuadShader.js +4 -14
- package/engine/graphics/shaders/glsl_gen_swizzled_read.js +39 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +10 -10
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +117 -11
- package/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +66 -0
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +2 -2
- package/engine/ui/GUIEngine.js +8 -1
- package/package.json +1 -1
- package/view/tooltip/gml/parser/readReferenceToken.js +1 -1
- package/engine/asset/GameAssetManager.js +0 -137
|
@@ -271,10 +271,10 @@ export class Sampler2D {
|
|
|
271
271
|
* @returns {number}
|
|
272
272
|
*/
|
|
273
273
|
sampleChannelCatmullRomUV(u, v, channel) {
|
|
274
|
-
const x = u * (this.width);
|
|
275
|
-
const y = v * (this.height);
|
|
274
|
+
const x = u * (this.width - 1);
|
|
275
|
+
const y = v * (this.height - 1);
|
|
276
276
|
|
|
277
|
-
return this.sampleChannelCatmullRom(x
|
|
277
|
+
return this.sampleChannelCatmullRom(x, y, channel);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
/**
|
|
@@ -366,8 +366,8 @@ export class Sampler2D {
|
|
|
366
366
|
* @returns {number}
|
|
367
367
|
*/
|
|
368
368
|
sampleChannelBicubicUV(u, v, channel) {
|
|
369
|
-
const x = u * (this.width);
|
|
370
|
-
const y = v * (this.height);
|
|
369
|
+
const x = u * (this.width - 1);
|
|
370
|
+
const y = v * (this.height - 1);
|
|
371
371
|
|
|
372
372
|
return this.sampleChannelBicubic(x - 0.5, y - 0.5, channel);
|
|
373
373
|
}
|
|
@@ -511,10 +511,10 @@ export class Sampler2D {
|
|
|
511
511
|
* @return {number}
|
|
512
512
|
*/
|
|
513
513
|
sampleChannelBilinearUV(u, v, channel) {
|
|
514
|
-
const x = u * (this.width);
|
|
515
|
-
const y = v * (this.height);
|
|
514
|
+
const x = u * (this.width - 1);
|
|
515
|
+
const y = v * (this.height - 1);
|
|
516
516
|
|
|
517
|
-
return this.sampleChannelBilinear(x
|
|
517
|
+
return this.sampleChannelBilinear(x, y, channel);
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
/**
|
|
@@ -599,8 +599,8 @@ export class Sampler2D {
|
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
sampleNearestUV(u, v, result) {
|
|
602
|
-
const x = Math.round(u * (this.width
|
|
603
|
-
const y = Math.round(v * (this.height
|
|
602
|
+
const x = Math.round(u * (this.width - 1));
|
|
603
|
+
const y = Math.round(v * (this.height - 1));
|
|
604
604
|
|
|
605
605
|
this.read(min2(x, this.width - 1), min2(y, this.height - 1), result);
|
|
606
606
|
}
|
|
@@ -6,17 +6,56 @@ import { sampler2D_scale_down_lanczos } from "./sampler2_d_scale_down_lanczos.js
|
|
|
6
6
|
import { Sampler2D } from "./Sampler2D.js";
|
|
7
7
|
import { genericResampleSampler2D } from "./genericResampleSampler2D.js";
|
|
8
8
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
9
|
+
import LabelView from "../../../../view/common/LabelView.js";
|
|
10
|
+
import EmptyView from "../../../../view/elements/EmptyView.js";
|
|
11
|
+
import { sampler2d_downsample_mipmap } from "./resize/sampler2d_downsample_mipmap.js";
|
|
9
12
|
|
|
10
13
|
function grid(engine, input, transforms, size = new Vector2(input.width, input.height)) {
|
|
11
14
|
|
|
15
|
+
let draw_index = 0;
|
|
16
|
+
|
|
12
17
|
for (let i = 0; i < transforms.length; i++) {
|
|
13
18
|
const out = input.clone();
|
|
14
19
|
|
|
15
20
|
out.resize(size.x, size.y);
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
const params = {
|
|
23
|
+
label: '',
|
|
24
|
+
skip: false
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
transforms[i](out, input, params);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
// error, skip
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (params.skip) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const view = display(engine, out, draw_index * (size.x + 4), 0);
|
|
39
|
+
|
|
40
|
+
if (params.label.length > 0) {
|
|
41
|
+
view.addChild(new LabelView(params.label, {
|
|
42
|
+
css: {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
fontFamily: 'sans-serif',
|
|
45
|
+
fontWeight: 'bold',
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
zIndex: 1,
|
|
49
|
+
color: '#000000',
|
|
50
|
+
textShadow: '1px 1px 1px white',
|
|
51
|
+
background: 'rgba(255,255,255,0.7)',
|
|
52
|
+
padding: '2px'
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
draw_index++;
|
|
18
58
|
|
|
19
|
-
display(engine, out, i * (size.x + 4), 0);
|
|
20
59
|
}
|
|
21
60
|
|
|
22
61
|
}
|
|
@@ -30,11 +69,23 @@ function display(engine, sampler, x = 0, y = 0) {
|
|
|
30
69
|
|
|
31
70
|
view.css({
|
|
32
71
|
position: 'absolute',
|
|
33
|
-
top:
|
|
34
|
-
left:
|
|
72
|
+
top: "0",
|
|
73
|
+
left: "0"
|
|
35
74
|
});
|
|
36
75
|
|
|
37
|
-
|
|
76
|
+
const container = new EmptyView({
|
|
77
|
+
css: {
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
top: `${y}px`,
|
|
80
|
+
left: `${x}px`
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
container.size.set(sampler.width, sampler.height);
|
|
84
|
+
container.addChild(view);
|
|
85
|
+
|
|
86
|
+
engine.gameView.addChild(container);
|
|
87
|
+
|
|
88
|
+
return container;
|
|
38
89
|
}
|
|
39
90
|
|
|
40
91
|
|
|
@@ -44,7 +95,13 @@ new EngineHarness().initialize({
|
|
|
44
95
|
}
|
|
45
96
|
}).then(async engine => {
|
|
46
97
|
|
|
47
|
-
const asset = await engine.assetManager.promise("data/textures/utility/Lenna.png", 'image');
|
|
98
|
+
// const asset = await engine.assetManager.promise("data/textures/utility/Lenna.png", 'image');
|
|
99
|
+
// const asset = await engine.assetManager.promise("data/textures/utility/uv_map_reference.jpg", 'image');
|
|
100
|
+
const asset = await engine.assetManager.promise("data/textures/utility/image018.jpg", 'image');
|
|
101
|
+
// const asset = await engine.assetManager.promise("data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_clips.png", 'image');
|
|
102
|
+
// const asset = await engine.assetManager.promise("data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_coins.png", 'image');
|
|
103
|
+
// const asset = await engine.assetManager.promise("data/models/LowPolyTownshipSet/Small_house/diffuse_512.png", 'image');
|
|
104
|
+
// const asset = await engine.assetManager.promise("data/models/LowPolyTownshipSet/Barrel/diffuse_256.png", 'image');
|
|
48
105
|
// const asset = await engine.assetManager.promise("data/textures/utility/resolver.jpeg", 'image');
|
|
49
106
|
// const asset = await engine.assetManager.promise("data/textures/icons/500_skill_icons_02/Skill_nobg/skill_492_noBG.png", 'image');
|
|
50
107
|
// const asset = await engine.assetManager.promise("data/textures/utility/sampling-test.png", 'image');
|
|
@@ -88,7 +145,9 @@ new EngineHarness().initialize({
|
|
|
88
145
|
|
|
89
146
|
function test_sampling(source, engine) {
|
|
90
147
|
grid(engine, source, [
|
|
91
|
-
(out, input) => {
|
|
148
|
+
(out, input, params) => {
|
|
149
|
+
params.label = 'Nearest';
|
|
150
|
+
|
|
92
151
|
const sample = [];
|
|
93
152
|
for (let y = 0; y < out.height; y++) {
|
|
94
153
|
|
|
@@ -100,7 +159,11 @@ function test_sampling(source, engine) {
|
|
|
100
159
|
}
|
|
101
160
|
}
|
|
102
161
|
},
|
|
103
|
-
(out, input) => {
|
|
162
|
+
(out, input, params) => {
|
|
163
|
+
|
|
164
|
+
params.label = 'Bilinear';
|
|
165
|
+
params.skip = true;
|
|
166
|
+
|
|
104
167
|
const sample = new Uint8ClampedArray(4);
|
|
105
168
|
for (let y = 0; y < out.height; y++) {
|
|
106
169
|
|
|
@@ -112,7 +175,10 @@ function test_sampling(source, engine) {
|
|
|
112
175
|
}
|
|
113
176
|
}
|
|
114
177
|
},
|
|
115
|
-
(out, input) => {
|
|
178
|
+
(out, input, params) => {
|
|
179
|
+
params.label = 'Bicubic';
|
|
180
|
+
params.skip = true;
|
|
181
|
+
|
|
116
182
|
const sample = new Uint8ClampedArray(4);
|
|
117
183
|
for (let y = 0; y < out.height; y++) {
|
|
118
184
|
|
|
@@ -124,7 +190,10 @@ function test_sampling(source, engine) {
|
|
|
124
190
|
}
|
|
125
191
|
}
|
|
126
192
|
},
|
|
127
|
-
(out, input) => {
|
|
193
|
+
(out, input, params) => {
|
|
194
|
+
params.label = 'catmull-rom';
|
|
195
|
+
params.skip = true;
|
|
196
|
+
|
|
128
197
|
const sample = new Uint8ClampedArray(4);
|
|
129
198
|
for (let y = 0; y < out.height; y++) {
|
|
130
199
|
|
|
@@ -135,9 +204,46 @@ function test_sampling(source, engine) {
|
|
|
135
204
|
out.set(x, y, sample);
|
|
136
205
|
}
|
|
137
206
|
}
|
|
207
|
+
},
|
|
208
|
+
(out, input, params) => {
|
|
209
|
+
params.label = 'mip';
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
sampler2d_downsample_mipmap(input, out);
|
|
213
|
+
|
|
214
|
+
},
|
|
215
|
+
(out, input, params) => {
|
|
216
|
+
const lobes = 2;
|
|
217
|
+
params.label = `lanczos_${lobes}`;
|
|
218
|
+
params.skip = true;
|
|
219
|
+
|
|
220
|
+
return;
|
|
221
|
+
|
|
222
|
+
sampler2D_scale_down_lanczos(input, out, lobes);
|
|
223
|
+
|
|
224
|
+
},
|
|
225
|
+
(out, input, params) => {
|
|
226
|
+
const lobes = 3;
|
|
227
|
+
params.label = `lanczos_${lobes}`;
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
sampler2D_scale_down_lanczos(input, out, lobes);
|
|
231
|
+
|
|
232
|
+
},
|
|
233
|
+
(out, input, params) => {
|
|
234
|
+
const lobes = 5;
|
|
235
|
+
params.skip = true;
|
|
236
|
+
params.label = `lanczos_${lobes}`;
|
|
237
|
+
|
|
238
|
+
return;
|
|
239
|
+
|
|
240
|
+
sampler2D_scale_down_lanczos(input, out, lobes);
|
|
241
|
+
|
|
138
242
|
}
|
|
139
243
|
], new Vector2(
|
|
140
|
-
|
|
244
|
+
// 100, 100
|
|
245
|
+
1024, 1024
|
|
246
|
+
// 136, 136
|
|
141
247
|
));
|
|
142
248
|
}
|
|
143
249
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Sampler2D } from "../Sampler2D.js";
|
|
2
|
+
import { sampler2D_scale_down_linear } from "../sampler2D_scale_down_linear.js";
|
|
3
|
+
import { inverseLerp } from "../../../../../core/math/inverseLerp.js";
|
|
4
|
+
import { lerp } from "../../../../../core/math/lerp.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Emulated how downsampling is done in OpenGL using autogenerated mipmaps with LINEAR_MIPMAP_LINEAR parameters
|
|
8
|
+
* @param {Sampler2D} source
|
|
9
|
+
* @param {Sampler2D} destination
|
|
10
|
+
*/
|
|
11
|
+
export function sampler2d_downsample_mipmap(source, destination) {
|
|
12
|
+
let current_mip = source;
|
|
13
|
+
let previous_mip = source;
|
|
14
|
+
|
|
15
|
+
const itemSize = current_mip.itemSize;
|
|
16
|
+
|
|
17
|
+
const dest_width = destination.width;
|
|
18
|
+
const dest_height = destination.height;
|
|
19
|
+
|
|
20
|
+
while (current_mip.width > dest_width && current_mip.width > 1) {
|
|
21
|
+
const new_w = Math.floor(current_mip.width * 0.5);
|
|
22
|
+
const new_h = Math.floor(current_mip.height * 0.5);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const out = new Sampler2D(new current_mip.data.constructor(new_w * new_h * itemSize), itemSize, new_w, new_h);
|
|
26
|
+
|
|
27
|
+
sampler2D_scale_down_linear(current_mip, out);
|
|
28
|
+
|
|
29
|
+
previous_mip = current_mip;
|
|
30
|
+
current_mip = out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const mip_mix = inverseLerp(previous_mip.width, current_mip.width, dest_width);
|
|
34
|
+
|
|
35
|
+
const m1_hp_x = 0.5 / previous_mip.width;
|
|
36
|
+
const m1_hp_y = 0.5 / previous_mip.height;
|
|
37
|
+
|
|
38
|
+
const m0_hp_x = 0.5 / current_mip.width;
|
|
39
|
+
const m0_hp_y = 0.5 / current_mip.height;
|
|
40
|
+
|
|
41
|
+
const m1_sx = (previous_mip.width + 1) / (previous_mip.width);
|
|
42
|
+
const m1_sy = (previous_mip.height + 1) / (previous_mip.height);
|
|
43
|
+
|
|
44
|
+
const m0_sx = (current_mip.width + 1) / (current_mip.width);
|
|
45
|
+
const m0_sy = (current_mip.height + 1) / (current_mip.height);
|
|
46
|
+
|
|
47
|
+
for (let y = 0; y < dest_height; y++) {
|
|
48
|
+
const v = y / (dest_height - 1);
|
|
49
|
+
|
|
50
|
+
for (let x = 0; x < dest_width; x++) {
|
|
51
|
+
|
|
52
|
+
const u = x / (dest_width - 1);
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < itemSize; i++) {
|
|
55
|
+
|
|
56
|
+
const c0 = previous_mip.sampleChannelBilinearUV(u * m1_sx - m1_hp_x, v * m1_sy - m1_hp_y, i);
|
|
57
|
+
const c1 = current_mip.sampleChannelBilinearUV(u * m0_sx - m0_hp_x, v * m0_sy - m0_hp_y, i);
|
|
58
|
+
|
|
59
|
+
const c_out = lerp(c0, c1, mip_mix);
|
|
60
|
+
|
|
61
|
+
destination.data[(y * dest_width + x) * itemSize + i] = c_out;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
@@ -77,12 +77,12 @@ export function sampler2D_scale_down_lanczos(source, destination, lobes = 3) {
|
|
|
77
77
|
|
|
78
78
|
for (v = 0; v < d_h; v++) {
|
|
79
79
|
|
|
80
|
-
const center_y = (v) * ratio_y;
|
|
80
|
+
const center_y = (v) * ratio_y - 0.5;
|
|
81
81
|
const source_y0 = max2(Math.ceil(center_y - range2_y), 0);
|
|
82
82
|
const source_y1 = min2(Math.floor(center_y + range2_y), source_height - 1);
|
|
83
83
|
|
|
84
84
|
for (u = 0; u < d_w; u++) {
|
|
85
|
-
const center_x = (u) * ratio_x;
|
|
85
|
+
const center_x = (u) * ratio_x - 0.5;
|
|
86
86
|
|
|
87
87
|
const source_x0 = max2(Math.ceil(center_x - range2_x), 0);
|
|
88
88
|
const source_x1 = min2(Math.floor(center_x + range2_x), source_width - 1);
|
package/engine/ui/GUIEngine.js
CHANGED
|
@@ -103,7 +103,14 @@ function GUIEngine() {
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
this.view = new EmptyView({
|
|
106
|
+
this.view = new EmptyView({
|
|
107
|
+
classList: ['gui-engine-root'],
|
|
108
|
+
css: {
|
|
109
|
+
position: "absolute",
|
|
110
|
+
left: "0",
|
|
111
|
+
top: "0"
|
|
112
|
+
}
|
|
113
|
+
});
|
|
107
114
|
|
|
108
115
|
/**
|
|
109
116
|
*
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.42.0",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ParserError from "../../../../core/parser/simple/ParserError.js";
|
|
2
|
-
import { skipWhitespace } from "../../../../core/parser/simple/SimpleParser.js";
|
|
3
2
|
import { readReferenceValueToken } from "./readReferenceValueToken.js";
|
|
4
3
|
import { TooltipReferenceValue } from "./TooltipReferenceValue.js";
|
|
5
4
|
import Token from "../../../../core/parser/simple/Token.js";
|
|
6
5
|
import { TooltipTokenType } from "./TooltipTokenType.js";
|
|
6
|
+
import { skipWhitespace } from "../../../../core/parser/simple/skipWhitespace.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Alex on 03/09/2014.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { sRGBEncoding, TextureLoader as ThreeTextureLoader } from "three";
|
|
6
|
-
|
|
7
|
-
import { Asset } from "./Asset.js";
|
|
8
|
-
import { computeFileExtension } from "../../core/FilePath.js";
|
|
9
|
-
import { DDSLoader } from "three/examples/jsm/loaders/DDSLoader.js";
|
|
10
|
-
import { ArrayBufferLoader } from "./loaders/ArrayBufferLoader.js";
|
|
11
|
-
import { JsonAssetLoader } from "./loaders/JsonAssetLoader.js";
|
|
12
|
-
import { GameAssetType } from "./GameAssetType.js";
|
|
13
|
-
import { TextAssetLoader } from "./loaders/TextAssetLoader.js";
|
|
14
|
-
import { AnimationGraphDefinitionAssetLoader } from "../graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.js";
|
|
15
|
-
import { JavascriptAssetLoader } from "./loaders/JavascriptAssetLoader.js";
|
|
16
|
-
import { ImageRGBADataLoader } from "./loaders/image/ImageRGBADataLoader.js";
|
|
17
|
-
import { GLTFAssetLoader } from "./loaders/GLTFAssetLoader.js";
|
|
18
|
-
import { SVGAssetLoader } from "./loaders/SVGAssetLoader.js";
|
|
19
|
-
import { AttachmentSocketsAssetLoader } from "../ecs/sockets/serialization/AttachmentSocketsAssetLoader.js";
|
|
20
|
-
import { FontAssetLoader } from "../../core/font/FontAssetLoader.js";
|
|
21
|
-
import { computeTextureByteSize } from "./loaders/texture/loadStandardImageTexture.js";
|
|
22
|
-
import { TextureAssetLoader } from "./loaders/texture/TextureAssetLoader.js";
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const textureLoader = new ThreeTextureLoader();
|
|
26
|
-
const ddsLoader = new DDSLoader();
|
|
27
|
-
|
|
28
|
-
export function deferredTextureLoader(path, success, failure, progress) {
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {Texture} texture
|
|
33
|
-
*/
|
|
34
|
-
function handleLoad(texture) {
|
|
35
|
-
const byteSize = computeTextureByteSize(texture);
|
|
36
|
-
|
|
37
|
-
asset.byteSize = byteSize;
|
|
38
|
-
|
|
39
|
-
pending.forEach(p => {
|
|
40
|
-
p.image = texture.image;
|
|
41
|
-
p.mipmaps = texture.mipmaps;
|
|
42
|
-
|
|
43
|
-
p.format = texture.format;
|
|
44
|
-
|
|
45
|
-
p.needsUpdate = true;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
isLoaded = true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function loadCompressed() {
|
|
52
|
-
const texture = ddsLoader.load(path, handleLoad, progress, failure);
|
|
53
|
-
|
|
54
|
-
if (texture.mipmaps === undefined) {
|
|
55
|
-
texture.mipmaps = [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return texture;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const pending = [];
|
|
62
|
-
|
|
63
|
-
let isLoaded = false;
|
|
64
|
-
|
|
65
|
-
//figure out what kind of a texture it is
|
|
66
|
-
const fileExtension = computeFileExtension(path);
|
|
67
|
-
if (fileExtension === null) {
|
|
68
|
-
throw new Error(`no file extension on path '${path}'`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const lowerCaseExtension = fileExtension.toLowerCase();
|
|
72
|
-
|
|
73
|
-
let texture;
|
|
74
|
-
|
|
75
|
-
switch (lowerCaseExtension) {
|
|
76
|
-
case "dds":
|
|
77
|
-
texture = loadCompressed();
|
|
78
|
-
break;
|
|
79
|
-
case "png":
|
|
80
|
-
case "jpg":
|
|
81
|
-
texture = textureLoader.load(path, handleLoad, progress, failure);
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
throw new Error(`Unsupported texture file format: '${lowerCaseExtension}'`);
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
texture.encoding = sRGBEncoding;
|
|
89
|
-
|
|
90
|
-
const asset = new Asset(function () {
|
|
91
|
-
|
|
92
|
-
const clone = texture.clone();
|
|
93
|
-
|
|
94
|
-
if (isLoaded) {
|
|
95
|
-
clone.needsUpdate = true;
|
|
96
|
-
} else {
|
|
97
|
-
pending.push(clone);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return clone;
|
|
101
|
-
}, 1);
|
|
102
|
-
|
|
103
|
-
success(asset);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
* @param {AssetManager} assetManager
|
|
110
|
-
*/
|
|
111
|
-
function initAssetManager(assetManager) {
|
|
112
|
-
|
|
113
|
-
assetManager.registerLoader(GameAssetType.ModelGLTF, new GLTFAssetLoader());
|
|
114
|
-
assetManager.registerLoader(GameAssetType.ModelGLTF_JSON, new GLTFAssetLoader());
|
|
115
|
-
assetManager.registerLoader(GameAssetType.ArrayBuffer, new ArrayBufferLoader());
|
|
116
|
-
assetManager.registerLoader(GameAssetType.Texture, new TextureAssetLoader());
|
|
117
|
-
assetManager.registerLoader(GameAssetType.DeferredTexture, deferredTextureLoader);
|
|
118
|
-
|
|
119
|
-
assetManager.registerLoader(GameAssetType.JSON, new JsonAssetLoader());
|
|
120
|
-
assetManager.registerLoader(GameAssetType.Text, new TextAssetLoader());
|
|
121
|
-
|
|
122
|
-
assetManager.registerLoader(GameAssetType.JavaScript, new JavascriptAssetLoader());
|
|
123
|
-
|
|
124
|
-
assetManager.registerLoader(GameAssetType.Font, new FontAssetLoader());
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
assetManager.registerLoader(GameAssetType.AnimationGraph, new AnimationGraphDefinitionAssetLoader());
|
|
128
|
-
assetManager.registerLoader(GameAssetType.AttachmentSockets, new AttachmentSocketsAssetLoader());
|
|
129
|
-
|
|
130
|
-
assetManager.registerLoader(GameAssetType.Image, new ImageRGBADataLoader());
|
|
131
|
-
|
|
132
|
-
assetManager.registerLoader(GameAssetType.ImageSvg, new SVGAssetLoader());
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export {
|
|
136
|
-
initAssetManager
|
|
137
|
-
};
|