Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Model IO Fixes #8280

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions packages/editor/src/components/assets/ImageConvertPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Dialog, DialogTitle, Grid, Typography } from '@mui/material'

import BooleanInput from '../inputs/BooleanInput'
import { Button } from '../inputs/Button'
import NumericInput from '../inputs/NumericInput'
import SelectInput from '../inputs/SelectInput'
import styles from './styles.module.scss'

Expand Down Expand Up @@ -97,9 +98,31 @@ export default function ImageConvertPanel({
onChange={(val: boolean) => convertProperties.resize.set(val)}
/>
</Grid>
<Grid item xs={12}>
<Button onClick={convertImage}> Convert </Button>
</Grid>
{convertProperties.resize.value && (
<>
<Grid item xs={4}>
<Typography className={styles.secondaryText}>Width</Typography>
</Grid>
<Grid item xs={8}>
<NumericInput
value={convertProperties.width.value}
onChange={(val: number) => convertProperties.width.set(val)}
/>
</Grid>
<Grid item xs={4}>
<Typography className={styles.secondaryText}>Height</Typography>
</Grid>
<Grid item xs={8}>
<NumericInput
value={convertProperties.height.value}
onChange={(val: number) => convertProperties.height.set(val)}
/>
</Grid>
<Grid item xs={12}>
<Button onClick={convertImage}> Convert </Button>
</Grid>
</>
)}
</Grid>
</Dialog>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default class BasisuExporterExtension extends ExporterExtension implement
writeTexture(_texture: CompressedTexture, textureDef) {
if (!_texture?.isCompressedTexture) return
const writer = this.writer
_texture.encoding = LinearEncoding
writer.pending.push(
new Promise((resolve) => {
createReadableTexture(_texture, { canvas: true, flipY: true }).then((texture: Texture) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function blitTexture(map: Texture, options?: BlitTextureOptions | undefined) {
if ((map as CubeTexture).isCubeTexture) {
blit = new Texture(map.source.data[0])
}
map.encoding = LinearEncoding
const temporaryRenderer = getTemporaryRenderer()
const temporaryScene = getTemporaryScene()
if (options?.keepTransform) {
Expand Down Expand Up @@ -206,5 +205,6 @@ export default async function createReadableTexture(
}
finalTexture.wrapS = map.wrapS
finalTexture.wrapT = map.wrapT
finalTexture.encoding = map.encoding
return finalTexture
}
3 changes: 1 addition & 2 deletions packages/engine/src/scene/components/ModelComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function ModelReactor() {
if (source === model.scene?.userData?.src) return

try {
if (model.scene && model.scene.userData.src && model.scene.userData.src !== model.src) {
if (model.scene)
try {
removeMaterialSource({ type: SourceType.MODEL, path: model.scene.userData.src })
} catch (e) {
Expand All @@ -124,7 +124,6 @@ function ModelReactor() {
throw e
}
}
}
if (!model.src) return

const uuid = getComponent(entity, UUIDComponent)
Expand Down