@woosh/meep-engine 2.33.76 → 2.34.3
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/Set.js +0 -61
- package/core/collection/array/arrayIndexByEquality.js +20 -0
- package/core/collection/array/arraySetDiff.js +42 -0
- package/core/collection/array/arraySetSortingDiff.js +67 -0
- package/core/collection/array/arraySetSortingDiff.spec.js +74 -0
- package/core/collection/array/array_filter_by_multiple.js +36 -0
- package/core/collection/array/weightedRandomFromArray.js +9 -5
- package/core/collection/list/FilteredListProjection.js +1 -1
- package/core/collection/list/List.js +2 -1
- package/core/geom/3d/topology/compareEdges.js +16 -0
- package/core/geom/3d/topology/compareFaces.js +9 -0
- package/core/geom/3d/topology/compareVertices.js +9 -0
- package/core/geom/3d/topology/computeTopoMeshVertexDuplicates.js +25 -6
- package/core/geom/3d/topology/expandConnectivityByLocality.js +35 -19
- package/core/geom/Vector2.js +7 -2
- package/core/geom/Vector3.js +2 -2
- package/core/geom/v3_angle_between.js +3 -1
- package/editor/Editor.js +2 -2
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +1 -1
- package/engine/EngineHarness.js +0 -1
- package/engine/asset/loaders/image/ImageDecoderWorker.js +3 -2
- package/engine/asset/loaders/image/ImageRGBADataAsset.js +2 -6
- package/engine/asset/loaders/image/ImageRGBADataLoader.js +18 -2
- package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
- package/engine/asset/loaders/image/png/PNG.js +3 -2
- package/engine/asset/loaders/image/png/PNGReader.js +1 -0
- package/engine/ecs/EntityComponentDataset.js +1 -1
- package/engine/ecs/storage/BinaryBufferSerializer.js +2 -2
- package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +9 -0
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +72 -26
- package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +1 -2
- package/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts +3 -2
- package/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts +3 -1
- package/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts +8 -0
- package/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.js +180 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +74 -16
- package/engine/graphics/ecs/mesh-v2/ShadedGeometryFlags.js +7 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +9 -0
- package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +4 -2
- package/engine/graphics/geometry/VertexDataSpec.js +20 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +41 -1
- package/engine/graphics/micron/format/MicronGeometry.d.ts +6 -0
- package/engine/graphics/micron/format/MicronGeometry.js +156 -4
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +10 -1
- package/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +7 -2
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +3 -2
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +7 -3
- package/engine/graphics/texture/sampler/Sampler2D.js +2 -0
- package/engine/graphics/texture/sampler/downsampleSampler2D.js +3 -1
- package/engine/graphics/texture/sampler/genericResampleSampler2D.js +67 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +29 -35
- package/engine/graphics/texture/sampler/upsampleSampler2D.js +47 -0
- package/generation/filtering/numeric/CellFilterReadGridLayer.js +2 -2
- package/generation/filtering/numeric/math/CellFilterSaturate.js +24 -0
- package/package.json +1 -1
- package/samples/terrain/editor.js +346 -0
- package/samples/terrain/from_image.js +289 -0
- package/samples/terrain/from_image_2.js +219 -0
- package/view/controller/controls/NativeListController.js +6 -3
- package/view/elements/radial/RadialMenu.js +1 -1
- package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +0 -32
- package/generation/theme/TerrainThemeApplicator.js +0 -6
|
@@ -19,10 +19,11 @@ async function decode_png(png_bytes) {
|
|
|
19
19
|
// console.profileEnd('decode');
|
|
20
20
|
|
|
21
21
|
resolve({
|
|
22
|
-
data: uint_channels.data,
|
|
22
|
+
data: uint_channels.data.buffer,
|
|
23
23
|
width,
|
|
24
24
|
height,
|
|
25
|
-
itemSize: uint_channels.itemSize
|
|
25
|
+
itemSize: uint_channels.itemSize,
|
|
26
|
+
bitDepth: uint_channels.bitDepth
|
|
26
27
|
});
|
|
27
28
|
});
|
|
28
29
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Asset } from "../../Asset.js";
|
|
2
|
+
import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
|
|
2
3
|
|
|
3
4
|
export class ImageRGBADataAsset extends Asset {
|
|
4
5
|
/**
|
|
@@ -39,11 +40,6 @@ export class ImageRGBADataAsset extends Asset {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
create() {
|
|
42
|
-
return
|
|
43
|
-
data: this.data,
|
|
44
|
-
width: this.width,
|
|
45
|
-
height: this.height,
|
|
46
|
-
itemSize: this.itemSize
|
|
47
|
-
};
|
|
43
|
+
return new Sampler2D(this.data, this.itemSize, this.width, this.height);
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -23,7 +23,7 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
23
23
|
/**
|
|
24
24
|
*
|
|
25
25
|
* @param {string} path
|
|
26
|
-
* @returns {Promise<{data:ArrayBuffer, width: number, height:number, itemSize: number}>}
|
|
26
|
+
* @returns {Promise<{data:ArrayBuffer, width: number, height:number, itemSize: number, bitDepth:number}>}
|
|
27
27
|
* @private
|
|
28
28
|
*/
|
|
29
29
|
async __decode_via_worker(path) {
|
|
@@ -45,7 +45,23 @@ export class ImageRGBADataLoader extends AssetLoader {
|
|
|
45
45
|
|
|
46
46
|
const bitmap = await this.__decode_via_worker(path);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
let data;
|
|
50
|
+
|
|
51
|
+
switch (bitmap.bitDepth) {
|
|
52
|
+
case 8:
|
|
53
|
+
|
|
54
|
+
data = new Uint8Array(bitmap.data);
|
|
55
|
+
break
|
|
56
|
+
case 16:
|
|
57
|
+
data = new Uint16Array(bitmap.data);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unsupported bit depth '${bitmap.bitDepth}'`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
return new ImageRGBADataAsset(data, bitmap.width, bitmap.height, bitmap.itemSize);
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
load(path, success, failure, progress) {
|
|
@@ -364,7 +364,7 @@ PNG.prototype.getUint8Data_case3 = function () {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
/**
|
|
367
|
-
* @returns {{itemSize:number, data:Uint8Array}}
|
|
367
|
+
* @returns {{itemSize:number, data:Uint8Array, bitDepth: number}}
|
|
368
368
|
*/
|
|
369
369
|
PNG.prototype.getUint8Data = function () {
|
|
370
370
|
let data;
|
|
@@ -397,6 +397,7 @@ PNG.prototype.getUint8Data = function () {
|
|
|
397
397
|
|
|
398
398
|
return {
|
|
399
399
|
data,
|
|
400
|
-
itemSize
|
|
400
|
+
itemSize,
|
|
401
|
+
bitDepth: this.bitDepth
|
|
401
402
|
};
|
|
402
403
|
};
|
|
@@ -61,6 +61,7 @@ PNGReader.prototype.decodeHeader = function () {
|
|
|
61
61
|
|
|
62
62
|
buffer.readBytes(header, 0, 8)
|
|
63
63
|
|
|
64
|
+
// see https://www.w3.org/TR/PNG-Structure.html
|
|
64
65
|
if (!isArrayEqualStrict(header, [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
65
66
|
throw new Error('invalid PNGReader file (bad signature)');
|
|
66
67
|
}
|
|
@@ -5,8 +5,8 @@ import Signal, {
|
|
|
5
5
|
findSignalHandlerIndexByHandleAndContext
|
|
6
6
|
} from "../../core/events/signal/Signal.js";
|
|
7
7
|
import { EventType } from "./EntityManager.js";
|
|
8
|
-
import { arraySetDiff } from "../../core/collection/Set.js";
|
|
9
8
|
import { SignalHandler } from "../../core/events/signal/SignalHandler.js";
|
|
9
|
+
import { arraySetDiff } from "../../core/collection/array/arraySetDiff.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
@@ -48,7 +48,7 @@ function isEntityTransient(entity, dataset, smComponentIndex, componentInstance)
|
|
|
48
48
|
return isTransient;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
class
|
|
51
|
+
class BinaryBufferSerializer {
|
|
52
52
|
constructor() {
|
|
53
53
|
/**
|
|
54
54
|
*
|
|
@@ -171,4 +171,4 @@ class BinaryBufferSerialization {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
export default
|
|
174
|
+
export default BinaryBufferSerializer;
|
|
@@ -267,6 +267,15 @@ export class TerrainLayers {
|
|
|
267
267
|
return index;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
/**
|
|
271
|
+
*
|
|
272
|
+
* @param {TerrainLayer} layer
|
|
273
|
+
* @return {boolean}
|
|
274
|
+
*/
|
|
275
|
+
removeLayer(layer) {
|
|
276
|
+
return this.layers.removeOneOf(layer);
|
|
277
|
+
}
|
|
278
|
+
|
|
270
279
|
/**
|
|
271
280
|
*
|
|
272
281
|
* @param {TerrainLayer} layer
|
|
@@ -46,32 +46,7 @@ export function loadLegacyTerrainSplats(description, mapping, am) {
|
|
|
46
46
|
|
|
47
47
|
mapping.resize(width, height, 4);
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
const weightData = mapping.weightData;
|
|
51
|
-
|
|
52
|
-
const dataOffset = index * width * height;
|
|
53
|
-
|
|
54
|
-
const sourceWidth = source.width;
|
|
55
|
-
const sourceHeight = source.height;
|
|
56
|
-
|
|
57
|
-
const source_max_y = sourceHeight - 1;
|
|
58
|
-
const source_max_x = sourceWidth - 1;
|
|
59
|
-
|
|
60
|
-
for (let y = 0; y < height; y++) {
|
|
61
|
-
const v = y / height;
|
|
62
|
-
|
|
63
|
-
for (let x = 0; x < width; x++) {
|
|
64
|
-
|
|
65
|
-
const u = x / width;
|
|
66
|
-
|
|
67
|
-
const targetIndex = y * width + x;
|
|
68
|
-
const targetAddress = dataOffset + targetIndex;
|
|
69
|
-
|
|
70
|
-
const value = source.sampleChannelBilinear(u * source_max_x, v * source_max_y, 0);
|
|
71
|
-
|
|
72
|
-
weightData[targetAddress] = value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
49
|
+
mapping.writeLayerFromSampler(source, index, 0);
|
|
75
50
|
|
|
76
51
|
});
|
|
77
52
|
}
|
|
@@ -146,6 +121,77 @@ export class SplatMapping {
|
|
|
146
121
|
this.materialTexture = new DataTexture(new Uint8Array(width * height * 4), width, height);
|
|
147
122
|
}
|
|
148
123
|
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @param {Sampler2D} source
|
|
127
|
+
* @param {number} index
|
|
128
|
+
* @param {number} channel
|
|
129
|
+
*/
|
|
130
|
+
writeLayerFromSampler(source, index, channel = 0) {
|
|
131
|
+
const weightData = this.weightData;
|
|
132
|
+
|
|
133
|
+
const width = this.size.x;
|
|
134
|
+
const height = this.size.y;
|
|
135
|
+
|
|
136
|
+
const dataOffset = index * width * height;
|
|
137
|
+
|
|
138
|
+
const sourceWidth = source.width;
|
|
139
|
+
const sourceHeight = source.height;
|
|
140
|
+
|
|
141
|
+
const source_max_y = sourceHeight - 1;
|
|
142
|
+
const source_max_x = sourceWidth - 1;
|
|
143
|
+
|
|
144
|
+
for (let y = 0; y < height; y++) {
|
|
145
|
+
const v = y / height;
|
|
146
|
+
|
|
147
|
+
for (let x = 0; x < width; x++) {
|
|
148
|
+
|
|
149
|
+
const u = x / width;
|
|
150
|
+
|
|
151
|
+
const targetIndex = y * width + x;
|
|
152
|
+
const targetAddress = dataOffset + targetIndex;
|
|
153
|
+
|
|
154
|
+
const value = source.sampleChannelBilinear(u * source_max_x, v * source_max_y, channel);
|
|
155
|
+
|
|
156
|
+
weightData[targetAddress] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @param {Sampler2D} destination
|
|
165
|
+
* @param {number} index
|
|
166
|
+
* @param {number} channel
|
|
167
|
+
*/
|
|
168
|
+
readLayerToSampler(destination, index, channel = 0) {
|
|
169
|
+
const weightData = this.weightData;
|
|
170
|
+
|
|
171
|
+
const width = this.size.x;
|
|
172
|
+
const height = this.size.y;
|
|
173
|
+
|
|
174
|
+
assert.equal(destination.width, width, 'destination dimensions mismatch');
|
|
175
|
+
assert.equal(destination.height, height, 'destination dimensions mismatch');
|
|
176
|
+
|
|
177
|
+
const dataOffset = index * width * height;
|
|
178
|
+
|
|
179
|
+
for (let y = 0; y < height; y++) {
|
|
180
|
+
|
|
181
|
+
for (let x = 0; x < width; x++) {
|
|
182
|
+
|
|
183
|
+
const targetIndex = y * width + x;
|
|
184
|
+
const targetAddress = dataOffset + targetIndex;
|
|
185
|
+
|
|
186
|
+
const value = weightData[targetAddress];
|
|
187
|
+
|
|
188
|
+
destination.writeChannel(x, y, channel, value);
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
149
195
|
/**
|
|
150
196
|
*
|
|
151
197
|
* @param {Uint8Array} source
|
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
import Vector3 from '../../../../../core/geom/Vector3.js';
|
|
7
7
|
import { assert } from "../../../../../core/assert.js";
|
|
8
8
|
import { lerp } from "../../../../../core/math/lerp.js";
|
|
9
|
-
import {
|
|
9
|
+
import { Matrix4 } from "three";
|
|
10
10
|
import { normalize_angle_rad } from "../../../../../core/geom/normalize_angle_rad.js";
|
|
11
11
|
import { eulerAnglesFromMatrix } from "../../../../../core/geom/3d/eulerAnglesFromMatrix.js";
|
|
12
12
|
|
|
13
13
|
const m4 = new Matrix4();
|
|
14
|
-
const euler = new Euler();
|
|
15
14
|
const angles = [];
|
|
16
15
|
|
|
17
16
|
const panOffset = new Vector3();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {System} from "../../../../ecs/System";
|
|
2
|
-
import {GraphicsEngine} from "../../../GraphicsEngine";
|
|
3
2
|
import Engine from "../../../../Engine";
|
|
3
|
+
import Highlight from "../Highlight";
|
|
4
|
+
import Mesh from "../../mesh/Mesh";
|
|
4
5
|
|
|
5
|
-
export default class MeshHighlightSystem extends System {
|
|
6
|
+
export default class MeshHighlightSystem extends System<Highlight, Mesh> {
|
|
6
7
|
constructor(engine: Engine)
|
|
7
8
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {System} from "../../../../ecs/System";
|
|
2
2
|
import Engine from "../../../../Engine";
|
|
3
|
+
import Highlight from "../Highlight";
|
|
4
|
+
import Renderable from "../../../../ecs/components/Renderable";
|
|
3
5
|
|
|
4
|
-
export class RenderableHighlightSystem extends System {
|
|
6
|
+
export class RenderableHighlightSystem extends System<Highlight, Renderable> {
|
|
5
7
|
constructor(engine: Engine)
|
|
6
8
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {System} from "../../../../ecs/System";
|
|
2
|
+
import {ShadedGeometry} from "../../mesh-v2/ShadedGeometry";
|
|
3
|
+
import Highlight from "../Highlight";
|
|
4
|
+
import Engine from "../../../../Engine";
|
|
5
|
+
|
|
6
|
+
export class ShadedGeometryHighlightSystem extends System<Highlight, ShadedGeometry> {
|
|
7
|
+
constructor(engine: Engine)
|
|
8
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { System } from "../../../../ecs/System.js";
|
|
2
|
+
import { HighlightRenderElementSource } from "../plugin/HighlightRenderElementSource.js";
|
|
3
|
+
import Highlight from "../Highlight.js";
|
|
4
|
+
import { OutlineRenderPlugin } from "../plugin/OutlineRenderPlugin.js";
|
|
5
|
+
import { ShadedGeometry } from "../../mesh-v2/ShadedGeometry.js";
|
|
6
|
+
|
|
7
|
+
class Supplier extends HighlightRenderElementSource {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {ShadedGeometryHighlightSystem} system
|
|
11
|
+
*/
|
|
12
|
+
constructor(system) {
|
|
13
|
+
super();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {ShadedGeometryHighlightSystem}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
this.__system = system;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @type {ObjectPoolFactory<HighlightRenderElement>}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
this.__pool = null;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {HighlightRenderGroup}
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
this.__group = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
collect(pool, group) {
|
|
37
|
+
|
|
38
|
+
this.__pool = pool;
|
|
39
|
+
this.__group = group;
|
|
40
|
+
|
|
41
|
+
const system = this.__system;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {EntityManager}
|
|
46
|
+
*/
|
|
47
|
+
const em = system.entityManager;
|
|
48
|
+
|
|
49
|
+
const dataset = em.dataset;
|
|
50
|
+
|
|
51
|
+
if (dataset === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dataset.traverseEntities([Highlight, ShadedGeometry], this.__visit, this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {Highlight} highlight
|
|
61
|
+
* @param {ShadedGeometry} sg
|
|
62
|
+
* @param {number} entity
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
__visit(highlight, sg, entity) {
|
|
66
|
+
|
|
67
|
+
// TODO cull by visibility
|
|
68
|
+
|
|
69
|
+
// if (!sg.getFlag(ShadedGeometryFlags.InView)) {
|
|
70
|
+
// return;
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
const elements = highlight.elements;
|
|
74
|
+
|
|
75
|
+
if (elements.isEmpty()) {
|
|
76
|
+
// no elements
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const object = sg.__cached_object;
|
|
81
|
+
|
|
82
|
+
if (object === null) {
|
|
83
|
+
// no renderable primitive
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const renderElement = this.__pool.create();
|
|
88
|
+
|
|
89
|
+
renderElement.definitions = elements.asArray();
|
|
90
|
+
renderElement.object = object;
|
|
91
|
+
|
|
92
|
+
this.__group.elements.add(renderElement);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export class ShadedGeometryHighlightSystem extends System {
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param {Engine} engine
|
|
100
|
+
* @constructor
|
|
101
|
+
*/
|
|
102
|
+
constructor(engine) {
|
|
103
|
+
super();
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @type {Engine}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
this.__engine = engine;
|
|
111
|
+
|
|
112
|
+
this.dependencies = [Highlight, ShadedGeometry];
|
|
113
|
+
|
|
114
|
+
this.__element_source = new Supplier(this);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @type {Reference<OutlineRenderPlugin>}
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
this.__plugin_renderer_ref = null;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* @param {EntityManager} entityManager
|
|
128
|
+
* @param {function} readyCallback
|
|
129
|
+
* @param {function} errorCallback
|
|
130
|
+
*/
|
|
131
|
+
shutdown(entityManager, readyCallback, errorCallback) {
|
|
132
|
+
try {
|
|
133
|
+
|
|
134
|
+
if (this.__plugin_renderer_ref !== null) {
|
|
135
|
+
|
|
136
|
+
this.__plugin_renderer_ref.getValue().removeSource(this.__element_source);
|
|
137
|
+
|
|
138
|
+
this.__plugin_renderer_ref.release();
|
|
139
|
+
|
|
140
|
+
this.__plugin_renderer_ref = null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
readyCallback();
|
|
144
|
+
} catch (e) {
|
|
145
|
+
errorCallback();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @param {EntityManager} entityManager
|
|
152
|
+
* @param {function} readyCallback
|
|
153
|
+
* @param {function} errorCallback
|
|
154
|
+
*/
|
|
155
|
+
startup(entityManager, readyCallback, errorCallback) {
|
|
156
|
+
/**
|
|
157
|
+
*
|
|
158
|
+
* @type {EntityManager}
|
|
159
|
+
*/
|
|
160
|
+
this.entityManager = entityManager;
|
|
161
|
+
|
|
162
|
+
const engine = this.__engine;
|
|
163
|
+
|
|
164
|
+
engine.plugins.acquire(OutlineRenderPlugin)
|
|
165
|
+
.then(ref => {
|
|
166
|
+
|
|
167
|
+
this.__plugin_renderer_ref = ref;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* @type {OutlineRenderPlugin}
|
|
172
|
+
*/
|
|
173
|
+
const plugin = ref.getValue();
|
|
174
|
+
|
|
175
|
+
plugin.addSource(this.__element_source);
|
|
176
|
+
|
|
177
|
+
}, errorCallback)
|
|
178
|
+
.then(readyCallback);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -53,6 +53,60 @@ export class ShadedGeometry {
|
|
|
53
53
|
* @private
|
|
54
54
|
*/
|
|
55
55
|
this.__transform = null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @type {number}
|
|
60
|
+
*/
|
|
61
|
+
this.flags = 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {number|ShadedGeometryFlags} flag
|
|
67
|
+
* @returns {void}
|
|
68
|
+
*/
|
|
69
|
+
setFlag(flag) {
|
|
70
|
+
this.flags |= flag;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {number|ShadedGeometryFlags} flag
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
clearFlag(flag) {
|
|
79
|
+
this.flags &= ~flag;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @param {number|ShadedGeometryFlags} flag
|
|
85
|
+
* @param {boolean} value
|
|
86
|
+
*/
|
|
87
|
+
writeFlag(flag, value) {
|
|
88
|
+
if (value) {
|
|
89
|
+
this.setFlag(flag);
|
|
90
|
+
} else {
|
|
91
|
+
this.clearFlag(flag);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {number|ShadedGeometryFlags} flag
|
|
98
|
+
* @returns {boolean}
|
|
99
|
+
*/
|
|
100
|
+
getFlag(flag) {
|
|
101
|
+
return (this.flags & flag) === flag;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Current cached entity that this component is attached to
|
|
106
|
+
* @return {number}
|
|
107
|
+
*/
|
|
108
|
+
get entity() {
|
|
109
|
+
return this.__entity;
|
|
56
110
|
}
|
|
57
111
|
|
|
58
112
|
/**
|
|
@@ -91,7 +145,7 @@ export class ShadedGeometry {
|
|
|
91
145
|
*
|
|
92
146
|
* @param {THREE.BufferGeometry} geometry
|
|
93
147
|
* @param {THREE.Material} material
|
|
94
|
-
* @param draw_mode
|
|
148
|
+
* @param {DrawMode} [draw_mode]
|
|
95
149
|
*/
|
|
96
150
|
from(geometry, material, draw_mode = DrawMode.Triangles) {
|
|
97
151
|
this.geometry = geometry;
|
|
@@ -113,38 +167,42 @@ export class ShadedGeometry {
|
|
|
113
167
|
|
|
114
168
|
/**
|
|
115
169
|
*
|
|
116
|
-
* @param geometry
|
|
117
|
-
* @param material
|
|
118
|
-
* @param
|
|
170
|
+
* @param {THREE.BufferGeometry} geometry
|
|
171
|
+
* @param {THREE.Material} material
|
|
172
|
+
* @param {DrawMode} [draw_mode]
|
|
119
173
|
* @return {ShadedGeometry}
|
|
120
174
|
*/
|
|
121
|
-
static from(geometry, material,
|
|
175
|
+
static from(geometry, material, draw_mode) {
|
|
122
176
|
const r = new ShadedGeometry();
|
|
123
177
|
|
|
124
|
-
r.from(geometry, material,
|
|
178
|
+
r.from(geometry, material, draw_mode);
|
|
125
179
|
|
|
126
180
|
return r;
|
|
127
181
|
}
|
|
128
182
|
|
|
129
183
|
updateTransform() {
|
|
184
|
+
const object_3d = this.__cached_object;
|
|
185
|
+
|
|
130
186
|
// update matrix
|
|
131
|
-
|
|
132
|
-
|
|
187
|
+
object_3d.updateMatrix();
|
|
188
|
+
object_3d.updateMatrixWorld();
|
|
133
189
|
|
|
134
190
|
// update bounds
|
|
135
|
-
|
|
136
191
|
const gbb = this.geometry.boundingBox;
|
|
137
192
|
|
|
193
|
+
const min = gbb.min;
|
|
194
|
+
const max = gbb.max;
|
|
195
|
+
|
|
138
196
|
_aabb3.setBounds(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
197
|
+
min.x,
|
|
198
|
+
min.y,
|
|
199
|
+
min.z,
|
|
200
|
+
max.x,
|
|
201
|
+
max.y,
|
|
202
|
+
max.z
|
|
145
203
|
);
|
|
146
204
|
|
|
147
|
-
updateNodeByMatrix4AndBBB(this.__bvh_leaf, _aabb3,
|
|
205
|
+
updateNodeByMatrix4AndBBB(this.__bvh_leaf, _aabb3, object_3d.matrix.elements);
|
|
148
206
|
}
|
|
149
207
|
|
|
150
208
|
/**
|
|
@@ -8,7 +8,16 @@ import { v3_distance_sqr } from "../../../../core/geom/v3_distance_sqr.js";
|
|
|
8
8
|
import { mat4 } from "gl-matrix";
|
|
9
9
|
import { returnTrue } from "../../../../core/function/Functions.js";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @type {BinaryNode|LeafNode[]}
|
|
14
|
+
*/
|
|
11
15
|
const traversal_stack = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
12
21
|
let traversal_cursor = 0;
|
|
13
22
|
|
|
14
23
|
/**
|
|
@@ -13,12 +13,14 @@ const eh = new EngineHarness();
|
|
|
13
13
|
*/
|
|
14
14
|
async function main(engine) {
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const em = engine.entityManager;
|
|
17
|
+
|
|
18
|
+
await em.addSystem(new ShadedGeometrySystem(engine));
|
|
17
19
|
|
|
18
20
|
EngineHarness.buildBasics({ engine })
|
|
19
21
|
|
|
20
22
|
|
|
21
|
-
const ecd =
|
|
23
|
+
const ecd = em.dataset;
|
|
22
24
|
|
|
23
25
|
new EntityBuilder()
|
|
24
26
|
.add(new Transform())
|
|
@@ -41,6 +41,26 @@ export class VertexDataSpec {
|
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @returns {number} -1 if not found
|
|
46
|
+
* @param {string} name
|
|
47
|
+
*/
|
|
48
|
+
getAttributeIndexByName(name) {
|
|
49
|
+
|
|
50
|
+
const attributes = this.attributes;
|
|
51
|
+
const n = attributes.length;
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < n; i++) {
|
|
54
|
+
const attribute = attributes[i];
|
|
55
|
+
|
|
56
|
+
if (attribute.name === name) {
|
|
57
|
+
return i;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
/**
|
|
45
65
|
*
|
|
46
66
|
* @param {AttributeSpec} attribute
|