some tidbits
This commit is contained in:
parent
0502504d07
commit
c4f8f564d2
@ -46,34 +46,6 @@ export class Game {
|
|||||||
// end of
|
// end of
|
||||||
|
|
||||||
this.chat.registerSendFunction((message) => {
|
this.chat.registerSendFunction((message) => {
|
||||||
if (message.startsWith('!party')) {
|
|
||||||
const array = message.split(' ');
|
|
||||||
const name = array.slice(2).join(' ');
|
|
||||||
|
|
||||||
if (array[1] === 'join') {
|
|
||||||
this.party.push(name);
|
|
||||||
this.chat.addMessage(`Joined party of user "${name}".`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array[1] === 'leave') {
|
|
||||||
this.party.splice(this.party.indexOf(name), 1);
|
|
||||||
this.chat.addMessage(`Left party of user "${name}".`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array[1] === 'clear') {
|
|
||||||
this.party.length = 0;
|
|
||||||
this.chat.addMessage('Cleared party list.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array[1] === 'list') {
|
|
||||||
this.chat.addMessage(
|
|
||||||
`You have joined the watch party of: ${this.party.join(', ')}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem('party', this.party.join('|'));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.socket.emit('chat-send', message);
|
this.socket.emit('chat-send', message);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,12 +162,45 @@ export class Game {
|
|||||||
this.chat.addMessage(event.message, event.sender.display_name);
|
this.chat.addMessage(event.message, event.sender.display_name);
|
||||||
|
|
||||||
// experimental stuff
|
// experimental stuff
|
||||||
this.experimentalPlayerCmd(event.message, event.sender.display_name);
|
this.experimentalPlayerCmd(event.message, event.sender);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private experimentalPlayerCmd(message: string, sender: string) {
|
private experimentalPlayerCmd(message: string, sender: IcyNetUser) {
|
||||||
if (!(sender === this.me.display_name || this.party.includes(sender))) {
|
if (message.startsWith('!party') && this.me.id === sender.id) {
|
||||||
|
const array = message.split(' ');
|
||||||
|
const name = array.slice(2).join(' ');
|
||||||
|
|
||||||
|
if (array[1] === 'join') {
|
||||||
|
this.party.push(name);
|
||||||
|
this.chat.addMessage(`Joined party of user "${name}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array[1] === 'leave') {
|
||||||
|
this.party.splice(this.party.indexOf(name), 1);
|
||||||
|
this.chat.addMessage(`Left party of user "${name}".`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array[1] === 'clear') {
|
||||||
|
this.party.length = 0;
|
||||||
|
this.chat.addMessage('Cleared party list.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array[1] === 'list') {
|
||||||
|
this.chat.addMessage(
|
||||||
|
`You have joined the watch party of: ${this.party.join(', ')}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.setItem('party', this.party.join('|'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!(
|
||||||
|
sender.display_name === this.me.display_name ||
|
||||||
|
this.party.includes(sender.display_name)
|
||||||
|
)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,14 +119,15 @@ export class Chat {
|
|||||||
|
|
||||||
public show() {
|
public show() {
|
||||||
this._visible = true;
|
this._visible = true;
|
||||||
this._wrapper.classList.add('visible');
|
this.element.classList.add('visible');
|
||||||
this._wrapper.classList.remove('invisible');
|
this.element.classList.remove('invisible');
|
||||||
|
this.scrollBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
public hide() {
|
public hide() {
|
||||||
this._visible = false;
|
this._visible = false;
|
||||||
this._wrapper.classList.remove('visible');
|
this.element.classList.remove('visible');
|
||||||
this._wrapper.classList.add('invisible');
|
this.element.classList.add('invisible');
|
||||||
}
|
}
|
||||||
|
|
||||||
public focus(rehide = false) {
|
public focus(rehide = false) {
|
||||||
@ -172,9 +173,12 @@ export class Chat {
|
|||||||
msgContent.innerText = message;
|
msgContent.innerText = message;
|
||||||
msg.append(msgContent);
|
msg.append(msgContent);
|
||||||
|
|
||||||
// const bottomed = this._history.scrollTop ,this._history.scrollHeight;
|
const lFactor = this._history.offsetHeight + this._history.scrollTop;
|
||||||
|
const wasAtBottom = lFactor > this._history.scrollHeight - 100;
|
||||||
|
|
||||||
this._history.append(msg);
|
this._history.append(msg);
|
||||||
this._history.scrollTop = this._history.scrollHeight;
|
|
||||||
|
wasAtBottom && this.scrollBottom();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
msg.classList.add('chat__message--old');
|
msg.classList.add('chat__message--old');
|
||||||
@ -192,4 +196,8 @@ export class Chat {
|
|||||||
public setKeyHandlerEnabled(isEnabled: boolean) {
|
public setKeyHandlerEnabled(isEnabled: boolean) {
|
||||||
this._keyhandler = isEnabled;
|
this._keyhandler = isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public scrollBottom() {
|
||||||
|
this._history.scrollTop = this._history.scrollHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export class Joystick {
|
|||||||
private prevMousePos = new Vector2();
|
private prevMousePos = new Vector2();
|
||||||
private center = new Vector2();
|
private center = new Vector2();
|
||||||
private knobCenter = new Vector2();
|
private knobCenter = new Vector2();
|
||||||
|
private knobPosition = new Vector2();
|
||||||
private mouseCenterOffset = new Vector2();
|
private mouseCenterOffset = new Vector2();
|
||||||
private radiusSquare = new Vector2();
|
private radiusSquare = new Vector2();
|
||||||
private negRadiusSquare = new Vector2();
|
private negRadiusSquare = new Vector2();
|
||||||
@ -37,11 +38,10 @@ export class Joystick {
|
|||||||
this.prevMousePos.copy(this.mousePos);
|
this.prevMousePos.copy(this.mousePos);
|
||||||
this.mousePos.fromArray([e.touches[0].clientX, e.touches[0].clientY]);
|
this.mousePos.fromArray([e.touches[0].clientX, e.touches[0].clientY]);
|
||||||
this.mouseCenterOffset.copy(this.center).sub(this.mousePos);
|
this.mouseCenterOffset.copy(this.center).sub(this.mousePos);
|
||||||
this.mouseCenterOffset.clamp(this.negRadiusSquare, this.radiusSquare);
|
this.mouseCenterOffset.clampLength(-this.radius, this.radius);
|
||||||
|
|
||||||
const knobPosition = new Vector2();
|
this.knobPosition.copy(this.knobCenter).sub(this.mouseCenterOffset);
|
||||||
knobPosition.copy(this.knobCenter).sub(this.mouseCenterOffset);
|
this.knob.style.transform = `translate(${this.knobPosition.x}px, ${this.knobPosition.y}px)`;
|
||||||
this.knob.style.transform = `translate(${knobPosition.x}px, ${knobPosition.y}px)`;
|
|
||||||
|
|
||||||
this.appliedForce
|
this.appliedForce
|
||||||
.copy(this.mouseCenterOffset)
|
.copy(this.mouseCenterOffset)
|
||||||
|
@ -23,6 +23,9 @@ class PonyModel {
|
|||||||
(gltf) => {
|
(gltf) => {
|
||||||
this.ponyModel = gltf.scene;
|
this.ponyModel = gltf.scene;
|
||||||
this.animations = gltf.animations;
|
this.animations = gltf.animations;
|
||||||
|
// temp: disable frustum culling for eyes
|
||||||
|
this.ponyModel.children[0].children[2].frustumCulled = false;
|
||||||
|
|
||||||
resolve(gltf.scene);
|
resolve(gltf.scene);
|
||||||
|
|
||||||
// gltf.animations; // Array<THREE.AnimationClip>
|
// gltf.animations; // Array<THREE.AnimationClip>
|
||||||
|
@ -53,7 +53,7 @@ body {
|
|||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 style=%27width:24px;height:24px%27 viewBox=%270 0 24 24%27%3E%3Cpath fill=%27currentColor%27 d=%27M20 2H4C2.9 2 2 2.9 2 4V22L6 18H20C21.1 18 22 17.1 22 16V4C22 2.9 21.1 2 20 2M20 16H5.2L4 17.2V4H20V16Z%27 /%3E%3C/svg%3E");
|
background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 style=%27width:24px;height:24px%27 viewBox=%270 0 24 24%27%3E%3Cpath fill=%27%23ffffff%27 d=%27M20 2H4C2.9 2 2 2.9 2 4V22L6 18H20C21.1 18 22 17.1 22 16V4C22 2.9 21.1 2 20 2M20 16H5.2L4 17.2V4H20V16Z%27 /%3E%3C/svg%3E");
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border: 2px solid #ddd;
|
border: 2px solid #ddd;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
@ -112,7 +112,7 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.invisible {
|
&__wrapper.invisible {
|
||||||
.chat {
|
.chat {
|
||||||
&__input-wrapper {
|
&__input-wrapper {
|
||||||
display: none;
|
display: none;
|
||||||
@ -135,7 +135,7 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.visible {
|
&__wrapper.visible {
|
||||||
.chat__history {
|
.chat__history {
|
||||||
background-color: #6464644d;
|
background-color: #6464644d;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ body {
|
|||||||
&__wrapper {
|
&__wrapper {
|
||||||
right: 8px;
|
right: 8px;
|
||||||
|
|
||||||
&:not(.focused) {
|
&:not(.visible) {
|
||||||
&, *:not(input):not(button) {
|
&, *:not(input):not(button) {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user