@shd-developer/interactive-map
Advanced tools
Comparing version 2.2.2 to 2.2.3
import { AnimationMixer } from "three"; | ||
import constants from "../../constants"; | ||
var AnimationMixerPlugin = /** @class */ (function () { | ||
@@ -7,8 +8,8 @@ function AnimationMixerPlugin() { | ||
this.dataStore = dataStore; | ||
this.scene = dataStore.get("scene"); | ||
this.scene = dataStore.get(constants.store.scene); | ||
this.mixer = new AnimationMixer(this.scene); | ||
dataStore.set("animationMixer", this.mixer); | ||
dataStore.set(constants.store.animationMixer, this.mixer); | ||
} | ||
class_1.prototype.update = function () { | ||
var deltaTime = this.dataStore.get("deltaTime"); | ||
var deltaTime = this.dataStore.get(constants.store.deltaTime); | ||
this.mixer.update(deltaTime); | ||
@@ -15,0 +16,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
import constants from "../../constants"; | ||
import { isMatching } from "../../utils/bindings"; | ||
@@ -7,4 +8,4 @@ var AnimationPlugin = /** @class */ (function () { | ||
this.dataStore = dataStore; | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.dataStore.set("animationConfig", config); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set(constants.store.animationConfig, config); | ||
this.animationsStarted = false; | ||
@@ -14,3 +15,3 @@ } | ||
var _this = this; | ||
var animations = this.dataStore.get('animations'); | ||
var animations = this.dataStore.get(constants.store.animations); | ||
config.forEach(function (animationData) { | ||
@@ -27,3 +28,3 @@ animations.forEach(function (animationClip, i) { | ||
class_1.prototype.update = function () { | ||
if (this.dataStore.get("mapLoaded") && !this.animationsStarted) { | ||
if (this.dataStore.get(constants.store.mapLoaded) && !this.animationsStarted) { | ||
this.startAnimations(); | ||
@@ -30,0 +31,0 @@ this.animationsStarted = true; |
import { onWindowResize } from "../../utils"; | ||
import constants from "../../constants"; | ||
var BrowserResizePlugin = /** @class */ (function () { | ||
@@ -8,5 +9,5 @@ function BrowserResizePlugin(window, element) { | ||
this.dataStore = dataStore; | ||
this.renderer = dataStore.get("renderer"); | ||
this.camera = dataStore.get("camera"); | ||
this.cameraConfig = dataStore.get("cameraConfig"); | ||
this.renderer = dataStore.get(constants.store.renderer); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.cameraConfig = dataStore.get(constants.store.cameraConfig); | ||
} | ||
@@ -25,3 +26,3 @@ class_1.prototype.bindEventListener = function () { | ||
class_1.prototype.setSize = function () { | ||
this.dataStore.set("sizes", onWindowResize(element ? element : window, this.renderer, this.camera, this.cameraConfig.config)); | ||
this.dataStore.set(constants.store.sizes, onWindowResize(element ? element : window, this.renderer, this.camera, this.cameraConfig.config)); | ||
}; | ||
@@ -28,0 +29,0 @@ return class_1; |
import { Mesh } from "three"; | ||
import { isMatching } from "../../utils"; | ||
import constants from "../../constants"; | ||
var ClickPlugin = /** @class */ (function () { | ||
@@ -9,3 +10,3 @@ function ClickPlugin(bindings) { | ||
this.handleClick = function (e) { | ||
var intersection = _this.dataStore.get("intersection"); | ||
var intersection = _this.dataStore.get(constants.store.intersection); | ||
if (!intersection) { | ||
@@ -31,5 +32,5 @@ return; | ||
this.dataStore = dataStore; | ||
this.animations = dataStore.get("animations"); | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.dataStore.set("clickBindings", bindings); | ||
this.animations = dataStore.get(constants.store.animations); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set(constants.store.clickBindings, bindings); | ||
} | ||
@@ -45,3 +46,3 @@ class_1.prototype.bindEventListener = function () { | ||
if (binding.animate) { | ||
this.animations = this.dataStore.get("animations"); | ||
this.animations = this.dataStore.get(constants.store.animations); | ||
binding.animate.forEach(function (animationBinding) { | ||
@@ -48,0 +49,0 @@ _this.animations.forEach(function (animation) { |
import { Clock } from "three"; | ||
import constants from "../../constants"; | ||
var ClockPlugin = /** @class */ (function () { | ||
@@ -14,4 +15,4 @@ function ClockPlugin() { | ||
this.previousTime = elapsedTime; | ||
this.dataStore.set("elapsedTime", elapsedTime); | ||
this.dataStore.set("deltaTime", deltaTime); | ||
this.dataStore.set(constants.store.elapsedTime, elapsedTime); | ||
this.dataStore.set(constants.store.deltaTime, deltaTime); | ||
}; | ||
@@ -18,0 +19,0 @@ return class_1; |
import { AmbientLight, DirectionalLight } from "three"; | ||
import constants from "../../constants"; | ||
var GlobalIlluminationPlugin = /** @class */ (function () { | ||
@@ -7,3 +8,3 @@ function GlobalIlluminationPlugin() { | ||
this.dataStore = dataStore; | ||
this.scene = this.dataStore.get("scene"); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
this.addLights(); | ||
@@ -10,0 +11,0 @@ } |
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"; | ||
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader"; | ||
import constants from "../../constants"; | ||
var GltfDracoLoaderPlugin = /** @class */ (function () { | ||
@@ -8,5 +9,5 @@ function GltfDracoLoaderPlugin(path) { | ||
this.dataStore = dataStore; | ||
dataStore.set("mapLoaded", false); | ||
dataStore.set("animations", []); | ||
this.scene = dataStore.get("scene"); | ||
dataStore.set(constants.store.mapLoaded, false); | ||
dataStore.set(constants.store.animations, []); | ||
this.scene = dataStore.get(constants.store.scene); | ||
this.dracoLoader = new DRACOLoader(); | ||
@@ -21,5 +22,5 @@ this.dracoLoader.setDecoderPath('decoder/'); | ||
this.gltfLoader.load(path, function (gltf) { | ||
_this.dataStore.set("animations", gltf.animations); | ||
_this.dataStore.set(constants.store.animations, gltf.animations); | ||
_this.scene.add(gltf.scene); | ||
_this.dataStore.set("mapLoaded", true); | ||
_this.dataStore.set(constants.store.mapLoaded, true); | ||
}); | ||
@@ -26,0 +27,0 @@ }; |
import { LoopOnce, Mesh } from "three"; | ||
import constants from "../../constants"; | ||
import { isMatching } from "../../utils/bindings"; | ||
@@ -12,3 +13,3 @@ var HoverPlugin = /** @class */ (function () { | ||
var previous = _this.hovered; | ||
var current = (_a = _this.dataStore.get("intersection")) === null || _a === void 0 ? void 0 : _a.object; | ||
var current = (_a = _this.dataStore.get(constants.store.intersection)) === null || _a === void 0 ? void 0 : _a.object; | ||
if (previous === current) { | ||
@@ -45,5 +46,5 @@ return; | ||
this.dataStore = dataStore; | ||
this.animations = dataStore.get("animations"); | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.dataStore.set("hoverBindings", bindings); | ||
this.animations = dataStore.get(constants.store.animations); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set(constants.store.hoverBindings, bindings); | ||
} | ||
@@ -59,3 +60,3 @@ class_1.prototype.bindEventListener = function () { | ||
if (binding.animate) { | ||
this.animations = this.dataStore.get("animations"); | ||
this.animations = this.dataStore.get(constants.store.animations); | ||
binding.animate.forEach(function (animationBinding) { | ||
@@ -62,0 +63,0 @@ _this.animations.forEach(function (animation) { |
@@ -0,1 +1,2 @@ | ||
import constants from "../../constants"; | ||
var IlluminationPlugin = /** @class */ (function () { | ||
@@ -8,3 +9,3 @@ function IlluminationPlugin(config) { | ||
this.dataStore = dataStore; | ||
this.scene = this.dataStore.get("scene"); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
if (config) { | ||
@@ -11,0 +12,0 @@ if (config.lights) { |
import { Vector3 } from "three"; | ||
import { MapControls } from "three/examples/jsm/controls/OrbitControls"; | ||
import constants from "../../constants"; | ||
var MapControlsPlugin = /** @class */ (function () { | ||
@@ -8,6 +9,6 @@ function MapControlsPlugin(config) { | ||
this.dataStore = dataStore; | ||
this.camera = dataStore.get("camera"); | ||
this.canvas = dataStore.get("canvas"); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.canvas = dataStore.get(constants.store.canvas); | ||
this.mapControls = this.createMapControls(this.camera, this.canvas); | ||
this.dataStore.set("controls", this.mapControls); | ||
this.dataStore.set(constants.store.controls, this.mapControls); | ||
} | ||
@@ -14,0 +15,0 @@ class_1.prototype.update = function () { |
import { calculateCursorX, calculateCursorY } from "../../utils"; | ||
import constants from "../../constants"; | ||
var MousePositionPlugin = /** @class */ (function () { | ||
@@ -8,6 +9,6 @@ function MousePositionPlugin() { | ||
this.handleMouseMove = function (e) { | ||
_this.dataStore.set("mousePosition", { x: calculateCursorX(e), y: calculateCursorY(e) }); | ||
_this.dataStore.set(constants.store.mousePosition, { x: calculateCursorX(e), y: calculateCursorY(e) }); | ||
}; | ||
this.clearMousePosition = function () { | ||
_this.dataStore.set("mousePosition", undefined); | ||
_this.dataStore.set(constants.store.mousePosition, undefined); | ||
}; | ||
@@ -14,0 +15,0 @@ this.dataStore = dataStore; |
import { Raycaster } from "three"; | ||
import constants from "../../constants"; | ||
var RaycasterPlugin = /** @class */ (function () { | ||
@@ -8,5 +9,5 @@ function RaycasterPlugin(config) { | ||
this.handleClick = function () { | ||
var pos = _this.dataStore.get("mousePosition"); | ||
var pos = _this.dataStore.get(constants.store.mousePosition); | ||
if (pos === undefined) { | ||
_this.dataStore.set("intersection", []); | ||
_this.dataStore.set(constants.store.intersection, []); | ||
return; | ||
@@ -16,8 +17,8 @@ } | ||
_this.raycaster.setFromCamera(pos, _this.camera); | ||
_this.dataStore.set("intersection", _this.raycaster.intersectObjects(_this.scene.children, true)[0]); | ||
_this.dataStore.set(constants.store.intersection, _this.raycaster.intersectObjects(_this.scene.children, true)[0]); | ||
}; | ||
this.dataStore = dataStore; | ||
this.raycaster = new Raycaster(); | ||
this.camera = dataStore.get("camera"); | ||
this.scene = dataStore.get("scene"); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.scene = dataStore.get(constants.store.scene); | ||
} | ||
@@ -24,0 +25,0 @@ class_1.prototype.bindEventListener = function () { |
import { flattenChildren, isMatching } from "../../utils"; | ||
import constants from "../../constants"; | ||
var TabNavigationPlugin = /** @class */ (function () { | ||
@@ -10,3 +11,3 @@ function TabNavigationPlugin(bindings) { | ||
this.dataStore = dataStore; | ||
this.scene = dataStore.get("scene"); | ||
this.scene = dataStore.get(constants.store.scene); | ||
this.handleTabPressListener = function (e) { _this.handleTabPress(e); }; | ||
@@ -35,3 +36,3 @@ this.handleShiftTabPressListener = function (e) { _this.handleShiftTabPress(e); }; | ||
var _this = this; | ||
if (!this.dataStore.get("mapLoaded")) | ||
if (!this.dataStore.get(constants.store.mapLoaded)) | ||
return; | ||
@@ -55,3 +56,3 @@ var fallback = forward ? -1 : this.bindings.length; | ||
if (next && isMatching(child, next)) { | ||
next.afterNavigate(_this.dataStore.get("camera"), _this.dataStore.get("controls"), [child]); | ||
next.afterNavigate(_this.dataStore.get(constants.store.camera), _this.dataStore.get(constants.store.controls), [child]); | ||
} | ||
@@ -58,0 +59,0 @@ }); |
import { buildRenderer } from "../../utils"; | ||
import constants from "../../constants"; | ||
var WebglRendererPlugin = /** @class */ (function () { | ||
@@ -7,8 +8,8 @@ function WebglRendererPlugin(config) { | ||
this.dataStore = dataStore; | ||
this.canvas = this.dataStore.get("canvas"); | ||
this.sizes = this.dataStore.get("sizes"); | ||
this.scene = this.dataStore.get("scene"); | ||
this.camera = this.dataStore.get("camera"); | ||
this.canvas = this.dataStore.get(constants.store.canvas); | ||
this.sizes = this.dataStore.get(constants.store.sizes); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
this.camera = this.dataStore.get(constants.store.camera); | ||
this.renderer = buildRenderer(this.canvas, this.sizes, config); | ||
this.dataStore.set("renderer", this.renderer); | ||
this.dataStore.set(constants.store.renderer, this.renderer); | ||
} | ||
@@ -15,0 +16,0 @@ class_1.prototype.update = function () { |
import { buildScene, buildPerspectiveCamera, buildOrthographicCamera } from "./utils/build"; | ||
import constants from "./constants"; | ||
var SceneManager = /** @class */ (function () { | ||
function SceneManager(canvas, sceneConfig, dataStore, plugins) { | ||
var _this = this; | ||
this.dataStore = dataStore; | ||
@@ -14,8 +16,8 @@ this.sizes = { | ||
: buildPerspectiveCamera(this.scene, this.sizes, this.sceneConfig.camera.config); | ||
dataStore.set("canvas", canvas); | ||
dataStore.set("sizes", this.sizes); | ||
dataStore.set("scene", this.scene); | ||
dataStore.set("camera", this.camera); | ||
dataStore.set("cameraConfig", sceneConfig.camera); | ||
this.plugins = plugins.map(function (Plugin) { return new Plugin(dataStore); }); | ||
this.dataStore.set(constants.store.canvas, canvas); | ||
this.dataStore.set(constants.store.sizes, this.sizes); | ||
this.dataStore.set(constants.store.scene, this.scene); | ||
this.dataStore.set(constants.store.camera, this.camera); | ||
this.dataStore.set(constants.store.cameraConfig, sceneConfig.camera); | ||
this.plugins = plugins.map(function (Plugin) { return new Plugin(_this.dataStore); }); | ||
} | ||
@@ -22,0 +24,0 @@ /** |
{ | ||
"name": "@shd-developer/interactive-map", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "A package aimed at simplifying common three.js setups for interactive maps.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
import { AnimationMixer, Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types" | ||
import constants from "../../constants"; | ||
@@ -18,10 +19,10 @@ import { IAnimationMixerPlugin } from "./animation-mixer-plugin.types"; | ||
this.scene = dataStore.get("scene"); | ||
this.scene = dataStore.get(constants.store.scene); | ||
this.mixer = new AnimationMixer(this.scene); | ||
dataStore.set("animationMixer", this.mixer); | ||
dataStore.set(constants.store.animationMixer, this.mixer); | ||
} | ||
public update() { | ||
const deltaTime = this.dataStore.get("deltaTime"); | ||
const deltaTime = this.dataStore.get(constants.store.deltaTime); | ||
this.mixer.update(deltaTime); | ||
@@ -28,0 +29,0 @@ } |
@@ -6,2 +6,3 @@ import { AnimationClip, AnimationMixer } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -22,5 +23,5 @@ import { IAnimationPlugin } from "./animation-plugin.types"; | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set("animationConfig", config); | ||
this.dataStore.set(constants.store.animationConfig, config); | ||
@@ -31,3 +32,3 @@ this.animationsStarted = false; | ||
public startAnimations() { | ||
const animations: AnimationClip[] = this.dataStore.get('animations'); | ||
const animations: AnimationClip[] = this.dataStore.get(constants.store.animations); | ||
@@ -46,3 +47,3 @@ config.forEach(animationData => { | ||
public update() { | ||
if (this.dataStore.get("mapLoaded") && !this.animationsStarted) { | ||
if (this.dataStore.get(constants.store.mapLoaded) && !this.animationsStarted) { | ||
this.startAnimations(); | ||
@@ -49,0 +50,0 @@ this.animationsStarted = true; |
@@ -7,2 +7,3 @@ import { OrthographicCamera, PerspectiveCamera, WebGLRenderer } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -23,5 +24,5 @@ import { IBrowserResizePlugin } from "./browser-resize-plugin.types"; | ||
this.renderer = dataStore.get("renderer"); | ||
this.camera = dataStore.get("camera"); | ||
this.cameraConfig = dataStore.get("cameraConfig"); | ||
this.renderer = dataStore.get(constants.store.renderer); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.cameraConfig = dataStore.get(constants.store.cameraConfig); | ||
} | ||
@@ -45,3 +46,3 @@ | ||
public setSize() { | ||
this.dataStore.set("sizes", onWindowResize(element ? element : window, this.renderer, this.camera, this.cameraConfig.config)) | ||
this.dataStore.set(constants.store.sizes, onWindowResize(element ? element : window, this.renderer, this.camera, this.cameraConfig.config)) | ||
} | ||
@@ -48,0 +49,0 @@ } |
@@ -7,2 +7,3 @@ import { AnimationClip, AnimationMixer, Mesh } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -22,6 +23,6 @@ import { IClickPlugin } from "./click-plugin.types"; | ||
this.animations = dataStore.get("animations"); | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.animations = dataStore.get(constants.store.animations); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set("clickBindings", bindings); | ||
this.dataStore.set(constants.store.clickBindings, bindings); | ||
} | ||
@@ -38,3 +39,3 @@ | ||
public handleClick = (e: MouseEvent): void => { | ||
const intersection = this.dataStore.get("intersection"); | ||
const intersection = this.dataStore.get(constants.store.intersection); | ||
@@ -66,3 +67,3 @@ if (!intersection) { | ||
if (binding.animate) { | ||
this.animations = this.dataStore.get("animations") | ||
this.animations = this.dataStore.get(constants.store.animations) | ||
@@ -69,0 +70,0 @@ binding.animate.forEach((animationBinding) => { |
import { Clock } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types" | ||
import constants from "../../constants"; | ||
@@ -19,3 +20,3 @@ import { IClockPlugin } from "./clock-plugin.types"; | ||
this.clock = new Clock(); | ||
this.previousTime = 0; | ||
this.previousTime = 0; | ||
} | ||
@@ -27,5 +28,5 @@ | ||
this.previousTime = elapsedTime; | ||
this.dataStore.set("elapsedTime", elapsedTime) | ||
this.dataStore.set("deltaTime", deltaTime) | ||
this.dataStore.set(constants.store.elapsedTime, elapsedTime) | ||
this.dataStore.set(constants.store.deltaTime, deltaTime) | ||
} | ||
@@ -32,0 +33,0 @@ } |
import { AmbientLight, DirectionalLight, Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -17,3 +18,3 @@ import { IGlobalIlluminationPlugin } from "./global-illumination-plugin.types"; | ||
this.scene = this.dataStore.get("scene"); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
this.addLights(); | ||
@@ -20,0 +21,0 @@ } |
@@ -6,2 +6,3 @@ import { Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -22,6 +23,6 @@ import { IGltfDracoLoaderPlugin } from "./gltf-draco-loader-plugin.types"; | ||
dataStore.set("mapLoaded", false); | ||
dataStore.set("animations", []); | ||
dataStore.set(constants.store.mapLoaded, false); | ||
dataStore.set(constants.store.animations, []); | ||
this.scene = dataStore.get("scene"); | ||
this.scene = dataStore.get(constants.store.scene); | ||
@@ -39,5 +40,5 @@ this.dracoLoader = new DRACOLoader(); | ||
this.gltfLoader.load(path, (gltf) => { | ||
this.dataStore.set("animations", gltf.animations); | ||
this.dataStore.set(constants.store.animations, gltf.animations); | ||
this.scene.add(gltf.scene); | ||
this.dataStore.set("mapLoaded", true); | ||
this.dataStore.set(constants.store.mapLoaded, true); | ||
}); | ||
@@ -44,0 +45,0 @@ } |
@@ -7,2 +7,3 @@ import { AnimationClip, AnimationMixer, LoopOnce, Mesh } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -24,6 +25,6 @@ import { IHoverPlugin } from "./hover-plugin.types"; | ||
this.animations = dataStore.get("animations"); | ||
this.mixer = dataStore.get("animationMixer"); | ||
this.animations = dataStore.get(constants.store.animations); | ||
this.mixer = dataStore.get(constants.store.animationMixer); | ||
this.dataStore.set("hoverBindings", bindings); | ||
this.dataStore.set(constants.store.hoverBindings, bindings); | ||
} | ||
@@ -41,3 +42,3 @@ | ||
const previous = this.hovered; | ||
const current = this.dataStore.get("intersection")?.object; | ||
const current = this.dataStore.get(constants.store.intersection)?.object; | ||
@@ -80,3 +81,3 @@ if (previous === current) { | ||
if (binding.animate) { | ||
this.animations = this.dataStore.get("animations") | ||
this.animations = this.dataStore.get(constants.store.animations) | ||
@@ -83,0 +84,0 @@ binding.animate.forEach((animationBinding) => { |
@@ -5,2 +5,3 @@ import { Light, Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -22,8 +23,6 @@ import { IIlluminationPlugin } from "./illumination-plugin.types"; | ||
this.scene = this.dataStore.get("scene"); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
if (config) { | ||
if (config.lights) { | ||
this.lights = this.addLights(this.scene, config.lights); | ||
} | ||
if (config?.lights) { | ||
this.lights = this.addLights(this.scene, config.lights); | ||
} | ||
@@ -30,0 +29,0 @@ } |
@@ -5,2 +5,3 @@ import { Camera, Vector3 } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -21,8 +22,8 @@ import { IMapControlsPlugin, IMapControlsConfig } from "./map-controls-plugin.types"; | ||
this.camera = dataStore.get("camera"); | ||
this.canvas = dataStore.get("canvas"); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.canvas = dataStore.get(constants.store.canvas); | ||
this.mapControls = this.createMapControls(this.camera, this.canvas); | ||
this.dataStore.set("controls", this.mapControls); | ||
this.dataStore.set(constants.store.controls, this.mapControls); | ||
} | ||
@@ -32,6 +33,2 @@ | ||
this.mapControls.update(); | ||
// this.mapControls.enabled = false; | ||
// Update the camera here | ||
// this.mapControls.enabled = true; | ||
}; | ||
@@ -38,0 +35,0 @@ |
import { calculateCursorX, calculateCursorY } from "../../utils"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -24,7 +26,7 @@ import { IMousePositionPlugin } from "./mouse-position-plugin.types"; | ||
public handleMouseMove = (e: MouseEvent) => { | ||
this.dataStore.set("mousePosition", {x: calculateCursorX(e), y: calculateCursorY(e)}); | ||
this.dataStore.set(constants.store.mousePosition, {x: calculateCursorX(e), y: calculateCursorY(e)}); | ||
} | ||
public clearMousePosition = () => { | ||
this.dataStore.set("mousePosition", undefined); | ||
this.dataStore.set(constants.store.mousePosition, undefined); | ||
} | ||
@@ -31,0 +33,0 @@ } |
import { Camera, Raycaster, Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
import { IRaycasterPlugin, IRaycasterConfig } from "./raycaster-plugin.types"; | ||
@@ -19,4 +21,4 @@ | ||
this.camera = dataStore.get("camera"); | ||
this.scene = dataStore.get("scene"); | ||
this.camera = dataStore.get(constants.store.camera); | ||
this.scene = dataStore.get(constants.store.scene); | ||
} | ||
@@ -33,6 +35,6 @@ | ||
public handleClick = () => { | ||
const pos = this.dataStore.get("mousePosition"); | ||
const pos = this.dataStore.get(constants.store.mousePosition); | ||
if (pos === undefined) { | ||
this.dataStore.set("intersection", []); | ||
this.dataStore.set(constants.store.intersection, []); | ||
return | ||
@@ -43,3 +45,3 @@ }; | ||
this.dataStore.set("intersection", this.raycaster.intersectObjects(this.scene.children, true)[0]); | ||
this.dataStore.set(constants.store.intersection, this.raycaster.intersectObjects(this.scene.children, true)[0]); | ||
} | ||
@@ -46,0 +48,0 @@ } |
@@ -7,2 +7,3 @@ import { Scene } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -27,3 +28,3 @@ import { ITabNavigationPlugin, ITabNavigationBinding } from "./tab-navigation-plugin.types"; | ||
this.scene = dataStore.get("scene"); | ||
this.scene = dataStore.get(constants.store.scene); | ||
@@ -57,3 +58,3 @@ this.handleTabPressListener = (e: Event) => {this.handleTabPress((e as KeyboardEvent))}; | ||
public navigate(e: KeyboardEvent, forward: boolean): void { | ||
if (!this.dataStore.get("mapLoaded")) return; | ||
if (!this.dataStore.get(constants.store.mapLoaded)) return; | ||
@@ -83,3 +84,3 @@ const fallback = forward ? -1 : this.bindings.length; | ||
if (next && isMatching(child, next)) { | ||
(next.afterNavigate as Function)(this.dataStore.get("camera"), this.dataStore.get("controls"), [child]); | ||
(next.afterNavigate as Function)(this.dataStore.get(constants.store.camera), this.dataStore.get(constants.store.controls), [child]); | ||
} | ||
@@ -86,0 +87,0 @@ }); |
@@ -7,2 +7,3 @@ import { Camera, Scene, WebGLRenderer } from "three"; | ||
import { IDataStore } from "../../data-store/data-store.types"; | ||
import constants from "../../constants"; | ||
@@ -25,10 +26,10 @@ import { IWebglRendererPlugin } from "./webgl-renderer-plugin.types"; | ||
this.canvas = this.dataStore.get("canvas"); | ||
this.sizes = this.dataStore.get("sizes"); | ||
this.scene = this.dataStore.get("scene"); | ||
this.camera = this.dataStore.get("camera"); | ||
this.canvas = this.dataStore.get(constants.store.canvas); | ||
this.sizes = this.dataStore.get(constants.store.sizes); | ||
this.scene = this.dataStore.get(constants.store.scene); | ||
this.camera = this.dataStore.get(constants.store.camera); | ||
this.renderer = buildRenderer(this.canvas, this.sizes, config); | ||
this.dataStore.set("renderer", this.renderer); | ||
this.dataStore.set(constants.store.renderer, this.renderer); | ||
} | ||
@@ -35,0 +36,0 @@ |
import { OrthographicCamera, PerspectiveCamera, Scene, WebGLRenderer } from "three"; | ||
import { IManager, ISize, ISceneConfig, IOrthographicCameraConfig, IPerspectiveCameraConfig } from "./types"; | ||
import { buildScene, buildRenderer, buildPerspectiveCamera, buildOrthographicCamera } from "./utils/build"; | ||
import { buildScene, buildPerspectiveCamera, buildOrthographicCamera } from "./utils/build"; | ||
import DataStore from "./data-store/data-store"; | ||
import constants from "./constants"; | ||
@@ -32,11 +33,11 @@ export default class SceneManager implements IManager { | ||
dataStore.set("canvas", canvas); | ||
this.dataStore.set(constants.store.canvas, canvas); | ||
dataStore.set("sizes", this.sizes); | ||
dataStore.set("scene", this.scene); | ||
dataStore.set("camera", this.camera); | ||
this.dataStore.set(constants.store.sizes, this.sizes); | ||
this.dataStore.set(constants.store.scene, this.scene); | ||
this.dataStore.set(constants.store.camera, this.camera); | ||
dataStore.set("cameraConfig", sceneConfig.camera); | ||
this.dataStore.set(constants.store.cameraConfig, sceneConfig.camera); | ||
this.plugins = plugins.map(Plugin => new Plugin(dataStore)); | ||
this.plugins = plugins.map(Plugin => new Plugin(this.dataStore)); | ||
} | ||
@@ -43,0 +44,0 @@ |
148698
143
2825