feat: yaaay first stem

This commit is contained in:
2024-04-18 00:02:50 +02:00
parent 1da13523ea
commit 2edd22136f
21 changed files with 297 additions and 102 deletions

View File

@ -16,29 +16,29 @@
}
</script>
<T.GridHelper args={[20, 20]} />
<T.PerspectiveCamera position={[-10, 10, 10]} makeDefault fov={50}>
<OrbitControls />
</T.PerspectiveCamera>
<T.DirectionalLight position={[0, 10, 10]} />
<T.AmbientLight intensity={0.5} />
{#each geometry as geo}
{#each geo.attributes.position.array as attr, i}
{#if i % 3 === 0}
<Text text={i / 3} fontSize={1} position={getPosition(geo, i)} />
{/if}
{/each}
{#if false}
{#each geo.attributes.position.array as _, i}
{#if i % 3 === 0}
<Text text={i / 3} fontSize={0.25} position={getPosition(geo, i)} />
{/if}
{/each}
<T.Points visible={true}>
<T is={geo} />
<T.PointsMaterial size={0.25} />
</T.Points>
<T.Points visible={true}>
<T is={geo} />
<T.PointsMaterial size={0.25} />
</T.Points>
{/if}
<T.Mesh geometry={geo}>
<T.MeshStandardMaterial color="hotpink" />
</T.Mesh>
{:else}
<T.Mesh>
<T.BoxGeometry args={[1, 1, 1]} />
<T.MeshStandardMaterial color="hotpink" />
<T.MeshStandardMaterial color="green" />
</T.Mesh>
{/each}

View File

@ -38,12 +38,13 @@
);
index = index + vertexCount * 3;
console.log({ vertices, normals, indices });
// Add data to geometry
geometry.setIndex([...indices]);
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
// geometry.computeVertexNormals();
//geometry.computeVertexNormals();
geometry.computeVertexNormals();
return geometry;
}
@ -94,19 +95,19 @@
$: if (result) {
const inputs = parse_args(result);
for (let input of inputs) {
if (input[0] === 1) {
const geo = createGeometryFromEncodedData(input);
geometries = [geo];
console.log(geo);
}
}
console.log({ inputs });
geometries = inputs
.map((input) => {
if (input[0] === 1) {
const geo = createGeometryFromEncodedData(input);
return geo;
}
})
.filter(Boolean) as BufferGeometry[];
}
</script>
<Canvas>
<Scene geometry={geometries} />
</Canvas>
<style>
</style>