Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/camera preview #425

Merged
merged 30 commits into from
Apr 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a0b650b
feat: add support of camera preview
julien-moreau Feb 7, 2023
c425327
feat: add support of "None" for node list in inspector
julien-moreau Mar 1, 2023
b7d117b
feat: keep camera preview opened
julien-moreau Mar 1, 2023
74294bc
feat: add support of doubled size for camera preview
julien-moreau Mar 1, 2023
ab11ffc
feat: add export of "editor" in index.ts so scripts and plugins can i…
julien-moreau Mar 1, 2023
ee53137
style: fix var to const
julien-moreau Mar 2, 2023
7902d89
feat: add support of loading phases for "appendScene" method in tools.ts
julien-moreau Mar 18, 2023
7573b7c
feat: add "scaling" tool type to thin instances painting tool
julien-moreau Mar 22, 2023
283361c
feat: add support of "use last camera" shortcut
julien-moreau Mar 23, 2023
d98f3ca
chore: update to latest Babylon.JS version
julien-moreau Mar 26, 2023
db6fd09
fix: rename wrong whatsnew
julien-moreau Mar 27, 2023
ca60600
fix: clean render targets before saving project to handle null case
julien-moreau Apr 3, 2023
87480d9
fix: limit height for suggestion lists in inspecetor and enable overflow
julien-moreau Apr 4, 2023
b6becff
feat: adding support of video textures
julien-moreau Apr 6, 2023
7464606
feat: improve camera preview sub-panel
julien-moreau Apr 8, 2023
d0f22ab
fix: handle mutli cameras only when editor camera is active
julien-moreau Apr 9, 2023
174bae8
feat: add missing properties to cascaded shadow maps
julien-moreau Apr 9, 2023
1b48980
feat: restore sub-meshes menu in graph context menu
julien-moreau Apr 10, 2023
094400c
fix: SSR and MB post-processes in editor preview
julien-moreau Apr 10, 2023
08c94c7
fix: use plugins from file system
julien-moreau Apr 10, 2023
391624c
feat: handle textures with loading errors in assets panel
julien-moreau Apr 12, 2023
986a1bc
feat: add support of JS script editor
julien-moreau Apr 13, 2023
d490665
feat: add support of Compute Range Excluded Meshes for lights
julien-moreau Apr 13, 2023
ca3e59a
feat: improve saving speed for geometries
julien-moreau Apr 16, 2023
fdb734a
feat: add support of SSR rendering pipeline
julien-moreau Apr 16, 2023
f69cc7a
feat: add support of JS files in assets
julien-moreau Apr 17, 2023
62cb12d
Fixed #424: prevent default and unfocus keymap buttons to allow "spac…
julien-moreau Apr 18, 2023
2e145ca
fix: don't reset pipeline on camera selected in preview
julien-moreau Apr 18, 2023
98ce48f
feat: add support of "Update Dependencies" menu in toolbar
julien-moreau Apr 18, 2023
631101e
chore: update to Babylon.JS v6
julien-moreau Apr 22, 2023
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
Prev Previous commit
Next Next commit
fix: clean render targets before saving project to handle null case
  • Loading branch information
