当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript sequence.flatten函数代码示例

本文整理汇总了TypeScript中tvs-libs/dist/utils/sequence.flatten函数的典型用法代码示例。如果您正苦于以下问题:TypeScript flatten函数的具体用法?TypeScript flatten怎么用?TypeScript flatten使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了flatten函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: mapcat

					mapcat(c => {
						const n1 = nodes[c[0]]
						const n2 = nodes[c[1]]
						const vDiff = normalize(sub(n2.pos, n1.pos))
						const normal = [vDiff[1], -vDiff[0]]
						const p1 = add(n1.pos, mul(lineWidth / 2, normal))
						const p2 = add(n1.pos, mul(-lineWidth / 2, normal))
						const p3 = add(n2.pos, mul(lineWidth / 2, normal))
						const p4 = add(n2.pos, mul(-lineWidth / 2, normal))
						return flatten([p3, p2, p1, p2, p3, p4])
					}, connections),
开发者ID:trivial-space,项目名称:playground,代码行数:11,代码来源:geometries.ts

示例2: flatten

			box.map((side, i) => flatten(side).map(() => faceNormals[i])),
开发者ID:trivial-space,项目名称:playground,代码行数:1,代码来源:geometries.ts

示例3: randomDivide

	return randomDivide(q, count).map(q => flatten(subdivide(horzDiv(q))))
开发者ID:trivial-space,项目名称:playground,代码行数:1,代码来源:geometries.ts

示例4: subdivide

function subdivide(quads: Quad[], times = 1): Quad[] {
	for (let i = 0; i < times; i++) {
		quads = flatten(quads.map(q => flatten(vertDiv(q).map(horzDiv))))
	}
	return quads
}
开发者ID:trivial-space,项目名称:playground,代码行数:6,代码来源:geometries.ts

示例5: extrudeRight

	const rt = extrudeRight([0, 0, 20], right(bk))
	const ft = extrudeRight([-20, 0, 0], right(rt))
	const lf = extrudeRight([0, 0, -20], right(ft))
	return [
		makeSideSegments(bk, count),
		makeSideSegments(rt, count),
		makeSideSegments(ft, count),
		makeSideSegments(lf, count),
	]
})()

export const faceNormals = box.map(q => normal(q[1]))

export const wallsForm = getForm(painter, 'wallsForm').update(
	convertStackGLGeometry({
		position: flatten(flatten(box)),
		// color: flatten(b.map((side) => flatten(side.map((slice) => flatten(slice.map((q) => (q as any[]).map(() => pickRandom(c)))))))),
		color: flatten(
			box.map((side, i) =>
				flatten(
					side.map((slice, j) =>
						slice.map(() => colors[i * boxSliceCount + j]),
					),
				),
			),
		),
		normal: flatten(
			box.map((side, i) => flatten(side).map(() => faceNormals[i])),
		),
		cells: triangulate(4 * boxSliceCount * 4 * 2),
	}),
开发者ID:trivial-space,项目名称:playground,代码行数:31,代码来源:geometries.ts

示例6: getShade

import sideFrag from './shaders/side.frag'

// ===== shaders =====

const pointsShade = getShade(painter, 'point').update({
	vert: pointVert,
	frag: pointFrag,
})

// ===== geometries =====

const pointsForm = getForm(painter, 'points').update({
	drawType: 'POINTS',
	attribs: {
		position: {
			buffer: new Float32Array(flatten(nodes)),
			storeType: 'DYNAMIC',
		},
	},
	itemCount: nodes.length,
})

// ===== objects =====

const pointsSketch = getSketch(painter, 'points').update({
	form: pointsForm,
	shade: pointsShade,
})

// ===== layers =====
开发者ID:trivial-space,项目名称:playground,代码行数:30,代码来源:index.ts

示例7: randInt

		id: i,
		pos: [Math.random() * canvas.width, Math.random() * canvas.height],
		ns: randInt(nameSpaceCount),
		force: [0, 0],
	}),
	nodeCount,
)

export const connections = flatten(
	times(i => {
		if (i < nodeCount - 3) {
			const i1 = randIntInRange(i + 1, nodeCount - 1)
			const cs = [[i, i1] as [number, number]]
			const i2 = randIntInRange(i + 1, nodeCount - 1)
			if (i2 !== i1) {
				cs.push([i, i2])
			}
			return cs
		} else {
			return []
		}
	}, nodeCount),
)

function updateForces(force: M<number>, dir: M<number[]>, from: any, to: any) {
	const update = (f: M<number>) => (v: number[]) =>
		f.combine(mul, dir).pull(add, v).value

	alter(from, 'force', update(force))
	alter(to, 'force', update(force.map(f => -f)))
}
开发者ID:trivial-space,项目名称:playground,代码行数:31,代码来源:nodes.ts


注:本文中的tvs-libs/dist/utils/sequence.flatten函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。