Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
めたねのおくすり専用アバターを読み込めるようにする
Browse files Browse the repository at this point in the history
  • Loading branch information
calmery committed Feb 27, 2021
1 parent 3d11764 commit 0ee78f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/components/Exhibition/3d/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ControllerKeys } from "./Controller";
import { useMultiplay } from "~/hooks/exhibition/useMultuplay";
import { Area, AreaName, AreaObject } from "~/types/exhibition";
import { getGltf, rewriteMaterials } from "~/utils/exhibition";
import { getMetanenoToken } from "~/utils/exhibition/metaneno";

CameraControls.install({ THREE });

Expand Down Expand Up @@ -129,7 +130,7 @@ export const Exhibition3dPlayer = React.memo<

accessory.position.set(
scene?.position.x || 0,
(scene?.position.y || 0) + 0.95,
(scene?.position.y || 0) + (getMetanenoToken() ? 1.21 : 0.95),
scene?.position.z || 0
);

Expand All @@ -152,7 +153,9 @@ export const Exhibition3dPlayer = React.memo<

useEffect(() => {
(async () => {
const { animations, scene } = await getGltf(url);
const { animations, scene } = await getGltf(
getMetanenoToken() ? "/objects/metaneno.glb" : url
);

scene.scale.set(0.5, 0.5, 0.5);

Expand Down Expand Up @@ -284,7 +287,7 @@ export const Exhibition3dPlayer = React.memo<
if (accessory) {
accessory.position.set(
nextPosition.x,
nextPosition.y + 0.95,
nextPosition.y + (getMetanenoToken() ? 1.21 : 0.95),
nextPosition.z
);
accessory.rotation.y = Math.atan2(rotation.x, rotation.z);
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/exhibition/useMultuplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react";
import { io } from "socket.io-client";
import { AreaName } from "~/types/exhibition";
import * as GA from "~/utils/exhibition/google-analytics";
import { getMetanenoToken } from "~/utils/exhibition/metaneno";

export type UpdateResponse = UpdatePayload & {
metaneno: boolean;
Expand Down Expand Up @@ -47,7 +48,7 @@ export const useMultiplay = () => {
//

useEffect(() => {
const token = localStorage.getItem("_metaneno");
const token = getMetanenoToken();

if (token) {
if (socket.connected) {
Expand Down
1 change: 1 addition & 0 deletions src/utils/exhibition/metaneno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getMetanenoToken = () => localStorage.getItem("_metaneno");

0 comments on commit 0ee78f7

Please sign in to comment.