From 3a53cbedcdc6dea0d3ce1ab4375ce34e52d7d820 Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sun, 11 Aug 2024 00:15:43 +0900 Subject: [PATCH 1/9] hotfix: ci build --- .github/workflows/ci.yml | 16 +++++++++++----- .github/workflows/deploy.yml | 6 ++++-- .github/workflows/pull-request.yml | 13 ++++++++----- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ff9e4e..5bd573d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,18 +9,22 @@ jobs: steps: - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 - run: | npm install - npm run check:ci + npm check:ci spell: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 - run: | - npm install - npm run spell + pnpm install + pnpm spell build: needs: [check, spell] @@ -28,6 +32,8 @@ jobs: steps: - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 - run: | - npm install - npm run build + pnpm install + pnpm build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 72c9908..7055b3f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,9 +11,11 @@ jobs: steps: - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 - run: | - npm install - npm run build + pnpm install + pnpm build - uses: FirebaseExtended/action-hosting-deploy@v0 with: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 06a4d74..61c2fa7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -17,9 +17,11 @@ jobs: steps: - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 - run: | - npm install - npm run build + pnpm install + pnpm build - uses: FirebaseExtended/action-hosting-deploy@v0 with: @@ -101,9 +103,10 @@ jobs: uses: actions/checkout@v4 - name: Install and Build - run: | - npm install - npm run build + uses: pnpm/action-setup@v4 + - run: | + pnpm install + pnpm build - name: Upload artifact uses: actions/upload-pages-artifact@v3 From 13941606f7e19624e7a74cdf6dc480646ba0a67d Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sun, 11 Aug 2024 00:17:09 +0900 Subject: [PATCH 2/9] add: ci pnpm version --- .github/workflows/ci.yml | 6 ++++++ .github/workflows/deploy.yml | 2 ++ .github/workflows/pull-request.yml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5bd573d..6de51cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 + with: + version: 9 - run: | npm install npm check:ci @@ -22,6 +24,8 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 + with: + version: 9 - run: | pnpm install pnpm spell @@ -34,6 +38,8 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 + with: + version: 9 - run: | pnpm install pnpm build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7055b3f..352bc13 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 + with: + version: 9 - run: | pnpm install pnpm build diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 61c2fa7..9a56aca 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -19,6 +19,8 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 + with: + version: 9 - run: | pnpm install pnpm build @@ -104,6 +106,8 @@ jobs: - name: Install and Build uses: pnpm/action-setup@v4 + with: + version: 9 - run: | pnpm install pnpm build From d42bf68ccf13c753f4d85895b363b34a37be539d Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sun, 11 Aug 2024 00:17:57 +0900 Subject: [PATCH 3/9] fix: use pnpm --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6de51cd..316a626 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: with: version: 9 - run: | - npm install - npm check:ci + pnpm install + pnpm check:ci spell: runs-on: ubuntu-latest From 62ea1c557424e9514a4573d314770f14fb168e3b Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sat, 10 Aug 2024 21:31:05 +0900 Subject: [PATCH 4/9] update: active mode bu hover --- src/pages/yatai/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index 0870a2d..76d50ae 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -1,5 +1,6 @@ import { Canvas, type ThreeElements, useThree } from "@react-three/fiber"; import styles from "./index.module.css"; +import { useState } from "react"; function Yatai() { // 土台 @@ -14,10 +15,12 @@ function Yatai() { // 的 const Target = (props: ThreeElements["mesh"]) => { + // 一旦ホバーでアクションを起こす + const [isActive, setIsActive] = useState(false); return ( - + setIsActive(!isActive)}> - + ); }; From c37c91de32cbae979171bc122bc840087df8de86 Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sat, 10 Aug 2024 22:40:24 +0900 Subject: [PATCH 5/9] wip: cannon engine --- package.json | 1 + pnpm-lock.yaml | 52 +++++++++++++++++++++++++++ src/pages/yatai/index.tsx | 76 +++++++++++++++++++++++++++------------ 3 files changed, 107 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index bfa28f1..5409cba 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "spell": "cspell ./src" }, "dependencies": { + "@react-three/cannon": "^6.6.0", "@react-three/fiber": "^8.16.8", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7ace73..3bf080f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@react-three/cannon': + specifier: ^6.6.0 + version: 6.6.0(@react-three/fiber@8.16.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1))(react@18.3.1)(three@0.167.1)(typescript@5.5.4) '@react-three/fiber': specifier: ^8.16.8 version: 8.16.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1) @@ -505,6 +508,18 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@pmndrs/cannon-worker-api@2.4.0': + resolution: {integrity: sha512-oJA1Bboc+WObksRaGDKJG0Wna9Q75xi1MdXVAZ9qXzBOyPsadmAnrmiKOEF0R8v/4zsuJElvscNZmyo3msbZjA==} + peerDependencies: + three: '>=0.139' + + '@react-three/cannon@6.6.0': + resolution: {integrity: sha512-lP9rJoVHQi0w+dYF8FJAm2xr5eLfNEckb04j72kjqndUkuOPr26N4rSBhQbHl5b5N3tEnhQaIMungAvHkcY8/A==} + peerDependencies: + '@react-three/fiber': '>=8' + react: '>=18' + three: '>=0.139' + '@react-three/fiber@8.16.8': resolution: {integrity: sha512-Lc8fjATtvQEfSd8d5iKdbpHtRm/aPMeFj7jQvp6TNHfpo8IQTW3wwcE1ZMrGGoUH+w2mnyS+0MK1NLPLnuzGkQ==} peerDependencies: @@ -843,6 +858,19 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} + cannon-es-debugger@1.0.0: + resolution: {integrity: sha512-sE9lDOBAYFKlh+0w+cvWKwUhJef8HYnUSVPWPL0jD15MAuVRQKno4QYZSGxgOoJkMR3mQqxL4bxys2b3RSWH8g==} + peerDependencies: + cannon-es: 0.x + three: 0.x + typescript: '>=3.8' + peerDependenciesMeta: + typescript: + optional: true + + cannon-es@0.20.0: + resolution: {integrity: sha512-eZhWTZIkFOnMAJOgfXJa9+b3kVlvG+FX4mdkpePev/w/rP5V8NRquGyEozcjPfEoXUlb+p7d9SUcmDSn14prOA==} + chalk-template@1.1.0: resolution: {integrity: sha512-T2VJbcDuZQ0Tb2EWwSotMPJjgpy1/tGee1BTpUNsGZ/qgNjV2t7Mvu+d4600U564nbLesN1x2dPL+xii174Ekg==} engines: {node: '>=14.16'} @@ -1946,6 +1974,21 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 + '@pmndrs/cannon-worker-api@2.4.0(three@0.167.1)': + dependencies: + three: 0.167.1 + + '@react-three/cannon@6.6.0(@react-three/fiber@8.16.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1))(react@18.3.1)(three@0.167.1)(typescript@5.5.4)': + dependencies: + '@pmndrs/cannon-worker-api': 2.4.0(three@0.167.1) + '@react-three/fiber': 8.16.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1) + cannon-es: 0.20.0 + cannon-es-debugger: 1.0.0(cannon-es@0.20.0)(three@0.167.1)(typescript@5.5.4) + react: 18.3.1 + three: 0.167.1 + transitivePeerDependencies: + - typescript + '@react-three/fiber@8.16.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(three@0.167.1)': dependencies: '@babel/runtime': 7.25.0 @@ -2242,6 +2285,15 @@ snapshots: callsites@3.1.0: {} + cannon-es-debugger@1.0.0(cannon-es@0.20.0)(three@0.167.1)(typescript@5.5.4): + dependencies: + cannon-es: 0.20.0 + three: 0.167.1 + optionalDependencies: + typescript: 5.5.4 + + cannon-es@0.20.0: {} + chalk-template@1.1.0: dependencies: chalk: 5.3.0 diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index 76d50ae..b9f5cf9 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -1,6 +1,15 @@ +import { Physics, useBox } from "@react-three/cannon"; import { Canvas, type ThreeElements, useThree } from "@react-three/fiber"; -import styles from "./index.module.css"; import { useState } from "react"; +import { + type BufferGeometry, + type Material, + type Mesh, + type NormalBufferAttributes, + type Object3DEventMap, + Vector3, +} from "three"; +import styles from "./index.module.css"; function Yatai() { // 土台 @@ -17,8 +26,29 @@ function Yatai() { const Target = (props: ThreeElements["mesh"]) => { // 一旦ホバーでアクションを起こす const [isActive, setIsActive] = useState(false); + const [ref] = useBox(() => ({ + mass: 1, + position: + props.position instanceof Vector3 + ? props.position.toArray() + : new Vector3().toArray(), + })); return ( - setIsActive(!isActive)}> + , + Material | Material[], + Object3DEventMap + > + > + } + {...props} + castShadow + receiveShadow + onPointerOver={() => setIsActive(!isActive)} + > @@ -35,26 +65,28 @@ function Yatai() { return (
- {/* 全体ライト */} - - {/* スポットライト */} - - - - - - - + + {/* 全体ライト */} + + {/* スポットライト */} + + + + + + + +
); From b2f2db9306ae493f19adaf5d0d0ee2a75bca07a3 Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sat, 10 Aug 2024 22:55:12 +0900 Subject: [PATCH 6/9] update: foundation physics --- src/pages/yatai/index.tsx | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index b9f5cf9..088623f 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -1,21 +1,37 @@ import { Physics, useBox } from "@react-three/cannon"; -import { Canvas, type ThreeElements, useThree } from "@react-three/fiber"; +import { Canvas, MeshProps, type ThreeElements, useThree } from "@react-three/fiber"; import { useState } from "react"; -import { - type BufferGeometry, - type Material, - type Mesh, - type NormalBufferAttributes, - type Object3DEventMap, - Vector3, +import type { + BufferGeometry, + Material, + Mesh, + NormalBufferAttributes, + Object3DEventMap, } from "three"; import styles from "./index.module.css"; function Yatai() { // 土台 const Foundation = (props: ThreeElements["mesh"]) => { + const [ref] = useBox(() => ({ + mass: 0, + position: props.position as [number, number, number], + })); return ( - + , + Material | Material[], + Object3DEventMap + > + > + } + {...props} + castShadow + receiveShadow + > @@ -28,10 +44,7 @@ function Yatai() { const [isActive, setIsActive] = useState(false); const [ref] = useBox(() => ({ mass: 1, - position: - props.position instanceof Vector3 - ? props.position.toArray() - : new Vector3().toArray(), + position: props.position as [number, number, number], })); return ( Date: Sat, 10 Aug 2024 23:01:17 +0900 Subject: [PATCH 7/9] fix: box args --- src/pages/yatai/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index 088623f..31fc7da 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -13,9 +13,11 @@ import styles from "./index.module.css"; function Yatai() { // 土台 const Foundation = (props: ThreeElements["mesh"]) => { + const args: [number, number, number] = [10, 2, 2]; const [ref] = useBox(() => ({ mass: 0, position: props.position as [number, number, number], + args: args, })); return ( - + ); @@ -40,11 +42,13 @@ function Yatai() { // 的 const Target = (props: ThreeElements["mesh"]) => { + const args: [number, number, number] = [0.7, 2, 0.7]; // 一旦ホバーでアクションを起こす const [isActive, setIsActive] = useState(false); const [ref] = useBox(() => ({ mass: 1, position: props.position as [number, number, number], + args: args, })); return ( setIsActive(!isActive)} > - + ); From ca61a6da498fe1c530491aa91af8a67c2f754cde Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sun, 11 Aug 2024 00:05:12 +0900 Subject: [PATCH 8/9] add: target impact trigger --- src/pages/yatai/index.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index 31fc7da..c83a13c 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -1,6 +1,9 @@ import { Physics, useBox } from "@react-three/cannon"; -import { Canvas, MeshProps, type ThreeElements, useThree } from "@react-three/fiber"; -import { useState } from "react"; +import { + Canvas, + type ThreeElements, + useThree, +} from "@react-three/fiber"; import type { BufferGeometry, Material, @@ -8,6 +11,7 @@ import type { NormalBufferAttributes, Object3DEventMap, } from "three"; +import { randFloat } from "three/src/math/MathUtils.js"; import styles from "./index.module.css"; function Yatai() { @@ -43,13 +47,20 @@ function Yatai() { // 的 const Target = (props: ThreeElements["mesh"]) => { const args: [number, number, number] = [0.7, 2, 0.7]; - // 一旦ホバーでアクションを起こす - const [isActive, setIsActive] = useState(false); - const [ref] = useBox(() => ({ + const [ref, api] = useBox(() => ({ mass: 1, position: props.position as [number, number, number], args: args, })); + + // 弾が当たった時はこれを呼び出す + const handleHit = () => { + api.applyImpulse( + [randFloat(-2, 2), 4, 8], + [randFloat(-1, 1), randFloat(-1, 1), randFloat(-1, 1)], + ); + }; + return ( setIsActive(!isActive)} + onPointerOver={() => handleHit()} > - + ); }; From 01fb52677b6026b4e154250f3e8e7671ff329a47 Mon Sep 17 00:00:00 2001 From: claustra01 Date: Sun, 11 Aug 2024 00:06:30 +0900 Subject: [PATCH 9/9] fix: check --- src/pages/yatai/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/yatai/index.tsx b/src/pages/yatai/index.tsx index c83a13c..707f13a 100644 --- a/src/pages/yatai/index.tsx +++ b/src/pages/yatai/index.tsx @@ -1,9 +1,5 @@ import { Physics, useBox } from "@react-three/cannon"; -import { - Canvas, - type ThreeElements, - useThree, -} from "@react-three/fiber"; +import { Canvas, type ThreeElements, useThree } from "@react-three/fiber"; import type { BufferGeometry, Material,