diff --git a/src/Add-on/KJL/KJLImportConfig/KJLImportConfigStore.ts b/src/Add-on/KJL/KJLImportConfig/KJLImportConfigStore.ts index 6e6de8de7..3d4eadd89 100644 --- a/src/Add-on/KJL/KJLImportConfig/KJLImportConfigStore.ts +++ b/src/Add-on/KJL/KJLImportConfig/KJLImportConfigStore.ts @@ -96,6 +96,7 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore UpdateOption(cof: IConfigOption) { this.UpdataVersion(cof); + this.materialList = []; Object.assign(this.m_Option, cof.option); if (this.uiOption) this.uiOption = { @@ -159,16 +160,19 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore this.materialList.push({ keyIndex: i, kjlName: mtl.kjlName, materialName: "", url: "", isSelect: false, isRender: false }); } - await this.AsyncLoadMaterials(); + await this.AsyncLoadMaterials(0); }); }; - AsyncLoadMaterials = async () => + AsyncLoadMaterials = async (startIndex: number) => { this.queue.clear(); - for (let i = 0, length = this.m_Option.materials.length; i < length; i++) + for (let i = startIndex; i < startIndex + 11; i++) { + if (i >= this.m_Option.materials.length) continue; let mtl = this.m_Option.materials[i]; + if (!mtl || !mtl.id) continue; + let mtlInfo = this.materialList[i]; this.queue.add(async () => { let promise: Promise<{ materialName: string, url: string; }>; @@ -183,7 +187,7 @@ export class KJLImportConfigStore extends Singleton implements IConfigStore } let { materialName, url } = await promise; - this.materialList[i] = { keyIndex: i, kjlName: mtl.kjlName, materialName, url, isSelect: false, isRender: true }; + Object.assign(mtlInfo, { keyIndex: i, kjlName: mtl.kjlName, materialName, url, isSelect: false, isRender: true }); }); } }; diff --git a/src/Add-on/KJL/KJLImportConfig/KJLMaterialMap.tsx b/src/Add-on/KJL/KJLImportConfig/KJLMaterialMap.tsx index ac888b7aa..f23932984 100644 --- a/src/Add-on/KJL/KJLImportConfig/KJLMaterialMap.tsx +++ b/src/Add-on/KJL/KJLImportConfig/KJLMaterialMap.tsx @@ -8,17 +8,39 @@ import { KJLMaterialMapData } from "./KJLMaterialMapData"; @observer export class KJLMaterialMap extends React.Component<{ store: KJLImportConfigStore; }> { + private scrollEl = React.createRef(); + private timer = null; componentWillUnmount(): void { this.props.store.materialMap.clear(); } + render() { let store = this.props.store; return (
酷家乐材质映射
-
+
+ { + if (this.timer !== null) + { + clearTimeout(this.timer); + } + this.timer = setTimeout(() => + { + if (this.scrollEl.current) + { + let scrollTop = this.scrollEl.current.scrollTop; + let index = Math.max(Math.floor((scrollTop - 30) / 52) - 1, 0); + this.props.store.AsyncLoadMaterials(index); + } + this.timer = null; + }, 100); + }} + >