Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, (extensionContext, extension) => {
if (primitive.mode != undefined) {
if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP &&
primitive.mode !== MeshPrimitiveMode.TRIANGLES) {
throw new Error(`${context}: Unsupported mode ${primitive.mode}`);
}
// TODO: handle triangle strips
if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {
throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);
}
}
const attributes: { [kind: string]: number } = {};
const loadAttribute = (name: string, kind: string) => {
const uniqueId = extension.attributes[name];
if (uniqueId == undefined) {
return;
}
private static _GetDrawMode(context: string, mode: number | undefined): number {
if (mode == undefined) {
mode = MeshPrimitiveMode.TRIANGLES;
}
switch (mode) {
case MeshPrimitiveMode.POINTS: return Material.PointListDrawMode;
case MeshPrimitiveMode.LINES: return Material.LineListDrawMode;
case MeshPrimitiveMode.LINE_LOOP: return Material.LineLoopDrawMode;
case MeshPrimitiveMode.LINE_STRIP: return Material.LineStripDrawMode;
case MeshPrimitiveMode.TRIANGLES: return Material.TriangleFillMode;
case MeshPrimitiveMode.TRIANGLE_STRIP: return Material.TriangleStripDrawMode;
case MeshPrimitiveMode.TRIANGLE_FAN: return Material.TriangleFanDrawMode;
}
throw new Error(`${context}: Invalid mesh primitive mode (${mode})`);
}
private static _GetDrawMode(context: string, mode: number | undefined): number {
if (mode == undefined) {
mode = MeshPrimitiveMode.TRIANGLES;
}
switch (mode) {
case MeshPrimitiveMode.POINTS: return Material.PointListDrawMode;
case MeshPrimitiveMode.LINES: return Material.LineListDrawMode;
case MeshPrimitiveMode.LINE_LOOP: return Material.LineLoopDrawMode;
case MeshPrimitiveMode.LINE_STRIP: return Material.LineStripDrawMode;
case MeshPrimitiveMode.TRIANGLES: return Material.TriangleFillMode;
case MeshPrimitiveMode.TRIANGLE_STRIP: return Material.TriangleStripDrawMode;
case MeshPrimitiveMode.TRIANGLE_FAN: return Material.TriangleFanDrawMode;
}
throw new Error(`${context}: Invalid mesh primitive mode (${mode})`);
}
private static _GetDrawMode(context: string, mode: number | undefined): number {
if (mode == undefined) {
mode = MeshPrimitiveMode.TRIANGLES;
}
switch (mode) {
case MeshPrimitiveMode.POINTS: return Material.PointListDrawMode;
case MeshPrimitiveMode.LINES: return Material.LineListDrawMode;
case MeshPrimitiveMode.LINE_LOOP: return Material.LineLoopDrawMode;
case MeshPrimitiveMode.LINE_STRIP: return Material.LineStripDrawMode;
case MeshPrimitiveMode.TRIANGLES: return Material.TriangleFillMode;
case MeshPrimitiveMode.TRIANGLE_STRIP: return Material.TriangleStripDrawMode;
case MeshPrimitiveMode.TRIANGLE_FAN: return Material.TriangleFanDrawMode;
}
throw new Error(`${context}: Invalid mesh primitive mode (${mode})`);
}
private static _GetDrawMode(context: string, mode: number | undefined): number {
if (mode == undefined) {
mode = MeshPrimitiveMode.TRIANGLES;
}
switch (mode) {
case MeshPrimitiveMode.POINTS: return Material.PointListDrawMode;
case MeshPrimitiveMode.LINES: return Material.LineListDrawMode;
case MeshPrimitiveMode.LINE_LOOP: return Material.LineLoopDrawMode;
case MeshPrimitiveMode.LINE_STRIP: return Material.LineStripDrawMode;
case MeshPrimitiveMode.TRIANGLES: return Material.TriangleFillMode;
case MeshPrimitiveMode.TRIANGLE_STRIP: return Material.TriangleStripDrawMode;
case MeshPrimitiveMode.TRIANGLE_FAN: return Material.TriangleFanDrawMode;
}
throw new Error(`${context}: Invalid mesh primitive mode (${mode})`);
}