@woosh/meep-engine 2.62.0 → 2.64.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 +1061 -1058
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +1061 -1058
- package/package.json +1 -1
- package/src/core/binary/EncodingBinaryBuffer.js +7 -43
- package/src/core/binary/EncodingBinaryBuffer.spec.js +16 -0
- package/src/core/binary/UINT16_MAX.js +5 -0
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +4 -2
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +5 -5
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +8 -10
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +7 -7
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsSphere.js +37 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +12 -4
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.spec.js +29 -0
- package/src/core/cache/LoadingCache.js +4 -1
- package/src/core/collection/list/List.js +9 -3
- package/src/core/collection/map/BiMap.js +49 -0
- package/src/core/geom/3d/aabb/aabb3_from_v3_array.js +11 -4
- package/src/core/geom/Vector2.js +6 -4
- package/src/engine/ecs/components/Tag.d.ts +2 -0
- package/src/engine/ecs/components/Tag.js +19 -28
- package/src/engine/ecs/components/Tag.spec.js +47 -0
- package/src/engine/ecs/fow/FogOfWar.js +4 -0
- package/src/engine/ecs/fow/FogOfWarEditor.js +3 -0
- package/src/engine/ecs/terrain/TerrainPreview.js +45 -44
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +22 -4
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +17 -12
- package/src/engine/graphics/ecs/mesh/Mesh.d.ts +0 -4
- package/src/engine/graphics/ecs/mesh/Mesh.js +0 -11
- package/src/engine/graphics/ecs/mesh/MeshSystem.js +57 -67
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +49 -86
- package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +41 -72
- package/src/engine/graphics/particles/particular/engine/emitter/write_particle_patch_uv.js +28 -0
- package/src/engine/grid/ORTHOGONAL_NEIGHBOURHOOD_MASK.js +11 -0
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +17 -17
- package/src/core/binary/stringToByteArray.js +0 -24
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +0 -81
- package/src/engine/ecs/foliage/Foliage.js +0 -151
- package/src/engine/ecs/foliage/FoliageLoader.js +0 -39
- package/src/engine/ecs/foliage/FoliageVisibilitySetBuilder.js +0 -27
- package/src/engine/ecs/foliage/ImpostorFoliage.js +0 -106
- package/src/engine/ecs/foliage/InstancedFoliage.js +0 -395
- package/src/engine/ecs/foliage/ViewState.js +0 -181
- package/src/engine/ecs/foliage/ecs/Foliage2System.js +0 -333
- package/src/engine/ecs/foliage/ecs/InstancedMeshComponent.js +0 -70
- package/src/engine/ecs/foliage/ecs/InstancedMeshLayer.js +0 -138
- package/src/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +0 -28
- package/src/engine/ecs/foliage/ecs/convertInstancedMeshComponents2Entities.js +0 -64
- package/src/engine/ecs/foliage/ecs/optimizeIndividualMeshesEntitiesToInstances.js +0 -233
- package/src/engine/save/storage/GooglePlayStorage.js +0 -47
- package/src/engine/save/storage/JsonStringCodec.js +0 -24
- package/src/engine/save/storage/LocalStorage.js +0 -148
- package/src/engine/save/storage/MsgPackCodec.js +0 -22
- /package/src/engine/sound/ecs/emitter/{SoundEmitter.spec.js → SoundEmitterSerializationAdapter.spec.js} +0 -0
|
@@ -1,66 +1,67 @@
|
|
|
1
1
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export class TerrainPreview {
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @type {String}
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
url = "";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @type {Vector2}
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
offset = new Vector2(0, 0);
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
* @type {Vector2}
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
scale = new Vector2(1, 1);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {TerrainPreview} other
|
|
24
|
+
*/
|
|
25
|
+
copy(other) {
|
|
26
|
+
this.url = other.url;
|
|
27
|
+
this.scale.copy(other.scale);
|
|
28
|
+
this.offset.copy(other.offset);
|
|
29
|
+
}
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.offset.copy(other.offset);
|
|
30
|
-
};
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
url: this.url,
|
|
34
|
+
offset: this.offset.toJSON(),
|
|
35
|
+
scale: this.scale.toJSON()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
+
fromJSON(obj) {
|
|
40
|
+
this.url = obj.url;
|
|
41
|
+
this.offset.fromJSON(obj.offset);
|
|
42
|
+
this.scale.fromJSON(obj.scale);
|
|
43
|
+
}
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {BinaryBuffer} buffer
|
|
48
|
+
*/
|
|
49
|
+
toBinaryBuffer(buffer) {
|
|
50
|
+
buffer.writeUTF8String(this.url);
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*/
|
|
50
|
-
TerrainPreview.prototype.toBinaryBuffer = function (buffer) {
|
|
51
|
-
buffer.writeUTF8String(this.url);
|
|
52
|
+
this.offset.toBinaryBuffer(buffer);
|
|
53
|
+
this.scale.toBinaryBuffer(buffer);
|
|
54
|
+
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param {BinaryBuffer} buffer
|
|
59
|
+
*/
|
|
60
|
+
fromBinaryBuffer(buffer) {
|
|
61
|
+
this.url = buffer.readUTF8String();
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
TerrainPreview.prototype.fromBinaryBuffer = function (buffer) {
|
|
62
|
-
this.url = buffer.readUTF8String();
|
|
63
|
+
this.offset.fromBinaryBuffer(buffer);
|
|
64
|
+
this.scale.fromBinaryBuffer(buffer);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
63
67
|
|
|
64
|
-
this.offset.fromBinaryBuffer(buffer);
|
|
65
|
-
this.scale.fromBinaryBuffer(buffer);
|
|
66
|
-
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by Alex on 13/05/2016.
|
|
3
3
|
*/
|
|
4
|
-
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
5
4
|
import Quaternion from "../../../../../core/geom/Quaternion.js";
|
|
5
|
+
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
6
6
|
|
|
7
7
|
class ClingToTerrain {
|
|
8
8
|
/**
|
|
@@ -13,12 +13,12 @@ class ClingToTerrain {
|
|
|
13
13
|
* Used internally for caching updates
|
|
14
14
|
* @type {Vector3}
|
|
15
15
|
*/
|
|
16
|
-
__lastPosition=new Vector3(0, 0, 0);
|
|
16
|
+
__lastPosition = new Vector3(0, 0, 0);
|
|
17
17
|
/**
|
|
18
18
|
*
|
|
19
19
|
* @type {Quaternion}
|
|
20
20
|
*/
|
|
21
|
-
__lastRotation=new Quaternion(0, 0, 0, 1);
|
|
21
|
+
__lastRotation = new Quaternion(0, 0, 0, 1);
|
|
22
22
|
/**
|
|
23
23
|
* Speed in Rad/s (Radians/second) by which rotation can change
|
|
24
24
|
* @type {number}
|
|
@@ -26,11 +26,29 @@ class ClingToTerrain {
|
|
|
26
26
|
rotationSpeed = 3;
|
|
27
27
|
|
|
28
28
|
constructor(opt) {
|
|
29
|
-
if(opt !== undefined){
|
|
29
|
+
if (opt !== undefined) {
|
|
30
30
|
throw new Error("constructor options deprecated");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {ClingToTerrain} other
|
|
37
|
+
* @returns {boolean}
|
|
38
|
+
*/
|
|
39
|
+
equals(other) {
|
|
40
|
+
return this.normalAlign === other.normalAlign
|
|
41
|
+
&& this.rotationSpeed === other.rotationSpeed;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @returns {number}
|
|
47
|
+
*/
|
|
48
|
+
hash() {
|
|
49
|
+
return this.normalAlign ? 1 : 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
34
52
|
toJSON() {
|
|
35
53
|
return {
|
|
36
54
|
normalAlign: this.normalAlign,
|
|
@@ -3,31 +3,36 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import { mat4 } from "gl-matrix";
|
|
6
7
|
import {
|
|
7
8
|
Box3 as ThreeBox3,
|
|
8
9
|
BufferAttribute as ThreeBufferAttribute,
|
|
9
10
|
BufferGeometry as ThreeBufferGeometry,
|
|
11
|
+
MeshBasicMaterial,
|
|
10
12
|
Sphere as ThreeSphere,
|
|
11
13
|
Vector3 as ThreeVector3
|
|
12
14
|
} from 'three';
|
|
13
|
-
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
14
|
-
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
15
15
|
|
|
16
|
-
import
|
|
16
|
+
import IndexedBinaryBVH from '../../../../core/bvh2/binary/IndexedBinaryBVH.js';
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
import { LeafNode } from '../../../../core/bvh2/LeafNode.js';
|
|
20
|
-
|
|
21
|
-
import IndexedBinaryBVH from '../../../../core/bvh2/binary/IndexedBinaryBVH.js';
|
|
22
|
-
import { BVHGeometryRaycaster } from "../../../graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js";
|
|
23
|
-
import ObservedInteger from "../../../../core/model/ObservedInteger.js";
|
|
24
|
-
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
20
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
25
21
|
import Signal from "../../../../core/events/signal/Signal.js";
|
|
26
|
-
import {
|
|
22
|
+
import { passThrough } from "../../../../core/function/Functions.js";
|
|
27
23
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
24
|
+
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
25
|
+
import Vector2 from '../../../../core/geom/Vector2.js';
|
|
26
|
+
import Vector3 from '../../../../core/geom/Vector3.js';
|
|
28
27
|
import { NumericInterval } from "../../../../core/math/interval/NumericInterval.js";
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
28
|
+
import ObservedInteger from "../../../../core/model/ObservedInteger.js";
|
|
29
|
+
import { BVHGeometryRaycaster } from "../../../graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js";
|
|
30
|
+
|
|
31
|
+
import ThreeFactory from '../../../graphics/three/ThreeFactory.js';
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const EMPTY_GEOMETRY = new ThreeBufferGeometry();
|
|
35
|
+
const DEFAULT_MATERIAL = new MeshBasicMaterial();
|
|
31
36
|
|
|
32
37
|
/**
|
|
33
38
|
* terrain tile is a part of a 2d array
|
|
@@ -44,7 +49,7 @@ class TerrainTile {
|
|
|
44
49
|
* @type {Material}
|
|
45
50
|
*/
|
|
46
51
|
material = null;
|
|
47
|
-
mesh = ThreeFactory.createMesh();
|
|
52
|
+
mesh = ThreeFactory.createMesh(EMPTY_GEOMETRY, DEFAULT_MATERIAL);
|
|
48
53
|
|
|
49
54
|
|
|
50
55
|
/**
|
|
@@ -51,12 +51,6 @@ class Mesh {
|
|
|
51
51
|
*/
|
|
52
52
|
this.mesh = null;
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
* Override Mesh data, if available. Typically set via plugins
|
|
56
|
-
* @type {Object3D|null}
|
|
57
|
-
*/
|
|
58
|
-
this.override_mesh = null;
|
|
59
|
-
|
|
60
54
|
/**
|
|
61
55
|
* @transient
|
|
62
56
|
* @type {Asset|null}
|
|
@@ -129,11 +123,6 @@ class Mesh {
|
|
|
129
123
|
aabb3_matrix4_project(this.__bvh_leaf.bounds, this.boundingBox, _t.matrix);
|
|
130
124
|
|
|
131
125
|
this.__bvh_leaf.write_bounds();
|
|
132
|
-
|
|
133
|
-
// override
|
|
134
|
-
if (this.override_mesh !== null) {
|
|
135
|
-
applyTransformToThreeObject(this.override_mesh, _t);
|
|
136
|
-
}
|
|
137
126
|
}
|
|
138
127
|
|
|
139
128
|
/**
|
|
@@ -4,9 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
import { BoxBufferGeometry, MeshLambertMaterial } from "three";
|
|
7
|
+
import { assert } from "../../../../core/assert.js";
|
|
8
|
+
import {
|
|
9
|
+
ExplicitBinaryBoundingVolumeHierarchy
|
|
10
|
+
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
11
|
+
import {
|
|
12
|
+
bvh_query_user_data_overlaps_frustum
|
|
13
|
+
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
7
14
|
import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
8
15
|
|
|
9
16
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
17
|
+
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
18
|
+
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
19
|
+
import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
|
|
10
20
|
import { System } from "../../../ecs/System.js";
|
|
11
21
|
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
12
22
|
|
|
@@ -15,26 +25,16 @@ import checkerTexture from "../../texture/CheckersTexture.js";
|
|
|
15
25
|
import ThreeFactory from "../../three/ThreeFactory.js";
|
|
16
26
|
import { assetTypeByPath } from "./assetTypeByPath.js";
|
|
17
27
|
import Mesh, { MeshFlags } from "./Mesh.js";
|
|
18
|
-
import { applyComponentPropertiesToThreeObject, setMesh } from "./setMesh.js";
|
|
19
|
-
import { GLTFAssetLoader } from "../../../asset/loaders/GLTFAssetLoader.js";
|
|
20
28
|
import { MeshEvents } from "./MeshEvents.js";
|
|
21
|
-
import {
|
|
22
|
-
import { ResourceAccessSpecification } from "../../../../core/model/ResourceAccessSpecification.js";
|
|
23
|
-
import { ResourceAccessKind } from "../../../../core/model/ResourceAccessKind.js";
|
|
24
|
-
import {
|
|
25
|
-
ExplicitBinaryBoundingVolumeHierarchy
|
|
26
|
-
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
27
|
-
import {
|
|
28
|
-
bvh_query_user_data_overlaps_frustum
|
|
29
|
-
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
29
|
+
import { setMesh } from "./setMesh.js";
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const PLACEHOLDER_GEOMETRY = new BoxBufferGeometry(1, 1, 1);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
PLACEHOLDER_GEOMETRY.computeBoundingSphere();
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const PLACEHOLDER_TEXTURE = checkerTexture.create();
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const PLACEHOLDER_MATERIAL = new MeshLambertMaterial({ map: PLACEHOLDER_TEXTURE });
|
|
38
38
|
|
|
39
39
|
const scratch_array = [];
|
|
40
40
|
|
|
@@ -134,13 +134,6 @@ export class MeshSystem extends System {
|
|
|
134
134
|
|
|
135
135
|
component.setFlag(MeshFlags.Loaded);
|
|
136
136
|
|
|
137
|
-
// override
|
|
138
|
-
if (asset.override_mesh !== undefined) {
|
|
139
|
-
component.override_mesh = asset.override_mesh.clone();
|
|
140
|
-
|
|
141
|
-
applyComponentPropertiesToThreeObject(component, component.override_mesh, entity);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
137
|
setMesh(dataset, entity, component, mesh);
|
|
145
138
|
|
|
146
139
|
|
|
@@ -318,8 +311,6 @@ export class MeshSystem extends System {
|
|
|
318
311
|
bScale
|
|
319
312
|
];
|
|
320
313
|
|
|
321
|
-
apply_transform();
|
|
322
|
-
|
|
323
314
|
model.__bvh_leaf.link(this.__bvh_binary, entity);
|
|
324
315
|
}
|
|
325
316
|
|
|
@@ -375,38 +366,6 @@ export class MeshSystem extends System {
|
|
|
375
366
|
|
|
376
367
|
const dataset = em.dataset;
|
|
377
368
|
|
|
378
|
-
/**
|
|
379
|
-
*
|
|
380
|
-
* @param {Asset<Object3D>} asset
|
|
381
|
-
*/
|
|
382
|
-
const assetLoaded = (asset) => {
|
|
383
|
-
if (!dataset.entityExists(entity)) {
|
|
384
|
-
//entity no longer exists, probably dataset has been switched, abort
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
//check that component is still actual
|
|
389
|
-
const actualComponent = dataset.getComponent(entity, Mesh);
|
|
390
|
-
|
|
391
|
-
if (actualComponent === component) {
|
|
392
|
-
// scene.remove(component.mesh);
|
|
393
|
-
this.__set_mesh_from_asset(entity, dataset, asset, component);
|
|
394
|
-
|
|
395
|
-
} else {
|
|
396
|
-
//component is no longer in the manager. do nothing.
|
|
397
|
-
//console.warn("component is no longer in the manager");
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
function assetFailure(error) {
|
|
403
|
-
console.error("failed to load model " + component.url, error);
|
|
404
|
-
|
|
405
|
-
dataset.sendEvent(entity, MeshEvents.AssetLoadFailed, {
|
|
406
|
-
reason: error
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
|
|
410
369
|
if (component.hasMesh()) {
|
|
411
370
|
//do not re-run if mesh is set
|
|
412
371
|
setMesh(dataset, entity, component, component.mesh);
|
|
@@ -425,28 +384,59 @@ export class MeshSystem extends System {
|
|
|
425
384
|
if (asset !== null) {
|
|
426
385
|
// asset is already loaded, use it
|
|
427
386
|
this.__set_mesh_from_asset(entity, dataset, asset, component);
|
|
428
|
-
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// mesh was not found, use temp mesh and submit a request
|
|
391
|
+
|
|
392
|
+
if (this.__use_placeholder_mesh) {
|
|
393
|
+
// set placeholder mesh
|
|
394
|
+
const mesh = ThreeFactory.createMesh(PLACEHOLDER_GEOMETRY, PLACEHOLDER_MATERIAL);
|
|
395
|
+
|
|
396
|
+
setMesh(dataset, entity, component, mesh);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function assetFailure(error) {
|
|
400
|
+
console.error("failed to load model " + component.url, error);
|
|
401
|
+
|
|
402
|
+
dataset.sendEvent(entity, MeshEvents.AssetLoadFailed, {
|
|
403
|
+
reason: error
|
|
404
|
+
});
|
|
405
|
+
}
|
|
429
406
|
|
|
430
|
-
|
|
407
|
+
if (assetType === null) {
|
|
408
|
+
// couldn't figure out what the asset type is
|
|
409
|
+
assetFailure("no asset type deduced");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
431
412
|
|
|
432
|
-
if (this.__use_placeholder_mesh) {
|
|
433
|
-
// set placeholder mesh
|
|
434
|
-
const mesh = ThreeFactory.createMesh(placeholderGeometry, placeholderMaterial);
|
|
435
413
|
|
|
436
|
-
|
|
414
|
+
/**
|
|
415
|
+
*
|
|
416
|
+
* @param {Asset<Object3D>} asset
|
|
417
|
+
*/
|
|
418
|
+
const assetLoaded = (asset) => {
|
|
419
|
+
if (!dataset.entityExists(entity)) {
|
|
420
|
+
//entity no longer exists, probably dataset has been switched, abort
|
|
421
|
+
return;
|
|
437
422
|
}
|
|
438
423
|
|
|
439
|
-
|
|
424
|
+
//check that component is still actual
|
|
425
|
+
const actualComponent = dataset.getComponent(entity, Mesh);
|
|
440
426
|
|
|
441
|
-
|
|
427
|
+
if (actualComponent === component) {
|
|
428
|
+
// scene.remove(component.mesh);
|
|
429
|
+
this.__set_mesh_from_asset(entity, dataset, asset, component);
|
|
442
430
|
|
|
443
431
|
} else {
|
|
444
|
-
//
|
|
445
|
-
|
|
432
|
+
//component is no longer in the manager. do nothing.
|
|
433
|
+
//console.warn("component is no longer in the manager");
|
|
446
434
|
}
|
|
447
435
|
}
|
|
448
436
|
|
|
449
|
-
|
|
437
|
+
// load the asset
|
|
438
|
+
am.get({ path: component.url, type: assetType, callback: assetLoaded, failure: assetFailure });
|
|
439
|
+
|
|
450
440
|
}
|
|
451
441
|
|
|
452
442
|
update(timeDelta) {
|