本文整理汇总了TypeScript中neuroglancer/util/geom.vec3Key函数的典型用法代码示例。如果您正苦于以下问题:TypeScript vec3Key函数的具体用法?TypeScript vec3Key怎么用?TypeScript vec3Key使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vec3Key函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: checkPosition
// Position within chunk in floating point range [0, chunkDataSize].
function checkPosition(positionInChunk: vec3) {
gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
chunkFormat.beginDrawing(gl, shader);
chunkFormat.beginSource(gl, shader);
chunkFormat.setupTextureLayout(gl, shader, textureLayout);
gl.bindTexture(textureTarget, texture);
tester.execute();
chunkFormat.endDrawing(gl, shader);
let offset = 0;
for (let i = 0; i < 3; ++i) {
offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
strides[i];
}
const values = tester.values;
for (let channel = 0; channel < numChannels; ++channel) {
const curOffset = offset + channel * strides[3];
const msg = `volumeSize = ${vec3Key(volumeSize)}, ` +
`positionInChunk = ${vec3Key(positionInChunk)}, ` +
`channel = ${channel}, offset = ${curOffset}`;
switch (dataType) {
case DataType.UINT64: {
let low = values[`output${channel}Low`];
let high = values[`output${channel}High`];
expect(low).toBe(rawData[curOffset * 2], `${msg} (low)`);
expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
break;
}
default: {
let result = values[`output${channel}`];
expect(result).toBe(rawData[curOffset], msg);
break;
}
}
}
}
示例2: download
download(chunk: VolumeChunk) {
let path: string;
{
// chunkPosition must not be captured, since it will be invalidated by the next call to
// computeChunkBounds.
let chunkPosition = this.computeChunkBounds(chunk);
let {chunkDataSize} = chunk;
path = `/v1beta2/volumes/${this.key}/binary/subvolume/corner=${vec3Key(chunkPosition)}/size=${vec3Key(chunkDataSize)}/scale=${this.scaleIndex}/changeStackId=/${this.encodingParams}?alt=media`;
}
handleChunkDownloadPromise(
chunk, makeRequest(this.instance, 'GET', path, 'arraybuffer'), this.chunkDecoder);
}
示例3: setTimeout
setTimeout(() => {
try{
chunk.data = this.getColor(vec3Key(chunk.chunkGridPosition));
resolve(chunk); // Yay! Everything went well!
}
catch(e){
reject(e);
}
}, 0);
示例4: checkPosition
// Position within chunk in floating point range [0, chunkDataSize].
function checkPosition(positionInChunk: vec3) {
gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
chunkFormat.beginDrawing(gl, shader);
chunkFormat.beginSource(gl, shader);
chunkFormat.setupTextureLayout(gl, shader, textureLayout);
gl.bindTexture(gl.TEXTURE_2D, texture);
tester.execute();
chunkFormat.endDrawing(gl, shader);
let offset = 0;
for (let i = 0; i < 3; ++i) {
offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
strides[i];
}
let outputChannel = 0;
for (let channel = 0; channel < numChannels; ++channel) {
const curOffset = offset + channel * strides[3];
const msg = `volumeSize = ${vec3Key(volumeSize)}, ` +
`positionInChunk = ${vec3Key(positionInChunk)}, ` +
`channel = ${channel}, offset = ${curOffset}`;
switch (dataType) {
case DataType.UINT64: {
let low = tester.readUint32(outputChannel++);
let high = tester.readUint32(outputChannel++);
expect(low).toBe(rawData[curOffset * 2], `${msg} (low)`);
expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
break;
}
case DataType.FLOAT32: {
let result = tester.readFloat(outputChannel++);
expect(result).toBe(rawData[curOffset], msg);
break;
}
default: {
// uint8, uint16, and uint32 values can all be read as uint32.
let result = tester.readUint32(outputChannel++);
expect(result).toEqual(rawData[curOffset], msg);
break;
}
}
}
}
示例5: suite
suite('compressed_segmentation', () => {
const blockSize = [8, 8, 8];
const output = new Uint32ArrayBuilder(1000000);
for (let volumeSize of [ //
[16, 16, 16, 1], //
// [64, 64, 64, 1], //
]) {
const numPossibleValues = 15;
const input = makeRandomUint64Array(prod4(volumeSize), numPossibleValues);
benchmark(`encode_uint64 ${vec3Key(volumeSize)}`, () => {
output.clear();
encodeChannelsUint64(output, blockSize, input, volumeSize);
});
}
});
示例6: decodeBossNpzChunk
export function decodeBossNpzChunk(chunk: VolumeChunk, response: ArrayBuffer) {
let parseResult = parseNpy(inflate(new Uint8Array(response)));
let chunkDataSize = chunk.chunkDataSize!;
let source = chunk.source!;
let {shape} = parseResult;
if (shape.length !== 3 || shape[0] !== chunkDataSize[2] ||
shape[1] !== chunkDataSize[1] || shape[2] !== chunkDataSize[0]) {
throw new Error(
`Shape ${JSON.stringify(shape)} does not match chunkDataSize ${vec3Key(chunkDataSize)}`);
}
let parsedDataType = parseResult.dataType.dataType;
let {spec} = source;
if (parsedDataType !== spec.dataType) {
throw new Error(
`Data type ${DataType[parsedDataType]} does not match expected data type ${DataType[spec.dataType]}`);
}
postProcessRawData(chunk, parseResult.data);
}
示例7: describe
describe('encodeChannels', () => {
it('basic 1-channel 1-block', () => {
const blockSize = [2, 2, 1];
const input = Uint32Array.of(
4, 4, 4, 4 //
);
const volumeSize = [2, 2, 1, 1];
const output = new Uint32ArrayBuilder();
encodeChannels(output, blockSize, input, volumeSize);
expect(output.view)
.toEqual(Uint32Array.of(
1, //
2, 2, 4 //
));
});
for (let blockSize of [vec3.fromValues(2, 2, 2), vec3.fromValues(8, 4, 1), ]) {
for (let volumeSize of [ //
[1, 2, 1, 1], //
[1, 2, 1, 3], //
[2, 2, 2, 1], //
[2, 2, 2, 3], //
[4, 4, 5, 3], //
]) {
it(`round trip ${volumeSize.join(',')} with blockSize ${vec3Key(blockSize)}`, () => {
const numPossibleValues = 15;
const input = makeRandomUint32Array(prod4(volumeSize), numPossibleValues);
const output = new Uint32ArrayBuilder();
encodeChannels(output, blockSize, input, volumeSize);
const decoded = new Uint32Array(input.length);
decodeChannels(decoded, output.view, 0, volumeSize, blockSize);
expect(decoded).toEqual(input);
});
}
}
});
示例8: get
static get(gl: GL, dataType: DataType, subchunkSize: Vec3, numChannels: number) {
let shaderKey = `sliceview.CompressedSegmentationChunkFormat:${dataType}:${numChannels}`;
let cacheKey = `${shaderKey}:${vec3Key(subchunkSize)}`;
return gl.memoize.get(
cacheKey, () => new ChunkFormat(dataType, subchunkSize, numChannels, shaderKey));
}
示例9: getFortranOrderStrides
export function chunkFormatTest<TextureLayout extends Disposable>(
dataType: DataType, volumeSize: Vec4,
getChunkFormatAndTextureLayout:
(gl: GL) => [SingleTextureChunkFormat<TextureLayout>, TextureLayout],
rawData: TypedArray, encodedData: TypedArray) {
const numChannels = volumeSize[3];
let strides = getFortranOrderStrides(volumeSize);
let outputChannelsPerChannel = dataType === DataType.UINT64 ? 2 : 1;
it(`volumeSize = ${vec3Key(volumeSize)}, numChannels = ${volumeSize[3]}, dataType = ${DataType[dataType]}`,
() => {
fragmentShaderTest(outputChannelsPerChannel * numChannels, tester => {
let {gl, builder} = tester;
let [chunkFormat, textureLayout] = getChunkFormatAndTextureLayout(gl);
builder.addUniform('vec3', 'vChunkPosition');
builder.addUniform('vec3', 'uChunkDataSize');
builder.addFragmentCode(glsl_getPositionWithinChunk);
chunkFormat.defineShader(builder);
{
let fragmentMain = '';
let outputChannel = 0;
for (let channel = 0; channel < numChannels; ++channel) {
switch (dataType) {
case DataType.UINT64:
fragmentMain += `
{
uint64_t value = getDataValue(${channel});
gl_FragData[${outputChannel++}] = value.low;
gl_FragData[${outputChannel++}] = value.high;
}
`;
break;
case DataType.UINT8:
fragmentMain += `
gl_FragData[${outputChannel++}] = vec4(getDataValue(${channel}).value, 0, 0, 0);
`;
break;
case DataType.FLOAT32:
fragmentMain += `
gl_FragData[${outputChannel++}] = packFloatIntoVec4(getDataValue(${channel}));
`;
break;
case DataType.UINT16:
fragmentMain += `
gl_FragData[${outputChannel++}] = vec4(getDataValue(${channel}).value, 0, 0);
`;
break;
case DataType.UINT32:
fragmentMain += `
gl_FragData[${outputChannel++}] = getDataValue(${channel}).value;
`;
break;
}
}
builder.setFragmentMain(fragmentMain);
}
tester.build();
let {shader} = tester;
shader.bind();
gl.uniform3fv(shader.uniform('uChunkDataSize'), volumeSize.subarray(0, 3));
let texture = gl.createTexture();
tester.registerDisposer(() => { gl.deleteTexture(texture); });
chunkFormat.beginDrawing(gl, shader);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
setRawTextureParameters(gl);
chunkFormat.setTextureData(gl, textureLayout, encodedData);
chunkFormat.setupTextureLayout(gl, shader, textureLayout);
// Position within chunk in floating point range [0, chunkDataSize].
function checkPosition(positionInChunk: Vec3) {
gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
chunkFormat.beginDrawing(gl, shader);
chunkFormat.beginSource(gl, shader);
chunkFormat.setupTextureLayout(gl, shader, textureLayout);
gl.bindTexture(gl.TEXTURE_2D, texture);
tester.execute();
chunkFormat.endDrawing(gl, shader);
let offset = 0;
for (let i = 0; i < 3; ++i) {
offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
strides[i];
}
let outputChannel = 0;
for (let channel = 0; channel < numChannels; ++channel) {
const curOffset = offset + channel * strides[3];
const msg =
`volumeSize = ${vec3Key(volumeSize)}, positionInChunk = ${vec3Key(positionInChunk)}, channel = ${channel}, offset = ${curOffset}`;
switch (dataType) {
case DataType.UINT64: {
let low = tester.readUint32(outputChannel++);
let high = tester.readUint32(outputChannel++);
expect(low).toEqual(rawData[curOffset * 2], `${msg} (low)`);
expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
break;
}
case DataType.FLOAT32: {
let result = tester.readFloat(outputChannel++);
//.........这里部分代码省略.........