Blender exporter - "uncaught syntaxError unexpected token" THREE.JSONLoader() - three.js

Have you come across this erro: "uncaught syntaxError unexpected token"
When loading a model exported from Blender 2.63a with the three exporter addon?
From this code copied from three.js github example
var loader = new THREE.JSONLoader();
loader.load( {"buffalo.js", function(geo){createModel(geo)}});
Thanks
Regards
Chris

Check whether the model has a material. Search in buffalo.s for the string: "material" : ,. If you find that string, your model has no material assigned - bad syntax error appears! Go to blender, assign material, and export again to buffalo.js.
Not working:
...
"objects" :
{
"Monkey" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"material" : ,
"position" : [ -0.150241, 5.41906, 2.96394 ],
"rotation" : [ 0.874236, 0.0220203, -3.11527 ],
"quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
"scale" : [ 2.9257, 2.86503, 2.68207 ],
"visible" : true,
"castShadow" : false,
"receiveShadow" : false,
"doubleSided" : false
},
...
},
...
Working:
...
"objects" :
{
"Monkey" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"material" : "Material",
"position" : [ -0.150241, 5.41906, 2.96394 ],
"rotation" : [ 0.874236, 0.0220203, -3.11527 ],
"quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
"scale" : [ 2.9257, 2.86503, 2.68207 ],
"visible" : true,
"castShadow" : false,
"receiveShadow" : false,
"doubleSided" : false
},
...
},
...

