performance improvements

This commit is contained in:
2024-03-04 21:46:19 +01:00
parent 369df93204
commit 830fa22bee
3 changed files with 8 additions and 7 deletions

View File

@@ -14,7 +14,7 @@
</Canvas>
<div class="controls">
<input type="range" min="0" max="1" step="0.01" bind:value={showSlices} orient="vertical" />
<input type="range" min="0" max="1" step="0.001" bind:value={showSlices} orient="vertical" />
</div>
{#if $progress !== undefined}
@@ -28,6 +28,7 @@
<style lang="scss">
input[type='range'] {
height: 80%;
}
.controls {

View File

@@ -10,7 +10,8 @@
Mesh,
DoubleSide,
Color,
BufferGeometryLoader
BufferGeometryLoader,
ConeGeometry
} from 'three';
import { writable } from 'svelte/store';
import { onDestroy, onMount } from 'svelte';
@@ -63,7 +64,6 @@
export let maxNonPlanarAngle = MathUtils.degToRad(20);
export let bedNormal = new Vector3(0, 0, 1);
let mesh: Mesh;
let layers = writable<Layer[]>([]);
const stl: AsyncWritable<BufferGeometry> = useLoader(STLLoader).load('/benchy.stl');
@@ -113,8 +113,8 @@
{/if}
{/each}
{#if $stl && false}
<T.Mesh geometry={$stl} bind:ref={mesh}>
{#if $stl}
<T.Mesh geometry={$stl} position.y={40}>
<T.MeshNormalMaterial />
</T.Mesh>
{/if}

View File

@@ -153,14 +153,14 @@ function slice({
const positions: number[] = [];
for (let i = 0; i < nonPlanarSurfaces.length; i++) {
if (consumedNonPlanarSurfaces[i]) continue;
if (nonPlanarSurfaces[i].geometry.boundingBox!.min.z > layer) {
if (layer >= nonPlanarSurfaces[i].geometry.boundingBox!.min.z) {
consumedNonPlanarSurfaces[i] = true;
activeNonPlanarSurfaces.push([i, nonPlanarSurfaces[i]]);
}
}
deactivate: for (let i = 0; i < activeNonPlanarSurfaces.length; i++) {
const [index, surface] = activeNonPlanarSurfaces[i];
if (surface.geometry.boundingBox!.max.z <= layer) {
if (layer > surface.geometry.boundingBox!.max.z) {
activeNonPlanarSurfaces.splice(i, 1);
i--;