Skip to content

Instantly share code, notes, and snippets.

View prestomation's full-sized avatar

Preston Tamkin prestomation

View GitHub Profile
@prestomation
prestomation / Enforce tag == session name(Untested)
Created April 22, 2020 04:24
Enforce tag == session name(Untested)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowIamUserAssumeRole",
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Principal": {"AWS": "arn:aws:iam::123456789012:user/external-user"},
"Condition": {
"StringEquals": {
'use strict';
function setup(args, ctx) {
// This is a HTMLVideoElement that is powering the video texture for the current entity
// You can use any standard method on the Video element. See the docs here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement
// The following example uses the 'Space' key to toggle play/pause
ctx.video = ctx.entity.meshRendererComponent.materials[0].getTexture("DIFFUSE_MAP").image;
ctx.onKeyDown = (e) => {
@prestomation
prestomation / sumerian_lex_action_with_session_attributes.js
Created January 9, 2019 01:33
Setting lex session/request attributes from Sumerian Lex State Machine actions
// This will override an internal method of the sumerian lex actions
// This override is NOT guaranteed to work as we upgrade engine versions, but works with some limited testing with Sumerian 0.18
// In the following version, the code is exactly what we have in the engine, with the addition of the 'sessionAttributes' property
// Any parameter supported by PostContent in the Lex API documentation may be added here, specifically `requestAttributes` and `sessionAttributes`
// See more here: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/LexRuntime.html#postContent-property
//
// Add this in a script before executing a lex action
// You may execute this whenever updating session attributes OR you may pull from other global data from within this function
// Do not change any of the other parameters, or the Lex actions likely won't work
sumerian.api.aws.lex.LexProcessingAction.prototype._getLexConfig = function(entity, inputStream) {
@prestomation
prestomation / sumerian_set_material_texture.js
Created November 14, 2018 07:39
Sumerian: Set texture from a URL
const material = ctx.entity.getComponent("MeshRendererComponent").materials[0];
new sumerian.TextureCreator().loadTexture2D("https://images-na.ssl-images-amazon.com/images/G/01/support_images/GUID-15BCCE28-8970-45C8-BF29-5F9FBF2293B5_en-US.png").then(texture =>{
material.setTexture("DIFFUSE_MAP", texture);
});
@prestomation
prestomation / Sumerian_QueryParams.js
Created October 12, 2018 18:05
Passing parameters to Sumerian using the query string
//To pass in parameters to your Sumerian scene at load time, you may use query parameters
//Link to your scene like this: https://SCENEID.us-east-1.sumerian.aws/?
//Now in your script code:
const params = new URLSearchParams(window.location.search);
//prints 'value1'
console.log(params.get("key1"))
@prestomation
prestomation / createHeightMap.js
Created October 9, 2018 18:47
Randomly generate a height map, create a Surface from the heightmap, and add it to the world
'use strict';
// Paste this script into a script component to use
const start = Date.now();
const nLin = 100;
const nCol = 30;
function getMatrix() {
@prestomation
prestomation / sumerian.dynamicspeech.js
Last active April 12, 2019 20:04
javascript snippet for creating dynamic speech in a Sumerian Host
//Put the below in a script in the ScriptComponent attached to the host entity
//It must be attached to the host entity so that `ctx.entity` below refers to the host
//If this script is attached elsewhere, the lip syncing will not work
const speech = new sumerian.Speech();
speech.body = "The sentene to be spoken by the host";
speech.type = 'ssml';
// This sets up the entity so the right ssml events fire (We can make the host lip sync and move)
speech.updateConfig({ entity: ctx.entity });
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: API Gateway Request Model Validation using Lambda Proxy Integration
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
DefinitionBody:
swagger: 2.0
---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: API Gateway Request Model Validation using Lambda Proxy Integration
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
DefinitionBody:
swagger: 2.0
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient()
//Create a Translator object, which comes from the DocumentClient
var dynamodbTranslator = docClient.getTranslator();
//It needs a SDK 'shape'. The individual Items in the Stream record
//are themselves the same Item shape as we see in a getItem response
var ItemShape = docClient.service.api.operations.getItem.output.members.Item;