How to use the @microsoft/mixed-reality-extension-sdk.Vector2 function in @microsoft/mixed-reality-extension-sdk

To help you get started, we’ve selected a few @microsoft/mixed-reality-extension-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / mixed-reality-extension-sdk / packages / gltf-gen / src / geometry / sphere.ts View on Github external
longNbr = i - 1 + (i == ringStart ? longLines + 1 : 0),
					latNbr = i <= longLines + 1 ? 0 : i - longLines - 1,
					latLongNbr = longNbr - longLines - 1;

				// fill in the tri/quad connecting this vert to the sphereA
				this.triangles.push(i, longNbr, latNbr);
				if (latLongNbr > 0)
					this.triangles.push(longNbr, latLongNbr, latNbr);
			}
		}

		// generate south pole
		const south = new Vertex({
			position: new Vector3(0, -radius, 0),
			normal: new Vector3(0, -1, 0),
			texCoord0: new Vector2(0.5, 0)
		});
		const southIdx = this.vertices.push(south) - 1;

		// connect last long ring to the south pole
		const ringStart = southIdx - longLines - 1;
		for (let i = southIdx - longLines - 1; i < southIdx; i++) {
			const longNbr = i - 1 + (i == ringStart ? longLines + 1 : 0);
			this.triangles.push(longNbr, i, southIdx);
		}
	}
}
github microsoft / mixed-reality-extension-sdk / packages / gltf-gen / src / geometry / sphere.ts View on Github external
this.vertices.push(north);

		const longAngle = 2 * Math.PI / longLines,
			latAngle = Math.PI / latLines;

		// generate verts in rings starting from the north pole
		for (let lat = latAngle; lat < Math.PI - 0.001; lat += latAngle) {
			const ringStart = this.vertices.length;
			for (let long = 0; long < 2 * Math.PI + 0.001; long += longAngle) {

				// generate a vertex
				const normal = new Vector3(Math.sin(lat) * Math.cos(long), Math.cos(lat), Math.sin(lat) * Math.sin(long))
				const vert = new Vertex({
					position: normal.scale(radius),
					normal: normal,
					texCoord0: new Vector2(1 - long / (2 * Math.PI), lat / Math.PI)
				});

				// get the indices of the neighboring verts
				const i = this.vertices.push(vert) - 1,
					longNbr = i - 1 + (i == ringStart ? longLines + 1 : 0),
					latNbr = i <= longLines + 1 ? 0 : i - longLines - 1,
					latLongNbr = longNbr - longLines - 1;

				// fill in the tri/quad connecting this vert to the sphereA
				this.triangles.push(i, longNbr, latNbr);
				if (latLongNbr > 0)
					this.triangles.push(longNbr, latLongNbr, latNbr);
			}
		}

		// generate south pole
github microsoft / mixed-reality-extension-sdk / packages / gltf-gen / src / geometry / sphere.ts View on Github external
public constructor(radius: number, longLines = 12, latLines = 8, material: Material = null) {
		super({material});

		// generate north pole
		const north = new Vertex({
			position: new Vector3(0, radius, 0),
			normal: new Vector3(0, 1, 0),
			texCoord0: new Vector2(0.5, 1)
		});
		this.vertices.push(north);

		const longAngle = 2 * Math.PI / longLines,
			latAngle = Math.PI / latLines;

		// generate verts in rings starting from the north pole
		for (let lat = latAngle; lat < Math.PI - 0.001; lat += latAngle) {
			const ringStart = this.vertices.length;
			for (let long = 0; long < 2 * Math.PI + 0.001; long += longAngle) {

				// generate a vertex
				const normal = new Vector3(Math.sin(lat) * Math.cos(long), Math.cos(lat), Math.sin(lat) * Math.sin(long))
				const vert = new Vertex({
					position: normal.scale(radius),
					normal: normal,
github microsoft / mixed-reality-extension-sdk / packages / gltf-gen / src / vertex.ts View on Github external
new Vector3(init.normal[0], init.normal[1], init.normal[2]);
		}
		if (init.tangent) {
			this.tangent = init.tangent instanceof Vector4 ?
				init.tangent :
				new Vector4(init.tangent[0], init.tangent[1], init.tangent[2], init.tangent[3]);
		}
		if (init.texCoord0) {
			this.texCoord0 = init.texCoord0 instanceof Vector2 ?
				init.texCoord0 :
				new Vector2(init.texCoord0[0], init.texCoord0[1]);
		}
		if (init.texCoord1) {
			this.texCoord1 = init.texCoord1 instanceof Vector2 ?
				init.texCoord1 :
				new Vector2(init.texCoord1[0], init.texCoord1[1]);
		}
		if (init.color0) {
			this.color0 = init.color0 instanceof Vector3 ?
				init.color0 :
				new Vector3(init.color0[0], init.color0[1], init.color0[2]);
		}
	}
github microsoft / mixed-reality-extension-sdk / packages / gltf-gen / src / vertex.ts View on Github external
new Vector3(init.position[0], init.position[1], init.position[2]);
		}
		if (init.normal) {
			this.normal = init.normal instanceof Vector3 ?
				init.normal :
				new Vector3(init.normal[0], init.normal[1], init.normal[2]);
		}
		if (init.tangent) {
			this.tangent = init.tangent instanceof Vector4 ?
				init.tangent :
				new Vector4(init.tangent[0], init.tangent[1], init.tangent[2], init.tangent[3]);
		}
		if (init.texCoord0) {
			this.texCoord0 = init.texCoord0 instanceof Vector2 ?
				init.texCoord0 :
				new Vector2(init.texCoord0[0], init.texCoord0[1]);
		}
		if (init.texCoord1) {
			this.texCoord1 = init.texCoord1 instanceof Vector2 ?
				init.texCoord1 :
				new Vector2(init.texCoord1[0], init.texCoord1[1]);
		}
		if (init.color0) {
			this.color0 = init.color0 instanceof Vector3 ?
				init.color0 :
				new Vector3(init.color0[0], init.color0[1], init.color0[2]);
		}
	}

@microsoft/mixed-reality-extension-sdk

The Mixed Reality Extension SDK enables developers to build 3D world extensions for AltspaceVR, using Node.JS.

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis