lythreeframe 1.2.51 → 1.2.52
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/dist/bundle.cjs.js
CHANGED
|
@@ -930,16 +930,16 @@ class TAssetPointer extends TSmartPointer {
|
|
|
930
930
|
value.userData["assetPointer"] = this;
|
|
931
931
|
}
|
|
932
932
|
release() {
|
|
933
|
-
if (this.value) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
console.log("realease", this)
|
|
933
|
+
// if (this.value) {
|
|
934
|
+
// this.referenceCount--;
|
|
935
|
+
// if (this.referenceCount === 0) {
|
|
936
|
+
// setTimeout(() => {
|
|
937
|
+
// this.value!.dispose();
|
|
938
|
+
// this.value = null;
|
|
939
|
+
// }, 0);
|
|
940
|
+
// }
|
|
941
|
+
// }
|
|
942
|
+
// console.log("realease", this)
|
|
943
943
|
}
|
|
944
944
|
forceRelease() {
|
|
945
945
|
console.log("forceRelease", this);
|
|
@@ -1045,63 +1045,58 @@ class AssetManager {
|
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
convertThreeObjectToLYObject(parentLYComponent, threejsObject) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
const location = threejsObject.position.clone();
|
|
1049
|
+
const rotation = threejsObject.rotation.clone();
|
|
1050
|
+
const scale = threejsObject.scale.clone();
|
|
1051
1051
|
let newComp = null;
|
|
1052
|
-
|
|
1052
|
+
const children = threejsObject.children;
|
|
1053
1053
|
threejsObject.children = [];
|
|
1054
1054
|
if (threejsObject.type === "Group" || threejsObject.type === "Object3D") {
|
|
1055
|
-
newComp = new SceneComponent(this.app, threejsObject);
|
|
1055
|
+
newComp = new SceneComponent(this.app, threejsObject.uuid);
|
|
1056
1056
|
}
|
|
1057
1057
|
else if (threejsObject.isMesh) {
|
|
1058
|
-
|
|
1058
|
+
const obj = threejsObject;
|
|
1059
1059
|
newComp = new MeshComponent(this.app, obj.geometry, obj.material);
|
|
1060
|
-
// assetManager.#collectMatAndGeoInMesh(threejsObject)
|
|
1061
1060
|
threejsObject.layers.set(0);
|
|
1062
1061
|
}
|
|
1063
1062
|
else {
|
|
1064
|
-
newComp = new SceneComponent(this.app, threejsObject);
|
|
1063
|
+
newComp = new SceneComponent(this.app, threejsObject.uuid);
|
|
1065
1064
|
}
|
|
1066
1065
|
if (newComp === null) {
|
|
1067
1066
|
threejsObject.children = children;
|
|
1068
|
-
//threejsObject.parent = parent
|
|
1069
|
-
//console.log("Unprocess", threejsObject);
|
|
1070
1067
|
return null;
|
|
1071
1068
|
}
|
|
1072
1069
|
parentLYComponent.addChildComponent(newComp);
|
|
1073
1070
|
newComp.setPosition(location);
|
|
1074
1071
|
newComp.setRotation(rotation);
|
|
1075
1072
|
newComp.setScale(scale);
|
|
1076
|
-
for (
|
|
1077
|
-
this.convertThreeObjectToLYObject(newComp,
|
|
1073
|
+
for (const child of children) {
|
|
1074
|
+
this.convertThreeObjectToLYObject(newComp, child);
|
|
1078
1075
|
}
|
|
1079
1076
|
return newComp;
|
|
1080
1077
|
}
|
|
1081
1078
|
collectResourcesAndReferences(object) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
map.set(resource, map.get(resource) + 1);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1079
|
+
const countResource = (map, resource) => {
|
|
1080
|
+
var _a;
|
|
1081
|
+
const currentCount = (_a = map.get(resource)) !== null && _a !== void 0 ? _a : 0;
|
|
1082
|
+
map.set(resource, currentCount + 1);
|
|
1083
|
+
};
|
|
1090
1084
|
const resources = {
|
|
1091
1085
|
geometries: new Map(),
|
|
1092
1086
|
materials: new Map(),
|
|
1093
1087
|
textures: new Map()
|
|
1094
1088
|
};
|
|
1095
1089
|
object.traverse((child) => {
|
|
1096
|
-
|
|
1097
|
-
|
|
1090
|
+
const meshChild = child;
|
|
1091
|
+
if (meshChild.geometry instanceof webgpu.BufferGeometry) {
|
|
1092
|
+
countResource(resources.geometries, meshChild.geometry);
|
|
1098
1093
|
}
|
|
1099
|
-
if (
|
|
1100
|
-
const mats = Array.isArray(
|
|
1094
|
+
if (meshChild.material) {
|
|
1095
|
+
const mats = Array.isArray(meshChild.material) ? meshChild.material : [meshChild.material];
|
|
1101
1096
|
mats.forEach((mat) => {
|
|
1102
1097
|
if (mat) {
|
|
1103
1098
|
countResource(resources.materials, mat);
|
|
1104
|
-
Object.
|
|
1099
|
+
Object.values(mat).forEach((value) => {
|
|
1105
1100
|
if (value instanceof webgpu.Texture) {
|
|
1106
1101
|
countResource(resources.textures, value);
|
|
1107
1102
|
}
|
|
@@ -1110,49 +1105,36 @@ class AssetManager {
|
|
|
1110
1105
|
});
|
|
1111
1106
|
}
|
|
1112
1107
|
});
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
createPointer(this, resources.geometries);
|
|
1119
|
-
createPointer(this, resources.materials);
|
|
1120
|
-
createPointer(this, resources.textures);
|
|
1121
|
-
// console.log('Geometries:', Array.from(resources.geometries.entries()));
|
|
1122
|
-
// console.log('Materials:', Array.from(resources.materials.entries()));
|
|
1123
|
-
// console.log('Textures:', Array.from(resources.textures.entries()));
|
|
1124
|
-
// console.log('assetPointer:', this.assetPointer);
|
|
1108
|
+
resources.geometries.forEach((count, geometry) => this.addAsset(geometry, count));
|
|
1109
|
+
resources.materials.forEach((count, material) => this.addAsset(material, count));
|
|
1110
|
+
resources.textures.forEach((count, texture) => this.addAsset(texture, count));
|
|
1125
1111
|
}
|
|
1126
1112
|
checkMeshResource(mesh) {
|
|
1127
|
-
if (mesh.geometry) {
|
|
1128
|
-
|
|
1129
|
-
this.addAsset(mesh.geometry);
|
|
1130
|
-
}
|
|
1113
|
+
if (mesh.geometry && !mesh.geometry.userData["assetPointer"]) {
|
|
1114
|
+
this.addAsset(mesh.geometry);
|
|
1131
1115
|
}
|
|
1132
1116
|
if (mesh.material) {
|
|
1133
1117
|
const mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1134
1118
|
mats.forEach((material) => {
|
|
1135
|
-
if (material)
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
Object.entries(material).forEach(([key, value]) => {
|
|
1140
|
-
if (value instanceof webgpu.Texture) {
|
|
1141
|
-
if (!(value.userData["assetPointer"])) {
|
|
1142
|
-
this.addAsset(value);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1119
|
+
if (!material)
|
|
1120
|
+
return;
|
|
1121
|
+
if (!material.userData["assetPointer"]) {
|
|
1122
|
+
this.addAsset(material);
|
|
1146
1123
|
}
|
|
1124
|
+
Object.values(material).forEach((value) => {
|
|
1125
|
+
if (value instanceof webgpu.Texture && !value.userData["assetPointer"]) {
|
|
1126
|
+
this.addAsset(value);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1147
1129
|
});
|
|
1148
1130
|
}
|
|
1149
1131
|
}
|
|
1150
1132
|
async loadGltfFromPathAsync(path) {
|
|
1151
1133
|
this.setupDracoLoader("/SceneResource/draco/");
|
|
1152
|
-
|
|
1153
|
-
return res;
|
|
1134
|
+
return await this.gltfLoader.loadAsync(path);
|
|
1154
1135
|
}
|
|
1155
1136
|
loadGltfFromPath(path, onLoadFinished) {
|
|
1137
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1156
1138
|
this.gltfLoader.load(path, onLoadFinished);
|
|
1157
1139
|
}
|
|
1158
1140
|
loadGltfFromBuffer(data, path, onLoadFinished) {
|
|
@@ -1161,33 +1143,30 @@ class AssetManager {
|
|
|
1161
1143
|
}
|
|
1162
1144
|
loadFile(filepath = '', onLoadFinished) {
|
|
1163
1145
|
const loader = new webgpu.FileLoader();
|
|
1164
|
-
loader.load(filepath,
|
|
1165
|
-
onLoadFinished(data);
|
|
1166
|
-
});
|
|
1146
|
+
loader.load(filepath, onLoadFinished);
|
|
1167
1147
|
}
|
|
1168
1148
|
addAsset(asset, referenceCount = 0) {
|
|
1169
1149
|
if (asset instanceof webgpu.BufferGeometry) {
|
|
1170
1150
|
return this.addGeometryAsset(asset, referenceCount);
|
|
1171
1151
|
}
|
|
1172
|
-
|
|
1152
|
+
if (asset instanceof webgpu.Material) {
|
|
1173
1153
|
return this.addMaterialAsset(asset, referenceCount);
|
|
1174
1154
|
}
|
|
1175
|
-
|
|
1155
|
+
if (asset instanceof webgpu.Texture) {
|
|
1176
1156
|
return this.addTextureAsset(asset, referenceCount);
|
|
1177
1157
|
}
|
|
1178
1158
|
return undefined;
|
|
1179
1159
|
}
|
|
1180
1160
|
addMaterialAsset(asset, referenceCount = 0) {
|
|
1181
|
-
let pointer =
|
|
1161
|
+
let pointer = asset.userData["assetPointer"];
|
|
1182
1162
|
if (!pointer) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
const value = asset[k];
|
|
1163
|
+
const textureMap = new Map();
|
|
1164
|
+
Object.entries(asset).forEach(([key, value]) => {
|
|
1186
1165
|
if (value instanceof webgpu.Texture) {
|
|
1187
|
-
|
|
1188
|
-
textureMap.set(
|
|
1166
|
+
const texturePointer = this.addTextureAsset(value, 1);
|
|
1167
|
+
textureMap.set(key, texturePointer);
|
|
1189
1168
|
}
|
|
1190
|
-
}
|
|
1169
|
+
});
|
|
1191
1170
|
pointer = new MaterialAssetPointer(asset, textureMap, referenceCount);
|
|
1192
1171
|
this.materialAssets.set(asset.uuid, pointer);
|
|
1193
1172
|
}
|
|
@@ -1197,7 +1176,7 @@ class AssetManager {
|
|
|
1197
1176
|
return pointer;
|
|
1198
1177
|
}
|
|
1199
1178
|
addTextureAsset(asset, referenceCount = 0) {
|
|
1200
|
-
let pointer =
|
|
1179
|
+
let pointer = asset.userData["assetPointer"];
|
|
1201
1180
|
if (!pointer) {
|
|
1202
1181
|
pointer = new TextureAssetPointer(asset, referenceCount);
|
|
1203
1182
|
this.textureAssets.set(asset.uuid, pointer);
|
|
@@ -1208,7 +1187,7 @@ class AssetManager {
|
|
|
1208
1187
|
return pointer;
|
|
1209
1188
|
}
|
|
1210
1189
|
addGeometryAsset(asset, referenceCount = 0) {
|
|
1211
|
-
let pointer =
|
|
1190
|
+
let pointer = asset.userData["assetPointer"];
|
|
1212
1191
|
if (!pointer) {
|
|
1213
1192
|
pointer = new GeometryAssetPointer(asset, referenceCount);
|
|
1214
1193
|
this.geometryAssets.set(asset.uuid, pointer);
|
|
@@ -1219,34 +1198,21 @@ class AssetManager {
|
|
|
1219
1198
|
return pointer;
|
|
1220
1199
|
}
|
|
1221
1200
|
releaseAsset(asset) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
p.release();
|
|
1201
|
+
const pointer = asset.userData["assetPointer"];
|
|
1202
|
+
if (pointer) {
|
|
1203
|
+
pointer.release();
|
|
1226
1204
|
}
|
|
1227
1205
|
else {
|
|
1228
1206
|
asset.dispose();
|
|
1229
1207
|
}
|
|
1230
1208
|
}
|
|
1231
1209
|
clearAssets() {
|
|
1232
|
-
this.geometryAssets.forEach((
|
|
1233
|
-
p.forceRelease();
|
|
1234
|
-
});
|
|
1210
|
+
this.geometryAssets.forEach((pointer) => pointer.forceRelease());
|
|
1235
1211
|
this.geometryAssets.clear();
|
|
1236
|
-
this.materialAssets.forEach((
|
|
1237
|
-
p.forceRelease();
|
|
1238
|
-
});
|
|
1212
|
+
this.materialAssets.forEach((pointer) => pointer.forceRelease());
|
|
1239
1213
|
this.materialAssets.clear();
|
|
1240
|
-
this.textureAssets.forEach((
|
|
1241
|
-
p.forceRelease();
|
|
1242
|
-
});
|
|
1214
|
+
this.textureAssets.forEach((pointer) => pointer.forceRelease());
|
|
1243
1215
|
this.textureAssets.clear();
|
|
1244
|
-
// let pointers = Array.from(this.assetPointer.values());
|
|
1245
|
-
// pointers.forEach((p) =>
|
|
1246
|
-
// {
|
|
1247
|
-
// p.forceRelease();
|
|
1248
|
-
// });
|
|
1249
|
-
// this.assetPointer.clear();
|
|
1250
1216
|
}
|
|
1251
1217
|
}
|
|
1252
1218
|
|
package/dist/bundle.esm.js
CHANGED
|
@@ -928,16 +928,16 @@ class TAssetPointer extends TSmartPointer {
|
|
|
928
928
|
value.userData["assetPointer"] = this;
|
|
929
929
|
}
|
|
930
930
|
release() {
|
|
931
|
-
if (this.value) {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
console.log("realease", this)
|
|
931
|
+
// if (this.value) {
|
|
932
|
+
// this.referenceCount--;
|
|
933
|
+
// if (this.referenceCount === 0) {
|
|
934
|
+
// setTimeout(() => {
|
|
935
|
+
// this.value!.dispose();
|
|
936
|
+
// this.value = null;
|
|
937
|
+
// }, 0);
|
|
938
|
+
// }
|
|
939
|
+
// }
|
|
940
|
+
// console.log("realease", this)
|
|
941
941
|
}
|
|
942
942
|
forceRelease() {
|
|
943
943
|
console.log("forceRelease", this);
|
|
@@ -1043,63 +1043,58 @@ class AssetManager {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
1045
|
convertThreeObjectToLYObject(parentLYComponent, threejsObject) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1046
|
+
const location = threejsObject.position.clone();
|
|
1047
|
+
const rotation = threejsObject.rotation.clone();
|
|
1048
|
+
const scale = threejsObject.scale.clone();
|
|
1049
1049
|
let newComp = null;
|
|
1050
|
-
|
|
1050
|
+
const children = threejsObject.children;
|
|
1051
1051
|
threejsObject.children = [];
|
|
1052
1052
|
if (threejsObject.type === "Group" || threejsObject.type === "Object3D") {
|
|
1053
|
-
newComp = new SceneComponent(this.app, threejsObject);
|
|
1053
|
+
newComp = new SceneComponent(this.app, threejsObject.uuid);
|
|
1054
1054
|
}
|
|
1055
1055
|
else if (threejsObject.isMesh) {
|
|
1056
|
-
|
|
1056
|
+
const obj = threejsObject;
|
|
1057
1057
|
newComp = new MeshComponent(this.app, obj.geometry, obj.material);
|
|
1058
|
-
// assetManager.#collectMatAndGeoInMesh(threejsObject)
|
|
1059
1058
|
threejsObject.layers.set(0);
|
|
1060
1059
|
}
|
|
1061
1060
|
else {
|
|
1062
|
-
newComp = new SceneComponent(this.app, threejsObject);
|
|
1061
|
+
newComp = new SceneComponent(this.app, threejsObject.uuid);
|
|
1063
1062
|
}
|
|
1064
1063
|
if (newComp === null) {
|
|
1065
1064
|
threejsObject.children = children;
|
|
1066
|
-
//threejsObject.parent = parent
|
|
1067
|
-
//console.log("Unprocess", threejsObject);
|
|
1068
1065
|
return null;
|
|
1069
1066
|
}
|
|
1070
1067
|
parentLYComponent.addChildComponent(newComp);
|
|
1071
1068
|
newComp.setPosition(location);
|
|
1072
1069
|
newComp.setRotation(rotation);
|
|
1073
1070
|
newComp.setScale(scale);
|
|
1074
|
-
for (
|
|
1075
|
-
this.convertThreeObjectToLYObject(newComp,
|
|
1071
|
+
for (const child of children) {
|
|
1072
|
+
this.convertThreeObjectToLYObject(newComp, child);
|
|
1076
1073
|
}
|
|
1077
1074
|
return newComp;
|
|
1078
1075
|
}
|
|
1079
1076
|
collectResourcesAndReferences(object) {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
map.set(resource, map.get(resource) + 1);
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1077
|
+
const countResource = (map, resource) => {
|
|
1078
|
+
var _a;
|
|
1079
|
+
const currentCount = (_a = map.get(resource)) !== null && _a !== void 0 ? _a : 0;
|
|
1080
|
+
map.set(resource, currentCount + 1);
|
|
1081
|
+
};
|
|
1088
1082
|
const resources = {
|
|
1089
1083
|
geometries: new Map(),
|
|
1090
1084
|
materials: new Map(),
|
|
1091
1085
|
textures: new Map()
|
|
1092
1086
|
};
|
|
1093
1087
|
object.traverse((child) => {
|
|
1094
|
-
|
|
1095
|
-
|
|
1088
|
+
const meshChild = child;
|
|
1089
|
+
if (meshChild.geometry instanceof BufferGeometry) {
|
|
1090
|
+
countResource(resources.geometries, meshChild.geometry);
|
|
1096
1091
|
}
|
|
1097
|
-
if (
|
|
1098
|
-
const mats = Array.isArray(
|
|
1092
|
+
if (meshChild.material) {
|
|
1093
|
+
const mats = Array.isArray(meshChild.material) ? meshChild.material : [meshChild.material];
|
|
1099
1094
|
mats.forEach((mat) => {
|
|
1100
1095
|
if (mat) {
|
|
1101
1096
|
countResource(resources.materials, mat);
|
|
1102
|
-
Object.
|
|
1097
|
+
Object.values(mat).forEach((value) => {
|
|
1103
1098
|
if (value instanceof Texture) {
|
|
1104
1099
|
countResource(resources.textures, value);
|
|
1105
1100
|
}
|
|
@@ -1108,49 +1103,36 @@ class AssetManager {
|
|
|
1108
1103
|
});
|
|
1109
1104
|
}
|
|
1110
1105
|
});
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
createPointer(this, resources.geometries);
|
|
1117
|
-
createPointer(this, resources.materials);
|
|
1118
|
-
createPointer(this, resources.textures);
|
|
1119
|
-
// console.log('Geometries:', Array.from(resources.geometries.entries()));
|
|
1120
|
-
// console.log('Materials:', Array.from(resources.materials.entries()));
|
|
1121
|
-
// console.log('Textures:', Array.from(resources.textures.entries()));
|
|
1122
|
-
// console.log('assetPointer:', this.assetPointer);
|
|
1106
|
+
resources.geometries.forEach((count, geometry) => this.addAsset(geometry, count));
|
|
1107
|
+
resources.materials.forEach((count, material) => this.addAsset(material, count));
|
|
1108
|
+
resources.textures.forEach((count, texture) => this.addAsset(texture, count));
|
|
1123
1109
|
}
|
|
1124
1110
|
checkMeshResource(mesh) {
|
|
1125
|
-
if (mesh.geometry) {
|
|
1126
|
-
|
|
1127
|
-
this.addAsset(mesh.geometry);
|
|
1128
|
-
}
|
|
1111
|
+
if (mesh.geometry && !mesh.geometry.userData["assetPointer"]) {
|
|
1112
|
+
this.addAsset(mesh.geometry);
|
|
1129
1113
|
}
|
|
1130
1114
|
if (mesh.material) {
|
|
1131
1115
|
const mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
1132
1116
|
mats.forEach((material) => {
|
|
1133
|
-
if (material)
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
Object.entries(material).forEach(([key, value]) => {
|
|
1138
|
-
if (value instanceof Texture) {
|
|
1139
|
-
if (!(value.userData["assetPointer"])) {
|
|
1140
|
-
this.addAsset(value);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1117
|
+
if (!material)
|
|
1118
|
+
return;
|
|
1119
|
+
if (!material.userData["assetPointer"]) {
|
|
1120
|
+
this.addAsset(material);
|
|
1144
1121
|
}
|
|
1122
|
+
Object.values(material).forEach((value) => {
|
|
1123
|
+
if (value instanceof Texture && !value.userData["assetPointer"]) {
|
|
1124
|
+
this.addAsset(value);
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1145
1127
|
});
|
|
1146
1128
|
}
|
|
1147
1129
|
}
|
|
1148
1130
|
async loadGltfFromPathAsync(path) {
|
|
1149
1131
|
this.setupDracoLoader("/SceneResource/draco/");
|
|
1150
|
-
|
|
1151
|
-
return res;
|
|
1132
|
+
return await this.gltfLoader.loadAsync(path);
|
|
1152
1133
|
}
|
|
1153
1134
|
loadGltfFromPath(path, onLoadFinished) {
|
|
1135
|
+
this.setupDracoLoader("/SceneResource/draco/");
|
|
1154
1136
|
this.gltfLoader.load(path, onLoadFinished);
|
|
1155
1137
|
}
|
|
1156
1138
|
loadGltfFromBuffer(data, path, onLoadFinished) {
|
|
@@ -1159,33 +1141,30 @@ class AssetManager {
|
|
|
1159
1141
|
}
|
|
1160
1142
|
loadFile(filepath = '', onLoadFinished) {
|
|
1161
1143
|
const loader = new FileLoader();
|
|
1162
|
-
loader.load(filepath,
|
|
1163
|
-
onLoadFinished(data);
|
|
1164
|
-
});
|
|
1144
|
+
loader.load(filepath, onLoadFinished);
|
|
1165
1145
|
}
|
|
1166
1146
|
addAsset(asset, referenceCount = 0) {
|
|
1167
1147
|
if (asset instanceof BufferGeometry) {
|
|
1168
1148
|
return this.addGeometryAsset(asset, referenceCount);
|
|
1169
1149
|
}
|
|
1170
|
-
|
|
1150
|
+
if (asset instanceof Material) {
|
|
1171
1151
|
return this.addMaterialAsset(asset, referenceCount);
|
|
1172
1152
|
}
|
|
1173
|
-
|
|
1153
|
+
if (asset instanceof Texture) {
|
|
1174
1154
|
return this.addTextureAsset(asset, referenceCount);
|
|
1175
1155
|
}
|
|
1176
1156
|
return undefined;
|
|
1177
1157
|
}
|
|
1178
1158
|
addMaterialAsset(asset, referenceCount = 0) {
|
|
1179
|
-
let pointer =
|
|
1159
|
+
let pointer = asset.userData["assetPointer"];
|
|
1180
1160
|
if (!pointer) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
const value = asset[k];
|
|
1161
|
+
const textureMap = new Map();
|
|
1162
|
+
Object.entries(asset).forEach(([key, value]) => {
|
|
1184
1163
|
if (value instanceof Texture) {
|
|
1185
|
-
|
|
1186
|
-
textureMap.set(
|
|
1164
|
+
const texturePointer = this.addTextureAsset(value, 1);
|
|
1165
|
+
textureMap.set(key, texturePointer);
|
|
1187
1166
|
}
|
|
1188
|
-
}
|
|
1167
|
+
});
|
|
1189
1168
|
pointer = new MaterialAssetPointer(asset, textureMap, referenceCount);
|
|
1190
1169
|
this.materialAssets.set(asset.uuid, pointer);
|
|
1191
1170
|
}
|
|
@@ -1195,7 +1174,7 @@ class AssetManager {
|
|
|
1195
1174
|
return pointer;
|
|
1196
1175
|
}
|
|
1197
1176
|
addTextureAsset(asset, referenceCount = 0) {
|
|
1198
|
-
let pointer =
|
|
1177
|
+
let pointer = asset.userData["assetPointer"];
|
|
1199
1178
|
if (!pointer) {
|
|
1200
1179
|
pointer = new TextureAssetPointer(asset, referenceCount);
|
|
1201
1180
|
this.textureAssets.set(asset.uuid, pointer);
|
|
@@ -1206,7 +1185,7 @@ class AssetManager {
|
|
|
1206
1185
|
return pointer;
|
|
1207
1186
|
}
|
|
1208
1187
|
addGeometryAsset(asset, referenceCount = 0) {
|
|
1209
|
-
let pointer =
|
|
1188
|
+
let pointer = asset.userData["assetPointer"];
|
|
1210
1189
|
if (!pointer) {
|
|
1211
1190
|
pointer = new GeometryAssetPointer(asset, referenceCount);
|
|
1212
1191
|
this.geometryAssets.set(asset.uuid, pointer);
|
|
@@ -1217,34 +1196,21 @@ class AssetManager {
|
|
|
1217
1196
|
return pointer;
|
|
1218
1197
|
}
|
|
1219
1198
|
releaseAsset(asset) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
p.release();
|
|
1199
|
+
const pointer = asset.userData["assetPointer"];
|
|
1200
|
+
if (pointer) {
|
|
1201
|
+
pointer.release();
|
|
1224
1202
|
}
|
|
1225
1203
|
else {
|
|
1226
1204
|
asset.dispose();
|
|
1227
1205
|
}
|
|
1228
1206
|
}
|
|
1229
1207
|
clearAssets() {
|
|
1230
|
-
this.geometryAssets.forEach((
|
|
1231
|
-
p.forceRelease();
|
|
1232
|
-
});
|
|
1208
|
+
this.geometryAssets.forEach((pointer) => pointer.forceRelease());
|
|
1233
1209
|
this.geometryAssets.clear();
|
|
1234
|
-
this.materialAssets.forEach((
|
|
1235
|
-
p.forceRelease();
|
|
1236
|
-
});
|
|
1210
|
+
this.materialAssets.forEach((pointer) => pointer.forceRelease());
|
|
1237
1211
|
this.materialAssets.clear();
|
|
1238
|
-
this.textureAssets.forEach((
|
|
1239
|
-
p.forceRelease();
|
|
1240
|
-
});
|
|
1212
|
+
this.textureAssets.forEach((pointer) => pointer.forceRelease());
|
|
1241
1213
|
this.textureAssets.clear();
|
|
1242
|
-
// let pointers = Array.from(this.assetPointer.values());
|
|
1243
|
-
// pointers.forEach((p) =>
|
|
1244
|
-
// {
|
|
1245
|
-
// p.forceRelease();
|
|
1246
|
-
// });
|
|
1247
|
-
// this.assetPointer.clear();
|
|
1248
1214
|
}
|
|
1249
1215
|
}
|
|
1250
1216
|
|
|
@@ -19,13 +19,13 @@ export declare class AssetManager {
|
|
|
19
19
|
get LoadingManager(): LoadingManager;
|
|
20
20
|
init(): Promise<void>;
|
|
21
21
|
setupDracoLoader(dracoPath: string): void;
|
|
22
|
-
convertThreeObjectToLYObject(parentLYComponent: SceneComponent, threejsObject:
|
|
22
|
+
convertThreeObjectToLYObject(parentLYComponent: SceneComponent, threejsObject: Object3D): SceneComponent | null;
|
|
23
23
|
collectResourcesAndReferences(object: Object3D): void;
|
|
24
24
|
checkMeshResource(mesh: Mesh): void;
|
|
25
25
|
loadGltfFromPathAsync(path: string): Promise<GLTF>;
|
|
26
26
|
loadGltfFromPath(path: string, onLoadFinished: (gltf: GLTF) => void): void;
|
|
27
27
|
loadGltfFromBuffer(data: ArrayBuffer | string, path: string, onLoadFinished: (gltf: GLTF) => void): void;
|
|
28
|
-
loadFile(filepath: string | undefined, onLoadFinished: (data:
|
|
28
|
+
loadFile(filepath: string | undefined, onLoadFinished: (data: string | ArrayBuffer) => void): void;
|
|
29
29
|
addAsset(asset: BufferGeometry | Material | Texture, referenceCount?: number): TAssetPointer<BufferGeometry | Material | Texture> | undefined;
|
|
30
30
|
addMaterialAsset(asset: Material, referenceCount?: number): MaterialAssetPointer;
|
|
31
31
|
addTextureAsset(asset: Texture, referenceCount?: number): TextureAssetPointer;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseObject } from "./BaseObject";
|
|
1
|
+
import { Euler, Matrix4, Quaternion, Vector3 } from "three/webgpu";
|
|
3
2
|
import { AttachmentRules } from "../Defines";
|
|
4
|
-
import {
|
|
3
|
+
import { BaseObject } from "./BaseObject";
|
|
5
4
|
import { World } from "../Frame/World";
|
|
6
5
|
import { ThreeJsApp } from "../ThreeJsApp";
|
|
6
|
+
import { SceneComponent } from "./Components/SceneComponent";
|
|
7
7
|
export declare class Actor extends BaseObject {
|
|
8
8
|
get world(): World | null;
|
|
9
9
|
get name(): string;
|