Deferring the holoplay import until it's determined that it's needed. Changing the holoplay effect version a little.

This commit is contained in:
Rezmason
2022-09-18 22:30:10 -07:00
parent b0406978d7
commit 5f544091a9
2 changed files with 28 additions and 22 deletions

View File

@@ -317,20 +317,29 @@ const versions = {
holoplay: { holoplay: {
font: "resurrections", font: "resurrections",
numColumns: 20, glintTexture: "metal",
fallSpeed: 0.35,
cycleSpeed: 0.04,
glyphEdgeCrop: 0.1, glyphEdgeCrop: 0.1,
ditherMagnitude: 0, cursorColor: [1.4, 2, 1.2],
isolateGlint: true,
glintColor: [3, 2.5, 0.6],
glintBrightness: -0.5,
glintContrast: 1.5,
baseBrightness: -0.4,
baseContrast: 1.5,
highPassThreshold: 0,
cycleSpeed: 0.03,
bloomStrength: 0.7,
fallSpeed: 0.3,
paletteEntries: [ paletteEntries: [
{ hsl: [0.39, 0.9, 0.0], at: 0.0 }, { hsl: [0.37, 0.6, 0.0], at: 0.0 },
{ hsl: [0.39, 1.0, 0.6], at: 0.5 }, { hsl: [0.37, 0.6, 0.5], at: 1.0 },
{ hsl: [0.39, 1.0, 1.0], at: 1.0 },
], ],
raindropLength: 1.4, cycleSpeed: 0.01,
highPassThreshold: 0.2, raindropLength: 0.3,
renderer: "regl", renderer: "regl",
numColumns: 20,
ditherMagnitude: 0,
bloomStrength: 0, bloomStrength: 0,
volumetric: true, volumetric: true,
forwardSpeed: 0, forwardSpeed: 0,

View File

@@ -1,5 +1,3 @@
import * as HoloPlayCore from "../../lib/holoplaycore.module.js";
const recordedDevice = { const recordedDevice = {
buttons: [0, 0, 0, 0], buttons: [0, 0, 0, 0],
calibration: { calibration: {
@@ -34,14 +32,6 @@ const recordedDevice = {
windowCoords: [1440, 900], windowCoords: [1440, 900],
}; };
const getDetectedDevice = new Promise(
(resolve, reject) =>
new HoloPlayCore.Client(
(data) => resolve(data.devices?.[0]),
(error) => resolve(null)
)
);
const interpretDevice = (device) => { const interpretDevice = (device) => {
if (device == null) { if (device == null) {
return { enabled: false, tileX: 1, tileY: 1 }; return { enabled: false, tileX: 1, tileY: 1 };
@@ -84,9 +74,16 @@ export default async (useHoloplay = false, useRecordedDevice = false) => {
if (!useHoloplay) { if (!useHoloplay) {
return interpretDevice(null); return interpretDevice(null);
} }
const detectedDevice = await getDetectedDevice; const HoloPlayCore = await import("../../lib/holoplaycore.module.js");
if (detectedDevice == null && useRecordedDevice) { const device = await new Promise(
(resolve, reject) =>
new HoloPlayCore.Client(
(data) => resolve(data.devices?.[0]),
(error) => resolve(null)
)
);
if (device == null && useRecordedDevice) {
return interpretDevice(recordedDevice); return interpretDevice(recordedDevice);
} }
return interpretDevice(detectedDevice); return interpretDevice(device);
}; };