in cam animation, add red tinting to cuts below z=0
This commit is contained in:
parent
4dc9e38a08
commit
40537de055
4 changed files with 45 additions and 3 deletions
|
|
@ -14,6 +14,39 @@ const asPoints = false;
|
||||||
|
|
||||||
// ---( CLIENT FUNCTIONS )---
|
// ---( CLIENT FUNCTIONS )---
|
||||||
|
|
||||||
|
// tint points below z=0 with red
|
||||||
|
function add_red_neg_z(material) {
|
||||||
|
material.onBeforeCompile = (shader) => {
|
||||||
|
console.log({ OBC: shader });
|
||||||
|
shader.vertexShader = shader.vertexShader.replace(
|
||||||
|
`#include <worldpos_vertex>`,
|
||||||
|
`
|
||||||
|
#include <worldpos_vertex>
|
||||||
|
vWorldPosition = vec3(transformed);
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
shader.vertexShader = `
|
||||||
|
varying vec3 vWorldPosition;
|
||||||
|
` + shader.vertexShader;
|
||||||
|
|
||||||
|
shader.fragmentShader = `
|
||||||
|
varying vec3 vWorldPosition;
|
||||||
|
` + shader.fragmentShader;
|
||||||
|
|
||||||
|
shader.fragmentShader = shader.fragmentShader.replace(
|
||||||
|
`#include <dithering_fragment>`,
|
||||||
|
`
|
||||||
|
#include <dithering_fragment>
|
||||||
|
if (vWorldPosition.z < 0.0) {
|
||||||
|
gl_FragColor.rgb += vec3(0.5, 0.0, 0.0); // Add red tint
|
||||||
|
}
|
||||||
|
`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
kiri.load(() => {
|
kiri.load(() => {
|
||||||
if (!kiri.client) {
|
if (!kiri.client) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -105,13 +138,15 @@ kiri.load(() => {
|
||||||
transparent = true,
|
transparent = true,
|
||||||
opacity = 0.9,
|
opacity = 0.9,
|
||||||
side = THREE.DoubleSide;
|
side = THREE.DoubleSide;
|
||||||
material = new THREE.MeshMatcapMaterial({
|
// material = new THREE.MeshMatcapMaterial({
|
||||||
|
material = new THREE.MeshPhongMaterial({
|
||||||
flatShading,
|
flatShading,
|
||||||
transparent,
|
transparent,
|
||||||
opacity,
|
opacity,
|
||||||
color,
|
color,
|
||||||
side
|
side
|
||||||
});
|
});
|
||||||
|
add_red_neg_z(material);
|
||||||
kiri.client.send("animate_setup", {settings}, ondone);
|
kiri.client.send("animate_setup", {settings}, ondone);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -156,6 +191,7 @@ kiri.load(() => {
|
||||||
geo.computeVertexNormals();
|
geo.computeVertexNormals();
|
||||||
}
|
}
|
||||||
mesh = new THREE.Mesh(geo, material);
|
mesh = new THREE.Mesh(geo, material);
|
||||||
|
mesh.renderOrder = -10;
|
||||||
}
|
}
|
||||||
space.world.add(mesh);
|
space.world.add(mesh);
|
||||||
meshes[id] = mesh;
|
meshes[id] = mesh;
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ function parse(text, opt = { soup: true }) {
|
||||||
for (let sub of path.subPaths) {
|
for (let sub of path.subPaths) {
|
||||||
let length = sub.getLength();
|
let length = sub.getLength();
|
||||||
let points = sub.getPoints(sub.curves ? Math.max(length/2, 12) : undefined);
|
let points = sub.getPoints(sub.curves ? Math.max(length/2, 12) : undefined);
|
||||||
|
if (points.length < 3) {
|
||||||
|
console.log({ sub, length, points });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let poly = base.newPolygon().addPoints(points.map(p => base.newPoint(p.x, -p.y, 0)));
|
let poly = base.newPolygon().addPoints(points.map(p => base.newPoint(p.x, -p.y, 0)));
|
||||||
if (poly.appearsClosed()) poly.points.pop();
|
if (poly.appearsClosed()) poly.points.pop();
|
||||||
if (type === 'polyline') poly.setOpen(true);
|
if (type === 'polyline') poly.setOpen(true);
|
||||||
|
|
|
||||||
|
|
@ -1097,9 +1097,11 @@ const tool = {
|
||||||
if (dup_sel) {
|
if (dup_sel) {
|
||||||
selection.clear();
|
selection.clear();
|
||||||
}
|
}
|
||||||
|
let nm = [];
|
||||||
for (let m of models) {
|
for (let m of models) {
|
||||||
m.duplicate({ select: dup_sel, shift: dup_shift });
|
nm.push(m.duplicate({ select: dup_sel, shift: dup_shift }));
|
||||||
}
|
}
|
||||||
|
tool.regroup(nm);
|
||||||
},
|
},
|
||||||
|
|
||||||
mirror() {
|
mirror() {
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ let materials = mesh.material = {
|
||||||
color: 0x0,
|
color: 0x0,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
})
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 3D model rendered on plaform **/
|
/** 3D model rendered on plaform **/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue