1
This commit is contained in:
15
index.html
15
index.html
@ -352,10 +352,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="category-content">
|
<div class="category-content">
|
||||||
<div class="option-group">
|
<div class="option-group">
|
||||||
<button class="option-btn" data-option="color-1">SPF111S1010C</button>
|
13
|
||||||
<button class="option-btn" data-option="color-2">SPF111S1010W</button>
|
<button class="option-btn" data-option="color-1">SPF111S1013W</button>
|
||||||
|
<button class="option-btn" data-option="color-2">SPF111S1013C</button>
|
||||||
|
<button class="option-btn" data-option="color-3">SPF111S1013TA</button>
|
||||||
|
10
|
||||||
|
<button class="option-btn" data-option="color-1">SPF111S1010W</button>
|
||||||
|
<button class="option-btn" data-option="color-2">SPF111S1010C</button>
|
||||||
<button class="option-btn" data-option="color-3">SPF111S1010TA</button>
|
<button class="option-btn" data-option="color-3">SPF111S1010TA</button>
|
||||||
<button class="option-btn" data-option="color-4">木色</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -749,9 +754,13 @@
|
|||||||
// 移除按钮事件
|
// 移除按钮事件
|
||||||
document.getElementById('remove-model-btn').addEventListener('click', () => {
|
document.getElementById('remove-model-btn').addEventListener('click', () => {
|
||||||
const pickedMesh = window.getCurrentPickedMesh();
|
const pickedMesh = window.getCurrentPickedMesh();
|
||||||
|
console.log(pickedMesh);
|
||||||
|
|
||||||
if (pickedMesh) {
|
if (pickedMesh) {
|
||||||
const meshName = pickedMesh.name;
|
const meshName = pickedMesh.name;
|
||||||
const modelName = kernel.model.findModelNameByMesh(pickedMesh);
|
const modelName = kernel.model.findModelNameByMesh(pickedMesh);
|
||||||
|
console.log(modelName);
|
||||||
|
|
||||||
const success = kernel.model.removeByName(modelName);
|
const success = kernel.model.removeByName(modelName);
|
||||||
if (success) {
|
if (success) {
|
||||||
console.log('模型已移除');
|
console.log('模型已移除');
|
||||||
|
|||||||
@ -268,9 +268,9 @@ export class AppModel extends Monobehiver {
|
|||||||
*/
|
*/
|
||||||
private async addSingle(modelName: string, modelId: string, modelUrl: string, modelControlType?: ModelControlType, drag?: DragConfig, transform?: ModelTransform): Promise<LoadResult> {
|
private async addSingle(modelName: string, modelId: string, modelUrl: string, modelControlType?: ModelControlType, drag?: DragConfig, transform?: ModelTransform): Promise<LoadResult> {
|
||||||
// 检查是否已存在
|
// 检查是否已存在
|
||||||
const existingMeshes = this.modelDic.Get(modelName+'_'+modelId);
|
const existingMeshes = this.modelDic.Get(modelName + '_' + modelId);
|
||||||
if (existingMeshes?.length && !existingMeshes[0].isDisposed()) {
|
if (existingMeshes?.length && !existingMeshes[0].isDisposed()) {
|
||||||
console.log(`模型 ${modelName+modelId} 已存在,直接显示`);
|
console.log(`模型 ${modelName + modelId} 已存在,直接显示`);
|
||||||
this.showMeshes(existingMeshes);
|
this.showMeshes(existingMeshes);
|
||||||
return { success: true, meshes: existingMeshes };
|
return { success: true, meshes: existingMeshes };
|
||||||
}
|
}
|
||||||
@ -285,11 +285,11 @@ export class AppModel extends Monobehiver {
|
|||||||
this.cloneMaterials(result.meshes, modelId);
|
this.cloneMaterials(result.meshes, modelId);
|
||||||
|
|
||||||
// 存储模型
|
// 存储模型
|
||||||
result.meshes = this.createModelRoot(modelName+'_'+modelId, result.meshes);
|
result.meshes = this.createModelRoot(modelName + '_' + modelId, result.meshes);
|
||||||
this.modelDic.Set(modelName+'_'+modelId, result.meshes);
|
this.modelDic.Set(modelName + '_' + modelId, result.meshes);
|
||||||
|
|
||||||
// 存储元数据
|
// 存储元数据
|
||||||
this.modelMetadataDic.Set(modelName+'_'+modelId, {
|
this.modelMetadataDic.Set(modelName + '_' + modelId, {
|
||||||
modelName: modelName,
|
modelName: modelName,
|
||||||
modelId: modelId,
|
modelId: modelId,
|
||||||
modelUrl: modelUrl,
|
modelUrl: modelUrl,
|
||||||
@ -300,12 +300,12 @@ export class AppModel extends Monobehiver {
|
|||||||
|
|
||||||
// 应用 transform
|
// 应用 transform
|
||||||
if (transform) {
|
if (transform) {
|
||||||
this.applyTransform(modelName+'_'+modelId, transform);
|
this.applyTransform(modelName + '_' + modelId, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置拖拽功能
|
// 配置拖拽功能
|
||||||
if (drag) {
|
if (drag) {
|
||||||
this.mainApp.appModelDrag?.configureDrag(modelName+'_'+modelId, drag);
|
this.mainApp.appModelDrag?.configureDrag(modelName + '_' + modelId, drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 GameManager 的字典
|
// 更新 GameManager 的字典
|
||||||
@ -340,10 +340,10 @@ export class AppModel extends Monobehiver {
|
|||||||
this.cloneMaterials(result.meshes, modelId);
|
this.cloneMaterials(result.meshes, modelId);
|
||||||
|
|
||||||
result.meshes = this.createModelRoot(modelName, result.meshes);
|
result.meshes = this.createModelRoot(modelName, result.meshes);
|
||||||
this.modelDic.Set(modelName+'_'+modelId, result.meshes);
|
this.modelDic.Set(modelName + '_' + modelId, result.meshes);
|
||||||
|
|
||||||
// 存储元数据
|
// 存储元数据
|
||||||
this.modelMetadataDic.Set(modelName+'_'+modelId, {
|
this.modelMetadataDic.Set(modelName + '_' + modelId, {
|
||||||
modelName: modelName,
|
modelName: modelName,
|
||||||
modelId: modelId,
|
modelId: modelId,
|
||||||
modelUrl: modelUrl,
|
modelUrl: modelUrl,
|
||||||
@ -354,12 +354,12 @@ export class AppModel extends Monobehiver {
|
|||||||
|
|
||||||
// 应用 transform
|
// 应用 transform
|
||||||
if (transform) {
|
if (transform) {
|
||||||
this.applyTransform(modelName+'_'+modelId, transform);
|
this.applyTransform(modelName + '_' + modelId, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置拖拽功能
|
// 配置拖拽功能
|
||||||
if (drag) {
|
if (drag) {
|
||||||
this.mainApp.appModelDrag?.configureDrag(modelName+'_'+modelId, drag);
|
this.mainApp.appModelDrag?.configureDrag(modelName + '_' + modelId, drag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,11 +436,6 @@ export class AppModel extends Monobehiver {
|
|||||||
const keys = this.modelDic.Keys();
|
const keys = this.modelDic.Keys();
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
const meshes = this.modelDic.Get(key);
|
const meshes = this.modelDic.Get(key);
|
||||||
meshes.forEach(mesh => {
|
|
||||||
console.log(mesh.uniqueId);
|
|
||||||
console.log(mesh.name);
|
|
||||||
|
|
||||||
});
|
|
||||||
if (meshes?.some(m => m === mesh || m.uniqueId === mesh.uniqueId)) {
|
if (meshes?.some(m => m === mesh || m.uniqueId === mesh.uniqueId)) {
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
@ -501,18 +496,18 @@ export class AppModel extends Monobehiver {
|
|||||||
* 销毁指定模型
|
* 销毁指定模型
|
||||||
* @param modelName 模型名称
|
* @param modelName 模型名称
|
||||||
*/
|
*/
|
||||||
removeByName(modelName: string): void {
|
removeByName(modelName: string): boolean {
|
||||||
const meshes = this.modelDic.Get(modelName);
|
const meshes = this.modelDic.Get(modelName);
|
||||||
if (!meshes?.length) {
|
if (!meshes?.length) {
|
||||||
console.warn(`Model not found: ${modelName}`);
|
console.warn(`Model not found: ${modelName}`);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getModelTransformTargets(meshes).forEach(mesh => mesh.dispose(false, true));
|
this.getModelTransformTargets(meshes).forEach(mesh => mesh.dispose(false, true));
|
||||||
this.modelDic.Remove(modelName);
|
this.modelDic.Remove(modelName);
|
||||||
this.modelMetadataDic.Remove(modelName);
|
this.modelMetadataDic.Remove(modelName);
|
||||||
this.mainApp.gameManager?.updateDictionaries();
|
this.mainApp.gameManager?.updateDictionaries();
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,8 @@ export class KernelAdapter {
|
|||||||
* 销毁指定模型
|
* 销毁指定模型
|
||||||
* @param modelName 模型名称
|
* @param modelName 模型名称
|
||||||
*/
|
*/
|
||||||
removeByName: (modelName: string): void => {
|
removeByName: (modelName: string): boolean => {
|
||||||
this.mainApp.appModel.removeByName(modelName);
|
return this.mainApp.appModel.removeByName(modelName);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 根据网格移除所属的整个模型
|
* 根据网格移除所属的整个模型
|
||||||
|
|||||||
Reference in New Issue
Block a user