julien-moreau committed Apr 22, 2023
commit ca60600666b6167dfc45883a78f13432c7f9a0d6
46 changes: 35 additions & 11 deletions src/renderer/editor/project/project-exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,36 @@ export class ProjectExporter {
// Prepare
await editor.console.logSection("Exporting Project");
await editor.console.logInfo(`Exporting project to: ${Project.DirPath}`);

editor.beforeSaveProjectObservable.notifyObservers(Project.DirPath!);

const task = editor.addTaskFeedback(0, "Saving Files...");
await Tools.Wait(500);

// Clean render targets
const renderTargets = editor.scene!.customRenderTargets.slice(0);

const materialsWithRenderTargets = editor.scene!.materials.filter((m) => m.getRenderTargetTextures?.().length);
materialsWithRenderTargets.forEach((m) => {
m.getRenderTargetTextures?.().forEach((rt) => renderTargets.push(rt));
});

renderTargets.forEach((rt) => {
if (!rt.renderList) {
return;
}

for (let i = 0; i < rt.renderList.length; ++i) {
const m = rt.renderList[i];
if (m) {
continue;
}

rt.renderList.splice(i, 1);
--i;
}
});

// Create project
const project: IProject = {
animationGroups: [],
Expand Down Expand Up @@ -148,7 +172,7 @@ export class ProjectExporter {
const exportedCinematics: string[] = [];
const exportedAnimationGroups: string[] = [];
const exportedReflectionProbes: string[] = [];

let savePromises: Promise<void>[] = [];

let progressValue = 0;
Expand Down Expand Up @@ -267,8 +291,8 @@ export class ProjectExporter {
if (texture instanceof RenderTargetTexture || texture instanceof DynamicTexture) { continue; }
if (texture.name.indexOf("data:") === 0 || texture === editor.scene!.environmentBRDFTexture) { continue; }
if (!extname(texture.name)) { continue; }
texture.metadata ??= { };

texture.metadata ??= {};
texture.metadata.editorId ??= Tools.RandomId();

savePromises.push(new Promise<void>(async (resolve) => {
Expand Down Expand Up @@ -326,7 +350,7 @@ export class ProjectExporter {
if (json.customType === "BABYLON.PBRMaterial" && json.environmentBRDFTexture) {
delete json.environmentBRDFTexture;
}

try {
json.metadata = Tools.CloneObject(material.metadata);
} catch (e) {
Expand All @@ -339,8 +363,8 @@ export class ProjectExporter {
}

const dest = isMultiMaterial ?
join(materialsDir, `${normalize(`${basename(filenamify(material.name))}-${material.id}`)}.json`) :
join(editor.assetsBrowser.assetsDirectory, material.metadata.editorPath);
join(materialsDir, `${normalize(`${basename(filenamify(material.name))}-${material.id}`)}.json`) :
join(editor.assetsBrowser.assetsDirectory, material.metadata.editorPath);

const materialData = {
isMultiMaterial,
Expand All @@ -354,7 +378,7 @@ export class ProjectExporter {
project.materials.splice(project.materials.indexOf(materialData), 1);
return resolve();
}

await Workers.ExecuteFunction<SaveWorker, "writeFile">(this._Worker!, "writeFile", dest, json);

editor.updateTaskFeedback(task, progressValue += progressCount);
Expand Down Expand Up @@ -464,10 +488,10 @@ export class ProjectExporter {
const shadowJson = light.getShadowGenerator()?.serialize();
if (shadowJson) {
const shadowDest = `${normalize(`${basename(filenamify(light.name))}-${light.id}`)}.json`;

exportedShadows.push(shadowDest);
project.lights.push({ json: lightDest, shadowGenerator: shadowDest });

await Workers.ExecuteFunction<SaveWorker, "writeFile">(this._Worker!, "writeFile", join(shadowsDir, shadowDest), shadowJson);
} else {
project.lights.push({ json: lightDest, shadowGenerator: undefined });
Expand Down Expand Up @@ -597,7 +621,7 @@ export class ProjectExporter {
await Workers.ExecuteFunction<SaveWorker, "writeJSON">(this._Worker!, "writeJSON", join(Project.DirPath!, "../cache.json"), assetsCache);

// Write links
await Workers.ExecuteFunction<SaveWorker, "writeJSON">(this._Worker!, "writeJSON", join(Project.DirPath!, "../links.json"), { });
await Workers.ExecuteFunction<SaveWorker, "writeJSON">(this._Worker!, "writeJSON", join(Project.DirPath!, "../links.json"), {});

// Write files configurations
await Workers.ExecuteFunction<SaveWorker, "writeJSON">(this._Worker!, "writeJSON", join(Project.DirPath!, "../files.json"), AssetsBrowserItemHandler.AssetsConfiguration);
Expand Down