initial upload

almost finished but needs cleaning
This commit is contained in:
Nye Evans 2021-02-26 20:56:00 +00:00
parent 28e8ddb752
commit 7eab55a6b6
11 changed files with 8743 additions and 103 deletions

104
.gitignore vendored
View file

@ -1,104 +1,2 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
dist/

31
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Attach to aardvark_renderer",
"sourceMaps": true,
//"trace":"verbose",
"port": 8042,
"webRoot":"${workspaceFolder}",
"sourceMapPathOverrides": {
// If you have local Git clones of @aardvarkxr/aardvark-react or @aardvarkxr/aardvark-shared,
// you can use those repos as your source of these two packages with "npm install <path>" for each one.
// But if you do that, source maps will get lost, so you also need to set the environment variable
// "AV_SHARED_SRC=C:/some/path/aardvark-shared" so the following rules can make the source maps work
// through the sym linked packages. NOTE THE FORWARD SLASHES!
"webpack:///../aardvark-react/*": "${env:AV_REACT_SRC}/*",
"webpack:///../aardvark-shared/*": "${env:AV_SHARED_SRC}/*",
"webpack:///./~/*": "${webRoot}/node_modules/*", // Example: "webpack:///./~/querystring/index.js" -> "/Users/me/project/node_modules/querystring/index.js"
"webpack:///./*": "${webRoot}/*", // Example: "webpack:///./src/app.js" -> "/Users/me/project/src/app.js",
"webpack:///*": "*", // Example: "webpack:///project/app.ts" -> "/project/app.ts"
"webpack:///src/*": "${webRoot}/*", // Example: "webpack:///src/app.js" -> "/Users/me/project/app.js"
"meteor://💻app/*": "${webRoot}/*" // Example: "meteor://💻app/main.ts" -> "/Users/me/project/main.ts"
}
},
]
}

8355
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

42
package.json Normal file
View file

