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

Remove color attributes #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 27 additions & 1 deletion zine-geometry-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ export function depthFloat32ArrayToGeometry(

//

export function getDepthFloat32ArrayWorldPositionPx(
depthFloat32Array,
px,
py,
width,
height,
camera,
scale,
target
) {
px = Math.min(Math.max(px, 0), width - 1);
py = Math.min(Math.max(py, 0), height - 1);

let x = px / width;
let y = py / height;

const i = py * width + px;
y = 1 - y;

const viewZ = depthFloat32Array[i];
const worldPoint = setCameraViewPositionFromViewZ(x, y, viewZ, camera, target);
worldPoint.multiply(scale);
worldPoint.applyMatrix4(camera.matrixWorld);
return target;
}

export function getDepthFloat32ArrayWorldPosition(
depthFloat32Array,
x, // 0..1
Expand Down Expand Up @@ -418,4 +444,4 @@ export const setCameraViewPositionFromOrthographicViewZ = (x, y, viewZ, camera,
target.y = worldPoint.y;
target.z = worldPoint.z;
return target;
}
}
8 changes: 1 addition & 7 deletions zine-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ class SceneMesh extends THREE.Mesh {
height,
);
geometry.setAttribute('segment', new THREE.BufferAttribute(segmentSpecs.array, 1));
geometry.setAttribute('segmentColor', new THREE.BufferAttribute(segmentSpecs.colorArray, 3));
geometry.setAttribute('plane', new THREE.BufferAttribute(planeSpecs.array, 1));
geometry.setAttribute('planeColor', new THREE.BufferAttribute(planeSpecs.colorArray, 3));
// geometry.setAttribute('portal', new THREE.BufferAttribute(portalSpecs.array, 1));
geometry.setAttribute('portalColor', new THREE.BufferAttribute(portalSpecs.colorArray, 3));
const indexedGeometry = geometry;
geometry = geometry.toNonIndexed();
decorateGeometryTriangleIds(geometry);
Expand Down Expand Up @@ -206,11 +203,8 @@ class ScenePhysicsMesh extends THREE.Mesh {
physicsPixelStride,
);
// geometry.setAttribute('segment', new THREE.BufferAttribute(segmentSpecs.array, 1));
// geometry.setAttribute('segmentColor', new THREE.BufferAttribute(segmentSpecs.colorArray, 3));
// geometry.setAttribute('plane', new THREE.BufferAttribute(planeSpecs.array, 1));
// geometry.setAttribute('planeColor', new THREE.BufferAttribute(planeSpecs.colorArray, 3));
// // geometry.setAttribute('portal', new THREE.BufferAttribute(portalSpecs.array, 1));
// geometry.setAttribute('portalColor', new THREE.BufferAttribute(portalSpecs.colorArray, 3));
// const indexedGeometry = geometry;
// geometry = geometry.toNonIndexed();
// decorateGeometryTriangleIds(geometry);
Expand Down Expand Up @@ -507,4 +501,4 @@ export class ZineRenderer extends EventTarget {
);
targetZineRenderer.camera.updateMatrixWorld();
}
}
}