Skip to content

Commit 4df279d

Browse files
committed
feat(asset-bundle): fix "assembled sab->gameObject->texture->flipY not equal (generated single sab)sab->gameObject->texture->flipY" bug
description assembled sab->gameObject->texture->flipY not equal (generated single sab)sab->gameObject->texture->flipY reason 1.assembled sab->gameObject->texture is created new one, not use the dependency rab->texture! 2.assembled sab->gameObject->texture->flipY is set to be false when create(BatchCreateSystem->_batchCreateBasicSourceTexture), while the origin->flipY is true. solution 1.WDType,GLTFType->texture data add "flipY" 2.not set flipY to be false when create(BatchCreateSystem->_batchCreateBasicSourceTexture)
1 parent 2ac5441 commit 4df279d

File tree

20 files changed

+396
-77
lines changed

20 files changed

+396
-77
lines changed
12 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

src/asset/assemble/BatchCreateSystem.re

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -141,36 +141,18 @@ let _batchCreateBasicSourceTexture =
141141
basicSourceTextureRecord.disposedIndexArray,
142142
);
143143

144-
let (state, indexArr) =
145-
basicSourceTextures
146-
|> ArrayService.reduceOneParamValidi(
147-
(. (state, indexArr), _, basicSourceTextureIndex) => {
148-
let (state, index) =
149-
CreateBasicSourceTextureMainService.create(. state);
144+
basicSourceTextures
145+
|> ArrayService.reduceOneParamValidi(
146+
(. (state, indexArr), _, basicSourceTextureIndex) => {
147+
let (state, index) =
148+
CreateBasicSourceTextureMainService.create(. state);
150149

151-
Array.unsafe_set(indexArr, basicSourceTextureIndex, index);
150+
Array.unsafe_set(indexArr, basicSourceTextureIndex, index);
152151

153-
(state, indexArr);
154-
},
155-
(state, [||]),
156-
);
157-
158-
/* let (state, indexArr) =
159-
_batchCreateComponent(
160-
basicSourceTextures,
161-
CreateBasicSourceTextureMainService.create,
162-
state,
163-
); */
164-
165-
let state =
166-
indexArr
167-
|> WonderCommonlib.ArrayService.reduceOneParam(
168-
(. state, index) =>
169-
OperateBasicSourceTextureMainService.setFlipY(index, false, state),
170-
state,
171-
);
172-
173-
(state, indexArr);
152+
(state, indexArr);
153+
},
154+
(state, [||]),
155+
);
174156
};
175157

176158
let _batchCreateLightComponent = (components, createFunc, state) =>

src/asset/assemble/BatchOperateStreamSystem.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ let batchOperate =
118118
);
119119

120120
let state =
121-
BatchSetTextureAllDataSystem.batchSetFormat(
121+
BatchSetTextureAllDataSystem.batchSetFormatAndFlipY(
122122
basicSourceTextureArr,
123123
basicSourceTextures,
124124
state,

src/asset/assemble/BatchOperateWholeSystem.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let batchOperate =
149149
);
150150

151151
let state =
152-
BatchSetTextureAllDataSystem.batchSetFormat(
152+
BatchSetTextureAllDataSystem.batchSetFormatAndFlipY(
153153
basicSourceTextureArr,
154154
basicSourceTextures,
155155
state,

src/asset/assemble/BatchSetTextureAllDataSystem.re

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,22 @@ let batchSetBasicSourceTextureData =
110110
state,
111111
);
112112

113-
let batchSetFormat = (basicSourceTextureArr, basicSourceTextures, state) =>
113+
let batchSetFormatAndFlipY =
114+
(basicSourceTextureArr, basicSourceTextures, state) =>
114115
basicSourceTextureArr
115116
|> ArrayService.reduceOneParamValidi(
116-
(. state, basicSourceTexture, index) =>
117-
OperateBasicSourceTextureMainService.setFormat(
118-
basicSourceTexture,
119-
Array.unsafe_get(basicSourceTextures, index).format
120-
|> SourceTextureType.formatToUint8,
121-
state,
122-
),
117+
(. state, basicSourceTexture, index) => {
118+
let {format, flipY} = Array.unsafe_get(basicSourceTextures, index);
119+
120+
state
121+
|> OperateBasicSourceTextureMainService.setFormat(
122+
basicSourceTexture,
123+
format |> SourceTextureType.formatToUint8,
124+
)
125+
|> OperateBasicSourceTextureMainService.setFlipY(
126+
basicSourceTexture,
127+
flipY,
128+
);
129+
},
123130
state,
124131
);

src/asset/converter/ConvertGLTFJsonToRecordSystem.re

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ let _convertTextures = json =>
8181
name: json |> optional(field("name", string)),
8282
sampler: json |> optional(field("sampler", int)),
8383
source: json |> optional(field("source", int)),
84+
extras:
85+
json
86+
|> optional(
87+
field("extras", json =>
88+
{flipY: json |> field("flipY", bool)}
89+
),
90+
),
8491
}
8592
),
8693
),

