@woosh/meep-engine 2.34.5 → 2.34.9
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/assert.js +4 -1
- package/core/binary/BitSet.js +3 -3
- package/engine/asset/AssetManager.d.ts +9 -7
- package/engine/asset/loaders/image/png/PNG.js +9 -2
- package/engine/asset/loaders/material/bitmap2sampler_gl.js +8 -2
- package/engine/asset/loaders/material/computeTextureEquality.js +3 -0
- package/engine/asset/loaders/material/computeTextureHash.js +8 -0
- package/engine/ecs/EntityComponentDataset.js +9 -4
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +3 -3
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +3 -2
- package/engine/graphics/render/visibility/VisibilityComputer.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/editor.js +1 -4
package/core/assert.js
CHANGED
|
@@ -268,7 +268,10 @@ assert.isFunction = function (value, name = 'value') {
|
|
|
268
268
|
*/
|
|
269
269
|
assert.isNonNegativeInteger = function (value, name = 'value') {
|
|
270
270
|
assert.isNumber(value, name);
|
|
271
|
-
|
|
271
|
+
|
|
272
|
+
if (value < 0) {
|
|
273
|
+
throw new Error(`${name} must be >= 0, instead was ${value}`);
|
|
274
|
+
}
|
|
272
275
|
|
|
273
276
|
if (!Number.isInteger(value)) {
|
|
274
277
|
throw new Error(`${name} must be an integer, instead was ${value}`);
|
package/core/binary/BitSet.js
CHANGED
|
@@ -472,11 +472,11 @@ BitSet.prototype.get = function (bitIndex) {
|
|
|
472
472
|
const byteOffset = bitIndex >> 5;
|
|
473
473
|
const bitOffset = bitIndex & 31;
|
|
474
474
|
|
|
475
|
-
const
|
|
475
|
+
const word = this.__data_uint32[byteOffset];
|
|
476
476
|
|
|
477
|
-
const
|
|
477
|
+
const masked_word = word & (1 << bitOffset);
|
|
478
478
|
|
|
479
|
-
return
|
|
479
|
+
return masked_word !== 0;
|
|
480
480
|
};
|
|
481
481
|
|
|
482
482
|
/**
|
|
@@ -6,17 +6,19 @@ import {AssetTransformer} from "./AssetTransformer";
|
|
|
6
6
|
export class AssetManager {
|
|
7
7
|
public readonly crossOriginConfig: CrossOriginConfig
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
promise<T>(path: string, type: string): Promise<Asset<T>>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
remove(path: string, type: string): boolean
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
clear(): void
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
registerLoader<T>(type: string, loader: AssetLoader<T>): Promise<void>
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
unregisterLoader(type: string): Promise<void>
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
getLoaderByType<T>(type: string): AssetLoader<T> | undefined
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
registerTransformer<T extends Asset<X>, X = any>(type: string, transformer: AssetTransformer<T>): void
|
|
22
|
+
|
|
23
|
+
unregisterTransformer<T extends Asset<X>, X = any>(type: string, transformer: AssetTransformer<T>): boolean
|
|
22
24
|
}
|
|
@@ -343,7 +343,9 @@ PNG.prototype.getUint8Data_case3 = function () {
|
|
|
343
343
|
for (let i = 0; i < pixel_count; i++) {
|
|
344
344
|
const destination_address = i * itemSize;
|
|
345
345
|
|
|
346
|
-
const
|
|
346
|
+
const lookup_index = pixels[i * d];
|
|
347
|
+
|
|
348
|
+
const lookup_value = lookup_index * 3;
|
|
347
349
|
|
|
348
350
|
result_data[destination_address] = palette[lookup_value];
|
|
349
351
|
result_data[destination_address + 1] = palette[lookup_value + 1];
|
|
@@ -381,7 +383,12 @@ PNG.prototype.getUint8Data = function () {
|
|
|
381
383
|
break;
|
|
382
384
|
case 3:
|
|
383
385
|
// palette
|
|
384
|
-
|
|
386
|
+
const c3 = this.getUint8Data_case3();
|
|
387
|
+
|
|
388
|
+
data = c3.data;
|
|
389
|
+
itemSize = c3.itemSize;
|
|
390
|
+
|
|
391
|
+
break;
|
|
385
392
|
case 4:
|
|
386
393
|
// grayscale with alpha
|
|
387
394
|
data = this.pixels;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
|
|
3
3
|
* @param {WebGL2RenderingContext} gl
|
|
4
4
|
* @param {Sampler2D} sampler
|
|
5
|
-
* @param {ImageBitmap} bitmap
|
|
5
|
+
* @param {ImageBitmap|ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmap
|
|
6
6
|
*/
|
|
7
7
|
export function bitmap2sampler_gl(gl, sampler, bitmap) {
|
|
8
8
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap);
|
|
@@ -15,5 +15,11 @@ export function bitmap2sampler_gl(gl, sampler, bitmap) {
|
|
|
15
15
|
throw new Error(`Expected sampler.itemSize to be 4, instead was '${sampler.itemSize}'`);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {Uint8ClampedArray}
|
|
21
|
+
*/
|
|
22
|
+
const target_data = sampler.data;
|
|
23
|
+
|
|
24
|
+
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, target_data);
|
|
19
25
|
}
|
|
@@ -2,6 +2,7 @@ import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
|
|
|
2
2
|
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
3
3
|
import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
|
|
4
4
|
import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
|
|
5
|
+
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -20,6 +21,11 @@ function vector2Hash(v) {
|
|
|
20
21
|
*/
|
|
21
22
|
const data_cache = new WeakMap();
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {ImageBitmap|HTMLImageElement|{data,width:number,height:number}} image
|
|
27
|
+
* @return {number}
|
|
28
|
+
*/
|
|
23
29
|
export function computeImageDataHash(image) {
|
|
24
30
|
const cached_value = data_cache.get(image);
|
|
25
31
|
|
|
@@ -31,6 +37,8 @@ export function computeImageDataHash(image) {
|
|
|
31
37
|
|
|
32
38
|
if (image instanceof ImageBitmap) {
|
|
33
39
|
result = computeImageBitmapHash(image);
|
|
40
|
+
} else if (image instanceof HTMLImageElement) {
|
|
41
|
+
result = computeStringHash(image.src);
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
let width = 0;
|
|
@@ -1057,7 +1057,7 @@ export class EntityComponentDataset {
|
|
|
1057
1057
|
if (!ENV_PRODUCTION) {
|
|
1058
1058
|
assert.isArray(classes, "classes");
|
|
1059
1059
|
// assert.notOk(classes.some((c, i) => classes.indexOf(c) !== i), 'classes contains duplicates');
|
|
1060
|
-
assert.
|
|
1060
|
+
assert.isFunction(visitor, "visitor");
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
1063
1063
|
let entityIndex, i;
|
|
@@ -1093,18 +1093,23 @@ export class EntityComponentDataset {
|
|
|
1093
1093
|
|
|
1094
1094
|
const entityOccupancy = this.entityOccupancy;
|
|
1095
1095
|
|
|
1096
|
+
const component_type_count = this.componentTypeCount;
|
|
1097
|
+
const component_occupancy = this.componentOccupancy;
|
|
1098
|
+
const components = this.components;
|
|
1099
|
+
|
|
1096
1100
|
entity_loop: for (entityIndex = entityOccupancy.nextSetBit(0); entityIndex !== -1; entityIndex = entityOccupancy.nextSetBit(entityIndex + 1)) {
|
|
1097
|
-
const componentOccupancyAddress = entityIndex *
|
|
1101
|
+
const componentOccupancyAddress = entityIndex * component_type_count;
|
|
1102
|
+
|
|
1098
1103
|
for (i = 0; i < numClasses; i++) {
|
|
1099
1104
|
const componentIndex = indices[i];
|
|
1100
1105
|
|
|
1101
|
-
const componentPresent =
|
|
1106
|
+
const componentPresent = component_occupancy.get(componentOccupancyAddress + componentIndex);
|
|
1102
1107
|
|
|
1103
1108
|
if (!componentPresent) {
|
|
1104
1109
|
continue entity_loop;
|
|
1105
1110
|
}
|
|
1106
1111
|
|
|
1107
|
-
args[i] =
|
|
1112
|
+
args[i] = components[componentIndex][entityIndex];
|
|
1108
1113
|
}
|
|
1109
1114
|
|
|
1110
1115
|
args[numClasses] = entityIndex;
|
|
@@ -125,15 +125,15 @@ class GLTFAssetTransformer extends AssetTransformer {
|
|
|
125
125
|
/**
|
|
126
126
|
*
|
|
127
127
|
* @param {Asset} source
|
|
128
|
-
* @param asset_description
|
|
128
|
+
* @param {AssetDescription} asset_description
|
|
129
129
|
* @return {Promise<Asset>}
|
|
130
130
|
*/
|
|
131
131
|
async transform(source, asset_description) {
|
|
132
132
|
const animationClips = source.animations;
|
|
133
133
|
|
|
134
134
|
if (animationClips !== undefined && animationClips.length > 0) {
|
|
135
|
-
//
|
|
136
|
-
|
|
135
|
+
// animations might cause trouble
|
|
136
|
+
console.warn(`model '${asset_description.path}' contains animations, these animations might not works as intended with micron.`);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -184,10 +184,11 @@ export class IncrementalDeltaSet {
|
|
|
184
184
|
*/
|
|
185
185
|
push(element) {
|
|
186
186
|
//check if element is already in the set
|
|
187
|
-
const
|
|
187
|
+
const elements = this.elements;
|
|
188
|
+
const i = elements.indexOf(element); //TODO this can probably be done faster. Maybe use a bloom filter? or some kind of a hash
|
|
188
189
|
|
|
189
190
|
if (i === -1) {
|
|
190
|
-
|
|
191
|
+
elements.push(element);
|
|
191
192
|
this.size++;
|
|
192
193
|
|
|
193
194
|
this.onAdded.send1(element);
|
|
@@ -95,7 +95,7 @@ export class VisibilityComputer {
|
|
|
95
95
|
* @param {Object3D} object3d
|
|
96
96
|
*/
|
|
97
97
|
__includeObject(object3d) {
|
|
98
|
-
assert.equal(object3d.isObject3D, true,
|
|
98
|
+
assert.equal(object3d.isObject3D, true, 'object3d.isObject3D !== true');
|
|
99
99
|
|
|
100
100
|
// mark object, this is a hack, needs to be fixed at some point
|
|
101
101
|
object3d[SOURCE_RENDER_LAYER_PROPERTY] = this.__activeLayer;
|
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.34.
|
|
8
|
+
"version": "2.34.9",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
|
@@ -20,6 +20,7 @@ import { copy_Sampler2D_channel_data } from "../../engine/graphics/texture/sampl
|
|
|
20
20
|
import { TextureAssetLoader } from "../../engine/asset/loaders/texture/TextureAssetLoader.js";
|
|
21
21
|
import { CanvasView } from "../../view/elements/CanvasView.js";
|
|
22
22
|
import convertSampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
23
|
+
import { drawSamplerHTML } from "../../engine/graphics/texture/sampler/util/drawSamplerHTML.js";
|
|
23
24
|
|
|
24
25
|
const engineHarness = new EngineHarness();
|
|
25
26
|
|
|
@@ -309,10 +310,6 @@ async function main(engine) {
|
|
|
309
310
|
|
|
310
311
|
await EngineHarness.buildTerrain({ engine });
|
|
311
312
|
|
|
312
|
-
const image = await engine.assetManager.promise("diffuseMap1.png", 'image');
|
|
313
|
-
|
|
314
|
-
console.log(image.create());
|
|
315
|
-
|
|
316
313
|
const vMain = new EmptyView({ classList: ['ui-texture-testing-tool-view'] });
|
|
317
314
|
|
|
318
315
|
vMain.css({
|