@woosh/meep-engine 2.59.1 → 2.59.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/build/meep.cjs +172 -126
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +172 -126
- package/package.json +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.d.ts +2 -2
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.d.ts +3 -0
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +69 -28
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +21 -15
package/build/meep.cjs
CHANGED
|
@@ -69075,32 +69075,72 @@ const DEFAULT_FLAGS$4 = SGMeshFlags.CastShadow
|
|
|
69075
69075
|
;
|
|
69076
69076
|
|
|
69077
69077
|
class SGMesh {
|
|
69078
|
-
|
|
69079
|
-
|
|
69080
|
-
|
|
69081
|
-
|
|
69082
|
-
|
|
69083
|
-
this.__url = null;
|
|
69078
|
+
/**
|
|
69079
|
+
* Allows settings a new material to all parts of the mesh
|
|
69080
|
+
* @type {Material|null}
|
|
69081
|
+
*/
|
|
69082
|
+
#material_override = null;
|
|
69084
69083
|
|
|
69085
|
-
|
|
69086
|
-
|
|
69087
|
-
|
|
69088
|
-
|
|
69089
|
-
|
|
69090
|
-
this.__node = null;
|
|
69084
|
+
/**
|
|
69085
|
+
*
|
|
69086
|
+
* @type {number}
|
|
69087
|
+
*/
|
|
69088
|
+
flags = DEFAULT_FLAGS$4;
|
|
69091
69089
|
|
|
69092
|
-
|
|
69093
|
-
|
|
69094
|
-
|
|
69095
|
-
|
|
69096
|
-
|
|
69097
|
-
this.__initial_bounds = new AABB3();
|
|
69090
|
+
/**
|
|
69091
|
+
*
|
|
69092
|
+
* @type {string|null}
|
|
69093
|
+
*/
|
|
69094
|
+
__url = null;
|
|
69098
69095
|
|
|
69099
|
-
|
|
69100
|
-
|
|
69101
|
-
|
|
69102
|
-
|
|
69103
|
-
|
|
69096
|
+
/**
|
|
69097
|
+
*
|
|
69098
|
+
* @type {EntityNode|null}
|
|
69099
|
+
* @private
|
|
69100
|
+
*/
|
|
69101
|
+
__node = null;
|
|
69102
|
+
|
|
69103
|
+
/**
|
|
69104
|
+
*
|
|
69105
|
+
* @type {AABB3}
|
|
69106
|
+
* @private
|
|
69107
|
+
*/
|
|
69108
|
+
__initial_bounds = new AABB3();
|
|
69109
|
+
|
|
69110
|
+
/**
|
|
69111
|
+
*
|
|
69112
|
+
* @param {Material} v
|
|
69113
|
+
*/
|
|
69114
|
+
set materialOverride(v) {
|
|
69115
|
+
if (v === this.#material_override) {
|
|
69116
|
+
return;
|
|
69117
|
+
}
|
|
69118
|
+
|
|
69119
|
+
if (v === null) {
|
|
69120
|
+
throw new Error(`Once material override is set it can not be cleared, create a new SGMesh instance if you would like to clear override`);
|
|
69121
|
+
}
|
|
69122
|
+
|
|
69123
|
+
this.#material_override = v;
|
|
69124
|
+
|
|
69125
|
+
this.applyMaterialOverride();
|
|
69126
|
+
}
|
|
69127
|
+
|
|
69128
|
+
get materialOverride() {
|
|
69129
|
+
return this.#material_override;
|
|
69130
|
+
}
|
|
69131
|
+
|
|
69132
|
+
applyMaterialOverride() {
|
|
69133
|
+
if (this.__node === null) {
|
|
69134
|
+
return;
|
|
69135
|
+
}
|
|
69136
|
+
|
|
69137
|
+
this.__node.traverse(node => {
|
|
69138
|
+
const sg = node.entity.getComponent(ShadedGeometry);
|
|
69139
|
+
|
|
69140
|
+
if (sg !== null) {
|
|
69141
|
+
sg.material = this.#material_override;
|
|
69142
|
+
}
|
|
69143
|
+
});
|
|
69104
69144
|
}
|
|
69105
69145
|
|
|
69106
69146
|
/**
|
|
@@ -71982,35 +72022,6 @@ class TerrainSystem extends System {
|
|
|
71982
72022
|
}
|
|
71983
72023
|
}
|
|
71984
72024
|
|
|
71985
|
-
/**
|
|
71986
|
-
*
|
|
71987
|
-
* @param {string} url
|
|
71988
|
-
* @return {String|null}
|
|
71989
|
-
*/
|
|
71990
|
-
function assetTypeByPath(url) {
|
|
71991
|
-
//get extension
|
|
71992
|
-
const dotPosition = url.lastIndexOf(".");
|
|
71993
|
-
if (dotPosition === -1) {
|
|
71994
|
-
console.warn(`No model extension could be deduced for URL: '${url}'`);
|
|
71995
|
-
//no extension
|
|
71996
|
-
return null;
|
|
71997
|
-
} else {
|
|
71998
|
-
//retrieve extension
|
|
71999
|
-
const ext = url.substring(dotPosition + 1);
|
|
72000
|
-
switch (ext) {
|
|
72001
|
-
case "json":
|
|
72002
|
-
return "three.js";
|
|
72003
|
-
case "glb":
|
|
72004
|
-
return "model/gltf";
|
|
72005
|
-
case "gltf":
|
|
72006
|
-
return "model/gltf+json";
|
|
72007
|
-
default:
|
|
72008
|
-
console.warn(`Unknown 3d mesh format extension: '${ext}'`);
|
|
72009
|
-
return null;
|
|
72010
|
-
}
|
|
72011
|
-
}
|
|
72012
|
-
}
|
|
72013
|
-
|
|
72014
72025
|
/**
|
|
72015
72026
|
* Component representing logical attachment to another entity, when parent disappears - so does the child
|
|
72016
72027
|
*/
|
|
@@ -75647,80 +75658,6 @@ class EntityNode {
|
|
|
75647
75658
|
*/
|
|
75648
75659
|
EntityNode.prototype.isEntityNode = true;
|
|
75649
75660
|
|
|
75650
|
-
/**
|
|
75651
|
-
*
|
|
75652
|
-
* @param {Transform} transform
|
|
75653
|
-
* @param {THREE.Object3D} three_object
|
|
75654
|
-
*/
|
|
75655
|
-
function copy_three_transform(transform, three_object) {
|
|
75656
|
-
|
|
75657
|
-
// copy object transform
|
|
75658
|
-
transform.position.copy(three_object.position);
|
|
75659
|
-
transform.scale.copy(three_object.scale);
|
|
75660
|
-
transform.rotation.copy(three_object.quaternion);
|
|
75661
|
-
|
|
75662
|
-
//
|
|
75663
|
-
transform.matrix.set(three_object.matrix.elements);
|
|
75664
|
-
}
|
|
75665
|
-
|
|
75666
|
-
/**
|
|
75667
|
-
*
|
|
75668
|
-
* @param {THREE.Object3D} root
|
|
75669
|
-
* @returns {EntityNode}
|
|
75670
|
-
*/
|
|
75671
|
-
function three_object_to_entity_composition(root) {
|
|
75672
|
-
const node = new EntityNode();
|
|
75673
|
-
|
|
75674
|
-
const node_transform = node.transform;
|
|
75675
|
-
|
|
75676
|
-
// copy object transform
|
|
75677
|
-
copy_three_transform(node_transform, root);
|
|
75678
|
-
|
|
75679
|
-
const entity = node.entity;
|
|
75680
|
-
|
|
75681
|
-
const transform = new Transform();
|
|
75682
|
-
// initialize world transform
|
|
75683
|
-
transform.fromMatrix4(root.matrixWorld.elements);
|
|
75684
|
-
|
|
75685
|
-
entity.add(transform);
|
|
75686
|
-
|
|
75687
|
-
if (root.isMesh) {
|
|
75688
|
-
if (root.isSkinnedMesh) {
|
|
75689
|
-
console.error(`Skinned meshes are not supported`);
|
|
75690
|
-
}
|
|
75691
|
-
|
|
75692
|
-
const sg = ShadedGeometry.from(root.geometry, root.material);
|
|
75693
|
-
|
|
75694
|
-
entity.add(sg);
|
|
75695
|
-
}
|
|
75696
|
-
|
|
75697
|
-
const children = root.children;
|
|
75698
|
-
const child_count = children.length;
|
|
75699
|
-
|
|
75700
|
-
for (let i = 0; i < child_count; i++) {
|
|
75701
|
-
const child = children[i];
|
|
75702
|
-
|
|
75703
|
-
const child_node = three_object_to_entity_composition(child);
|
|
75704
|
-
|
|
75705
|
-
node.addChild(child_node);
|
|
75706
|
-
}
|
|
75707
|
-
|
|
75708
|
-
return node;
|
|
75709
|
-
}
|
|
75710
|
-
|
|
75711
|
-
const SGMeshEvents = {
|
|
75712
|
-
|
|
75713
|
-
/**
|
|
75714
|
-
* When asset is attached/loaded onto the Mesh component.
|
|
75715
|
-
* This is the time when the 3d data becomes renderable
|
|
75716
|
-
*/
|
|
75717
|
-
AssetLoaded: '@ecd-component-SGMesh/asset-attached',
|
|
75718
|
-
/**
|
|
75719
|
-
* Required asset failed to load for whatever reason
|
|
75720
|
-
*/
|
|
75721
|
-
AssetLoadFailed: '@ecd-component-SGMesh/asset-failed',
|
|
75722
|
-
};
|
|
75723
|
-
|
|
75724
75661
|
/**
|
|
75725
75662
|
* @readonly
|
|
75726
75663
|
* @type {number}
|
|
@@ -75943,6 +75880,109 @@ class TransformAttachmentSystem extends System {
|
|
|
75943
75880
|
}
|
|
75944
75881
|
}
|
|
75945
75882
|
|
|
75883
|
+
/**
|
|
75884
|
+
*
|
|
75885
|
+
* @param {string} url
|
|
75886
|
+
* @return {String|null}
|
|
75887
|
+
*/
|
|
75888
|
+
function assetTypeByPath(url) {
|
|
75889
|
+
//get extension
|
|
75890
|
+
const dotPosition = url.lastIndexOf(".");
|
|
75891
|
+
if (dotPosition === -1) {
|
|
75892
|
+
console.warn(`No model extension could be deduced for URL: '${url}'`);
|
|
75893
|
+
//no extension
|
|
75894
|
+
return null;
|
|
75895
|
+
} else {
|
|
75896
|
+
//retrieve extension
|
|
75897
|
+
const ext = url.substring(dotPosition + 1);
|
|
75898
|
+
switch (ext) {
|
|
75899
|
+
case "json":
|
|
75900
|
+
return "three.js";
|
|
75901
|
+
case "glb":
|
|
75902
|
+
return "model/gltf";
|
|
75903
|
+
case "gltf":
|
|
75904
|
+
return "model/gltf+json";
|
|
75905
|
+
default:
|
|
75906
|
+
console.warn(`Unknown 3d mesh format extension: '${ext}'`);
|
|
75907
|
+
return null;
|
|
75908
|
+
}
|
|
75909
|
+
}
|
|
75910
|
+
}
|
|
75911
|
+
|
|
75912
|
+
/**
|
|
75913
|
+
*
|
|
75914
|
+
* @param {Transform} transform
|
|
75915
|
+
* @param {THREE.Object3D} three_object
|
|
75916
|
+
*/
|
|
75917
|
+
function copy_three_transform(transform, three_object) {
|
|
75918
|
+
|
|
75919
|
+
// copy object transform
|
|
75920
|
+
transform.position.copy(three_object.position);
|
|
75921
|
+
transform.scale.copy(three_object.scale);
|
|
75922
|
+
transform.rotation.copy(three_object.quaternion);
|
|
75923
|
+
|
|
75924
|
+
//
|
|
75925
|
+
transform.matrix.set(three_object.matrix.elements);
|
|
75926
|
+
}
|
|
75927
|
+
|
|
75928
|
+
/**
|
|
75929
|
+
*
|
|
75930
|
+
* @param {THREE.Object3D} root
|
|
75931
|
+
* @returns {EntityNode}
|
|
75932
|
+
*/
|
|
75933
|
+
function three_object_to_entity_composition(root) {
|
|
75934
|
+
const node = new EntityNode();
|
|
75935
|
+
|
|
75936
|
+
const node_transform = node.transform;
|
|
75937
|
+
|
|
75938
|
+
// copy object transform
|
|
75939
|
+
copy_three_transform(node_transform, root);
|
|
75940
|
+
|
|
75941
|
+
const entity = node.entity;
|
|
75942
|
+
|
|
75943
|
+
const transform = new Transform();
|
|
75944
|
+
// initialize world transform
|
|
75945
|
+
transform.fromMatrix4(root.matrixWorld.elements);
|
|
75946
|
+
|
|
75947
|
+
entity.add(transform);
|
|
75948
|
+
|
|
75949
|
+
if (root.isMesh) {
|
|
75950
|
+
if (root.isSkinnedMesh) {
|
|
75951
|
+
console.error(`Skinned meshes are not supported`);
|
|
75952
|
+
}
|
|
75953
|
+
|
|
75954
|
+
const sg = ShadedGeometry.from(root.geometry, root.material);
|
|
75955
|
+
|
|
75956
|
+
entity.add(sg);
|
|
75957
|
+
}
|
|
75958
|
+
|
|
75959
|
+
const children = root.children;
|
|
75960
|
+
const child_count = children.length;
|
|
75961
|
+
|
|
75962
|
+
for (let i = 0; i < child_count; i++) {
|
|
75963
|
+
const child = children[i];
|
|
75964
|
+
|
|
75965
|
+
const child_node = three_object_to_entity_composition(child);
|
|
75966
|
+
|
|
75967
|
+
node.addChild(child_node);
|
|
75968
|
+
}
|
|
75969
|
+
|
|
75970
|
+
return node;
|
|
75971
|
+
}
|
|
75972
|
+
|
|
75973
|
+
const SGMeshEvents = {
|
|
75974
|
+
|
|
75975
|
+
/**
|
|
75976
|
+
* When asset is attached/loaded onto the Mesh component.
|
|
75977
|
+
* This is the time when the 3d data becomes renderable
|
|
75978
|
+
*/
|
|
75979
|
+
AssetLoaded: '@ecd-component-SGMesh/asset-attached',
|
|
75980
|
+
/**
|
|
75981
|
+
* Required asset failed to load for whatever reason
|
|
75982
|
+
*/
|
|
75983
|
+
AssetLoadFailed: '@ecd-component-SGMesh/asset-failed',
|
|
75984
|
+
};
|
|
75985
|
+
|
|
75946
75986
|
/**
|
|
75947
75987
|
* @readonly
|
|
75948
75988
|
* @type {number}
|
|
@@ -76107,6 +76147,8 @@ class SGMeshSystem extends System {
|
|
|
76107
76147
|
|
|
76108
76148
|
});
|
|
76109
76149
|
|
|
76150
|
+
const material_override = mesh.materialOverride;
|
|
76151
|
+
|
|
76110
76152
|
// apply flags to the hierarchy
|
|
76111
76153
|
entity_node.traverse(node => {
|
|
76112
76154
|
/**
|
|
@@ -76120,6 +76162,10 @@ class SGMeshSystem extends System {
|
|
|
76120
76162
|
|
|
76121
76163
|
sg.writeFlag(ShadedGeometryFlags.CastShadow, mesh.castShadow);
|
|
76122
76164
|
sg.writeFlag(ShadedGeometryFlags.ReceiveShadow, mesh.receiveShadow);
|
|
76165
|
+
|
|
76166
|
+
if (material_override !== null) {
|
|
76167
|
+
sg.material = material_override;
|
|
76168
|
+
}
|
|
76123
76169
|
});
|
|
76124
76170
|
|
|
76125
76171
|
|