gltf how do you deal with latice references? - json

I am working with the rigged figure gltf:
Not to post the entire gltf, i will post the relevant nodes:
{
"children": [
21,
1
],
"matrix": [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
],
"name": "Z_UP"
},
{
"mesh": 0,
"skin": 0,
"name": "Proxy"
},
...
{
"translation": [
0.0,
0.06650590896606446,
0.0
],
"rotation": [
4.2157907720330458e-10,
0.9999844431877136,
-0.005583992227911949,
-7.549667913053783e-8
],
"scale": [
1.0,
1.0000001192092896,
1.0
],
"name": "neck_joint_2"
},
{
"children": [
2
],
"name": "Armature"
}
So node 0 is the parent of node 1 and node 21. However the skin in node 1 has it's joints starting at node 2. i.e. the skin in node 1 is the "parent" of the skeleton defined by the nodes from 2 to 21.
The question is then, should the transformation in node 0 be applied twice to the nodes in the skin?

From glTF Specifications — Skins...
Client implementations should apply only the transform of the skeleton root node to the skinned mesh while ignoring the transform of the skinned mesh node.
So in this sample, the inherited world transform of Node 1 is not applied to the joints/bones of the skin. In other words, the node-skin relationship does not apply any transformation to the joints of the skin.

Related

Why is Jmeter JSON Assertion successful in this situation?

