Skip to content

Commit dbb27af

Browse files
committed
v5.3.0
1 parent 5d7d1f4 commit dbb27af

12 files changed

Lines changed: 102 additions & 42 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ It includes built-in templates, including a Next.js template, allowing you to by
1515

1616
## Download
1717

18-
**v5.2.5**
18+
**v5.3.0**
1919

20-
- Windows x64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor%20Setup%205.2.5.exe
21-
- macOS Apple Chip: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.2.5-arm64.dmg
22-
- macOS Intel Chip: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/x64/BabylonJS%20Editor-5.2.5.dmg
23-
- Linux x64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.2.5.AppImage
24-
- Linux arm64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.2.5-arm64.AppImage
20+
- Windows x64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor%20Setup%205.3.0.exe
21+
- macOS Apple Chip: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.3.0-arm64.dmg
22+
- macOS Intel Chip: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/x64/BabylonJS%20Editor-5.3.0.dmg
23+
- Linux x64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.3.0.AppImage
24+
- Linux arm64: https://babylonjs-editor.fra1.cdn.digitaloceanspaces.com/updates/BabylonJS%20Editor-5.3.0-arm64.AppImage
2525

2626
## Prerequisites
2727

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babylonjs-editor-cli",
3-
"version": "5.2.5",
3+
"version": "5.3.0",
44
"description": "Babylon.js Editor CLI is a command line interface to help you package your scenes made using the Babylon.js Editor",
55
"productName": "Babylon.js Editor CLI",
66
"scripts": {

cli/src/pack/assets/ktx.mts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function getCompressedTextureFilename(path: string, format: KTXToolsType)
5353

5454
export type CompressFileToKtxOptions = {
5555
format: KTXToolsType;
56+
compressedTexturesEnabled: boolean;
5657
force?: boolean;
5758
exportedAssets?: string[];
5859
destinationFolder?: string;
@@ -67,7 +68,7 @@ export async function compressFileToKtx(absolutePath: string, options: Partial<C
6768
compressFileToKtxFormat(absolutePath, {
6869
...options,
6970
format: f,
70-
})
71+
} as CompressFileToKtxOptions)
7172
)
7273
);
7374
}
@@ -86,10 +87,10 @@ export async function compressFileToKtxFormat(absolutePath: string, options: Com
8687
options.destinationFolder ??= dirname(absolutePath);
8788
options.destinationFolder = join(options.destinationFolder, filename);
8889

89-
// if (!editor.state.compressedTexturesEnabled) {
90-
// options.exportedAssets?.push(options.destinationFolder);
91-
// return null;
92-
// }
90+
if (!options.compressedTexturesEnabled) {
91+
options.exportedAssets?.push(options.destinationFolder);
92+
return null;
93+
}
9394

9495
if ((await fs.pathExists(options.destinationFolder)) && !options.force) {
9596
options.exportedAssets?.push(options.destinationFolder);

cli/src/pack/assets/process.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export async function processAssetFile(file: string, options: IProcessAssetFileO
7878

7979
options.exportedAssets.push(finalPath);
8080

81-
if (options.optimize && options.compressedTexturesEnabled) {
81+
if (options.optimize) {
8282
await compressFileToKtx(finalPath, {
8383
force: isNewFile,
84-
exportedAssets: options.exportedAssets,
84+
...options,
8585
});
8686
}
8787

cli/src/pack/assets/texture.mts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ export async function processExportedTexture(absolutePath: string, options: ICom
8787
}
8888
}
8989

90-
if (options.compressedTexturesEnabled) {
91-
await compressFileToKtx(finalPath, {
92-
...options,
93-
});
94-
}
90+
await compressFileToKtx(finalPath, {
91+
...options,
92+
});
9593
}
9694
}

cli/src/pack/pack.mts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,15 @@ export async function pack(projectDir: string, options: IPackOptions) {
200200
});
201201

202202
// Clean
203-
const publicFiles = await normalizedGlob(join(publicDir, "**/*"), {
204-
nodir: true,
205-
});
203+
if (options.optimize) {
204+
const publicFiles = await normalizedGlob(join(publicDir, "**/*"), {
205+
nodir: true,
206+
});
206207

207-
publicFiles.forEach((file) => {
208-
if (!exportedAssets.includes(file.toString())) {
209-
fs.remove(file);
210-
}
211-
});
208+
publicFiles.forEach((file) => {
209+
if (!exportedAssets.includes(file.toString())) {
210+
fs.remove(file);
211+
}
212+
});
213+
}
212214
}

editor/src/editor/dialogs/generate/generate-project.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Component, ReactNode } from "react";
22

3+
import { Grid } from "react-loader-spinner";
4+
35
import { CancellationToken } from "babylonjs-editor-cli";
46

57
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "../../../ui/shadcn/ui/alert-dialog";
@@ -69,7 +71,13 @@ export class EditorGenerateProjectComponent extends Component<IEditorGeneratePro
6971

7072
{this.state.step === "generation" && (
7173
<AlertDialogCancel disabled={this.state.cancellationToken?.isCanceled} className="w-32 hover:bg-red-500" onClick={() => this._cancel()}>
72-
Stop
74+
{this.state.cancellationToken?.isCanceled && (
75+
<div className="flex items-center gap-2">
76+
<Grid width={16} height={16} color="gray" />
77+
<div>Stopping...</div>
78+
</div>
79+
)}
80+
{!this.state.cancellationToken?.isCanceled && "Stop"}
7381
</AlertDialogCancel>
7482
)}
7583

