Skip to content

Commit

Permalink
🐀πŸ₯  ↝ Merge pull request #47 from Signal-K/sta-36-45
Browse files Browse the repository at this point in the history
πŸ¦πŸ§‰ ↝ Addition of Unity build
  • Loading branch information
Gizmotronn authored Jun 11, 2023
2 parents a09b028 + d68321a commit acc5ed1
Show file tree
Hide file tree
Showing 252 changed files with 26,827 additions and 220 deletions.
Binary file modified .DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions components/Gameplay/Unity/Build/LOD-Mars.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { Unity, useUnityContext } from 'react-unity-webgl';

export default function UnityBuildLod1 () {
const { unityProvider } = useUnityContext({
loaderUrl: "/assets/Mars/Rocky_Mars-base.loader.js",
dataUrl: "/assets/Mars/Rocky_Mars-base.data",
frameworkUrl: "/assets/Mars/Rocky_Mars-base.framework.js",
codeUrl: "/assets/Mars/Rocky_Mars-base.wasm",
});

return (
<Unity unityProvider={unityProvider} />
);
}
20 changes: 20 additions & 0 deletions components/Gameplay/Unity/Build/LOD-Rocky.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { Unity, useUnityContext } from 'react-unity-webgl';

export default function UnityBuildLod1 () {
const { unityProvider } = useUnityContext({
// loaderUrl: '/Unity/LOD1/Build/Webgl.loader.js',
// dataUrl: '/Unity/LOD1/Build/Webgl.data.gz',
// frameworkUrl: '/Unity/LOD1/Build/Webgl.framework.js.gz',
// codeUrl: '/Unity/LOD1/Build/Webgl.wasm.gz',
loaderUrl: "/assets/Earth/Rocky_Earth-gen.loader.js",
dataUrl: "/assets/Earth/Rocky_Earth-gen.data",
frameworkUrl: "/assets/Earth/Rocky_Earth-gen.framework.js",
codeUrl: "/assets/Earth/Rocky_Earth-gen.wasm",
});

return <Unity unityProvider={unityProvider} style={{ width: "100%", height: "500px" }} />
// return (
// <iframe src='Unity/index.html' height='1000px' width='1000px' />
// )
}
19 changes: 19 additions & 0 deletions components/Gameplay/Unity/Build/LOD-Water.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { Unity, useUnityContext } from 'react-unity-webgl';

export default function UnityBuildLod1 () {
const { unityProvider } = useUnityContext({
loaderUrl: "/assets/Water/Rocky_Water-base.loader.js",
dataUrl: "/assets/Water/Rocky_Water-base.data",
frameworkUrl: "/assets/Water/Rocky_Water-base.framework.js",
codeUrl: "/assets/Water/Rocky_Water-base.wasm",
});

return (
<Unity unityProvider={unityProvider} />
);

return (
<>Unity dev param</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Keys":["com.unity.services.core.version"],"Values":[{"m_Value":"1.4.0","m_IsReadOnly":true}]}
16 changes: 16 additions & 0 deletions components/Gameplay/Unity/TemplateData/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
body { padding: 0; margin: 0 }
#unity-container { position: absolute }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-mobile { width: 100%; height: 100% }
#unity-canvas { background: #231F20 }
.unity-mobile #unity-canvas { width: 100%; height: 100% }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
#unity-footer { position: relative }
.unity-mobile #unity-footer { display: none }
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
#unity-fullscreen-button { float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }
121 changes: 121 additions & 0 deletions components/Gameplay/Unity/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity WebGL Player | Low Poly Procedural Planets</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
</head>
<body>
<div id="unity-container" class="unity-desktop">
<canvas id="unity-canvas" width=960 height=600></canvas>
<div id="unity-loading-bar">
<div id="unity-logo"></div>
<div id="unity-progress-bar-empty">
<div id="unity-progress-bar-full"></div>
</div>
</div>
<div id="unity-warning"> </div>
<div id="unity-footer">
<div id="unity-webgl-logo"></div>
<div id="unity-fullscreen-button"></div>
<div id="unity-build-title">Low Poly Procedural Planets</div>
</div>
</div>
<script>
var container = document.querySelector("#unity-container");
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
var warningBanner = document.querySelector("#unity-warning");

// Shows a temporary message banner/ribbon for a few seconds, or
// a permanent error message on top of the canvas if type=='error'.
// If type=='warning', a yellow highlight color is used.
// Modify or remove this function to customize the visually presented
// way that non-critical warnings and error messages are presented to the
// user.
function unityShowBanner(msg, type) {
function updateBannerVisibility() {
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
}
var div = document.createElement('div');
div.innerHTML = msg;
warningBanner.appendChild(div);
if (type == 'error') div.style = 'background: red; padding: 10px;';
else {
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
setTimeout(function() {
warningBanner.removeChild(div);
updateBannerVisibility();
}, 5000);
}
updateBannerVisibility();
}

var buildUrl = "Build";
var loaderUrl = buildUrl + "/Webgl2.loader.js";
var config = {
dataUrl: buildUrl + "/Webgl2.data.gz",
frameworkUrl: buildUrl + "/Webgl2.framework.js.gz",
codeUrl: buildUrl + "/Webgl2.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "Low Poly Procedural Planets",
productVersion: "0.1",
showBanner: unityShowBanner,
};

// By default Unity keeps WebGL canvas render target size matched with
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
// Set this to false if you want to decouple this synchronization from
// happening inside the engine, and you would instead like to size up
// the canvas DOM size and WebGL render target sizes yourself.
// config.matchWebGLToCanvasSize = false;

if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
// Mobile device style: fill the whole browser client area with the game canvas:

var meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
document.getElementsByTagName('head')[0].appendChild(meta);
container.className = "unity-mobile";

// To lower canvas resolution on mobile devices to gain some
// performance, uncomment the following line:
// config.devicePixelRatio = 1;

canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';

unityShowBanner('WebGL builds are not supported on mobile devices.');
} else {
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:

canvas.style.width = "960px";
canvas.style.height = "600px";
}

loadingBar.style.display = "block";

var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
loadingBar.style.display = "none";
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}).catch((message) => {
alert(message);
});
};
document.body.appendChild(script);
</script>
</body>
</html>
49 changes: 49 additions & 0 deletions components/Tests/Planet/PlanetCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { useEffect, useState } from "react";
import Card from "../../Card";
import { useSupabaseClient } from "@supabase/auth-helpers-react";
import { SocialGraphHomeNoSidebar } from "../../../pages/posts";