I'm in need of help understanding how JSON Path assertions work in Jmeter.
Given the following JSON,
{
"isCompressed": true,
"rows": [
{
"_2": "",
"_4": "CustomString_1401",
"_5": {
"latitude": 0.0,
"longitude": 0.0,
"elevation": 0.0
},
"_6": "CustomString_1401",
"_8": "User0",
"_9": "User",
"_10": [],
"_11": 1641561103991
},
{
"_2": "",
"_4": "CustomString_3930",
"_5": {
"latitude": 0.0,
"longitude": 0.0,
"elevation": 0.0
},
"_6": "CustomString_3930",
"_8": "User0",
"_9": "User",
"_10": [],
"_11": 1641561045657
}
]
}
Any of the following different JSON Path assertions do NOT fail in a JSON Assertion in Jmeter 5.4.3. I'm using just a simple JSON assertion with no value assertion.
$.rows[?(#._4=="Custom")]._4
$.rows[?(#._4=="Custom_3930")]._122
In the case of assertion 1, there is no array element that satisfies that condition.
In case of assertion 2, there's no key with that name in there.
Why is the assertion successful if those paths do not exist?
It sounds like a bug in JMeter connected with presence of the Filter Operators in your query, you should raise it via JMeter Bugzilla
In the meantime you can switch to JSR223 Assertion and Groovy language, the equivalent code would be something like:
def result = com.jayway.jsonpath.JsonPath.read(prev.getResponseDataAsString(), '$.rows[?(#._4=="Custom")]._4')
if (result.size() == 0) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('There were no nodes matching the Json Path query')
}

How can I insert following JSON in MongoDB collection as different documents

I need to insert data in mongo but the JSON I am getting has multiple values in every field and I don't know how can I split them to insert in different documents.
I want to insert array data in different objects in MongoDB
{
"activity_template_id": [
1,
2,
3,
4,
5,
7
],
"done_date": [
"2019-08-10",
"2019-08-10",
"2019-08-10",
"0000-01-01",
"0000-01-01",
"0000-01-01"
],
"is_prescribed": [
"N",
"N",
"N",
"N",
"N",
"Y"
],
"material_id": [
1,
5,
21,
10,
14,
0
],
"qty": [
"1",
"1",
"1",
"0",
"0",
"0"
],
"unit_id": [
1,
1,
25,
0,
0,
0
],
}
(As far as I know) there is no feature in MongoDB itself that would process input data like that. You would do that in application code before calling MongoDB.
If there is no separate application, you can use standard JavaScript functions within the mongo shell to do that.

Convert R data.frame to specific json file for heatmap concept

I have following data frame in R:
df <- data.frame(RowNames <- c("FirstCol","SecondCol","ThirdCol","FourthCol"),
FirstCol <- c(0.4,0.5,0.1,0.2),
SecondCol <- c(0.8,0.6,0.4,0.1),
ThirdCol <- c(0.7,0.1,0.2,0.6),
FourthCol <- c(0.5,0.3,0.1,0.9))
names(df) <- c("RowNames", "FirstCol", "SecondCol", "ThirdCol", "FourthCol")
And I like to convert this data frame into very specific json file for further heatmap drawing concept:
# desired output
{
"x": [ "FirstCol", "SecondCol", "ThirdCol", "FourthCol" ],
"y": [ "FourthCol", "ThirdCol", "SecondCol", "FirstCol" ],
"z": [
[ 0.2, 0.1, 0.6, 0.9 ],
[ 0.1, 0.4, 0.2, 0.1 ],
[ 0.5, 0.6, 0.1, 0.3 ],
[ 0.4, 0.8, 0.7, 0.5 ]]
}
Is there any specific approach, how to do that in the easiest way? I really have no idea where should I start. Thank you very much for any of your help in advance.
We can use toJSON from jsonlite by placing the names and the data (reversed from last row to first row) in a named list.
library(jsonlite)
toJSON(list(x=names(df)[-1], y=rev(names(df)[-1]),
z=`dimnames<-`(as.matrix(df[nrow(df):1,-1]), NULL)))
{
"x":["FirstCol","SecondCol","ThirdCol","FourthCol"],
"y":["FourthCol","ThirdCol","SecondCol","FirstCol"],
"z":[[0.2,0.1,0.6,0.9],
[0.1,0.4,0.2,0.1],
[0.5,0.6,0.1,0.3],
[0.4,0.8,0.7,0.5]]
}

Three.js - Adding JSON file type to SceneLoader

Using http://threejs.org/examples/#webgl_loader_scene as an example, I am trying to add a js file exported from Blender. The file loads correctly with the JSONLoader, but now I would like it to be in combination with other files plus having a progress bar.
$( "progress" ).style.display = "block";
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
var loader = new THREE.SceneLoader();
loader.addGeometryHandler( "binary", THREE.BinaryLoader );
loader.addGeometryHandler( "ctm", THREE.CTMLoader );
loader.addGeometryHandler( "vtk", THREE.VTKLoader );
loader.addGeometryHandler( "stl", THREE.STLLoader );
loader.addHierarchyHandler( "obj", THREE.OBJLoader );
loader.addHierarchyHandler( "dae", THREE.ColladaLoader );
loader.addHierarchyHandler( "utf8", THREE.UTF8Loader );
loader.addHierarchyHandler( "json", THREE.JSONLoader );
loader.callbackProgress = callbackProgress;
loader.load( "scenes/test_scene.js", callbackFinished );
I added the json HierarchyHandler and included the JSONLoader.js file.
loader.addHierarchyHandler( "json", THREE.JSONLoader );
And then I added this to test_scene.js under "objects" where other dae and obj files are.
"tree" : {
"type": "json",
"url" : "models/json/tree.js",
"position" : [ -43, -10, 27 ],
"rotation" : [ -1.57, 0, 0 ],
"scale" : [ 5, 5, 5 ],
"visible" : true
},
The console logs that it reads the texture files referenced for the tree but never finishes - the progress bar remains at 99%.
But the error that I receive is:
Uncaught TypeError: Cannot read property 'fromArray' of undefined SceneLoader.js:554
Does anyone know why this may be happening or what I'm doing wrong? The three.js example loads all types of files except json. Could there a reason for that or am I just missing something? I've read that SceneLoader is to be depreciated and I should consider using ObjectLoader but there are no example of how to do so.
Thank you!
Actually, I think that the SceneLoader example that comes with Three.js includes a JSON. If I'm not mistaken, the Scene Loader is in fact capable of loading JSON files per se, without requiring any HierarchyHandler.
I actually think that your attempt in adding the JSONLoader.js file is not really linking anything.
I had a look at the example: webgl_loader_scene.html. If you open the related scene (test_scene.js) you can find an actual JSON geometry between the imports:
"embeds": {
"cube_fvc": {
"metadata" : {
"formatVersion" : 3
},
"scale" : 1.0,
"materials": [{
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Material",
"colorAmbient" : [0.0, 0.0, 0.0],
"colorDiffuse" : [0.8, 0.8, 0.8],
"colorSpecular" : [0.5, 0.5, 0.5],
"specularCoef" : 50,
"transparency" : 1.0,
"vertexColors" : true
}],
"vertices": [1.000000,-1.000000,-1.000000,1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,-1.000000,1.000000,1.000000,-1.000000,0.999999,1.000000,1.000001,-1.000000,1.000000,1.000000,-1.000000,1.000000,-1.000000],
"morphTargets": [],
"normals": [],
"colors": [16777215,16769421,16769424,8454135,15195931,7299839,16586715,16711687,1056014,6029475,13762484,9044089,7962349,6772991,16774622,4144383,11973887,1966063,1056285,9081232,13696943,5002581],
"uvs": [[]],
"faces": [131,0,1,2,3,0,0,1,2,3,131,4,7,6,5,0,4,5,6,7,131,0,4,5,1,0,0,8,9,10,131,1,5,6,2,0,0,11,12,13,131,2,6,7,3,0,14,15,16,17,131,4,0,3,7,0,18,19,20,21]
}
},
So I think that all you need to do is to refer a JSON file in the same syntax required by the SceneLoader.

Custom layouts, Sublime text 2

I've been working with a 2 column system so far but feel I'm needing a third and that 3 spread across the screen doesn't give much of a view without adjusting the width every time.
It's there a way to get the grid layout but have the bottom half of the screen one file.
I know it's a long shot but wondering if anyone knows of anything
Found that you can edit for custom layouts in Packages/default/Main.sublime-menu
Having problems saving though error in trying to parse file: expected value in ~/library/application support/sublime text 2/packages/default/Main.sublime-menu:407:21
Edited: for better layout
Found something that is similar, been trying to mod it but don't understand how the cells work
This one is similar
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells": [
[0, 0, 1, 2], // (0.0, 0.0) -> (0.5, 1.0)
[1, 0, 2, 1], // (0.5, 0.0) -> (1.0, 0.5)
[1, 1, 2, 2] // (0.5, 0.5) -> (1.0, 1.0)
]
}
which gives
Assuming these are just coordinates with 0,0 at the upper left, something like this should work:
[0, 0, 1, 1],
[1, 0, 2, 1],
[0, 1, 2, 2]
Edit: Just tested, and it does.
Create the file Main.sublime-menu in your Packages > User folder (best to leave the default menu alone) and put the following code in it:
[{
"id": "view",
"children": [{
"id": "layout",
"children": [{
"command": "set_layout",
"caption" : "Custom: 3 Pane",
"mnemonic": "C",
"args": {
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells": [
[0, 0, 1, 1],
[1, 0, 2, 1],
[0, 1, 2, 2]
]
}
}]
}]
}]
You will see Custom: 3 Pane in your layout options. No need to restart Sublime Text.
For anyone interested, here is a gist containing this layout as well as a flipped version.
This was very helpful for visualizing what points the coordinates are referring to: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=7284&start=0&hilit=set+layout