From d138e6c826d8de07f3fc9488baf61b462fb11abd Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 6 Jan 2024 17:00:37 -0600 Subject: [PATCH] feat(web): additional loading speed improvements in map viewer --- packages/spelunker-web/package-lock.json | 32 +++++++++---------- packages/spelunker-web/package.json | 4 +-- .../src/components/core/MapViewer/index.jsx | 12 ++++--- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/packages/spelunker-web/package-lock.json b/packages/spelunker-web/package-lock.json index f2a11c0..daa73c1 100644 --- a/packages/spelunker-web/package-lock.json +++ b/packages/spelunker-web/package-lock.json @@ -10,8 +10,8 @@ "license": "MIT", "dependencies": { "@apollo/client": "^3.8.8", - "@wowserhq/format": "^0.10.2", - "@wowserhq/scene": "^0.13.1", + "@wowserhq/format": "^0.11.0", + "@wowserhq/scene": "^0.14.0", "classnames": "^2.3.1", "crypto-hash": "^2.0.0", "graphql": "^16.8.1", @@ -2672,9 +2672,9 @@ } }, "node_modules/@wowserhq/format": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/@wowserhq/format/-/format-0.10.2.tgz", - "integrity": "sha512-KZ5ZIn7cQMZrRT7vpaqJFgTtNvC/gBuU5d+QlvulkB9wVpmiaFeM17VEs9Wz1HssiR6HdatJQmlTGn5mtq5v2g==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@wowserhq/format/-/format-0.11.0.tgz", + "integrity": "sha512-kZRztfgwhoIyp8ZITIYBZer3MQTW1cwg4spKgqOI+068TrZSu9Wte8RGCxnYvfycGVYyHwT687BocDiYDJO03w==", "dependencies": { "@wowserhq/io": "^2.0.2", "gl-matrix": "^3.4.3" @@ -2686,11 +2686,11 @@ "integrity": "sha512-YGjfUbo+wNuJiy6pOhsGeWAjq7bTvMDoGn5y+2LW2LJujOvRWNUx95MaRaJgtp8O+ig/+loJRVg5mTQoY9eoIg==" }, "node_modules/@wowserhq/scene": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/@wowserhq/scene/-/scene-0.13.1.tgz", - "integrity": "sha512-roXulp3owkRWmy6oldEFObhBLzvwTeE4R0uHu5RYigCk2tTd4hhFTfrlGMxkTcpdrW/HH27+FJv0T6bcFUJDwg==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@wowserhq/scene/-/scene-0.14.0.tgz", + "integrity": "sha512-xedu4/o9YYZweC4SbaNsFixq5d3Cf11EGg5f8j+ZkaxOk/RCVby9Uzc+BGAzgDRjxYtAEtim+LWIQhvZj1urRA==", "dependencies": { - "@wowserhq/format": "^0.10.2" + "@wowserhq/format": "^0.11.0" }, "peerDependencies": { "three": "^0.160.0" @@ -12644,9 +12644,9 @@ "requires": {} }, "@wowserhq/format": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/@wowserhq/format/-/format-0.10.2.tgz", - "integrity": "sha512-KZ5ZIn7cQMZrRT7vpaqJFgTtNvC/gBuU5d+QlvulkB9wVpmiaFeM17VEs9Wz1HssiR6HdatJQmlTGn5mtq5v2g==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@wowserhq/format/-/format-0.11.0.tgz", + "integrity": "sha512-kZRztfgwhoIyp8ZITIYBZer3MQTW1cwg4spKgqOI+068TrZSu9Wte8RGCxnYvfycGVYyHwT687BocDiYDJO03w==", "requires": { "@wowserhq/io": "^2.0.2", "gl-matrix": "^3.4.3" @@ -12658,11 +12658,11 @@ "integrity": "sha512-YGjfUbo+wNuJiy6pOhsGeWAjq7bTvMDoGn5y+2LW2LJujOvRWNUx95MaRaJgtp8O+ig/+loJRVg5mTQoY9eoIg==" }, "@wowserhq/scene": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/@wowserhq/scene/-/scene-0.13.1.tgz", - "integrity": "sha512-roXulp3owkRWmy6oldEFObhBLzvwTeE4R0uHu5RYigCk2tTd4hhFTfrlGMxkTcpdrW/HH27+FJv0T6bcFUJDwg==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@wowserhq/scene/-/scene-0.14.0.tgz", + "integrity": "sha512-xedu4/o9YYZweC4SbaNsFixq5d3Cf11EGg5f8j+ZkaxOk/RCVby9Uzc+BGAzgDRjxYtAEtim+LWIQhvZj1urRA==", "requires": { - "@wowserhq/format": "^0.10.2" + "@wowserhq/format": "^0.11.0" } }, "@wry/caches": { diff --git a/packages/spelunker-web/package.json b/packages/spelunker-web/package.json index 506d7a9..921d219 100644 --- a/packages/spelunker-web/package.json +++ b/packages/spelunker-web/package.json @@ -19,8 +19,8 @@ ], "dependencies": { "@apollo/client": "^3.8.8", - "@wowserhq/format": "^0.10.2", - "@wowserhq/scene": "^0.13.1", + "@wowserhq/format": "^0.11.0", + "@wowserhq/scene": "^0.14.0", "classnames": "^2.3.1", "crypto-hash": "^2.0.0", "graphql": "^16.8.1", diff --git a/packages/spelunker-web/src/components/core/MapViewer/index.jsx b/packages/spelunker-web/src/components/core/MapViewer/index.jsx index 546210f..d201f6d 100644 --- a/packages/spelunker-web/src/components/core/MapViewer/index.jsx +++ b/packages/spelunker-web/src/components/core/MapViewer/index.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useRef, useState } from 'react'; -import { AssetManager, FormatManager, TextureManager, MapManager, MapControls } from '@wowserhq/scene'; +import { FormatManager, TextureManager, MapManager, MapControls } from '@wowserhq/scene'; import * as THREE from 'three'; import styles from './index.styl'; @@ -9,9 +9,10 @@ THREE.Object3D.DEFAULT_UP.set(0, 0, 1); // We do our own color management! THREE.ColorManagement.enabled = false; -const assetManager = new AssetManager(process.env.DATA_URI, true); -const formatManager = new FormatManager(assetManager); -const textureManager = new TextureManager(formatManager); +const assetHost = { baseUrl: process.env.DATA_URI, normalizePath: true }; + +const formatManager = new FormatManager({ host: assetHost }); +const textureManager = new TextureManager({ host: assetHost }); const camera = new THREE.PerspectiveCamera( 60, @@ -79,7 +80,8 @@ const MapViewer = ({ map: { id, filename } }) => { const view = DEFAULT_VIEWS[id] || GENERIC_VIEW; controls.setView(view); - const mapManager = new MapManager(filename, formatManager, textureManager); + const mapManager = new MapManager({ host: assetHost, formatManager, textureManager }); + mapManager.load(filename); mapManagerRef.current = mapManager; scene.add(mapManager.root);