@ -0,0 +1,42 @@
{
"name": "menuprototype",
"version": "0.1.0",
"description": "Source for menuPrototype gadget",
"main": "index.js",
"scripts": {
"build": "webpack --env=production",
"start": "webpack --env=dev --watch --progress",
"dev-server": "http-server ./dist -p 8080 -c-1 --cors"
},
"keywords": [],
"author": "",
"license": "",
"repository": "",
"devDependencies": {
"@types/color": "^3.0.0",
"@types/express": "^4.17.0",
"@types/react": "^16.8.22",
"@types/react-dom": "^16.8.4",
"@types/ws": "^6.0.2",
"copy-webpack-plugin": "^5.0.3",
"css-loader": "^3.0.0",
"html-webpack-plugin": "^3.2.0",
"http-server": "^0.12.3",
"mini-css-extract-plugin": "^0.7.0",
"npm": "^6.12.0",
"source-map-loader": "^0.2.4",
"style-loader": "^1.2.1",
"ts-loader": "^6.0.4",
"tslib": "^1.10.0",
"typescript": "^3.5.2",
"webpack": "^4.34.0",
"webpack-cli": "^3.3.6"
},
"dependencies": {
"@aardvarkxr/aardvark-react": "^1.5.1",
"@aardvarkxr/aardvark-shared": "^1.5.1",
"bind-decorator": "^1.0.11",
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
}

13
src/index.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>menuPrototype</title>
<link href="styles.css?<%= htmlWebpackPlugin.options.now %>" rel="stylesheet">
</head>
<body>
<div id="root" class="FullPage"></div>
</body>
</html>

142
src/main.tsx Normal file
View file

@ -0,0 +1,142 @@
import { AvGadget, AvPanel, AvStandardGrabbable, AvTransform, HighlightType, DefaultLanding, GrabbableStyle, renderAardvarkRoot, AvOrigin, AvInterfaceEntity, AvModel, InterfaceProp, ActiveInterface, InterfaceRole} from '@aardvarkxr/aardvark-react';
import { EAction, EHand, g_builtinModelBox, InitialInterfaceLock, Av, EVolumeType, AvVolume } from '@aardvarkxr/aardvark-shared';
import bind from 'bind-decorator';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
interface menuProps
{
isOpen: boolean
}
class Menu extends React.Component<menuProps, {}>
{
constructor(props)
{
super(props)
}
public render()
{
if (this.props.isOpen)
{
return(
<AvTransform translateY = {0.15}>
<AvPanel interactive={true} widthInMeters={ 0.2 }/>
</AvTransform>
);
}
else
{
return(null);
}
}
}
interface gadgetState
{
collideDetection1: boolean,
collideDetection2: boolean,
}
class MyGadget extends React.Component< {}, gadgetState >
{
private drawMenu:boolean; // we store this outside of state to avoid uncescessary re-renders and a possible infinite loop
constructor( props: any )
{
super( props );
this.state =
{
collideDetection1: false,
collideDetection2: false,
};
}
private updateDrawMenu()
{
if(this.state.collideDetection1 && this.state.collideDetection2)
this.drawMenu = !this.drawMenu
}
@bind
public collideMain(givenInterface: ActiveInterface) // for volumes at bottom of controllers
{
if(givenInterface.role == InterfaceRole.Transmitter) // this function runs twice, once for transmitter and once for reciever, but we only want it to run once, so we check
{
givenInterface.onEnded(() => this.setState({collideDetection1: false}))
this.setState({collideDetection1: true});
}
}
@bind
public collideSecondary(givenInterface: ActiveInterface) // for volumes on top and far bottom of controllers
{
if(givenInterface.role == InterfaceRole.Transmitter) // this function runs twice, once for transmitter and once for reciever, but we only want it to run once, so we check
{
givenInterface.onEnded(() => this.setState({collideDetection2: false}))
this.setState({collideDetection2: true});
}
}
public render()
{
var handVolume:AvVolume =
{
type: EVolumeType.Sphere,
radius: 0.8,
visualize: true
};
var handVolumeLarger:AvVolume =
{
type: EVolumeType.Sphere,
radius: 1.5,
visualize: true
};
var handInterfaceMain:InterfaceProp[] =
[{
iface: "OpenMenuMain@1",
processor: this.collideMain
}];
var handInterfaceSecondary:InterfaceProp[] =
[{
iface: "OpenMenuSecondary@1",
processor: this.collideSecondary
}];
this.updateDrawMenu();
return (
<div>
<AvStandardGrabbable modelUri={ g_builtinModelBox } modelScale={ 0.03 } style={ GrabbableStyle.Gadget }>
<Menu isOpen = {this.drawMenu}></Menu>
<AvOrigin path = "/user/hand/left">
<AvTransform uniformScale = {0.03} translateY = {-0.13} translateZ = {0.13}>
<AvInterfaceEntity volume = {handVolume} transmits = {handInterfaceMain}></AvInterfaceEntity>
</AvTransform>
<AvTransform uniformScale = {0.03} translateY = {-0.24} translateZ = {0.23}>
<AvInterfaceEntity volume = {handVolumeLarger} transmits = {handInterfaceSecondary}></AvInterfaceEntity>
</AvTransform>
</AvOrigin>
<AvOrigin path = "/user/hand/right">
<AvTransform uniformScale = {0.03} translateY = {-0.13} translateZ = {0.13}>
<AvInterfaceEntity volume = {handVolume} receives = {handInterfaceMain}></AvInterfaceEntity>
</AvTransform>
<AvTransform uniformScale = {0.03} translateZ = {0.13}>
<AvInterfaceEntity volume = {handVolume} receives = {handInterfaceSecondary}></AvInterfaceEntity>
</AvTransform>
</AvOrigin>
</AvStandardGrabbable>
</div>
);
}
}
//run npm you buffoon
renderAardvarkRoot( "root", <MyGadget/> );

18
src/manifest.webmanifest Normal file
View file

@ -0,0 +1,18 @@
{
"xr_type": "aardvark-gadget@^1.5.1",
"name": "menuPrototype",
"icons": [
{
"src": "models/placeholder.glb",
"type": "model/gltf-binary"
}
],
"aardvark": {
"permissions": [
"scenegraph"
],
"browserWidth": 1024,
"browserHeight": 1024,
"startAutomatically": false
}
}

BIN
src/models/placeholder.glb Normal file

Binary file not shown.

41
src/styles.css Normal file
View file

@ -0,0 +1,41 @@
body, html
{
background-color: lightskyblue;
height: 100%;
}
.Button
{
background-color: lightcoral;
font-size: 4rem;
}
.Label
{
font-size: 4rem;
}
.Button:hover
{
background-color: red;
}
.FullPage
{
width: 100%;
height: 100%;
}
.NoGrabHighlight
{
background-color: white;
}
.InRangeHighlight
{
background-color: lightblue;
}
.GrabbedHighlight
{
background-color: blue;
}

25
tsconfig.json Normal file
View file

@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"lib": [
"es6",
"es2015",
"dom"
],
"declaration": true,
"jsx": "react",
"outDir": "dist",
"rootDir": "src",
"strict": false,
"types": [
"node"
],
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node"
}
}

75
webpack.config.js Normal file
View file

@ -0,0 +1,75 @@
const path = require('path');
var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
const CopyPlugin = require('copy-webpack-plugin');
module.exports =
[
{
mode: "development",
devtool: "inline-source-map",
entry: './src/main.tsx',
output:
{
filename: '[name].js',
path: path.resolve( __dirname, './dist' ),
},
plugins:
[
new HtmlWebpackPlugin(
{
hash: true,
filename: "./index.html",
template: "./src/index.html",
now: Date.now()
}
),
new CopyPlugin(
[
{ from: './src/styles.css', to: 'styles.css' },
{ from: './src/manifest.webmanifest', to: 'manifest.webmanifest' },
{ from: './src/models/placeholder.glb', to: 'models/placeholder.glb' },
]
),
],
module:
{
rules:
[
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /.css$/,
use:
[
'style-loader',
'css-loader'
]
},
{
test: /.(png|svg|jpg|gif)$/,
use:
[
'file-loader'
]
}
]
},
resolve:
{
modules:[ path.resolve( __dirname, 'node_modules' ) ],
extensions: [ '.ts', '.tsx', '.js' ]
},
}
];