I got this working by leaving out the JSON signature of the load function. Like this:
loader = new THREE.JSONLoader();
loader.load( 'buffalo.js',function( geo )
{
....
Hope this helps
Regards

Related

AppointmentType resource

I need to return AppointmentTypes as a FHIR resource. Unfortunately, I couldn't find it as an official FHIR resource format.
My best guess would be to create a Basic resource, like this:
{
"resourceType": "Basic",
"id" : "id-of-appointment-type",
"identifier" : [
{
"use" : "secondary",
"system" : "http://myUrl/myIdentifier",
"value" : "7"
}
],
"code" : {
"coding": [
{
"system": "http://myUrl/appointment-type",
"code": "appointment-type"
}
]
},
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">AppointmentType</div>"
},
"extension": [
{
"url": "http://myUrl/appointment-type-name",
"valueString": "New Patient"
},
{
"url": "http://myUrl/appointment-type-availability",
"valueBoolean": true
}
],
"meta" : {
"lastUpdated" : "2020-05-27T00:00:00.000Z"
}
}
Would this be the right way to create the AppointmentType resource?
I don't see any obvious issues, but did you evaluate using CodeSystem? You can define properties on CodeSystem codes which would be able to distinguish available from non-available appointment types - and that would work better with Appointment, where 'type' is expected to be a code.

Step function cloud formation issue with Fn::Sub when passing list as second parameter

I am trying to create step function using cloud formation. I want to pass the lambda arns as second argument to Fn::Sub function. It works if I pass just one Arn but fails when I pass multiple. (with Fn::Get). I checked the template with Yml validator and did not see any issues.
Cloud formation template definition for Step:
---
Resources:
ContractDraftStateMachine:
Type: "AWS::StepFunctions::StateMachine"
Properties:
RoleArn:
Fn::GetAtt: [ StepFunctionExecutionRole, Arn ]
DefinitionString:
Fn::Sub:
- |-
{
"Comment" : "Sample draft process",
"StartAt" : "AdvanceWorkflowToDraftInProgress",
"States" : {
"AdvanceWorkflowToDraftInProgress" : {
"Type" : "Task",
"Resource": "${WorkflowStateChangeLambdaArn}",
"InputPath":"$.contractId",
"OutputPath":"$",
"ResultPath":null,
"Next" : "CheckQuestionnaireType",
"Retry" : [
{
"ErrorEquals" : ["States.TaskTimeout"],
"MaxAttempts": 5,
"IntervalSeconds": 1
},
{
"ErrorEquals" : ["CustomErrorA"],
"MaxAttempts": 5
}
],
"Catch": [
{
"ErrorEquals": [ "States.ALL" ],
"Next": "FailureNotifier"
}
]
},
"CheckQuestionnaireType" : {
"Type" : "Choice",
"Choices" : [
{
"Variable" : "$.questionnaireType",
"StringEquals" : "CE",
"Next" : "PublishQuestionnaireAnswersToCE"
},
{
"Variable" : "$.questionnaireType",
"StringEquals" : "LEAF",
"Next" : "PublishQuestionnaireAnswersToLeaf"
}
]
},
"PublishQuestionnaireAnswersToCE" : {
"Type" : "Task",
"Resource": "${WorkflowStateChangeLambdaArn}",
"Next" : "UpdateCEMetadataAndGenerateDocuments",
"ResultPath" : null,
"OutputPath" : "$",
"Retry" : [
{
"ErrorEquals" : ["States.TaskTimeout"],
"MaxAttempts": 5,
"IntervalSeconds": 1
},
{
"ErrorEquals" : ["CustomErrorA"],
"MaxAttempts": 5
}
],
"Catch": [
{
"ErrorEquals": [ "States.ALL" ],
"Next": "FailureNotifier"
}
]
},
"PublishQuestionnaireAnswersToLeaflet" : {
"Type" : "Task",
"Resource": "${WorkflowStateChangeLambdaArn}",
"End" : true,
"Retry" : [
{
"ErrorEquals" : ["States.TaskTimeout"],
"MaxAttempts": 5,
"IntervalSeconds": 1
},
{
"ErrorEquals" : ["CustomErrorA"],
"MaxAttempts": 5
}
],
"Catch": [
{
"ErrorEquals": [ "States.ALL" ],
"Next": "FailureNotifier"
}
]
},
"UpdateCEMetadataAndGenerateDocuments" : {
"Type" : "Task",
"Resource": "${WorkflowStateChangeLambdaArn}",
"End" : true,
"Retry" : [
{
"ErrorEquals" : ["States.TaskTimeout"],
"MaxAttempts": 5,
"IntervalSeconds": 1
},
{
"ErrorEquals" : ["CustomErrorA"],
"MaxAttempts": 5
}
],
"Catch": [
{
"ErrorEquals": [ "States.ALL" ],
"Next": "FailureNotifier"
}
]
},
"FailureNotifier" : {
"Type" : "Task",
"Resource": "${FailureNotifierLambdaArn}",
"End" : true,
"Retry" : [
{
"ErrorEquals" : ["States.TaskTimeout"],
"MaxAttempts": 5,
"IntervalSeconds": 1
},
{
"ErrorEquals" : ["CustomErrorA"],
"MaxAttempts": 5
}
]
}
}
}
- WorkflowStateChangeLambdaArn:
Fn::GetAtt: [ CreateContractFromQuestionnaireFunction, Arn ]
- FailureNotifierLambdaArn:
Fn::GetAtt: [ CreateContractFromQuestionnaireFunction, Arn ]
Error - Template error: One or more Fn::Sub intrinsic functions don't specify expected arguments. Specify a string as first argument, and an optional second argument to specify a mapping of values to replace in the string
This is just a sample with same lambda used multiple times but the problem is in passing list/map to Fn::Sub.
Could anyone help me resolve this issue or provide an alternate solution to achieve the same?
Thanks,
Fn::Sub takes either a single string as a parameter or a list. When using the list method there should be just two elemenets in the list. The first element is a string (the template) and the second is a map.
From the Fn::Sub documentation
Fn::Sub:
- String
- { Var1Name: Var1Value, Var2Name: Var2Value }
Note: since you are just using Fn::Get attribute to build the substitution value you can just use ${CreateContractFromQuestionnaireFunction.Arn} and use the single string version of Fn::Sub.
E.g. (I've shortened the step function for clarity.
Fn::Sub:|-
{
"Comment" : "Sample draft process",
"StartAt" : "AdvanceWorkflowToDraftInProgress",
"States" : {
"AdvanceWorkflowToDraftInProgress" : {
"Type" : "Task",
"Resource": "${CreateContractFromQuestionnaireFunction.Arn}",
"InputPath":"$.contractId",
"OutputPath":"$",
"ResultPath":null,
"Next" : "CheckQuestionnaireType",
"Retry" : [
...

Google places API not returning address components

My program is trying to determine the City, state, and country based on some text, for example "New york yankee stadium" I want to get New york city, NY, USA. I am using Google places API to do this. According to the documentations, the API should return a list of address component https://developers.google.com/places/web-service/details. However, right now its only returning formatted address "1 E 161st St, Bronx, NY 10451, United States".
here is my web service url
https://maps.googleapis.com/maps/api/place/textsearch/json?key=MY_KEY&query=new%20york%20yankee%20stadium
Anyone familiar with google places API that can let me know if I am not writting the right query or parameter?
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "1 E 161st St, Bronx, NY 10451, United States",
"geometry" : {
"location" : {
"lat" : 40.82964260000001,
"lng" : -73.9261745
},
"viewport" : {
"northeast" : {
"lat" : 40.83279975,
"lng" : -73.92236575000001
},
"southwest" : {
"lat" : 40.82643674999999,
"lng" : -73.93052034999999
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "3d78036d61d35f48650bda737226432b57d82511",
"name" : "Yankee Stadium",
"opening_hours" : {
"open_now" : true,
"weekday_text" : []
},
"photos" : [
{
"height" : 540,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/101696810905045719819/photos\"\u003eYankee Stadium\u003c/a\u003e"
],
"photo_reference" : "CoQBdwAAAIxmCLrNS_XZ2FcJqVvRVtBUlNYMBVTVKppOWBu7sICj2q70cqJARBoJlTcZpydbMTzURKWWMVJhYpVCqsnia5pjmDhjvjsTirrEnAc6gvmRYKuUwgewB9Re--FulXzXZ5DY3P9fkwIwuc4U9BJVbqHD5O-N6SbbHcqn4XHUj_OdEhCoNPZ3kiNJhxOCGdYG5O4DGhTqVfUjdq7JzasqYATvQxkL1-H3xg",
"width" : 1242
}
],
"place_id" : "ChIJcWnnWiz0wokRCB6aVdnDQEk",
"rating" : 4.4,
"reference" : "CmRRAAAA5dHiw1YmLxW60_jITBZjMiUs48L4aVUqlPnPDpN_ySa7rw8kPp04WWk0qf8mG-kkMFSNzh39lP0YwfynW54tLcY4s_EYbAPvNWTMe6wXHm_FJiVbI0Lfenyxz4yOTzunEhDgI64EWoXkQe9k45y6qP3-GhSVSdCMPPZA3joFbnYGV-bqo2e0lw",
"types" : [ "stadium", "point_of_interest", "establishment" ]
}
],
"status" : "OK"
}
Its a two step process, first search and get the place_id from google places search service,
use the returned place_id and pass it with another call to receive the individual address components,
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJcWnnWiz0wokRCB6aVdnDQEk&key=
{"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "1",
"short_name": "1",
"types": [
"street_number"
]
},
{
"long_name": "East 161st Street",
"short_name": "E 161st St",
"types": [
"route"
]
},
{
"long_name": "Concourse",
"short_name": "Concourse",
"types": [
"neighborhood",
"political"
]
},
{
"long_name": "Bronx",
"short_name": "Bronx",
"types": [
"sublocality_level_1",
"sublocality",
"political"
]
},
{
"long_name": "Bronx County",
"short_name": "Bronx County",
"types": [
"administrative_area_level_2",
"political"
]
},

How to represent a Mongo based NumberLong() in org.springframework.data.mongodb.repository.Query()

I need to fetch records from a MongoDB which has a set of documents. I am using Spring Boot and MongoRepository to do the CRUD operations. I am using a Query annotation to pass my Mongo query.But Spring is unable to parse the query that I have written. I am new to MongoDB, so please excuse me if this is a silly question. Any help is appreciated, Thanks.
This is the Query I am using:
#Query("{ '_id.AID' : ?0, '_id.STS' : {'$gte': NumberLong(1475778600)}, '_id.ETS':{'$lte': NumberLong(1475781659)}}")
List<AggregatedData> findByAidAndStartTimeAndEndTime(String aid);
The exception I am getting:
Caused by: com.mongodb.util.JSONParseException:
{ '_id.AID' : "_param_0", '_id.STS' : {'$gte': NumberLong(1475778600)}, '_id.ETS':{'$lte': NumberLong(1475781659)}}
^
at com.mongodb.util.JSONParser.read(JSON.java:301) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.util.JSONParser.parse(JSON.java:180) ~[mongodb-driver-3.2.2.jar:na]
Mongo record structure:
{
"_id" : {
"SiteId" : "JATH",
"AID" : "JA04",
"STS" : NumberLong(1475778600),
"ETS" : NumberLong(1475781659)
},
"TS" : [
1475820600,
1475779200,
1475779800,
1475780400,
1475781000,
1475781600
],
"Tags" : {
"ActivePower" : {
"Max" : [
1181.5,
1181.5,
1181.5,
1181.5,
1181.5,
1181.5
],
"Min" : [
73.5,
73.5,
73.5,
73.5,
73.5,
73.5
],
"Sum" : [
224430,
224430,
224430,
224430,
224430,
224430
],
"Avg" : [
374.05,
374.05,
374.05,
374.05,
374.05,
374.05
],
"Count" : [
600,
600,
600,
600,
600,
600
],
"Std" : [
175.242871942532,
175.242871942532,
175.242871942532,
175.242871942532,
175.242871942532,
175.242871942532
]
}
}
}
Try this:
#Query(value = "{ '_id.AID' : ?0 }", fields = {"_id.STS' : {'$gte': NumberLong(1475778600)}, '_id.ETS':{'$lte': NumberLong(1475781659)}}")
Answer!!:
Hi, I got it solved....
This is how the query looks:
#Query("{ '_id.AID' : ?0, $and:[{'_id.STS' : {'$gte': ?1}}, {'_id.ETS':{'$lte': ?2}}]}")
List<AggregatedData> findByAidAndStartTimeAndEndTime(String aid, Long startTimeRange, Long endTimeRange);

Zend_Navigation, Zend_ACL + Roles not filtering correctly through an AJAX request

I have been using zend_acl and Zend_Navigation together on my project currently and it seems to work correctly. I am how ever using a lot of AJAX in my site and have made a login with jqModal and jQuery which logs in users without reloading the current page and have the need to reload the navigation as well. I have so far got it working but the navigation being return is all the links with the visible field as true which is incorrect. For example when I am logged in as a user the login link should not be visible.
My code below for Action, JavaScript function and JSON returned.
current role = admins
// CONTROLLER ACTION
public function getnavigationjsonAction()
{
//$view->navigation($container)->setAcl($this->_acl)->setRole(Zend_Registry::get('role'));
// echo $this->navigation()->menu();
$navigation = $this->getView()->navigation()->setAcl($this->_acl)->setRole(Zend_Registry::get('role'));
//die(Zend_Registry::get('role'));
//die($this->_acl);
$this->_helper->json($navigation->toArray());
}
// JAVASCRIPT FUNCTION
function reloadNavigationMenu()
{
//alert('reloading navigation');
$.ajax( {
url : "/default/ajax/getnavigationjson",
type : "POST",
cache : false,
async : false,
data : "format=json",
success : function(data) {
var html='<ul class="navigation">';
console.log(data);
$.each(data, function(i) {
if(data[i].visible === true) {
//console.log(data[i]);
html+='<li>';
html+=''+data[i].label+'';
html+='</li>';
}
});
html+='</ul>';
$('#zend_navigation_container').html(html);
}
});
}
// RETURN JSON data from controller
[ { "action" : "index",
"active" : false,
"class" : null,
"controller" : "admin",
"id" : null,
"label" : "Admin Section",
"module" : "admin",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "index",
"rel" : [ ],
"reset_params" : true,
"resource" : "admin:admin",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "index",
"active" : false,
"class" : null,
"controller" : "index",
"id" : null,
"label" : "Home",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : null,
"rel" : [ ],
"reset_params" : true,
"resource" : null,
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "index",
"active" : false,
"class" : null,
"controller" : "index",
"id" : null,
"label" : "News",
"module" : "news",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "index",
"rel" : [ ],
"reset_params" : true,
"resource" : "news:index",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "index",
"active" : false,
"class" : null,
"controller" : "index",
"id" : null,
"label" : "Tutorials",
"module" : "tutorials",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "index",
"rel" : [ ],
"reset_params" : true,
"resource" : "tutorials:index",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "about",
"active" : false,
"class" : null,
"controller" : "index",
"id" : null,
"label" : "About",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "about",
"rel" : [ ],
"reset_params" : true,
"resource" : "default:index",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "comments",
"active" : false,
"class" : null,
"controller" : "index",
"id" : null,
"label" : "Comments",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "comments",
"rel" : [ ],
"reset_params" : true,
"resource" : "default:index",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "index",
"active" : false,
"class" : null,
"controller" : "contact",
"id" : null,
"label" : "Contact",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "index",
"rel" : [ ],
"reset_params" : true,
"resource" : "default:contact",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "login",
"active" : false,
"class" : null,
"controller" : "auth",
"id" : null,
"label" : "Login",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "login",
"rel" : [ ],
"reset_params" : true,
"resource" : "default:auth",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
},
{ "action" : "logout",
"active" : false,
"class" : null,
"controller" : "auth",
"id" : null,
"label" : "Logout",
"module" : "default",
"order" : null,
"pages" : [ ],
"params" : [ ],
"privilege" : "logout",
"rel" : [ ],
"reset_params" : true,
"resource" : "default:auth",
"rev" : [ ],
"route" : null,
"target" : null,
"title" : null,
"type" : "Zend_Navigation_Page_Mvc",
"visible" : true
}
]
This is when I am currently logged in as admin and the links for login should be hidden but its not. This looks like the ACL is not being properly assigned to the navigation.
I think that Zend_Navigation uses ACL to determine if page should by visible during render time. It doesn't alter your navigation objects when you pass ACL object to it.
You need a different approach if you want to create custom navigation container reduced by ACL - maybe extending Zend Navigation classes and add appropriate methods.
You will need to force Zend_Navigation to re-render the navigation. As stated before, it "filters" the rendering based on the acl. Also, not sure how you are storing that role in Zend_Registry, but you may want to consider having that role returned when you query Zend_Auth to authenticate the user, if that role is not updated it could also cause issue. I would also suggest setting up your acl etc in a action helper instead of an action, so that it can process for "any" action instead of just this action. The fact that the items are present should indicate that the menu for some reason is not being re-rendered, or the updated role is not being passed to the Acl, if it were the menu items would not be present in the menu at all. Zend_Navigation will not render any items that have been filtered by the acl, it goes far beyond just setting the item to not be visible.
Furthermore, what role defines the privilege for showing the login tab? You should tell the acl to deny that to a standard user and up if your roles are inheriting from a common user role, if not, then it may indeed be working just as it should. As an example:
//..//..//
$this->addResource(new Zend_Acl_Resource('login')); //<- Allows the hiding of the login navigation tab
$this->addResource(new Zend_Acl_Resource('logout')); //<- Allows the hiding of the logout navigation tab
$this->allow($guest, array('user'), array('user.login', 'user.register'));
$this->allow('user', array('user', 'useraccount'), array('user.view', 'user.logout', 'user.account-editown', 'user.edit-account', //<-end user privs
));
//..//..//
$this->deny('user', array('user'), array('user.login', 'user.register'));

Resources