fix syntax
This commit is contained in:
46
fbx.c
46
fbx.c
@@ -8,7 +8,7 @@ static JSValue make_float_array(JSContext *js, const double *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;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ static JSValue make_float_array_f(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;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ JSValue js_fbx_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
|
||||
@@ -159,7 +159,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, pos_view, "byte_stride", JS_NULL);
|
||||
JS_SetPropertyStr(js, pos_view, "usage", JS_NewString(js, "vertex"));
|
||||
int pos_view_idx = view_idx;
|
||||
JS_SetPropertyUint32(js, views_arr, view_idx++, pos_view);
|
||||
JS_SetPropertyNumber(js, views_arr, view_idx++, pos_view);
|
||||
|
||||
int norm_view_idx = -1;
|
||||
if (global_has_normals) {
|
||||
@@ -170,7 +170,7 @@ JSValue js_fbx_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;
|
||||
@@ -182,7 +182,7 @@ JSValue js_fbx_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);
|
||||
}
|
||||
|
||||
JSValue idx_view = JS_NewObject(js);
|
||||
@@ -192,7 +192,7 @@ JSValue js_fbx_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);
|
||||
|
||||
@@ -217,7 +217,7 @@ JSValue js_fbx_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 mesh_norm_acc = -1;
|
||||
if (global_has_normals) {
|
||||
@@ -231,7 +231,7 @@ JSValue js_fbx_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 mesh_uv_acc = -1;
|
||||
@@ -246,7 +246,7 @@ JSValue js_fbx_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 mesh_idx_acc = acc_idx;
|
||||
@@ -259,7 +259,7 @@ JSValue js_fbx_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 m = JS_NewObject(js);
|
||||
@@ -280,10 +280,10 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, prim, "indices", JS_NewInt32(js, mesh_idx_acc));
|
||||
JS_SetPropertyStr(js, prim, "material", mesh->materials.count > 0 ? JS_NewInt32(js, mesh->materials.data[0]->typed_id) : JS_NULL);
|
||||
|
||||
JS_SetPropertyUint32(js, prims_arr, 0, prim);
|
||||
JS_SetPropertyNumber(js, prims_arr, 0, prim);
|
||||
JS_SetPropertyStr(js, m, "primitives", prims_arr);
|
||||
|
||||
JS_SetPropertyUint32(js, meshes_arr, mi, m);
|
||||
JS_SetPropertyNumber(js, meshes_arr, mi, m);
|
||||
}
|
||||
|
||||
JS_SetPropertyStr(js, obj, "accessors", accessors_arr);
|
||||
@@ -323,7 +323,7 @@ JSValue js_fbx_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);
|
||||
|
||||
@@ -335,7 +335,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, im, "kind", JS_NewString(js, "uri"));
|
||||
JS_SetPropertyStr(js, im, "uri", tf->filename.length > 0 ? JS_NewString(js, tf->filename.data) : JS_NULL);
|
||||
JS_SetPropertyStr(js, im, "mime", JS_NULL);
|
||||
JS_SetPropertyUint32(js, images_arr, i, im);
|
||||
JS_SetPropertyNumber(js, images_arr, i, im);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "images", images_arr);
|
||||
|
||||
@@ -345,7 +345,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JSValue t = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, t, "image", tex->file_index != UFBX_NO_INDEX ? JS_NewInt32(js, tex->file_index) : JS_NULL);
|
||||
JS_SetPropertyStr(js, t, "sampler", JS_NULL);
|
||||
JS_SetPropertyUint32(js, textures_arr, i, t);
|
||||
JS_SetPropertyNumber(js, textures_arr, i, t);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "textures", textures_arr);
|
||||
|
||||
@@ -375,7 +375,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
// Find child node index
|
||||
for (size_t ni = 0; ni < scene->nodes.count; ni++) {
|
||||
if (scene->nodes.data[ni] == node->children.data[ci]) {
|
||||
JS_SetPropertyUint32(js, children, ci, JS_NewInt32(js, ni));
|
||||
JS_SetPropertyNumber(js, children, ci, JS_NewInt32(js, ni));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -391,7 +391,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
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_SetPropertyNumber(js, nodes_arr, i, n);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "nodes", nodes_arr);
|
||||
|
||||
@@ -402,12 +402,12 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
// Find root node index
|
||||
for (size_t i = 0; i < scene->nodes.count; i++) {
|
||||
if (scene->nodes.data[i] == scene->root_node) {
|
||||
JS_SetPropertyUint32(js, scene_nodes, 0, JS_NewInt32(js, i));
|
||||
JS_SetPropertyNumber(js, scene_nodes, 0, JS_NewInt32(js, i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
JS_SetPropertyStr(js, scene_obj, "nodes", scene_nodes);
|
||||
JS_SetPropertyUint32(js, scenes_arr, 0, scene_obj);
|
||||
JS_SetPropertyNumber(js, scenes_arr, 0, scene_obj);
|
||||
JS_SetPropertyStr(js, obj, "scenes", scenes_arr);
|
||||
JS_SetPropertyStr(js, obj, "scene", JS_NewInt32(js, 0));
|
||||
|
||||
@@ -419,7 +419,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, a, "name", stack->element.name.length > 0 ? JS_NewString(js, stack->element.name.data) : JS_NULL);
|
||||
JS_SetPropertyStr(js, a, "samplers", JS_NewArray(js));
|
||||
JS_SetPropertyStr(js, a, "channels", JS_NewArray(js));
|
||||
JS_SetPropertyUint32(js, anims_arr, ai, a);
|
||||
JS_SetPropertyNumber(js, anims_arr, ai, a);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "animations", anims_arr);
|
||||
|
||||
@@ -436,7 +436,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
if (cluster->bone_node) {
|
||||
for (size_t ni = 0; ni < scene->nodes.count; ni++) {
|
||||
if (scene->nodes.data[ni] == cluster->bone_node) {
|
||||
JS_SetPropertyUint32(js, joints, ci, JS_NewInt32(js, ni));
|
||||
JS_SetPropertyNumber(js, joints, ci, JS_NewInt32(js, ni));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ JSValue js_fbx_decode(JSContext *js, JSValue this_val, int argc, JSValueConst *a
|
||||
JS_SetPropertyStr(js, s, "inverse_bind_matrices", JS_NULL);
|
||||
JS_SetPropertyStr(js, s, "skeleton", JS_NULL);
|
||||
|
||||
JS_SetPropertyUint32(js, skins_arr, i, s);
|
||||
JS_SetPropertyNumber(js, skins_arr, i, s);
|
||||
}
|
||||
JS_SetPropertyStr(js, obj, "skins", skins_arr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user