Skip to content

Commit

Permalink
Update 4.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nimadez committed Jul 29, 2024
1 parent 50a7e13 commit 41c20fe
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 81 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
All notable changes to this project will be documented in this file.

## 4.3.3
- Update three-mesh-bvh to 0.7.6
- Update three to r167
- Update to babylonjs 7.17.0
- Prevent frame camera on quickload voxels (holds the camera for further changes)
- Remove showSaveFilePicker, this experimental technology is not ready for production<br>
Fix save file functionality in electron and mobile<br>
Fix save format from .txt to .json in mobile

## 4.3.2
- Update to babylonjs 7.13.1
- Update to three r166
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Voxel-based 3D modeling application<br>
[https://nimadez.github.io/voxel-builder/](https://nimadez.github.io/voxel-builder/)

```Version 4.3.2 Beta```<br>
```Version 4.3.3 Beta```<br>
[Changelog](https://github.com/nimadez/voxel-builder/blob/main/CHANGELOG.md)

[Installation](https://github.com/nimadez/voxel-builder#installation)<br>
Expand Down
8 changes: 3 additions & 5 deletions electron.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
<li><button onclick="window.open('https://nimadez.github.io/voxel-builder/extras/pixel-monk', '_blank').focus();">Pixel Monk</button></li>
<li class="spacer"></li>
<li class="about">
4.3.2 Beta 2024
4.3.3 Beta 2024
<br>&#8627; <a href="https://github.com/nimadez/voxel-builder/">GitHub</a>
<br>Developer
<br>&#8627; <a href="https://nimadez.github.io/">@nimadez</a>
Expand Down
2 changes: 1 addition & 1 deletion libs/babylon.gui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/babylon.inspector.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/babylon.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/babylonjs.loaders.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/babylonjs.materials.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/babylonjs.serializers.min.js

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions libs/three-mesh-bvh.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/three.module.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voxel-builder",
"version": "4.3.2",
"version": "4.3.3",
"description": "Voxel-based 3D modeling application",
"main": "electron.js",
"scripts": {
Expand All @@ -10,9 +10,9 @@
"author": "@nimadez",
"license": "MIT",
"devDependencies": {
"electron": "^29.2.0",
"babylonjs": "^7.13.1",
"three": "^0.166.0",
"three-mesh-bvh": "^0.7.5"
"electron": "^30.0.0",
"babylonjs": "^7.17.0",
"three": "^0.167.0",
"three-mesh-bvh": "^0.7.6"
}
}
69 changes: 12 additions & 57 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4001,7 +4001,7 @@ function Snapshot(scene) {
return;
}
builder.setData(data);
clearScene();
clearScene(false);
}

this.setStorageBakes = function() {
Expand Down Expand Up @@ -4134,7 +4134,7 @@ function Memory() {
function Project(scene) {
function serializeScene(voxels, meshes) {
const json = {
version: "Voxel Builder 4.3.2",
version: "Voxel Builder 4.3.3",
project: {
name: "name",
voxels: builder.voxels.length,
Expand Down Expand Up @@ -4186,12 +4186,12 @@ function Project(scene) {
const reader = new FileReader();
reader.onload = () => {
json.data.meshes = reader.result;
saveDialog(JSON.stringify(json, null, 4), ui.domProjectName.value + '.json');
downloadJson(JSON.stringify(json, null, 4), ui.domProjectName.value + '.json');
}
reader.readAsDataURL(file);
});
} else {
saveDialog(JSON.stringify(json, null, 4), ui.domProjectName.value + '.json');
downloadJson(JSON.stringify(json, null, 4), ui.domProjectName.value + '.json');
}
}

Expand Down Expand Up @@ -5605,12 +5605,14 @@ function WebsocketClient() {
// Utils


function clearScene() {
function clearScene(frameCamera = true) {
memory.clear();
symmetry.resetAxis();
setTimeout(() => {
camera.frame();
}, 10);
if (frameCamera) {
setTimeout(() => {
camera.frame();
}, 10);
}
}

function clearSceneAndReset() {
Expand Down Expand Up @@ -5811,8 +5813,8 @@ function loadUrl(url, callback, onerror = null) {
});
}

function downloadText(txt, filename) {
const blob = new Blob([ txt ], { type: "text/plain" });
function downloadJson(data, filename) {
const blob = new Blob([ data ], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
Expand All @@ -5837,53 +5839,6 @@ function downloadBlob(blob, filename) {
URL.revokeObjectURL(url);
}

async function saveFile(blob, filename, reject) {
if ("showSaveFilePicker" in window) {
try {
const fileHandle = await window.showSaveFilePicker({
suggestedName: filename,
types: [ { description: "File" } ]
});
const writeFile = async (fileHandle, contents) => {
const writable = await fileHandle.createWritable();
await writable.write(contents);
await writable.close();
};
writeFile(fileHandle, blob).then(() => {
//
});
} catch (err) {
// canceled
}
} else {
reject();
}
}

function saveDialog(data, filename) {
const blob = new Blob([ data ], { type: "text/plain" });
saveFile(blob, filename, () => {
downloadText(data, filename);
});
}

function saveDialogImage(data, filename) {
const blob = dataURItoBlob(data);
saveFile(blob, filename, () => {
downloadImage(data, filename);
});
}

function dataURItoBlob(dataURI) {
const byteString = atob(dataURI.split(',')[1]);
const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
const ab = new ArrayBuffer(byteString.length);
const ia = new Uint8Array(ab);
for (let i = 0; i < byteString.length; i++)
ia[i] = byteString.charCodeAt(i);
return new Blob([ ab ], { type: mimeString });
}

function toggleFullscreen() {
(document.fullscreenElement) ? document.exitFullscreen() : document.body.requestFullscreen();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pathtracer/pathtracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class Pathtracer {

shot() {
const uri = this.renderer.domElement.toDataURL('image/png');
saveDialogImage(uri, `${ ui.domProjectName.value }_${ new Date().toJSON().slice(0,10) }_${ randomRangeInt(1000, 9999) }.png`);
downloadImage(uri, `${ ui.domProjectName.value }_${ new Date().toJSON().slice(0,10) }_${ randomRangeInt(1000, 9999) }.png`);
}

toggle() {
Expand Down

0 comments on commit 41c20fe

Please sign in to comment.