src/asset/converter/ConvertMeshRenderersSystem.re

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,27 @@ let convertToMeshRenderers =
3838
{extras, meshes}: GLTFType.gltf,
3939
) =>
4040
switch (extras) {
41-
| None => _convertByMesh(meshes, geometryGameObjectIndices, geometryIndices)
42-
| Some({meshRenderers}) =>
43-
switch (meshRenderers) {
44-
| Some(meshRenderers) when Js.Array.length(meshRenderers) > 0 =>
45-
meshRenderers
46-
|> WonderCommonlib.ArrayService.reduceOneParami(
47-
(. arr, {drawMode, isRender}: GLTFType.meshRenderer, index) =>
48-
arr
49-
|> ArrayService.push(
50-
Some(
51-
{
52-
drawMode: drawMode |> DrawModeType.uint8ToDrawMode,
53-
isRender,
54-
}: WDType.meshRenderer,
55-
),
41+
| Some({meshRenderers})
42+
when
43+
meshRenderers
44+
|> Js.Option.isSome
45+
&& meshRenderers
46+
|> OptionService.unsafeGet
47+
|> Js.Array.length > 0 =>
48+
meshRenderers
49+
|> OptionService.unsafeGet
50+
|> WonderCommonlib.ArrayService.reduceOneParami(
51+
(. arr, {drawMode, isRender}: GLTFType.meshRenderer, index) =>
52+
arr
53+
|> ArrayService.push(
54+
Some(
55+
{
56+
drawMode: drawMode |> DrawModeType.uint8ToDrawMode,
57+
isRender,
58+
}: WDType.meshRenderer,
5659
),
57-
[||],
58-
)
59-
| _ => _convertByMesh(meshes, geometryGameObjectIndices, geometryIndices)
60-
}
60+
),
61+
[||],
62+
)
63+
| _ => _convertByMesh(meshes, geometryGameObjectIndices, geometryIndices)
6164
};

src/asset/converter/ConvertTexturesSystem.re

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ let convertToBasicSourceTextures =
5454
| Some(textures) =>
5555
textures
5656
|> WonderCommonlib.ArrayService.reduceOneParami(
57-
(. arr, ({name, source}: GLTFType.texture) as texture, index) =>
57+
(.
58+
arr,
59+
({name, source, extras}: GLTFType.texture) as texture,
60+
index,
61+
) =>
5862
switch (source) {
5963
| None => arr
6064
| Some(source) =>
@@ -88,6 +92,12 @@ let convertToBasicSourceTextures =
8892

8993
_getFormat(mimeType |> OptionService.unsafeGet);
9094
},
95+
/* TODO test */
96+
flipY:
97+
switch (extras) {
98+
| Some({flipY}) => flipY
99+
| None => false
100+
},
91101
}: WDType.basicSourceTexture,
92102
);
93103

@@ -163,7 +173,7 @@ let _convertWrap = wrap =>
163173
}
164174
};
165175

166-
let convertToSamplers = ({samplers}: GLTFType.gltf) : array(WDType.sampler) =>
176+
let convertToSamplers = ({samplers}: GLTFType.gltf): array(WDType.sampler) =>
167177
switch (samplers) {
168178
| None => [||]
169179
| Some(samplers) =>

src/asset/data/GLTFType.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,13 @@ type sampler = {
144144
wrapT: option(int),
145145
};
146146

147+
type textureExtra = {flipY: bool};
148+
147149
type texture = {
148150
sampler: option(samplerIndex),
149151
source: option(imageIndex),
150152
name: option(string),
153+
extras: option(textureExtra),
151154
};
152155

153156
type textureInfo = {

0 commit comments

Comments
 (0)