fix syntax
This commit is contained in:
40
obj.c
40
obj.c
@@ -30,7 +30,7 @@ static JSValue make_float_array(JSContext *js, const float *arr, int count)
|
||||
{
|
||||
JSValue a = JS_NewArray(js);
|
||||
for (int i = 0; i < count; i++)
|
||||
JS_SetPropertyUint32(js, a, i, JS_NewFloat64(js, arr[i]));
|
||||
JS_SetPropertyNumber(js, a, i, JS_NewFloat64(js, arr[i]));
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JSValue buf = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, buf, "blob", js_new_blob_stoned_copy(js, buffer_data, total_buffer_size));
|
||||
JS_SetPropertyStr(js, buf, "byte_length", JS_NewInt64(js, total_buffer_size));
|
||||
JS_SetPropertyUint32(js, buffers_arr, 0, buf);
|
||||
JS_SetPropertyNumber(js, buffers_arr, 0, buf);
|
||||
JS_SetPropertyStr(js, obj, "buffers", buffers_arr);
|
||||
|
||||
// Create views
|
||||
@@ -174,7 +174,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, pos_view, "byte_length", JS_NewInt64(js, pos_size));
|
||||
JS_SetPropertyStr(js, pos_view, "byte_stride", JS_NULL);
|
||||
JS_SetPropertyStr(js, pos_view, "usage", JS_NewString(js, "vertex"));
|
||||
JS_SetPropertyUint32(js, views_arr, view_idx++, pos_view);
|
||||
JS_SetPropertyNumber(js, views_arr, view_idx++, pos_view);
|
||||
int pos_view_idx = 0;
|
||||
|
||||
int norm_view_idx = -1;
|
||||
@@ -186,7 +186,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, norm_view, "byte_stride", JS_NULL);
|
||||
JS_SetPropertyStr(js, norm_view, "usage", JS_NewString(js, "vertex"));
|
||||
norm_view_idx = view_idx;
|
||||
JS_SetPropertyUint32(js, views_arr, view_idx++, norm_view);
|
||||
JS_SetPropertyNumber(js, views_arr, view_idx++, norm_view);
|
||||
}
|
||||
|
||||
int uv_view_idx = -1;
|
||||
@@ -198,7 +198,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, uv_view, "byte_stride", JS_NULL);
|
||||
JS_SetPropertyStr(js, uv_view, "usage", JS_NewString(js, "vertex"));
|
||||
uv_view_idx = view_idx;
|
||||
JS_SetPropertyUint32(js, views_arr, view_idx++, uv_view);
|
||||
JS_SetPropertyNumber(js, views_arr, view_idx++, uv_view);
|
||||
}
|
||||
|
||||
// Index view
|
||||
@@ -209,7 +209,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, idx_view, "byte_stride", JS_NULL);
|
||||
JS_SetPropertyStr(js, idx_view, "usage", JS_NewString(js, "index"));
|
||||
int idx_view_idx = view_idx;
|
||||
JS_SetPropertyUint32(js, views_arr, view_idx++, idx_view);
|
||||
JS_SetPropertyNumber(js, views_arr, view_idx++, idx_view);
|
||||
|
||||
JS_SetPropertyStr(js, obj, "views", views_arr);
|
||||
|
||||
@@ -228,7 +228,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, pos_acc, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, pos_acc, "max", JS_NULL);
|
||||
int pos_acc_idx = acc_idx;
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, pos_acc);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, pos_acc);
|
||||
|
||||
int norm_acc_idx = -1;
|
||||
if (global_has_normals) {
|
||||
@@ -242,7 +242,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, norm_acc, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, norm_acc, "max", JS_NULL);
|
||||
norm_acc_idx = acc_idx;
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, norm_acc);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, norm_acc);
|
||||
}
|
||||
|
||||
int uv_acc_idx = -1;
|
||||
@@ -257,7 +257,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, uv_acc, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, uv_acc, "max", JS_NULL);
|
||||
uv_acc_idx = acc_idx;
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, uv_acc);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, uv_acc);
|
||||
}
|
||||
|
||||
// Index accessor
|
||||
@@ -271,7 +271,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, idx_acc, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, idx_acc, "max", JS_NULL);
|
||||
int idx_acc_idx = acc_idx;
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, idx_acc);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, idx_acc);
|
||||
|
||||
JS_SetPropertyStr(js, obj, "accessors", accessors_arr);
|
||||
|
||||
@@ -302,7 +302,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, spa, "normalized", JS_FALSE);
|
||||
JS_SetPropertyStr(js, spa, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, spa, "max", JS_NULL);
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, spa);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, spa);
|
||||
|
||||
int shape_norm_acc = -1;
|
||||
if (global_has_normals) {
|
||||
@@ -316,7 +316,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, sna, "normalized", JS_FALSE);
|
||||
JS_SetPropertyStr(js, sna, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, sna, "max", JS_NULL);
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, sna);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, sna);
|
||||
}
|
||||
|
||||
int shape_uv_acc = -1;
|
||||
@@ -331,7 +331,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, sua, "normalized", JS_FALSE);
|
||||
JS_SetPropertyStr(js, sua, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, sua, "max", JS_NULL);
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, sua);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, sua);
|
||||
}
|
||||
|
||||
int shape_idx_acc = acc_idx;
|
||||
@@ -344,7 +344,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, sia, "normalized", JS_FALSE);
|
||||
JS_SetPropertyStr(js, sia, "min", JS_NULL);
|
||||
JS_SetPropertyStr(js, sia, "max", JS_NULL);
|
||||
JS_SetPropertyUint32(js, accessors_arr, acc_idx++, sia);
|
||||
JS_SetPropertyNumber(js, accessors_arr, acc_idx++, sia);
|
||||
|
||||
// Create mesh
|
||||
JSValue mesh = JS_NewObject(js);
|
||||
@@ -365,10 +365,10 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, prim, "indices", JS_NewInt32(js, shape_idx_acc));
|
||||
JS_SetPropertyStr(js, prim, "material", JS_NULL);
|
||||
|
||||
JS_SetPropertyUint32(js, prims_arr, 0, prim);
|
||||
JS_SetPropertyNumber(js, prims_arr, 0, prim);
|
||||
JS_SetPropertyStr(js, mesh, "primitives", prims_arr);
|
||||
|
||||
JS_SetPropertyUint32(js, meshes_arr, si, mesh);
|
||||
JS_SetPropertyNumber(js, meshes_arr, si, mesh);
|
||||
vertex_offset += shape_vertices;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, m, "alpha_cutoff", JS_NewFloat64(js, 0.5));
|
||||
JS_SetPropertyStr(js, m, "double_sided", JS_FALSE);
|
||||
|
||||
JS_SetPropertyUint32(js, materials_arr, i, m);
|
||||
JS_SetPropertyNumber(js, materials_arr, i, m);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "materials", materials_arr);
|
||||
|
||||
@@ -425,8 +425,8 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, n, "rotation", make_float_array(js, r, 4));
|
||||
JS_SetPropertyStr(js, n, "scale", make_float_array(js, s, 3));
|
||||
JS_SetPropertyStr(js, n, "skin", JS_NULL);
|
||||
JS_SetPropertyUint32(js, nodes_arr, i, n);
|
||||
JS_SetPropertyUint32(js, scene_nodes, i, JS_NewInt32(js, i));
|
||||
JS_SetPropertyNumber(js, nodes_arr, i, n);
|
||||
JS_SetPropertyNumber(js, scene_nodes, i, JS_NewInt32(js, i));
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "nodes", nodes_arr);
|
||||
|
||||
@@ -434,7 +434,7 @@ JSValue js_obj_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JSValue scenes_arr = JS_NewArray(js);
|
||||
JSValue scene = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, scene, "nodes", scene_nodes);
|
||||
JS_SetPropertyUint32(js, scenes_arr, 0, scene);
|
||||
JS_SetPropertyNumber(js, scenes_arr, 0, scene);
|
||||
JS_SetPropertyStr(js, obj, "scenes", scenes_arr);
|
||||
JS_SetPropertyStr(js, obj, "scene", JS_NewInt32(js, 0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user