Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function subdivideMeshes (mesh) {
const planeNormal = rand.onSphere(1)
const planePt = rand.insideSphere(5)
const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
const offset1 = vec3.scale([], planeNormal, settings.offset)
const offset2 = vec3.scale([], planeNormal, -settings.offset)
// const rotation = mat4.fromRotation([], rand.range(0, Math.PI * 0.5), planeNormal)
return [
mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
// mesh1.map(points => points.map(pt => vec3.transformMat4([], pt, rotation))),
// mesh2
]
}
function subdivideMeshes (mesh) {
const planeNormal = rand.onSphere(1)
const planePt = rand.insideSphere(5)
const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
const offset1 = vec3.scale([], planeNormal, settings.offset)
const offset2 = vec3.scale([], planeNormal, -settings.offset)
// const rotation = mat4.fromRotation([], rand.range(0, Math.PI * 0.5), planeNormal)
return [
mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
// mesh1.map(points => points.map(pt => vec3.transformMat4([], pt, rotation))),
// mesh2
]
}
function subdivideMeshes (mesh) {
const planeNormal = rand.onSphere(1)
const planePt = rand.insideSphere(5)
const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
const offset1 = vec3.scale([], planeNormal, settings.offset)
const offset2 = vec3.scale([], planeNormal, -settings.offset)
mesh1.positions = mesh1.positions.map(pt => vec3.add([], pt, offset1))
mesh2.positions = mesh2.positions.map(pt => vec3.add([], pt, offset2))
return [mesh1, mesh2]
}
function subdivideMeshes (mesh) {
const planeNormal = rand.onSphere(1)
const planePt = rand.insideSphere(5)
const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
const offset1 = vec3.scale([], planeNormal, settings.offset)
const offset2 = vec3.scale([], planeNormal, -settings.offset)
return [
mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
]
}
function subdivideMeshes (mesh) {
const planeNormal = rand.onSphere(1)
const planePt = rand.insideSphere(5)
const [mesh1, mesh2] = clipMeshWithPlane(mesh, planeNormal, planePt)
const offset1 = vec3.scale([], planeNormal, settings.offset)
const offset2 = vec3.scale([], planeNormal, -settings.offset)
return [
mesh1.map(points => points.map(pt => vec3.add([], pt, offset1))),
mesh2.map(points => points.map(pt => vec3.add([], pt, offset2)))
]
}