export default function PlanetContent ({ activeTab, planetId }) {
const supabase = useSupabaseClient();

const [planetPosts, setPlanetPosts] = useState([]);
const [planet, setPlanet] = useState(null);

useEffect(() => {
if (!planetId) { return; };
getPlanetData(planetId);
console.log(planetId);
})

async function loadPlanet () {
//
}

async function getPlanetPosts ( planetId ) {
const { data, error } = await supabase.from('posts_duplicate')
.select('*')
.order('created_at', { ascending: false })
.eq('planets2', planetId)
return data;

if (error) {
console.error(error);
return [];
}
};

async function getPlanetData ( planetId ) {
const { data } = await supabase.from('planetsss')
.select()
.eq('id', planetId);
return data[0];
};

return (
<div>
{ planetPosts?.length > 0 && planetPosts.map(planetPost => (
<SocialGraphHomeNoSidebar key = { planetPost.id } {...planetPost} planets2 = {planetId} />
))}
</div>
)
}
43 changes: 0 additions & 43 deletions contracts/extension 2/ContractMetadata.sol

This file was deleted.

13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@
"eslint-config-next": "13.1.0",
"ether": "0.0.9",
"ethers": "5.7.2",
"extract-colors": "2.0.5",
"framer-motion": "9.0.2",
"fs": "0.0.1-security",
"hardhat": "2.13.0",
"html2canvas": "1.4.1",
"javascript-time-ago": "2.5.9",
"material-kit": "2.0.4",
"extract-colors": "^2.0.5",
"flowbite": "^1.6.5",
"flowbite-react": "^0.4.4",
Expand All @@ -70,8 +63,10 @@
"html2canvas": "^1.4.1",
"javascript-time-ago": "^2.5.9",
"material-kit": "^2.0.4",
"nano": "^10.1.2",
"next": "13.0.2",
"omit-deep": "^0.3.0",
"package.json": "^2.0.1",
"plotly.js": "^2.22.0",
"postcss": "^8.4.21",
"rc-slider": "^10.1.1",
Expand All @@ -88,7 +83,7 @@
"react-spinners": "0.13.8",
"react-time-ago": "7.2.1",
"react-toastify": "9.1.2",
"react-unity-webgl": "^9.4.0",
"react-unity-webgl": "^9.4.2",
"redux-typescript": "1.2.1",
"sass": "1.60.0",
"simplex-noise": "2.4.0",
Expand All @@ -114,8 +109,8 @@
"@tailwindcss/forms": "0.5.3",
"@tailwindcss/line-clamp": "0.4.2",
"@tailwindcss/typography": "0.5.9",
"@thirdweb-dev/contracts": "3.3.0",
"@thirdweb-dev/auth": "3.0.11",
"@thirdweb-dev/contracts": "3.3.0",
"@thirdweb-dev/react": "3.6.0",
"@thirdweb-dev/sdk": "3.10.7",
"@thirdweb-dev/storage": "1.0.8",
Expand Down
3 changes: 1 addition & 2 deletions pages/generator/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useScreenshot } from 'use-react-screenshot';

import PlanetEditor from "./planet-editor";

//type Profiles = Database['public']['Tables']['profiles']['Row'];
type Profiles = Database['public']['Tables']['profiles']['Row'];
type Planets = Database['public']['Tables']['planets']['Row']; // See `wb3-10` at this point https://github.com/Signal-K/client/blob/wb3-10-implement-off-chain-commenting-post/components/Data/OffchainAccount.tsx / https://github.com/Signal-K/client/commit/17301ae88f3f8d1aa673ac968ceef360192fa3b1 -> Clone that branch and compare the behaviour and UI to what occurs here and in planet-editor

export default function OffchainAccount({ session }: { session: Session}) {
Expand All @@ -25,7 +25,6 @@ export default function OffchainAccount({ session }: { session: Session}) {
const [address2, setAddress2] = useState<Profiles['address2']>(null);
const [address, setAddress] = useState<Profiles['address']>(null); // This should be set by the handler eventually (connected address).
const [images, setImages] = useState([]);
const [address2, setAddress2] = useState('');

// User planet
const [userIdForPlanet, setUserIdForPlanet] = useState<Planets['userId']>(null);
Expand Down
Loading

0 comments on commit acc5ed1

Please sign in to comment.