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 setPrimitiveMode(meshPrimitive: IMeshPrimitive, primitiveMode: number) {
switch (primitiveMode) {
case Material.TriangleFillMode: {
// glTF defaults to using Triangle Mode
break;
}
case Material.TriangleStripDrawMode: {
meshPrimitive.mode = MeshPrimitiveMode.TRIANGLE_STRIP;
break;
}
case Material.TriangleFanDrawMode: {
meshPrimitive.mode = MeshPrimitiveMode.TRIANGLE_FAN;
break;
}
case Material.PointListDrawMode: {
meshPrimitive.mode = MeshPrimitiveMode.POINTS;
}
case Material.PointFillMode: {
meshPrimitive.mode = MeshPrimitiveMode.POINTS;
break;
}
case Material.LineLoopDrawMode: {
meshPrimitive.mode = MeshPrimitiveMode.LINE_LOOP;
break;
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;
}
babylonMesh._delayInfo = babylonMesh._delayInfo || [];
if (babylonMesh._delayInfo.indexOf(kind) === -1) {
babylonMesh._delayInfo.push(kind);
}
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})`);
}