editor/src/editor/dialogs/generate/generate.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ export function EditorGenerateComponent(props: IEditorGenerateComponentProps) {
131131
{status.assets.success && <FaCheckCircle />}
132132
{!status.assets.success && status.assets.message && <Grid width={24} height={24} color="gray" />}
133133

134-
<div className="flex flex-col">
135-
<AlertTitle>Assets</AlertTitle>
134+
<div className="flex flex-col w-full">
135+
<AlertTitle className="flex justify-between">
136+
<div>Assets</div> ({packProgress.toFixed(2)}%)
137+
</AlertTitle>
136138
<AlertDescription className="w-72 overflow-hidden text-ellipsis whitespace-nowrap">{status.assets.message ?? "..."}</AlertDescription>
137139
</div>
138140
</Alert>
@@ -194,7 +196,9 @@ export function EditorGenerateComponent(props: IEditorGenerateComponentProps) {
194196
{!status.upload.success && status.upload.message && <Grid width={24} height={24} color="gray" />}
195197

196198
<div className="flex flex-col">
197-
<AlertTitle>Upload to S3</AlertTitle>
199+
<AlertTitle className="flex justify-between">
200+
<div>Upload to S3</div> ({uploadProgress.toFixed(2)}%)
201+
</AlertTitle>
198202
<AlertDescription className="w-72 overflow-hidden text-ellipsis whitespace-nowrap">{status.upload.message ?? "..."}</AlertDescription>
199203
</div>
200204
</Alert>

editor/src/project/load/install.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,31 @@ export async function installBabylonJSEditorTools(packageManager: EditorProjectP
5555
const p = await execNodePty(command, { cwd });
5656
return p.wait();
5757
}
58+
59+
/**
60+
* Installs the babylonjs-editor-cli package that matches the given version.
61+
* The given version is mostly the current version of the editor.
62+
* @param packageManager defines the package manager to use for installation.
63+
* @param cwd defines absolute path to the working directory where to install the dependencies.
64+
* @param version defines the version of babylonjs-editor-cli to install.
65+
*/
66+
export async function installBabylonJSEditorCLI(packageManager: EditorProjectPackageManager, cwd: string, version: string) {
67+
let command = "";
68+
switch (packageManager) {
69+
case "npm":
70+
command = `npm install --save-dev babylonjs-editor-cli@${version}`;
71+
break;
72+
case "pnpm":
73+
command = `pnpm add -D babylonjs-editor-cli@${version}`;
74+
break;
75+
case "bun":
76+
command = `bun add --dev babylonjs-editor-cli@${version}`;
77+
break;
78+
default:
79+
command = `yarn add -D babylonjs-editor-cli@${version}`;
80+
break;
81+
}
82+
83+
const p = await execNodePty(command, { cwd });
84+
return p.wait();
85+
}

editor/src/project/load/load.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { projectConfiguration } from "../configuration";
1414

1515
import { loadScene } from "./scene";
1616
import { LoadScenePrepareComponent } from "./prepare";
17-
import { installBabylonJSEditorTools, installDependencies } from "./install";
17+
import { installBabylonJSEditorCLI, installBabylonJSEditorTools, installDependencies } from "./install";
1818

1919
/**
2020
* Loads an editor project located at the given path. Typically called at startup when opening
@@ -93,26 +93,45 @@ export async function checkDependencies(
9393
toast.warning(`Package manager "${packageManager}" is not available on your system. Dependencies will not be updated.`);
9494
}
9595

96+
const cliPackageJsonPath = join(directory, "node_modules/babylonjs-editor-cli/package.json");
9697
const toolsPackageJsonPath = join(directory, "node_modules/babylonjs-editor-tools/package.json");
9798

98-
let matchesVersion = false;
99+
let matchesToolsVersion = false;
99100
try {
100101
const toolsPackageJson = await readJSON(toolsPackageJsonPath, "utf-8");
101102
if (toolsPackageJson.version === packageJson.version) {
102-
matchesVersion = true;
103+
matchesToolsVersion = true;
104+
}
105+
} catch (e) {
106+
// Catch silently
107+
}
108+
109+
let matchesCliVersion = false;
110+
try {
111+
const cliPackageJson = await readJSON(cliPackageJsonPath, "utf-8");
112+
if (cliPackageJson.version === packageJson.version) {
113+
matchesCliVersion = true;
103114
}
104115
} catch (e) {
105116
// Catch silently
106117
}
107118

108119
let toolsCode = 0;
109-
if (!matchesVersion) {
120+
if (!matchesToolsVersion) {
110121
toolsCode = await installBabylonJSEditorTools(packageManager, directory, packageJson.version);
111122
if (toolsCode !== 0) {
112123
toast.warning(`Package manager "${packageManager}" is not available on your system. Can't install "babylonjs-editor-tools" package dependency.`);
113124
}
114125
}
115126

127+
if (!matchesCliVersion) {
128+
installBabylonJSEditorCLI(packageManager, directory, packageJson.version).then((code) => {
129+
if (code !== 0) {
130+
toast.warning(`Package manager "${packageManager}" is not available on your system. Can't install "babylonjs-editor-cli" package dependency.`);
131+
}
132+
});
133+
}
134+
116135
toast.dismiss(toastId);
117136

118137
if (installCode === 0 && toolsCode === 0) {

0 commit comments

Comments
 (0)