Skip to content

Commit 3217b6c

Browse files
committed
feat(texture): basicSourceTextureAPI add disposeBasicSourceTexture;
publish npm
1 parent 8b2ea84 commit 3217b6c

File tree

13 files changed

+184
-12
lines changed

13 files changed

+184
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wonder.js",
3-
"version": "1.1.0-alpha.10",
3+
"version": "1.1.0-alpha.11",
44
"authors": "Wonder",
55
"description": "3d webgl engine",
66
"homepage": "https://github.com/Wonder-Technology/Wonder.js",

src/api/texture/BasicSourceTextureAPI.re

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,11 @@ let getAllTextures = state => {
425425
RecordBasicSourceTextureMainService.getRecord(state);
426426

427427
GetAllComponentService.getAllComponents(index, disposedIndexArray);
428-
};
428+
};
429+
430+
let disposeBasicSourceTexture = (texture, isRemoveTexture, state) =>
431+
DisposeBasicSourceTextureMainService.handleDisposeTexture(
432+
texture,
433+
isRemoveTexture,
434+
state,
435+
);

src/service/record/main/texture/GroupBasicSourceTextureService.re

100644100755
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,12 @@ let removeMaterial = (materialData, texture, {materialsMap} as record) => {
1717
...record,
1818
materialsMap:
1919
GroupTextureService.removeMaterial(materialData, texture, materialsMap),
20-
};
20+
};
21+
22+
let clearMaterial = (texture, {materialsMap} as record) => {
23+
...record,
24+
materialsMap: GroupTextureService.clearMaterial(texture, materialsMap),
25+
};
26+
27+
let getMaterialDataArr = (texture, {materialsMap} as record) =>
28+
MaterialsMapService.getMaterialDataArr(texture, materialsMap);

src/service/record/main/texture/GroupTextureService.re

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ let isGroup = (texture, materialsMap) =>
88
};
99

1010
let removeMaterial = (materialData, texture, materialsMap) =>
11-
MaterialsMapService.removeMaterial(materialData, texture, materialsMap);
11+
MaterialsMapService.removeMaterial(materialData, texture, materialsMap);
12+
13+
14+
let clearMaterial = ( texture, materialsMap) =>
15+
MaterialsMapService.clearMaterial( texture, materialsMap);

src/service/record/main/texture/MaterialsMapService.re

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ let removeMaterial = ((material, materialType), texture, materialsMap) => {
3838
),
3939
) :
4040
materialsMap;
41-
};
41+
};
42+
43+
let clearMaterial = (texture, materialsMap) =>
44+
materialsMap |> WonderCommonlib.MutableSparseMapService.deleteVal(texture);

src/service/state/main/texture/DisposeTextureMainService.re

100644100755
File mode changed.

src/service/state/main/texture/GroupTextureMainService.re

100644100755
File mode changed.

src/service/state/main/texture/basic_source/DisposeBasicSourceTextureMainService.re

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,75 @@ let handleDispose = (isRemoveTexture, materialData, textureArr, state) => {
176176
},
177177
state,
178178
);
179+
};
180+
181+
let handleDisposeTexture = ( texture, isRemoveTexture, state) => {
182+
WonderLog.Contract.requireCheck(
183+
() =>
184+
WonderLog.(
185+
Contract.(
186+
Operators.(
187+
DisposeComponentService.checkComponentShouldAlive(
188+
texture,
189+
isAlive,
190+
state |> RecordBasicSourceTextureMainService.getRecord,
191+
)
192+
)
193+
)
194+
),
195+
IsDebugMainService.getIsDebug(StateDataMain.stateData),
196+
);
197+
198+
let basicSourceTextureRecord =
199+
RecordBasicSourceTextureMainService.getRecord(state);
200+
201+
let basicSourceTextureRecord =
202+
GroupBasicSourceTextureService.clearMaterial(
203+
texture,
204+
basicSourceTextureRecord,
205+
);
206+
207+
isRemoveTexture ?
208+
{...state, basicSourceTextureRecord: Some(basicSourceTextureRecord)} :
209+
{
210+
let state = state |> _disposeData(texture);
211+
212+
let basicSourceTextureRecord =
213+
RecordBasicSourceTextureMainService.getRecord(state);
214+
215+
{
216+
...state,
217+
basicSourceTextureRecord:
218+
Some({
219+
...basicSourceTextureRecord,
220+
disposedIndexArray:
221+
DisposeTextureService.addDisposeIndex(
222+
texture,
223+
basicSourceTextureRecord.disposedIndexArray,
224+
),
225+
}),
226+
};
227+
}
228+
|> WonderLog.Contract.ensureCheck(
229+
state =>
230+
WonderLog.(
231+
Contract.(
232+
Operators.(
233+
test(
234+
Log.buildAssertMessage(
235+
~expect={j|texture:$texture not to be group|j},
236+
~actual={j|is|j},
237+
),
238+
() =>
239+
GroupBasicSourceTextureService.isGroupBasicSourceTexture(
240+
texture,
241+
RecordBasicSourceTextureMainService.getRecord(state),
242+
)
243+
|> assertFalse
244+
)
245+
)
246+
)
247+
),
248+
IsDebugMainService.getIsDebug(StateDataMain.stateData),
249+
);
179250
};

src/service/state/render_worker/texture/DisposeTextureRenderWorkerService.re

100644100755
File mode changed.

test/integration/worker/job/render_worker/tool/DeviceManagerRenderWorkerTool.re

100644100755
File mode changed.

0 commit comments

Comments
 (0)